auto-sync
This commit is contained in:
parent
10f83e20af
commit
d2a790bd0c
|
@ -38,13 +38,12 @@ public:
|
|||
class FuelSchedule {
|
||||
public:
|
||||
FuelSchedule();
|
||||
InjectionEventList injectionEvents;
|
||||
|
||||
/**
|
||||
* this method schedules all fuel events for an engine cycle
|
||||
*/
|
||||
void addFuelEvents(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
InjectionEventList injectionEvents;
|
||||
/**
|
||||
* This is a performance optimization for https://sourceforge.net/p/rusefi/tickets/64/
|
||||
* TODO: better data structure? better algorithm?
|
||||
|
|
|
@ -312,22 +312,23 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)prevAngle]);
|
||||
// now let's get precise angle for that event
|
||||
prevAngle = TRIGGER_SHAPE(eventAngles[prevIndex]);
|
||||
uint32_t time = nowNt - timeOfLastEvent[prevIndex];
|
||||
// todo: re-implement this as a subclass. we need two instances of
|
||||
// uint32_t time = nowNt - timeOfLastEvent[prevIndex];
|
||||
angle_t angleDiff = currentAngle - prevAngle;
|
||||
// todo: angle diff should be pre-calculated
|
||||
fixAngle(angleDiff);
|
||||
|
||||
float r = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
|
||||
// float r = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
|
||||
|
||||
#if EFI_SENSOR_CHART || defined(__DOXYGEN__)
|
||||
if (boardConfiguration->sensorChartMode == SC_DETAILED_RPM) {
|
||||
scAddData(currentAngle, r);
|
||||
// scAddData(currentAngle, r);
|
||||
} else {
|
||||
scAddData(currentAngle, r / instantRpmValue[prevIndex]);
|
||||
// scAddData(currentAngle, r / instantRpmValue[prevIndex]);
|
||||
}
|
||||
#endif
|
||||
instantRpmValue[currentCycle.current_index] = r;
|
||||
timeOfLastEvent[currentCycle.current_index] = nowNt;
|
||||
// instantRpmValue[currentCycle.current_index] = r;
|
||||
// timeOfLastEvent[currentCycle.current_index] = nowNt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +527,13 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET
|
|||
return;
|
||||
}
|
||||
wave.checkSwitchTimes(getSize());
|
||||
calculateTriggerSynchPoint(&engine->triggerCentral.triggerState PASS_ENGINE_PARAMETER);
|
||||
/**
|
||||
* this instance is used only to initialize 'this' TriggerShape instance
|
||||
* #192 BUG real hardware trigger events could be coming even while we are initializing trigger
|
||||
*/
|
||||
TriggerState state;
|
||||
state.reset();
|
||||
calculateTriggerSynchPoint(&state PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
static void onFindIndex(TriggerState *state) {
|
||||
|
|
|
@ -80,8 +80,10 @@ public:
|
|||
uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||
|
||||
uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
|
||||
float instantRpmValue[PWM_PHASE_MAX_COUNT];
|
||||
// we need two instances of TriggerState
|
||||
// todo: re-imiplement as a sub-class to reduce memory consumption
|
||||
// uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
|
||||
// float instantRpmValue[PWM_PHASE_MAX_COUNT];
|
||||
|
||||
/**
|
||||
* how many times since ECU reboot we had unexpected number of teeth in trigger cycle
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Launcher COM56" type="Application" factoryName="Application" folderName="5x">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||
<option name="VM_PARAMETERS" value="" />
|
||||
<option name="PROGRAM_PARAMETERS" value="COM56" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="ui" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Launcher COM66" type="Application" factoryName="Application" folderName="6x">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||
<option name="VM_PARAMETERS" value="" />
|
||||
<option name="PROGRAM_PARAMETERS" value="COM66" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="ui" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -47,8 +47,8 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
|||
engine->engineConfiguration->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL;
|
||||
}
|
||||
|
||||
void EngineTestHelper::fireTriggerEvents() {
|
||||
for (int i = 0; i < 24; i++) {
|
||||
void EngineTestHelper::fireTriggerEvents(int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
timeNow += 5000; // 5ms
|
||||
board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc;
|
||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||
|
|
|
@ -15,7 +15,7 @@ class EngineTestHelper {
|
|||
public:
|
||||
EngineTestHelper(engine_type_e engineType);
|
||||
void initTriggerShapeAndRpmCalculator();
|
||||
void fireTriggerEvents();
|
||||
void fireTriggerEvents(int count);
|
||||
|
||||
persistent_config_s persistentConfig;
|
||||
engine_configuration2_s ec2;
|
||||
|
|
|
@ -18,7 +18,7 @@ void testSpeedDensity(void) {
|
|||
eth.ec->trigger.customTotalToothCount = 8;
|
||||
eth.initTriggerShapeAndRpmCalculator();
|
||||
|
||||
eth.fireTriggerEvents();
|
||||
eth.fireTriggerEvents(36);
|
||||
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
// 427 cubic inches, that's a LOT of engine
|
||||
|
|
|
@ -302,7 +302,8 @@ static void testRpmCalculator(void) {
|
|||
timeNow = 0;
|
||||
assertEquals(0, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
eth.fireTriggerEvents();
|
||||
eth.fireTriggerEvents(48);
|
||||
|
||||
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("index #1", 15, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
||||
|
||||
|
@ -317,8 +318,13 @@ static void testRpmCalculator(void) {
|
|||
|
||||
debugSignalExecutor = true;
|
||||
|
||||
assertEquals(eth.engine.triggerCentral.triggerState.shaft_is_synchronized, 1);
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
|
||||
int st = timeNow;
|
||||
assertEqualsM("st value", 485000, st);
|
||||
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
|
@ -335,8 +341,8 @@ static void testRpmCalculator(void) {
|
|||
scheduling_s *ev1 = schedulingQueue.getForUnitText(0);
|
||||
assertREquals((void*)ev1->callback, (void*)turnPinHigh);
|
||||
|
||||
assertEqualsM("ev 1", 245000, ev1->momentX);
|
||||
assertEqualsM("ev 2", 245000, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM("ev 1", st, ev1->momentX);
|
||||
assertEqualsM("ev 2", st, schedulingQueue.getForUnitText(1)->momentX);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
|
@ -347,10 +353,10 @@ static void testRpmCalculator(void) {
|
|||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("index #3", 3, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 3", 6, schedulingQueue.size());
|
||||
assertEqualsM("ev 3", 258333, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("ev 4", 258333, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("ev 5", 259277, schedulingQueue.getForUnitText(2)->momentX, 2);
|
||||
assertEqualsM("3/3", 259777, schedulingQueue.getForUnitText(3)->momentX);
|
||||
assertEqualsM("ev 3", st + 13333, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("ev 4", st + 13333, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("ev 5", st + 14277, schedulingQueue.getForUnitText(2)->momentX, 2);
|
||||
assertEqualsM("3/3", st + 14777, schedulingQueue.getForUnitText(3)->momentX);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
|
@ -361,21 +367,20 @@ static void testRpmCalculator(void) {
|
|||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("index #4", 6, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
||||
assertEqualsM("queue size 4", 6, schedulingQueue.size());
|
||||
assertEqualsM("4/0", 271666, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("4/0", st + 26666, schedulingQueue.getForUnitText(0)->momentX);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 5", 0, schedulingQueue.size());
|
||||
// assertEqualsM("5/1", 284500, schedulingQueue.getForUnitText(0)->momentUs);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000; // 5ms
|
||||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 6", 6, schedulingQueue.size());
|
||||
assertEqualsM("6/0", 285000, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("6/1", 285000, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("6/2", 285944, schedulingQueue.getForUnitText(2)->momentX, 1);
|
||||
assertEqualsM("6/0", st + 40000, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("6/1", st + 40000, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("6/2", st + 40944, schedulingQueue.getForUnitText(2)->momentX, 1);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
|
@ -386,10 +391,10 @@ static void testRpmCalculator(void) {
|
|||
timeNow += 5000; // 5ms
|
||||
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
|
||||
assertEqualsM("queue size 8", 6, schedulingQueue.size());
|
||||
assertEqualsM("8/0", 298333, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("8/1", 298333, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("8/2", 299277, schedulingQueue.getForUnitText(2)->momentX, 0);
|
||||
assertEqualsM2("8/3", 299777, schedulingQueue.getForUnitText(3)->momentX, 0);
|
||||
assertEqualsM("8/0", st + 53333, schedulingQueue.getForUnitText(0)->momentX);
|
||||
assertEqualsM("8/1", st + 53333, schedulingQueue.getForUnitText(1)->momentX);
|
||||
assertEqualsM2("8/2", st + 54277, schedulingQueue.getForUnitText(2)->momentX, 0);
|
||||
assertEqualsM2("8/3", st + 54777, schedulingQueue.getForUnitText(3)->momentX, 0);
|
||||
schedulingQueue.clear();
|
||||
|
||||
timeNow += 5000;
|
||||
|
@ -480,8 +485,8 @@ void testTriggerDecoder(void) {
|
|||
eth.persistentConfig.engineConfiguration.bc.sensorChartMode = SC_DETAILED_RPM;
|
||||
applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER);
|
||||
|
||||
assertEqualsM2("rpm#1", 16666.9746, eth.engine.triggerCentral.triggerState.instantRpmValue[0], 0.5);
|
||||
assertEqualsM2("rpm#2", 16666.3750, eth.engine.triggerCentral.triggerState.instantRpmValue[1], 0.5);
|
||||
// assertEqualsM2("rpm#1", 16666.9746, eth.engine.triggerCentral.triggerState.instantRpmValue[0], 0.5);
|
||||
// assertEqualsM2("rpm#2", 16666.3750, eth.engine.triggerCentral.triggerState.instantRpmValue[1], 0.5);
|
||||
|
||||
}
|
||||
// testTriggerDecoder2("miata 1990", MIATA_1990, 0, 0.6280, 0.0);
|
||||
|
|
Loading…
Reference in New Issue