From 1660a5b3fd213969fe64d26dcb9778ae5a8178b7 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 2 Jul 2021 19:57:26 -0400 Subject: [PATCH] Nissan progress --- .../controllers/trigger/decoders/trigger_structure.cpp | 4 ---- unit_tests/tests/trigger/test_nissan_vq_vvt.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 921cc46c52..e392717ee7 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -150,10 +150,6 @@ size_t TriggerWaveform::getLength() const { } angle_t TriggerWaveform::getAngle(int index) const { - // todo: why is this check here? looks like the code below could be used universally - if (operationMode == FOUR_STROKE_CAM_SENSOR) { - return getSwitchAngle(index); - } /** * FOUR_STROKE_CRANK_SENSOR magic: * We have two crank shaft revolutions for each engine cycle diff --git a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp index aed41f860b..d853cfd00f 100644 --- a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp +++ b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp @@ -32,14 +32,14 @@ void func(TriggerCallback *callback) { } -static void scheduleTriggerEvents(TriggerWaveform *shape, bool isVvt DECLARE_ENGINE_PARAMETER_SUFFIX) { +static void scheduleTriggerEvents(TriggerWaveform *shape, int count, bool isVvt DECLARE_ENGINE_PARAMETER_SUFFIX) { int totalIndex = 0; /** * yet another approach to trigger testing: let's schedule a huge list of events from heap * and then execute those one */ - for (int r = 0; r < 20; r++) { + for (int r = 0; r < count; r++) { for (int i = 0; i < shape->getSize(); i++) { float angle = shape->getAngle(totalIndex); TriggerCallback *param = new TriggerCallback(); @@ -61,18 +61,20 @@ TEST(nissan, vq_vvt) { engineConfiguration->isIgnitionEnabled = false; engineConfiguration->isInjectionEnabled = false; + int cyclesCount = 12; + { static TriggerWaveform crank; initializeNissanVQcrank(&crank); - scheduleTriggerEvents(&crank, false PASS_ENGINE_PARAMETER_SUFFIX); + scheduleTriggerEvents(&crank, cyclesCount, false PASS_ENGINE_PARAMETER_SUFFIX); } { static TriggerWaveform vvt; initializeNissanVQvvt(&vvt); - scheduleTriggerEvents(&vvt, true PASS_ENGINE_PARAMETER_SUFFIX); + scheduleTriggerEvents(&vvt, cyclesCount / 6, true PASS_ENGINE_PARAMETER_SUFFIX); }