Refactoring, technical debt: export more of trigger attributes into triggers.txt file #2077
This commit is contained in:
parent
f3b2cefe27
commit
1b334656e1
|
@ -15,13 +15,15 @@ class TriggerWheelInfo {
|
||||||
final String triggerName;
|
final String triggerName;
|
||||||
final List<WaveState> waves;
|
final List<WaveState> waves;
|
||||||
final List<TriggerSignal> signals;
|
final List<TriggerSignal> signals;
|
||||||
|
private final boolean isCrankBased;
|
||||||
|
|
||||||
public TriggerWheelInfo(int id, double tdcPosition, String triggerName, List<WaveState> waves, List<TriggerSignal> signals) {
|
public TriggerWheelInfo(int id, double tdcPosition, String triggerName, List<WaveState> waves, List<TriggerSignal> signals, boolean isCrankBased) {
|
||||||
this.id = findByOrdinal(id);
|
this.id = findByOrdinal(id);
|
||||||
this.tdcPosition = tdcPosition;
|
this.tdcPosition = tdcPosition;
|
||||||
this.triggerName = triggerName;
|
this.triggerName = triggerName;
|
||||||
this.waves = waves;
|
this.waves = waves;
|
||||||
this.signals = signals;
|
this.signals = signals;
|
||||||
|
this.isCrankBased = isCrankBased;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static trigger_type_e findByOrdinal(int id) {
|
public static trigger_type_e findByOrdinal(int id) {
|
||||||
|
@ -44,17 +46,24 @@ class TriggerWheelInfo {
|
||||||
|
|
||||||
System.out.println("id=" + id + ", count=" + eventCount + ", name=" + triggerName);
|
System.out.println("id=" + id + ", count=" + eventCount + ", name=" + triggerName);
|
||||||
|
|
||||||
|
line = reader.readLine();
|
||||||
|
String[] keyValue = line.split("=");
|
||||||
|
if (keyValue.length!=2)
|
||||||
|
throw new IllegalStateException("Key/value lines expected");
|
||||||
|
boolean isCrankBased = Boolean.valueOf(keyValue[1]);
|
||||||
|
|
||||||
List<TriggerSignal> signals = TriggerImage.readSignals(reader, eventCount);
|
List<TriggerSignal> signals = TriggerImage.readSignals(reader, eventCount);
|
||||||
|
|
||||||
List<WaveState> waves = TriggerImage.convertSignalsToWaves(signals);
|
List<WaveState> waves = TriggerImage.convertSignalsToWaves(signals);
|
||||||
|
|
||||||
return new TriggerWheelInfo(id, tdcPosition, triggerName, waves, signals);
|
return new TriggerWheelInfo(id, tdcPosition, triggerName, waves, signals, isCrankBased);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
List<TriggerSignal> getFirstWheeTriggerSignals() {
|
List<TriggerSignal> getFirstWheeTriggerSignals() {
|
||||||
List<TriggerSignal> firstWheel = getTriggerSignals(0);
|
List<TriggerSignal> firstWheel = getTriggerSignals(0);
|
||||||
if (isFirstCrankBased()) {
|
// todo: support symmetrical crank
|
||||||
|
if (isCrankBased) {
|
||||||
return takeFirstHalf(firstWheel);
|
return takeFirstHalf(firstWheel);
|
||||||
} else {
|
} else {
|
||||||
return compressAngle(firstWheel);
|
return compressAngle(firstWheel);
|
||||||
|
@ -62,7 +71,7 @@ class TriggerWheelInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTdcPositionIn360() {
|
public double getTdcPositionIn360() {
|
||||||
return isFirstCrankBased() ? tdcPosition : getCompressedAngle(tdcPosition);
|
return isCrankBased ? tdcPosition : getCompressedAngle(tdcPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -99,24 +108,6 @@ class TriggerWheelInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: this 'isFirstCrankBased' should be taken from triggers.txt not hard-coded here!
|
|
||||||
// todo: open question if current firmware even has info to provide this info or not?
|
|
||||||
// todo: https://github.com/rusefi/rusefi/issues/2077
|
|
||||||
private boolean isFirstCrankBased() {
|
|
||||||
return id == trigger_type_e.TT_GM_LS_24 ||
|
|
||||||
id == trigger_type_e.TT_HONDA_K_12_1 ||
|
|
||||||
id == trigger_type_e.TT_RENIX_44_2_2 ||
|
|
||||||
id == trigger_type_e.TT_RENIX_66_2_2_2 ||
|
|
||||||
id == trigger_type_e.TT_MIATA_VVT ||
|
|
||||||
id == trigger_type_e.TT_TRI_TACH ||
|
|
||||||
id == trigger_type_e.TT_60_2_VW ||
|
|
||||||
id == trigger_type_e.TT_SKODA_FAVORIT ||
|
|
||||||
id == trigger_type_e.TT_KAWA_KX450F ||
|
|
||||||
id == trigger_type_e.TT_NISSAN_VQ35 ||
|
|
||||||
id == trigger_type_e.TT_NISSAN_QR25 ||
|
|
||||||
id == trigger_type_e.TT_GM_7X;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: this 'isFirstCrankBased' should be taken from triggers.txt not hard-coded here!
|
// todo: this 'isFirstCrankBased' should be taken from triggers.txt not hard-coded here!
|
||||||
// todo: open question if current firmware even has info to provide this info or not?
|
// todo: open question if current firmware even has info to provide this info or not?
|
||||||
// todo: https://github.com/rusefi/rusefi/issues/2077
|
// todo: https://github.com/rusefi/rusefi/issues/2077
|
||||||
|
|
|
@ -67,7 +67,8 @@ TEST_P(AllTriggersFixture, TestTrigger) {
|
||||||
ASSERT_FALSE(shape->shapeDefinitionError) << "Trigger shapeDefinitionError";
|
ASSERT_FALSE(shape->shapeDefinitionError) << "Trigger shapeDefinitionError";
|
||||||
|
|
||||||
fprintf(fp, "TRIGGERTYPE %d %d %s %.2f\n", tt, shape->getLength(), getTrigger_type_e(tt), shape->tdcPosition);
|
fprintf(fp, "TRIGGERTYPE %d %d %s %.2f\n", tt, shape->getLength(), getTrigger_type_e(tt), shape->tdcPosition);
|
||||||
|
// todo: use getCrankDivider insread to support symmetrical crank wheels?
|
||||||
|
fprintf(fp, "%s=%s\n", TRIGGER_IS_CRANK_KEY, shape->getOperationMode() == FOUR_STROKE_CRANK_SENSOR ? "true" : "false");
|
||||||
fprintf(fp, "# duty %.2f %.2f\n", shape->expectedDutyCycle[0], shape->expectedDutyCycle[1]);
|
fprintf(fp, "# duty %.2f %.2f\n", shape->expectedDutyCycle[0], shape->expectedDutyCycle[1]);
|
||||||
|
|
||||||
for (size_t i = 0; i < shape->getLength(); i++) {
|
for (size_t i = 0; i < shape->getLength(); i++) {
|
||||||
|
|
Loading…
Reference in New Issue