diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 1b08a3d1c3..d3c7f204eb 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -151,10 +151,15 @@ void Engine::initializeTriggerWaveform(DECLARE_ENGINE_PARAMETER_SIGNATURE) { * in very VERY rare circumstances */ if (CONFIG(overrideTriggerGaps)) { - for (int gapIndex = 0;gapIndex= 0 && gapIndex < GAP_TRACKING_LENGTH, "gapIndex out of range"); - this->syncronizationRatioFrom[gapIndex] = syncRatioFrom; - this->syncronizationRatioTo[gapIndex] = syncRatioTo; + syncronizationRatioFrom[gapIndex] = syncRatioFrom; + syncronizationRatioTo[gapIndex] = syncRatioTo; if (gapIndex == 0) { // we have a special case here - only sync with one gap has this feature this->syncRatioAvg = (int)efiRound((syncRatioFrom + syncRatioTo) * 0.5f, 1.0f); diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index dce674156d..450717a94b 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -7,6 +7,7 @@ TESTS_SRC_CPP = \ tests/trigger/test_2jz_vvt.cpp \ tests/trigger/test_real_cranking_miata_NA.cpp \ tests/trigger/test_quad_cam.cpp \ + tests/trigger/test_override_gaps.cpp \ tests/trigger/test_injection_scheduling.cpp \ tests/ignition_injection/injection_mode_transition.cpp \ tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp \ diff --git a/unit_tests/tests/trigger/recourses/cranking_na_4.csv b/unit_tests/tests/trigger/recourses/cranking_na_4.csv new file mode 100644 index 0000000000..7089cc275f --- /dev/null +++ b/unit_tests/tests/trigger/recourses/cranking_na_4.csv @@ -0,0 +1,353 @@ +Time[s], Channel 0, Channel 1, Channel 2, Channel 3 +0.000000000000000, 0, 1, 0, 0 +0.597303000000000, 1, 1, 0, 0 +0.690782250000000, 0, 1, 0, 0 +0.753783000000000, 0, 0, 0, 0 +0.793342750000000, 1, 0, 0, 0 +0.852666750000000, 0, 0, 0, 0 +0.934247250000000, 0, 1, 0, 0 +0.944100000000000, 1, 1, 0, 0 +0.982097250000000, 1, 0, 0, 0 +0.995239750000000, 0, 0, 0, 0 +1.076422000000000, 1, 0, 0, 0 +1.125428000000000, 0, 0, 0, 0 +1.194742000000000, 0, 1, 0, 0 +1.204179750000000, 1, 1, 0, 0 +1.253800750000000, 0, 1, 0, 0 +1.301142250000000, 0, 0, 0, 0 +1.334191500000000, 1, 0, 0, 0 +1.383534000000000, 0, 0, 0, 0 +1.394234500000000, 0, 0, 0, 1 +1.400246500000000, 0, 0, 0, 0 +1.453526750000000, 0, 1, 0, 0 +1.462915250000000, 1, 1, 0, 0 +1.496864500000000, 1, 1, 1, 0 +1.499390250000000, 1, 0, 1, 0 +1.500240750000000, 1, 0, 0, 0 +1.511785000000000, 0, 0, 0, 0 +1.590854500000000, 1, 0, 0, 0 +1.624796250000000, 1, 0, 0, 1 +1.628157500000000, 1, 0, 0, 0 +1.639984500000000, 0, 0, 0, 0 +1.709758750000000, 0, 1, 0, 0 +1.719445500000000, 1, 1, 0, 0 +1.753222500000000, 1, 1, 1, 0 +1.756599750000000, 1, 1, 0, 0 +1.769712500000000, 0, 1, 0, 0 +1.817179000000000, 0, 0, 0, 0 +1.851105500000000, 1, 0, 0, 0 +1.881458500000000, 1, 0, 0, 1 +1.887885000000000, 1, 0, 0, 0 +1.901183500000000, 0, 0, 0, 0 +1.976916750000000, 0, 1, 0, 0 +1.982245500000000, 1, 1, 0, 0 +2.001249000000000, 1, 0, 0, 0 +2.007023500000000, 0, 0, 0, 0 +2.013282250000000, 0, 0, 1, 0 +2.019240750000000, 0, 0, 0, 0 +2.044481750000000, 1, 0, 0, 0 +2.061358750000000, 0, 0, 0, 0 +2.075630250000000, 0, 0, 0, 1 +2.081616000000000, 0, 0, 0, 0 +2.085293250000000, 0, 1, 0, 0 +2.089132000000000, 1, 1, 0, 0 +2.107152000000000, 0, 1, 0, 0 +2.119999250000000, 0, 1, 1, 0 +2.122536250000000, 0, 0, 1, 0 +2.125959500000000, 0, 0, 0, 0 +2.136714000000000, 1, 0, 0, 0 +2.156019500000000, 0, 0, 0, 0 +2.183659250000000, 0, 1, 0, 0 +2.188138000000000, 1, 1, 0, 0 +2.204608750000000, 1, 0, 0, 0 +2.209400750000000, 0, 0, 0, 0 +2.244644500000000, 1, 0, 0, 0 +2.268264750000000, 0, 0, 0, 0 +2.302761250000000, 0, 1, 0, 0 +2.308357000000000, 1, 1, 0, 0 +2.335511750000000, 0, 1, 0, 0 +2.360120500000000, 0, 0, 0, 0 +2.382952000000000, 1, 0, 0, 0 +2.415355250000000, 0, 0, 0, 0 +2.415411000000000, 0, 0, 0, 1 +2.421711000000000, 0, 0, 0, 0 +2.453217250000000, 0, 1, 0, 0 +2.457700500000000, 1, 1, 0, 0 +2.473481250000000, 1, 0, 0, 0 +2.477961250000000, 0, 0, 0, 0 +2.490361750000000, 0, 0, 1, 0 +2.496701000000000, 0, 0, 0, 0 +2.511592750000000, 1, 0, 0, 0 +2.533664000000000, 0, 0, 0, 0 +2.544411750000000, 0, 0, 0, 1 +2.550750500000000, 0, 0, 0, 0 +2.565646750000000, 0, 1, 0, 0 +2.570874250000000, 1, 1, 0, 0 +2.596120750000000, 0, 1, 0, 0 +2.603356750000000, 0, 1, 1, 0 +2.609695500000000, 0, 1, 0, 0 +2.618533750000000, 0, 0, 0, 0 +2.636519500000000, 1, 0, 0, 0 +2.652089500000000, 1, 0, 0, 1 +2.654946250000000, 1, 0, 0, 0 +2.657360500000000, 0, 0, 0, 0 +2.684479750000000, 0, 1, 0, 0 +2.688290750000000, 1, 1, 0, 0 +2.701797000000000, 1, 0, 0, 0 +2.703975750000000, 1, 0, 1, 0 +2.705553000000000, 0, 0, 1, 0 +2.706832250000000, 0, 0, 0, 0 +2.731711750000000, 1, 0, 0, 0 +2.746657500000000, 0, 0, 0, 0 +2.747464750000000, 0, 0, 0, 1 +2.750320250000000, 0, 0, 0, 0 +2.767363750000000, 0, 1, 0, 0 +2.770612000000000, 1, 1, 0, 0 +2.784873500000000, 0, 1, 0, 0 +2.786212250000000, 0, 1, 1, 0 +2.789068250000000, 0, 1, 0, 0 +2.796690000000000, 0, 0, 0, 0 +2.808129000000000, 1, 0, 0, 0 +2.816713750000000, 1, 0, 0, 1 +2.820862000000000, 1, 0, 0, 0 +2.823204500000000, 0, 0, 0, 0 +2.844381250000000, 0, 1, 0, 0 +2.847948000000000, 1, 1, 0, 0 +2.856611500000000, 1, 1, 1, 0 +2.860670750000000, 1, 0, 1, 0 +2.861195750000000, 1, 0, 0, 0 +2.864234500000000, 0, 0, 0, 0 +2.891122250000000, 1, 0, 0, 0 +2.899834000000000, 1, 0, 0, 1 +2.903982000000000, 1, 0, 0, 0 +2.908962500000000, 0, 0, 0, 0 +2.934292750000000, 0, 1, 0, 0 +2.938504750000000, 1, 1, 0, 0 +2.947109000000000, 1, 1, 1, 0 +2.951265250000000, 1, 1, 0, 0 +2.958108000000000, 0, 1, 0, 0 +2.974461000000000, 0, 0, 0, 0 +2.988463250000000, 1, 0, 0, 0 +2.996741250000000, 1, 0, 0, 1 +3.000741000000000, 1, 0, 0, 0 +3.006508250000000, 0, 0, 0, 0 +3.031735000000000, 0, 1, 0, 0 +3.035770250000000, 1, 1, 0, 0 +3.044127000000000, 1, 1, 1, 0 +3.048126750000000, 1, 1, 0, 0 +3.050004750000000, 1, 0, 0, 0 +3.053938750000000, 0, 0, 0, 0 +3.082187500000000, 1, 0, 0, 0 +3.090599750000000, 1, 0, 0, 1 +3.094599000000000, 1, 0, 0, 0 +3.099064000000000, 0, 0, 0, 0 +3.121742500000000, 0, 1, 0, 0 +3.125211000000000, 1, 1, 0, 0 +3.133515250000000, 1, 1, 1, 0 +3.137515500000000, 1, 1, 0, 0 +3.140913250000000, 0, 1, 0, 0 +3.153884000000000, 0, 0, 0, 0 +3.165637500000000, 1, 0, 0, 0 +3.173992500000000, 1, 0, 0, 1 +3.178047250000000, 1, 0, 0, 0 +3.180729750000000, 0, 0, 0, 0 +3.201579000000000, 0, 1, 0, 0 +3.204921750000000, 1, 1, 0, 0 +3.213357750000000, 1, 1, 1, 0 +3.216623500000000, 1, 0, 1, 0 +3.217410500000000, 1, 0, 0, 0 +3.219858000000000, 0, 0, 0, 0 +3.244237500000000, 1, 0, 0, 0 +3.252720000000000, 1, 0, 0, 1 +3.256772750000000, 1, 0, 0, 0 +3.260246500000000, 0, 0, 0, 0 +3.282604750000000, 0, 1, 0, 0 +3.286237250000000, 1, 1, 0, 0 +3.294611250000000, 1, 1, 1, 0 +3.298664000000000, 1, 1, 0, 0 +3.302665500000000, 0, 1, 0, 0 +3.316308750000000, 0, 0, 0, 0 +3.328703250000000, 1, 0, 0, 0 +3.336327750000000, 1, 0, 0, 1 +3.339958750000000, 1, 0, 0, 0 +3.344727000000000, 0, 0, 0, 0 +3.367171500000000, 0, 1, 0, 0 +3.370925250000000, 1, 1, 0, 0 +3.378618250000000, 1, 1, 1, 0 +3.382252250000000, 1, 1, 0, 0 +3.384436250000000, 1, 0, 0, 0 +3.388222750000000, 0, 0, 0, 0 +3.416294750000000, 1, 0, 0, 0 +3.424031750000000, 1, 0, 0, 1 +3.427664250000000, 1, 0, 0, 0 +3.433887750000000, 0, 0, 0, 0 +3.458179750000000, 0, 1, 0, 0 +3.462032000000000, 1, 1, 0, 0 +3.469672750000000, 1, 1, 1, 0 +3.473303500000000, 1, 1, 0, 0 +3.479536000000000, 0, 1, 0, 0 +3.494128250000000, 0, 0, 0, 0 +3.507612750000000, 1, 0, 0, 0 +3.515348000000000, 1, 0, 0, 1 +3.519726250000000, 1, 0, 0, 0 +3.525064250000000, 0, 0, 0, 0 +3.549249500000000, 0, 1, 0, 0 +3.553064750000000, 1, 1, 0, 0 +3.560877750000000, 1, 1, 1, 0 +3.565257000000000, 1, 1, 0, 0 +3.566632500000000, 1, 0, 0, 0 +3.570395750000000, 0, 0, 0, 0 +3.598924250000000, 1, 0, 0, 0 +3.606786500000000, 1, 0, 0, 1 +3.611164250000000, 1, 0, 0, 0 +3.618061750000000, 0, 0, 0, 0 +3.645154250000000, 0, 1, 0, 0 +3.649681250000000, 1, 1, 0, 0 +3.657434500000000, 1, 1, 1, 0 +3.661813250000000, 1, 1, 0, 0 +3.670815750000000, 0, 1, 0, 0 +3.688438250000000, 0, 0, 0, 0 +3.704016250000000, 1, 0, 0, 0 +3.713044500000000, 1, 0, 0, 1 +3.717438250000000, 1, 0, 0, 0 +3.724337250000000, 0, 0, 0, 0 +3.753059000000000, 0, 1, 0, 0 +3.757789250000000, 1, 1, 0, 0 +3.766903750000000, 1, 1, 1, 0 +3.771298000000000, 1, 1, 0, 0 +3.774756000000000, 1, 0, 0, 0 +3.779567750000000, 0, 0, 0, 0 +3.813150750000000, 1, 0, 0, 0 +3.822316500000000, 1, 0, 0, 1 +3.826709750000000, 1, 0, 0, 0 +3.833365250000000, 0, 0, 0, 0 +3.861303250000000, 0, 1, 0, 0 +3.865678250000000, 1, 1, 0, 0 +3.874729500000000, 1, 1, 1, 0 +3.879122250000000, 1, 1, 0, 0 +3.885432500000000, 0, 1, 0, 0 +3.901804000000000, 0, 0, 0, 0 +3.916312500000000, 1, 0, 0, 0 +3.926710250000000, 1, 0, 0, 1 +3.931114000000000, 1, 0, 0, 0 +3.935154500000000, 0, 0, 0, 0 +3.960757500000000, 0, 1, 0, 0 +3.964707750000000, 1, 1, 0, 0 +3.975200000000000, 1, 1, 1, 0 +3.978687500000000, 1, 0, 1, 0 +3.979603250000000, 1, 0, 0, 0 +3.982577000000000, 0, 0, 0, 0 +4.012022250000000, 1, 0, 0, 0 +4.022571249999999, 1, 0, 0, 1 +4.026973250000000, 1, 0, 0, 0 +4.031498000000000, 0, 0, 0, 0 +4.058177000000000, 0, 1, 0, 0 +4.062353250000000, 1, 1, 0, 0 +4.072772000000000, 1, 1, 1, 0 +4.077174750000000, 1, 1, 0, 0 +4.081332000000000, 0, 1, 0, 0 +4.097002000000000, 0, 0, 0, 0 +4.110908999999999, 1, 0, 0, 0 +4.120788750000000, 1, 0, 0, 1 +4.124461999999999, 1, 0, 0, 0 +4.128978500000000, 0, 0, 0, 0 +4.153949750000000, 0, 1, 0, 0 +4.157891999999999, 1, 1, 0, 0 +4.167859500000000, 1, 1, 1, 0 +4.171531500000000, 1, 1, 0, 0 +4.171903750000000, 1, 0, 0, 0 +4.175793250000000, 0, 0, 0, 0 +4.203495999999999, 1, 0, 0, 0 +4.213517250000000, 1, 0, 0, 1 +4.217189750000000, 1, 0, 0, 0 +4.220478750000000, 0, 0, 0, 0 +4.244155249999999, 0, 1, 0, 0 +4.248003000000000, 1, 1, 0, 0 +4.257908250000000, 1, 1, 1, 0 +4.261581000000000, 1, 1, 0, 0 +4.265512500000000, 0, 1, 0, 0 +4.279967000000000, 0, 0, 0, 0 +4.292958500000000, 1, 0, 0, 0 +4.301921249999999, 1, 0, 0, 1 +4.305682500000000, 1, 0, 0, 0 +4.309842500000000, 0, 0, 0, 0 +4.333131000000000, 0, 1, 0, 0 +4.336821000000000, 1, 1, 0, 0 +4.345852250000000, 1, 1, 1, 0 +4.349612500000000, 1, 1, 0, 0 +4.349921750000000, 1, 0, 0, 0 +4.353559250000000, 0, 0, 0, 0 +4.380871000000000, 1, 0, 0, 0 +4.389951750000000, 1, 0, 0, 1 +4.393711750000000, 1, 0, 0, 0 +4.398547250000000, 0, 0, 0, 0 +4.422318750000000, 0, 1, 0, 0 +4.426012500000000, 1, 1, 0, 0 +4.434984000000000, 1, 1, 1, 0 +4.438747500000000, 1, 1, 0, 0 +4.442958500000000, 0, 1, 0, 0 +4.457011749999999, 0, 0, 0, 0 +4.469824000000000, 1, 0, 0, 0 +4.478235000000000, 1, 0, 0, 1 +4.482117250000000, 1, 0, 0, 0 +4.486370500000000, 0, 0, 0, 0 +4.509275250000000, 0, 1, 0, 0 +4.512929750000000, 1, 1, 0, 0 +4.521418000000000, 1, 1, 1, 0 +4.525300500000000, 1, 1, 0, 0 +4.525894750000000, 1, 0, 0, 0 +4.529504250000000, 0, 0, 0, 0 +4.555600500000000, 1, 0, 0, 0 +4.564136500000000, 1, 0, 0, 1 +4.568017250000000, 1, 0, 0, 0 +4.571718250000000, 0, 0, 0, 0 +4.594211500000000, 0, 1, 0, 0 +4.597895750000000, 1, 1, 0, 0 +4.606325249999999, 1, 1, 1, 0 +4.610207750000000, 1, 1, 0, 0 +4.614726500000000, 0, 1, 0, 0 +4.628670000000000, 0, 0, 0, 0 +4.641402250000000, 1, 0, 0, 0 +4.649373000000000, 1, 0, 0, 1 +4.653259750000000, 1, 0, 0, 0 +4.657920000000000, 0, 0, 0, 0 +4.680652250000000, 0, 1, 0, 0 +4.684264250000000, 1, 1, 0, 0 +4.692311999999999, 1, 1, 1, 0 +4.696197499999999, 1, 1, 0, 0 +4.697045250000000, 1, 0, 0, 0 +4.700623000000000, 0, 0, 0, 0 +4.727223749999999, 1, 0, 0, 0 +4.735317000000000, 1, 0, 0, 1 +4.739203250000000, 1, 0, 0, 0 +4.744205000000000, 0, 0, 0, 0 +4.767295000000000, 0, 1, 0, 0 +4.770934250000000, 1, 1, 0, 0 +4.778928250000000, 1, 1, 1, 0 +4.782818250000000, 1, 1, 0, 0 +4.787484249999999, 0, 1, 0, 0 +4.801081750000000, 0, 0, 0, 0 +4.813555249999999, 1, 0, 0, 0 +4.821384999999999, 1, 0, 0, 1 +4.825413999999999, 1, 0, 0, 0 +4.829746750000000, 0, 0, 0, 0 +4.852260500000000, 0, 1, 0, 0 +4.855929000000000, 1, 1, 0, 0 +4.863834499999999, 1, 1, 1, 0 +4.867862750000000, 1, 1, 0, 0 +4.868925250000000, 1, 0, 0, 0 +4.872512500000000, 0, 0, 0, 0 +4.898664000000000, 1, 0, 0, 0 +4.906615749999999, 1, 0, 0, 1 +4.910643750000000, 1, 0, 0, 0 +4.914934000000000, 0, 0, 0, 0 +4.937726250000000, 0, 1, 0, 0 +4.941493250000000, 1, 1, 0, 0 +4.949340500000000, 1, 1, 1, 0 +4.953369500000000, 1, 1, 0, 0 +4.958768750000000, 0, 1, 0, 0 +4.973157749999999, 0, 0, 0, 0 +4.986453249999999, 1, 0, 0, 0 +4.994298000000000, 1, 0, 0, 1 +4.998304500000000, 1, 0, 0, 0 +5.003722499999999, 0, 0, 0, 0 diff --git a/unit_tests/tests/trigger/test_override_gaps.cpp b/unit_tests/tests/trigger/test_override_gaps.cpp new file mode 100644 index 0000000000..6f06ea6ae2 --- /dev/null +++ b/unit_tests/tests/trigger/test_override_gaps.cpp @@ -0,0 +1,28 @@ +/* + * @file test_override_gaps.cpp + * + * Created on: May 25, 2021 + * @author Andrey Belomutskiy, (c) 2012-2021 + */ + +#include "engine_test_helper.h" +#include "globalaccess.h" + +TEST(subaru, overrideGap) { + WITH_ENGINE_TEST_HELPER(MIATA_NA6_MAP); + + CONFIG(overrideTriggerGaps) = true; + CONFIG(gapTrackingLengthOverride) = 2; + CONFIG(triggerGapOverride[0]) = 7.3; + CONFIG(triggerGapOverride[1]) = 1; + + eth.setTriggerType(TT_SUBARU_7_WITHOUT_6 PASS_ENGINE_PARAMETER_SUFFIX); + + ASSERT_EQ(2, engine->triggerCentral.triggerShape.gapTrackingLength); + + ASSERT_EQ(FALSE, engine->triggerCentral.triggerShape.shapeDefinitionError) << "overrideGap shapeDefinitionError"; + +} + + + diff --git a/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp b/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp index c6889fc8dc..98ebaf8edb 100644 --- a/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp +++ b/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp @@ -7,10 +7,7 @@ #include "engine_test_helper.h" - - - -TEST(cramking, realNA) { +TEST(cranking, realNA) { FILE * fp = fopen("tests/trigger/recourses/cranking_na_3.csv", "r"); ASSERT_TRUE(fp != nullptr); diff --git a/unit_tests/tests/trigger/test_trigger_multi_sync.cpp b/unit_tests/tests/trigger/test_trigger_multi_sync.cpp index 1a4a04002d..2183811809 100644 --- a/unit_tests/tests/trigger/test_trigger_multi_sync.cpp +++ b/unit_tests/tests/trigger/test_trigger_multi_sync.cpp @@ -12,6 +12,6 @@ TEST(trigger, miataNA) { TriggerWaveform naShape; initializeMazdaMiataNaShape(&naShape); - WITH_ENGINE_TEST_HELPER(MIATA_NA6_MAP); + // todo: https://github.com/rusefi/rusefi/issues/679 }