diff --git a/firmware/controllers/system/timer/event_queue.cpp b/firmware/controllers/system/timer/event_queue.cpp index b6c3ad5a5c..1ff69794d2 100644 --- a/firmware/controllers/system/timer/event_queue.cpp +++ b/firmware/controllers/system/timer/event_queue.cpp @@ -62,7 +62,7 @@ void EventQueue::tryReturnScheduling(scheduling_s* sched) { /** * @return true if inserted into the head of the list */ -bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s action) { +bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeNt, action_s action) { ScopePerf perf(PE::EventQueueInsertTask); if (!scheduling) { @@ -84,17 +84,17 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s if (scheduling->action) { #if EFI_UNIT_TEST if (verboseMode) { - printf("Already scheduled was %d\r\n", (int)scheduling->getMomentRaw()); - printf("Already scheduled now %d\r\n", (int)timeX); + printf("Already scheduled was %d\r\n", (int)scheduling->getMomentNt()); + printf("Already scheduled now %d\r\n", (int)timeNt); } #endif /* EFI_UNIT_TEST */ return false; } - scheduling->setMomentX(timeX); + scheduling->setMomentNt(timeNt); scheduling->action = action; - if (!m_head || timeX < m_head->getMomentNt()) { + if (!m_head || timeNt < m_head->getMomentNt()) { // here we insert into head of the linked list LL_PREPEND2(m_head, scheduling, nextScheduling_s); assertListIsSorted(); @@ -102,7 +102,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s } else { // here we know we are not in the head of the list, let's find the position - linear search scheduling_s *insertPosition = m_head; - while (insertPosition->nextScheduling_s != NULL && insertPosition->nextScheduling_s->getMomentNt() < timeX) { + while (insertPosition->nextScheduling_s != NULL && insertPosition->nextScheduling_s->getMomentNt() < timeNt) { insertPosition = insertPosition->nextScheduling_s; } @@ -323,7 +323,7 @@ void EventQueue::clear(void) { m_head = x->nextScheduling_s; // Reset this element - x->setMomentX(0); + x->setMomentNt(0); x->nextScheduling_s = nullptr; x->action = {}; } diff --git a/firmware/controllers/system/timer/scheduler.cpp b/firmware/controllers/system/timer/scheduler.cpp index be4c86d530..607bd19032 100644 --- a/firmware/controllers/system/timer/scheduler.cpp +++ b/firmware/controllers/system/timer/scheduler.cpp @@ -22,6 +22,6 @@ void * action_s::getArgument() const { #if EFI_UNIT_TEST efitick_t scheduling_s::getMomentUs() const { - return NT2US(momentX); + return NT2US(momentNt); } #endif diff --git a/firmware/controllers/system/timer/scheduler.h b/firmware/controllers/system/timer/scheduler.h index af25b5d409..5d80e1d69f 100644 --- a/firmware/controllers/system/timer/scheduler.h +++ b/firmware/controllers/system/timer/scheduler.h @@ -62,20 +62,15 @@ private: #pragma pack(push, 4) struct scheduling_s { efitick_t getMomentNt() const { - return momentX; + return momentNt; } #if EFI_UNIT_TEST efitick_t getMomentUs() const; - -// todo: get rid of this 'I am not sure what's the proper type' method once we are done cleaning things up in unit tests - efitick_t getMomentRaw() const { - return momentX; - } #endif - void setMomentX(efitick_t p_moment) { - momentX = p_moment; + void setMomentNt(efitick_t p_moment) { + momentNt = p_moment; } #if EFI_SIMULATOR @@ -92,10 +87,8 @@ struct scheduling_s { /** * timestamp represented as 64-bit value of ticks since MCU start */ - // actually looks like this is ALWAYS or sometimes us these days? - // todo: make private with explicit getter/setter? private: - volatile efitick_t momentX = 0; + volatile efitick_t momentNt = 0; }; #pragma pack(pop) diff --git a/unit_tests/test-framework/engine_test_helper.h b/unit_tests/test-framework/engine_test_helper.h index ce7c07f0ab..fd455f922a 100644 --- a/unit_tests/test-framework/engine_test_helper.h +++ b/unit_tests/test-framework/engine_test_helper.h @@ -96,8 +96,8 @@ public: const AngleBasedEvent* assertTriggerEvent(const char *msg, int index, AngleBasedEvent *expected, void *callback, angle_t enginePhase); void assertEvent(const char *msg, int index, void *callback, efitimeus_t momentUs, InjectionEvent *event); - void assertInjectorUpEvent(const char *msg, int eventIndex, efitimeus_t momentX, long injectorIndex); - void assertInjectorDownEvent(const char *msg, int eventIndex, efitimeus_t momentX, long injectorIndex); + void assertInjectorUpEvent(const char *msg, int eventIndex, efitimeus_t momentUs, long injectorIndex); + void assertInjectorDownEvent(const char *msg, int eventIndex, efitimeus_t momentUs, long injectorIndex); // todo: open question if this is worth a helper method or should be inlined? void assertRpm(int expectedRpm, const char *msg = "RPM"); diff --git a/unit_tests/tests/test_event_queue.cpp b/unit_tests/tests/test_event_queue.cpp index 59aa7a128e..1e96752103 100644 --- a/unit_tests/tests/test_event_queue.cpp +++ b/unit_tests/tests/test_event_queue.cpp @@ -96,10 +96,10 @@ TEST(EventQueue, complex) { eq.insertTask(&s2, 11, callback); ASSERT_EQ(4, eq.size()); - ASSERT_EQ(10, eq.getHead()->getMomentRaw()); - ASSERT_EQ(10, eq.getHead()->nextScheduling_s->getMomentRaw()); - ASSERT_EQ(11, eq.getHead()->nextScheduling_s->nextScheduling_s->getMomentRaw()); - ASSERT_EQ(12, eq.getHead()->nextScheduling_s->nextScheduling_s->nextScheduling_s->getMomentRaw()); + ASSERT_EQ(10, eq.getHead()->getMomentNt()); + ASSERT_EQ(10, eq.getHead()->nextScheduling_s->getMomentNt()); + ASSERT_EQ(11, eq.getHead()->nextScheduling_s->nextScheduling_s->getMomentNt()); + ASSERT_EQ(12, eq.getHead()->nextScheduling_s->nextScheduling_s->nextScheduling_s->getMomentNt()); callbackCounter = 0; eq.executeAll(10); diff --git a/unit_tests/tests/test_hpfp.cpp b/unit_tests/tests/test_hpfp.cpp index 2cf8cd339f..65ac30f71c 100755 --- a/unit_tests/tests/test_hpfp.cpp +++ b/unit_tests/tests/test_hpfp.cpp @@ -299,7 +299,7 @@ TEST(HPFP, Schedule) { // Since we have a mock scheduler, lets insert the correct timestamp in the scheduling // struct. - hpfp.m_event.scheduling.setMomentX(nt1); + hpfp.m_event.scheduling.setMomentNt(nt1); HpfpController::pinTurnOn(&hpfp);