Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7bb7744ec8
|
@ -168,7 +168,7 @@ void turnInjectionPinLow(InjectionEvent *event) {
|
||||||
ENGINE(injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX));
|
ENGINE(injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
|
void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
|
||||||
int rpm, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
int rpm, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -310,6 +310,11 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If duty cycle is high, impose a fuel cut rev limiter.
|
||||||
|
// This is safer than attempting to limp along with injectors or a pump that are out of flow.
|
||||||
|
if (getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER_SUFFIX) > 96.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignition events are defined by addFuelEvents() according to selected
|
* Ignition events are defined by addFuelEvents() according to selected
|
||||||
|
|
|
@ -24,3 +24,7 @@ void turnInjectionPinLow(InjectionEvent *event);
|
||||||
|
|
||||||
// reset injection switch counter if the engine started spinning
|
// reset injection switch counter if the engine started spinning
|
||||||
void updatePrimeInjectionPulseState(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void updatePrimeInjectionPulseState(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
// Internal use only - exposed for tests
|
||||||
|
void handleFuelInjectionEvent(int injEventIndex, InjectionEvent *event,
|
||||||
|
int rpm, efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -14,6 +14,12 @@ void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, actio
|
||||||
if (debugSignalExecutor) {
|
if (debugSignalExecutor) {
|
||||||
printf("scheduleTask %d\r\n", delayUs);
|
printf("scheduleTask %d\r\n", delayUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_mockExecutor) {
|
||||||
|
m_mockExecutor->scheduleForLater(scheduling, delayUs, action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, action);
|
scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +43,24 @@ void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t tim
|
||||||
if (debugSignalExecutor) {
|
if (debugSignalExecutor) {
|
||||||
printf("scheduleByTime %d\r\n", timeUs);
|
printf("scheduleByTime %d\r\n", timeUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_mockExecutor) {
|
||||||
|
m_mockExecutor->scheduleByTimestamp(scheduling, timeUs, action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
schedulingQueue.insertTask(scheduling, timeUs, action);
|
schedulingQueue.insertTask(scheduling, timeUs, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
void TestExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitick_t timeNt, action_s action) {
|
||||||
|
if (m_mockExecutor) {
|
||||||
|
m_mockExecutor->scheduleByTimestampNt(scheduling, timeNt, action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
scheduleByTimestamp(scheduling, NT2US(timeNt), action);
|
scheduleByTimestamp(scheduling, NT2US(timeNt), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestExecutor::setMockExecutor(ExecutorInterface* exec) {
|
||||||
|
m_mockExecutor = exec;
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
int executeAll(efitime_t now);
|
int executeAll(efitime_t now);
|
||||||
int size();
|
int size();
|
||||||
scheduling_s* getForUnitTest(int index);
|
scheduling_s* getForUnitTest(int index);
|
||||||
|
|
||||||
|
void setMockExecutor(ExecutorInterface* exec);
|
||||||
private:
|
private:
|
||||||
EventQueue schedulingQueue;
|
EventQueue schedulingQueue;
|
||||||
|
ExecutorInterface* m_mockExecutor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,3 +40,10 @@ class MockPwm : public SimplePwm {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD(void, setSimplePwmDutyCycle, (float dutyCycle), (override));
|
MOCK_METHOD(void, setSimplePwmDutyCycle, (float dutyCycle), (override));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MockExecutor : public TestExecutor {
|
||||||
|
public:
|
||||||
|
MOCK_METHOD(void, scheduleByTimestamp, (scheduling_s *scheduling, efitimeus_t timeUs, action_s action), (override));
|
||||||
|
MOCK_METHOD(void, scheduleByTimestampNt, (scheduling_s *scheduling, efitime_t timeUs, action_s action), (override));
|
||||||
|
MOCK_METHOD(void, scheduleForLater, (scheduling_s *scheduling, int delayUs, action_s action), (override));
|
||||||
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ TESTS_SRC_CPP = \
|
||||||
tests/trigger/test_trigger_multi_sync.cpp \
|
tests/trigger/test_trigger_multi_sync.cpp \
|
||||||
tests/trigger/test_cam_vvt_input.cpp \
|
tests/trigger/test_cam_vvt_input.cpp \
|
||||||
tests/trigger/test_2jz_vvt.cpp \
|
tests/trigger/test_2jz_vvt.cpp \
|
||||||
|
tests/trigger/test_injection_scheduling.cpp \
|
||||||
tests/test_util.cpp \
|
tests/test_util.cpp \
|
||||||
tests/test_ion.cpp \
|
tests/test_ion.cpp \
|
||||||
tests/test_aux_valves.cpp \
|
tests/test_aux_valves.cpp \
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "engine_test_helper.h"
|
||||||
|
#include "main_trigger_callback.h"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include "mocks.h"
|
||||||
|
|
||||||
|
using ::testing::_;
|
||||||
|
using ::testing::StrictMock;
|
||||||
|
using ::testing::InSequence;
|
||||||
|
|
||||||
|
TEST(injectionScheduling, NormalDutyCycle) {
|
||||||
|
StrictMock<MockExecutor> mockExec;
|
||||||
|
|
||||||
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||||
|
engine->executor.setMockExecutor(&mockExec);
|
||||||
|
|
||||||
|
efitick_t nowNt = 1000000;
|
||||||
|
|
||||||
|
InjectionEvent event;
|
||||||
|
InjectorOutputPin pin;
|
||||||
|
pin.injectorIndex = 0;
|
||||||
|
event.outputs[0] = &pin;
|
||||||
|
|
||||||
|
// Injection duration of 20ms
|
||||||
|
engine->injectionDuration = 20.0f;
|
||||||
|
|
||||||
|
{
|
||||||
|
InSequence is;
|
||||||
|
|
||||||
|
// Should schedule one normal injection:
|
||||||
|
// rising edge now
|
||||||
|
EXPECT_CALL(mockExec, scheduleByTimestampNt(&event.signalTimerUp, nowNt + 0, _));
|
||||||
|
// falling edge 10ms later
|
||||||
|
EXPECT_CALL(mockExec, scheduleByTimestampNt(&event.endOfInjectionEvent, nowNt + MS2NT(20), _));
|
||||||
|
}
|
||||||
|
|
||||||
|
engine->rpmCalculator.oneDegreeUs = 100;
|
||||||
|
|
||||||
|
handleFuelInjectionEvent(0, &event, 1000, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
}
|
Loading…
Reference in New Issue