From 0ba97379fba564a6f0daf82d7f9cef0170c48ed2 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 2 Dec 2020 22:17:38 -0500 Subject: [PATCH] all triggers should be documented way nicer #2001 --- .../trigger/decoders/trigger_structure.cpp | 7 ++--- .../trigger/decoders/trigger_structure.h | 3 ++- .../controllers/trigger/trigger_central.cpp | 6 ++++- .../main/java/com/rusefi/TriggerImage.java | 26 +++++++++---------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index f378b51d43..07dfffc6f2 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -102,7 +102,8 @@ void TriggerWaveform::initialize(operation_mode_e operationMode) { previousAngle = 0; memset(isRiseEvent, 0, sizeof(isRiseEvent)); #if EFI_UNIT_TEST - memset(&triggerSignals, 0, sizeof(triggerSignals)); + memset(&triggerSignalIndeces, 0, sizeof(triggerSignalIndeces)); + memset(&triggerSignalStates, 0, sizeof(triggerSignalStates)); #endif } @@ -228,8 +229,8 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex } #if EFI_UNIT_TEST - int signal = channelIndex * 1000 + stateParam; - triggerSignals[privateTriggerDefinitionSize] = signal; + triggerSignalIndeces[privateTriggerDefinitionSize] = channelIndex; + triggerSignalStates[privateTriggerDefinitionSize] = stateParam; #endif diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 5fd05cc99c..dd05fb7167 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -181,7 +181,8 @@ public: /** * These signals are used for trigger export only */ - int triggerSignals[PWM_PHASE_MAX_COUNT]; + int triggerSignalIndeces[PWM_PHASE_MAX_COUNT]; + int triggerSignalStates[PWM_PHASE_MAX_COUNT]; #endif MultiChannelStateSequence wave; diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 6b95b789e0..147f77ada1 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -566,7 +566,11 @@ void printAllTriggers() { int triggerDefinitionCoordinate = (shape->getTriggerWaveformSynchPointIndex() + i) % shape->getSize(); - fprintf(fp, "event %d %d %.2f\n", i, shape->triggerSignals[triggerDefinitionCoordinate], triggerFormDetails->eventAngles[i]); + fprintf(fp, "event %d %d %d %.2f\n", + i, + shape->triggerSignalIndeces[triggerDefinitionCoordinate], + shape->triggerSignalStates[triggerDefinitionCoordinate], + triggerFormDetails->eventAngles[i]); } } diff --git a/java_console/ui/src/main/java/com/rusefi/TriggerImage.java b/java_console/ui/src/main/java/com/rusefi/TriggerImage.java index 0f6f485f71..e160c93b07 100644 --- a/java_console/ui/src/main/java/com/rusefi/TriggerImage.java +++ b/java_console/ui/src/main/java/com/rusefi/TriggerImage.java @@ -187,12 +187,11 @@ public class TriggerImage { tokens = line.split(" "); if (tokens.length < 4) throw new IllegalStateException("Unexpected [" + line + "]"); - String signalStr = tokens[2]; - int signal = Integer.parseInt(signalStr); - String angleStr = tokens[3]; - double angle = Double.parseDouble(angleStr); + int signalIndex = Integer.parseInt(tokens[2]); + int signalState = Integer.parseInt(tokens[3]); + double angle = Double.parseDouble(tokens[4]); - Signal s = new Signal(signal, angle); + Signal s = new Signal(signalIndex, signalState, angle); // System.out.println(s); signals.add(s); index++; @@ -201,7 +200,7 @@ public class TriggerImage { List toShow = new ArrayList<>(signals); for (int i = 1; i <= 2 + EXTRA_COUNT; i++) { for (Signal s : signals) - toShow.add(new Signal(s.signal, s.angle + i * 720)); + toShow.add(new Signal(s.waveIndex, s.state, s.angle + i * 720)); } List waves = new ArrayList<>(); @@ -210,10 +209,9 @@ public class TriggerImage { waves.add(new WaveState()); for (Signal s : toShow) { - int waveIndex = s.signal / 1000; - WaveState.trigger_value_e signal = (s.signal % 1000 == 0) ? WaveState.trigger_value_e.TV_LOW : WaveState.trigger_value_e.TV_HIGH; + WaveState.trigger_value_e signal = (s.state == 0) ? WaveState.trigger_value_e.TV_LOW : WaveState.trigger_value_e.TV_HIGH; - WaveState waveState = waves.get(waveIndex); + WaveState waveState = waves.get(s.waveIndex); waveState.handle(signal, s.angle); } for (WaveState wave : waves) @@ -227,18 +225,20 @@ public class TriggerImage { } private static class Signal { - private final int signal; private final double angle; + private final int state; + private final int waveIndex; - public Signal(int signal, double angle) { - this.signal = signal; + public Signal(int waveIndex, int state, double angle) { + this.waveIndex = waveIndex; + this.state = state; this.angle = angle; } @Override public String toString() { return "Signal{" + - "signal=" + signal + + "signal=" + waveIndex + ", angle=" + angle + '}'; }