mirror of https://github.com/rusefi/rusefi.git
only: setTimeNowUs(): replace global fiddling with a function call
This commit is contained in:
parent
302b11abee
commit
a42092826a
|
@ -541,9 +541,8 @@ struct LuaPid final {
|
||||||
|
|
||||||
float get(float target, float input) {
|
float get(float target, float input) {
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
extern int timeNowUs;
|
|
||||||
// this is how we avoid zero dt
|
// this is how we avoid zero dt
|
||||||
timeNowUs += 1000;
|
advanceTimeUs(1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float dt = m_lastUpdate.getElapsedSecondsAndReset(getTimeNowNt());
|
float dt = m_lastUpdate.getElapsedSecondsAndReset(getTimeNowNt());
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "efitime.h"
|
#include "efitime.h"
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
extern int timeNowUs;
|
|
||||||
extern bool verboseMode;
|
extern bool verboseMode;
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
|
|
|
@ -537,20 +537,19 @@ TEST(etb, setpointLuaAdder) {
|
||||||
etb.setLuaAdjustment(-1000);
|
etb.setLuaAdjustment(-1000);
|
||||||
EXPECT_EQ(1, etb.getSetpoint().value_or(-1));
|
EXPECT_EQ(1, etb.getSetpoint().value_or(-1));
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
int startTime = 1e6;
|
int startTime = 1e6;
|
||||||
timeNowUs = startTime;
|
setTimeNowUs(startTime);
|
||||||
|
|
||||||
// Adjustment works immediately after setting
|
// Adjustment works immediately after setting
|
||||||
etb.setLuaAdjustment(10);
|
etb.setLuaAdjustment(10);
|
||||||
EXPECT_EQ(60, etb.getSetpoint().value_or(-1));
|
EXPECT_EQ(60, etb.getSetpoint().value_or(-1));
|
||||||
|
|
||||||
// Adjustment works 0.19 second after setting
|
// Adjustment works 0.19 second after setting
|
||||||
timeNowUs = startTime + 0.19 * 1e6;
|
setTimeNowUs(startTime + 0.19 * 1e6);
|
||||||
EXPECT_EQ(60, etb.getSetpoint().value_or(-1));
|
EXPECT_EQ(60, etb.getSetpoint().value_or(-1));
|
||||||
|
|
||||||
// Adjustment resets to 0 after 0.21 second
|
// Adjustment resets to 0 after 0.21 second
|
||||||
timeNowUs = startTime + 0.21 * 1e6;
|
setTimeNowUs(startTime + 0.21 * 1e6);
|
||||||
EXPECT_EQ(50, etb.getSetpoint().value_or(-1));
|
EXPECT_EQ(50, etb.getSetpoint().value_or(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,8 +762,6 @@ TEST(etb, closedLoopPid) {
|
||||||
EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 30).value_or(-1), 75);
|
EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 30).value_or(-1), 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
|
|
||||||
TEST(etb, jamDetection) {
|
TEST(etb, jamDetection) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
|
|
||||||
|
@ -789,7 +786,7 @@ TEST(etb, jamDetection) {
|
||||||
EtbController etb;
|
EtbController etb;
|
||||||
etb.init(DC_Throttle1, nullptr, &pid, nullptr, true);
|
etb.init(DC_Throttle1, nullptr, &pid, nullptr, true);
|
||||||
|
|
||||||
timeNowUs = 0;
|
setTimeNowUs(0);
|
||||||
|
|
||||||
// Reset timer while under integrator limit
|
// Reset timer while under integrator limit
|
||||||
EXPECT_EQ(etb.getPidState().iTerm, 0);
|
EXPECT_EQ(etb.getPidState().iTerm, 0);
|
||||||
|
@ -805,13 +802,13 @@ TEST(etb, jamDetection) {
|
||||||
EXPECT_NEAR(etb.getPidState().iTerm, 10.0f, 1e-3);
|
EXPECT_NEAR(etb.getPidState().iTerm, 10.0f, 1e-3);
|
||||||
|
|
||||||
// Just under time limit, no jam yet
|
// Just under time limit, no jam yet
|
||||||
timeNowUs = 0.9e6;
|
setTimeNowUs(0.9e6);
|
||||||
etb.checkOutput(0);
|
etb.checkOutput(0);
|
||||||
EXPECT_NEAR(etb.jamTimer, 0.9f, 1e-3);
|
EXPECT_NEAR(etb.jamTimer, 0.9f, 1e-3);
|
||||||
EXPECT_FALSE(etb.jamDetected);
|
EXPECT_FALSE(etb.jamDetected);
|
||||||
|
|
||||||
// Above the time limit, jam detected!
|
// Above the time limit, jam detected!
|
||||||
timeNowUs = 1.1e6;
|
setTimeNowUs(1.1e6);
|
||||||
etb.checkOutput(0);
|
etb.checkOutput(0);
|
||||||
EXPECT_TRUE(etb.jamDetected);
|
EXPECT_TRUE(etb.jamDetected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
|
|
||||||
TEST(Actuators, FuelPump) {
|
TEST(Actuators, FuelPump) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
|
|
||||||
|
@ -22,7 +20,7 @@ TEST(Actuators, FuelPump) {
|
||||||
enginePins.fuelPumpRelay.init();
|
enginePins.fuelPumpRelay.init();
|
||||||
|
|
||||||
// ECU just started, haven't seen trigger yet
|
// ECU just started, haven't seen trigger yet
|
||||||
timeNowUs = 0.5e6;
|
setTimeNowUs(0.5e6);
|
||||||
dut.onIgnitionStateChanged(true);
|
dut.onIgnitionStateChanged(true);
|
||||||
dut.onSlowCallback();
|
dut.onSlowCallback();
|
||||||
// Pump should be on!
|
// Pump should be on!
|
||||||
|
@ -30,22 +28,22 @@ TEST(Actuators, FuelPump) {
|
||||||
|
|
||||||
// Long time since ecu start, haven't seen trigger yet
|
// Long time since ecu start, haven't seen trigger yet
|
||||||
dut.onIgnitionStateChanged(true);
|
dut.onIgnitionStateChanged(true);
|
||||||
timeNowUs += 10e6;
|
advanceTimeUs(10e6);
|
||||||
dut.onSlowCallback();
|
dut.onSlowCallback();
|
||||||
// Pump should be off!
|
// Pump should be off!
|
||||||
EXPECT_FALSE(efiReadPin(Gpio::A0));
|
EXPECT_FALSE(efiReadPin(Gpio::A0));
|
||||||
|
|
||||||
// Long time since ecu start, just saw a trigger!
|
// Long time since ecu start, just saw a trigger!
|
||||||
dut.onIgnitionStateChanged(true);
|
dut.onIgnitionStateChanged(true);
|
||||||
timeNowUs += 10e6;
|
advanceTimeUs(10e6);
|
||||||
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, getTimeNowNt());
|
||||||
dut.onSlowCallback();
|
dut.onSlowCallback();
|
||||||
// Pump should be on!
|
// Pump should be on!
|
||||||
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
||||||
|
|
||||||
// ECU just started, and we just saw a trigger!
|
// ECU just started, and we just saw a trigger!
|
||||||
dut.onIgnitionStateChanged(true);
|
dut.onIgnitionStateChanged(true);
|
||||||
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, getTimeNowNt());
|
||||||
dut.onSlowCallback();
|
dut.onSlowCallback();
|
||||||
// Pump should be on!
|
// Pump should be on!
|
||||||
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
||||||
|
|
|
@ -333,8 +333,6 @@ TEST(idle_v2, openLoopCoastingTable) {
|
||||||
EXPECT_FLOAT_EQ(75, dut.getOpenLoop(ICP::Coasting, 1500, 0, 0, 2));
|
EXPECT_FLOAT_EQ(75, dut.getOpenLoop(ICP::Coasting, 1500, 0, 0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
|
|
||||||
TEST(idle_v2, closedLoopBasic) {
|
TEST(idle_v2, closedLoopBasic) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
IdleController dut;
|
IdleController dut;
|
||||||
|
@ -353,7 +351,7 @@ TEST(idle_v2, closedLoopBasic) {
|
||||||
|
|
||||||
// burn one update then advance time 5 seconds to avoid difficulty from wasResetPid
|
// burn one update then advance time 5 seconds to avoid difficulty from wasResetPid
|
||||||
dut.getClosedLoop(ICP::Idling, 0, 900, 900);
|
dut.getClosedLoop(ICP::Idling, 0, 900, 900);
|
||||||
timeNowUs += 5'000'000;
|
advanceTimeUs(5'000'000);
|
||||||
|
|
||||||
// Test above target, should return negative
|
// Test above target, should return negative
|
||||||
EXPECT_FLOAT_EQ(-25, dut.getClosedLoop(ICP::Idling, 0, /*rpm*/ 950, /*tgt*/ 900));
|
EXPECT_FLOAT_EQ(-25, dut.getClosedLoop(ICP::Idling, 0, /*rpm*/ 950, /*tgt*/ 900));
|
||||||
|
@ -381,7 +379,7 @@ TEST(idle_v2, closedLoopDeadzone) {
|
||||||
|
|
||||||
// burn one then advance time 5 seconds to avoid difficulty from wasResetPid
|
// burn one then advance time 5 seconds to avoid difficulty from wasResetPid
|
||||||
dut.getClosedLoop(ICP::Idling, 0, 900, 900);
|
dut.getClosedLoop(ICP::Idling, 0, 900, 900);
|
||||||
timeNowUs += 5'000'000;
|
advanceTimeUs(5'000'000);
|
||||||
|
|
||||||
// Test above target, should return negative
|
// Test above target, should return negative
|
||||||
EXPECT_FLOAT_EQ(-25, dut.getClosedLoop(ICP::Idling, 0, /*rpm*/ 950, /*tgt*/ 900));
|
EXPECT_FLOAT_EQ(-25, dut.getClosedLoop(ICP::Idling, 0, /*rpm*/ 950, /*tgt*/ 900));
|
||||||
|
|
|
@ -22,9 +22,8 @@ struct MockLambdaMonitor : public LambdaMonitorBase {
|
||||||
TEST(LambdaMonitor, Response) {
|
TEST(LambdaMonitor, Response) {
|
||||||
MockLambdaMonitor mlm;
|
MockLambdaMonitor mlm;
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
int startTime = 1e6;
|
int startTime = 1e6;
|
||||||
timeNowUs = startTime;
|
setTimeNowUs(startTime);
|
||||||
|
|
||||||
mlm.isGood = true;
|
mlm.isGood = true;
|
||||||
mlm.isRestore = false;
|
mlm.isRestore = false;
|
||||||
|
@ -39,13 +38,13 @@ TEST(LambdaMonitor, Response) {
|
||||||
EXPECT_FALSE(mlm.isCut());
|
EXPECT_FALSE(mlm.isCut());
|
||||||
|
|
||||||
// 0.9 second later, still not cut
|
// 0.9 second later, still not cut
|
||||||
timeNowUs = startTime + 0.9e6;
|
setTimeNowUs(startTime + 0.9e6);
|
||||||
mlm.update(2000, 50);
|
mlm.update(2000, 50);
|
||||||
EXPECT_FALSE(mlm.lambdaCurrentlyGood);
|
EXPECT_FALSE(mlm.lambdaCurrentlyGood);
|
||||||
EXPECT_FALSE(mlm.isCut());
|
EXPECT_FALSE(mlm.isCut());
|
||||||
|
|
||||||
// 1.1 second later, cut!
|
// 1.1 second later, cut!
|
||||||
timeNowUs = startTime + 1.1e6;
|
setTimeNowUs(startTime + 1.1e6);
|
||||||
mlm.update(2000, 50);
|
mlm.update(2000, 50);
|
||||||
EXPECT_FALSE(mlm.lambdaCurrentlyGood);
|
EXPECT_FALSE(mlm.lambdaCurrentlyGood);
|
||||||
EXPECT_TRUE(mlm.isCut());
|
EXPECT_TRUE(mlm.isCut());
|
||||||
|
|
|
@ -209,8 +209,6 @@ TEST(limp, boostCut) {
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
|
|
||||||
TEST(limp, oilPressureFailureCase) {
|
TEST(limp, oilPressureFailureCase) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
engineConfiguration->minOilPressureAfterStart = 200;
|
engineConfiguration->minOilPressureAfterStart = 200;
|
||||||
|
@ -228,12 +226,12 @@ TEST(limp, oilPressureFailureCase) {
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// 4.5 seconds later, should still be allowed (even though pressure is low)
|
// 4.5 seconds later, should still be allowed (even though pressure is low)
|
||||||
timeNowUs += 4.5e6;
|
advanceTimeUs(4.5e6);
|
||||||
dut.updateState(1000, getTimeNowNt());
|
dut.updateState(1000, getTimeNowNt());
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// 1 second later (5.5 since start), injection should cut
|
// 1 second later (5.5 since start), injection should cut
|
||||||
timeNowUs += 1.0e6;
|
advanceTimeUs(1.0e6);
|
||||||
dut.updateState(1000, getTimeNowNt());
|
dut.updateState(1000, getTimeNowNt());
|
||||||
ASSERT_FALSE(dut.allowInjection());
|
ASSERT_FALSE(dut.allowInjection());
|
||||||
|
|
||||||
|
@ -261,7 +259,7 @@ TEST(limp, oilPressureSuccessCase) {
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// 4.5 seconds later, should still be allowed (even though pressure is low)
|
// 4.5 seconds later, should still be allowed (even though pressure is low)
|
||||||
timeNowUs += 4.5e6;
|
advanceTimeUs(4.5e6);
|
||||||
dut.updateState(1000, getTimeNowNt());
|
dut.updateState(1000, getTimeNowNt());
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
|
@ -271,12 +269,12 @@ TEST(limp, oilPressureSuccessCase) {
|
||||||
ASSERT_TRUE(dut.allowInjection());
|
ASSERT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// 1 second later (5.5 since start), injection should be allowed since we saw pressure before the timeout
|
// 1 second later (5.5 since start), injection should be allowed since we saw pressure before the timeout
|
||||||
timeNowUs += 1.0e6;
|
advanceTimeUs(1.0e6);
|
||||||
dut.updateState(1000, getTimeNowNt());
|
dut.updateState(1000, getTimeNowNt());
|
||||||
ASSERT_TRUE(dut.allowInjection());
|
ASSERT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// Later, we lose oil pressure, but engine should stay running
|
// Later, we lose oil pressure, but engine should stay running
|
||||||
timeNowUs += 10e6;
|
advanceTimeUs(10e6);
|
||||||
Sensor::setMockValue(SensorType::OilPressure, 10);
|
Sensor::setMockValue(SensorType::OilPressure, 10);
|
||||||
dut.updateState(1000, getTimeNowNt());
|
dut.updateState(1000, getTimeNowNt());
|
||||||
ASSERT_TRUE(dut.allowInjection());
|
ASSERT_TRUE(dut.allowInjection());
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
#define LOW_VALUE 0
|
#define LOW_VALUE 0
|
||||||
#define HIGH_VALUE 1
|
#define HIGH_VALUE 1
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
|
|
||||||
static int expectedTimeOfNextEvent;
|
static int expectedTimeOfNextEvent;
|
||||||
|
|
||||||
static void assertNextEvent(const char *msg, int expectedPinState, TestExecutor *executor, OutputPin& pin) {
|
static void assertNextEvent(const char *msg, int expectedPinState, TestExecutor *executor, OutputPin& pin) {
|
||||||
|
@ -20,10 +17,10 @@ static void assertNextEvent(const char *msg, int expectedPinState, TestExecutor
|
||||||
ASSERT_EQ( 1, executor->size()) << "PWM_test: schedulingQueue size";
|
ASSERT_EQ( 1, executor->size()) << "PWM_test: schedulingQueue size";
|
||||||
|
|
||||||
// move time to next event timestamp
|
// move time to next event timestamp
|
||||||
timeNowUs = expectedTimeOfNextEvent;
|
setTimeNowUs(expectedTimeOfNextEvent);
|
||||||
|
|
||||||
// execute pending actions and assert that only one action was executed
|
// execute pending actions and assert that only one action was executed
|
||||||
ASSERT_EQ(1, executor->executeAll(timeNowUs)) << msg << " executed";
|
ASSERT_EQ(1, executor->executeAll(getTimeNowUs())) << msg << " executed";
|
||||||
ASSERT_EQ(expectedPinState, pin.currentLogicValue) << msg << " pin state";
|
ASSERT_EQ(expectedPinState, pin.currentLogicValue) << msg << " pin state";
|
||||||
|
|
||||||
// assert that we have one new action in queue
|
// assert that we have one new action in queue
|
||||||
|
@ -33,7 +30,8 @@ static void assertNextEvent(const char *msg, int expectedPinState, TestExecutor
|
||||||
static void test100dutyCycle() {
|
static void test100dutyCycle() {
|
||||||
printf("*************************************** test100dutyCycle\r\n");
|
printf("*************************************** test100dutyCycle\r\n");
|
||||||
|
|
||||||
expectedTimeOfNextEvent = timeNowUs = 0;
|
expectedTimeOfNextEvent = 0;
|
||||||
|
setTimeNowUs(0);
|
||||||
|
|
||||||
OutputPin pin;
|
OutputPin pin;
|
||||||
SimplePwm pwm("test PWM1");
|
SimplePwm pwm("test PWM1");
|
||||||
|
@ -60,7 +58,8 @@ static void test100dutyCycle() {
|
||||||
static void testSwitchToNanPeriod() {
|
static void testSwitchToNanPeriod() {
|
||||||
printf("*************************************** testSwitchToNanPeriod\r\n");
|
printf("*************************************** testSwitchToNanPeriod\r\n");
|
||||||
|
|
||||||
expectedTimeOfNextEvent = timeNowUs = 0;
|
expectedTimeOfNextEvent = 0;
|
||||||
|
setTimeNowUs(0);
|
||||||
|
|
||||||
OutputPin pin;
|
OutputPin pin;
|
||||||
SimplePwm pwm("test PWM1");
|
SimplePwm pwm("test PWM1");
|
||||||
|
@ -76,7 +75,7 @@ static void testSwitchToNanPeriod() {
|
||||||
assertEqualsM2("1@1000/70", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("1@1000/70", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@70", LOW_VALUE, &executor, pin);
|
assertNextEvent("exec@70", LOW_VALUE, &executor, pin);
|
||||||
ASSERT_EQ( 600, timeNowUs) << "time1";
|
ASSERT_EQ(600, getTimeNowUs()) << "time1";
|
||||||
|
|
||||||
expectedTimeOfNextEvent += 400;
|
expectedTimeOfNextEvent += 400;
|
||||||
assertNextEvent("exec2@70", HIGH_VALUE, &executor, pin);
|
assertNextEvent("exec2@70", HIGH_VALUE, &executor, pin);
|
||||||
|
@ -96,7 +95,8 @@ TEST(PWM, testPwmGenerator) {
|
||||||
test100dutyCycle();
|
test100dutyCycle();
|
||||||
testSwitchToNanPeriod();
|
testSwitchToNanPeriod();
|
||||||
|
|
||||||
expectedTimeOfNextEvent = timeNowUs = 0;
|
expectedTimeOfNextEvent = 0;
|
||||||
|
setTimeNowUs(0);
|
||||||
|
|
||||||
OutputPin pin;
|
OutputPin pin;
|
||||||
SimplePwm pwm("test PWM3");
|
SimplePwm pwm("test PWM3");
|
||||||
|
@ -113,7 +113,7 @@ TEST(PWM, testPwmGenerator) {
|
||||||
assertEqualsM2("1@1000/80", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("1@1000/80", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@0", LOW_VALUE, &executor, pin);
|
assertNextEvent("exec@0", LOW_VALUE, &executor, pin);
|
||||||
ASSERT_EQ( 800, timeNowUs) << "time1";
|
ASSERT_EQ(800, getTimeNowUs()) << "time1";
|
||||||
|
|
||||||
expectedTimeOfNextEvent += 200;
|
expectedTimeOfNextEvent += 200;
|
||||||
assertEqualsM2("2@1000/80", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("2@1000/80", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
@ -123,18 +123,18 @@ TEST(PWM, testPwmGenerator) {
|
||||||
assertEqualsM2("2@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("2@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@1", LOW_VALUE, &executor, pin);
|
assertNextEvent("exec@1", LOW_VALUE, &executor, pin);
|
||||||
ASSERT_EQ( 1000, timeNowUs) << "time2";
|
ASSERT_EQ(1000, getTimeNowUs()) << "time2";
|
||||||
|
|
||||||
expectedTimeOfNextEvent += 1000;
|
expectedTimeOfNextEvent += 1000;
|
||||||
assertEqualsM2("3@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("3@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@2", LOW_VALUE /* pin value */, &executor, pin);
|
assertNextEvent("exec@2", LOW_VALUE /* pin value */, &executor, pin);
|
||||||
ASSERT_EQ( 2000, timeNowUs) << "time3";
|
ASSERT_EQ(2000, getTimeNowUs()) << "time3";
|
||||||
expectedTimeOfNextEvent += 1000;
|
expectedTimeOfNextEvent += 1000;
|
||||||
assertEqualsM2("4@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("4@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@3", LOW_VALUE /* pin value */, &executor, pin);
|
assertNextEvent("exec@3", LOW_VALUE /* pin value */, &executor, pin);
|
||||||
ASSERT_EQ( 3000, timeNowUs) << "time4";
|
ASSERT_EQ(3000, getTimeNowUs()) << "time4";
|
||||||
expectedTimeOfNextEvent += 1000;
|
expectedTimeOfNextEvent += 1000;
|
||||||
assertEqualsM2("5@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("5@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ TEST(PWM, testPwmGenerator) {
|
||||||
|
|
||||||
assertNextEvent("exec@5", LOW_VALUE /* pin value */, &executor, pin);
|
assertNextEvent("exec@5", LOW_VALUE /* pin value */, &executor, pin);
|
||||||
expectedTimeOfNextEvent += 1000;
|
expectedTimeOfNextEvent += 1000;
|
||||||
ASSERT_EQ( 5000, timeNowUs) << "time4";
|
ASSERT_EQ(5000, getTimeNowUs()) << "time4";
|
||||||
assertEqualsM2("7@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
assertEqualsM2("7@1000/0", expectedTimeOfNextEvent, executor.getForUnitTest(0)->momentX, 0);
|
||||||
|
|
||||||
assertNextEvent("exec@6", LOW_VALUE /* pin value */, &executor, pin);
|
assertNextEvent("exec@6", LOW_VALUE /* pin value */, &executor, pin);
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "logicdata_csv_reader.h"
|
#include "logicdata_csv_reader.h"
|
||||||
|
|
||||||
extern int timeNowUs;
|
|
||||||
extern WarningCodeState unitTestWarningCodeState;
|
extern WarningCodeState unitTestWarningCodeState;
|
||||||
|
|
||||||
static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, TriggerWheel channel, bool isFall) {
|
static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, TriggerWheel channel, bool isFall) {
|
||||||
|
@ -28,9 +27,9 @@ static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, TriggerWhe
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine *engine = ð->engine;
|
Engine *engine = ð->engine;
|
||||||
|
|
||||||
timeNowUs = 1'000'000 * timestampS;
|
setTimeNowUs(1'000'000 * timestampS);
|
||||||
printf("MIATANA: posting time=%d event=%d\n", timeNowUs, event);
|
printf("MIATANA: posting time=%d event=%d\n", getTimeNowUs(), event);
|
||||||
hwHandleShaftSignal((int)channel, !isFall, getTimeNowNt());
|
hwHandleShaftSignal((int)channel, !isFall, getTimeNowNt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue