Mitsubishi 4G93 Trigger issues #4918
This commit is contained in:
parent
6fca7e4f14
commit
c32506954d
|
@ -21,7 +21,7 @@ import static com.rusefi.config.generated.Fields.PROTOCOL_ES_UP;
|
|||
*/
|
||||
public class EngineReport {
|
||||
public static final String ENGINE_CHART = Fields.PROTOCOL_ENGINE_SNIFFER;
|
||||
public static final EngineReport MOCK = new EngineReport(Collections.singletonList(new UpDown(0, -1, 1, -1)));
|
||||
public static final EngineReport MOCK = new EngineReport(Collections.singletonList(new UpDown(0, -1, 1, -1, Double.NaN, Double.NaN)));
|
||||
/**
|
||||
* number of Engine Sniffer ticks per ms
|
||||
*/
|
||||
|
@ -135,7 +135,7 @@ public class EngineReport {
|
|||
int downEventIndex = downString.length > 1 ? Integer.parseInt(downString[1]) : -1;
|
||||
|
||||
|
||||
times.add(new UpDown(upTime, upEventIndex, downTime, downEventIndex));
|
||||
times.add(new UpDown(upTime, upEventIndex, downTime, downEventIndex, Double.NaN, Double.NaN));
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Invalid? [" + Arrays.toString(upString) + "][" + Arrays.toString(downString) + "]");
|
||||
}
|
||||
|
@ -170,12 +170,16 @@ public class EngineReport {
|
|||
public final int upTriggerCycleIndex;
|
||||
public final int downTime;
|
||||
public final int downTriggerCycleIndex;
|
||||
public final double prevGap;
|
||||
public final double gap;
|
||||
|
||||
public UpDown(int upTime, int upIndex, int downTime, int downIndex) {
|
||||
public UpDown(int upTime, int upIndex, int downTime, int downIndex, double prevGap, double gap) {
|
||||
this.upTime = upTime;
|
||||
this.upTriggerCycleIndex = upIndex;
|
||||
this.downTime = downTime;
|
||||
this.downTriggerCycleIndex = downIndex;
|
||||
this.prevGap = prevGap;
|
||||
this.gap = gap;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
|
|
|
@ -291,7 +291,8 @@ public class TriggerImage {
|
|||
List<TriggerSignal> toShow = new ArrayList<>(signals);
|
||||
for (int i = 1; i <= 2 + EXTRA_COUNT; i++) {
|
||||
for (TriggerSignal s : signals)
|
||||
toShow.add(new TriggerSignal(s.getWaveIndex(), s.getState(), s.getAngle() + i * 720));
|
||||
toShow.add(new TriggerSignal(s.getWaveIndex(), s.getState(), s.getAngle() + i * 720,
|
||||
s.getGap()));
|
||||
}
|
||||
|
||||
List<WaveState> waves = new ArrayList<>();
|
||||
|
@ -303,7 +304,7 @@ public class TriggerImage {
|
|||
WaveState.trigger_value_e signal = (s.getState() == 0) ? WaveState.trigger_value_e.TV_LOW : WaveState.trigger_value_e.TV_HIGH;
|
||||
|
||||
WaveState waveState = waves.get(s.getWaveIndex());
|
||||
waveState.handle(signal, s.getAngle());
|
||||
waveState.handle(signal, s.getAngle(), s.getGap());
|
||||
}
|
||||
for (WaveState wave : waves)
|
||||
wave.wrap();
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
public class WaveState {
|
||||
double unusedDown = Double.NaN;
|
||||
double prevUp = Double.NaN;
|
||||
double prevGap = Double.NaN;
|
||||
|
||||
public List<EngineReport.UpDown> list = new ArrayList<>();
|
||||
|
||||
|
@ -24,26 +25,27 @@ public class WaveState {
|
|||
TV_HIGH
|
||||
}
|
||||
|
||||
public void handle(WaveState.trigger_value_e signal, double angle) {
|
||||
public void handle(trigger_value_e signal, double angle, double gap) {
|
||||
if (signal == trigger_value_e.TV_LOW) {
|
||||
// down signal
|
||||
if (Double.isNaN(prevUp)) {
|
||||
// we have down before up, we would need to use it later
|
||||
unusedDown = angle;
|
||||
} else {
|
||||
EngineReport.UpDown ud = new EngineReport.UpDown(angleToTime(prevUp), 0, angleToTime(angle), 0);
|
||||
EngineReport.UpDown ud = new EngineReport.UpDown(angleToTime(prevUp), 0, angleToTime(angle), 0, prevGap, gap);
|
||||
list.add(ud);
|
||||
}
|
||||
prevUp = Double.NaN;
|
||||
} else {
|
||||
// up signal handling
|
||||
prevUp = angle;
|
||||
prevGap = gap;
|
||||
}
|
||||
}
|
||||
|
||||
public void wrap() {
|
||||
if (!Double.isNaN(unusedDown)) {
|
||||
list.add(0, new EngineReport.UpDown(angleToTime(prevUp), 0, angleToTime(unusedDown + 720 * (3 + TriggerImage.EXTRA_COUNT)), 0));
|
||||
list.add(0, new EngineReport.UpDown(angleToTime(prevUp), 0, angleToTime(unusedDown + 720 * (3 + TriggerImage.EXTRA_COUNT)), 0, Double.NaN, Double.NaN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,6 +263,12 @@ public class UpDownImage extends JPanel {
|
|||
return;
|
||||
}
|
||||
|
||||
// '-1' actually means 'not first wheel' it's coming from
|
||||
if (!Double.isNaN(upDown.prevGap))
|
||||
g.drawString(String.format("gap %.2f", upDown.prevGap), x1, d.height / 2);
|
||||
if (!Double.isNaN(upDown.gap))
|
||||
g.drawString(String.format("gap %.2f", upDown.gap), x2, d.height / 2);
|
||||
|
||||
if (!this.renderText) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ public class TriggerSignal {
|
|||
private final double angle;
|
||||
private final int state;
|
||||
private final int waveIndex;
|
||||
private final double gap;
|
||||
|
||||
public TriggerSignal(int waveIndex, int state, double angle) {
|
||||
public TriggerSignal(int waveIndex, int state, double angle, double gap) {
|
||||
this.waveIndex = waveIndex;
|
||||
this.state = state;
|
||||
this.angle = angle;
|
||||
this.gap = gap;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,4 +33,8 @@ public class TriggerSignal {
|
|||
public int getWaveIndex() {
|
||||
return waveIndex;
|
||||
}
|
||||
|
||||
public double getGap() {
|
||||
return gap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,9 @@ public class TriggerSignalReader {
|
|||
int signalIndex = Integer.parseInt(tokens[2]);
|
||||
int signalState = Integer.parseInt(tokens[3]);
|
||||
double angle = Double.parseDouble(tokens[4]);
|
||||
double gap = Double.parseDouble(tokens[5]);
|
||||
|
||||
TriggerSignal s = new TriggerSignal(signalIndex, signalState, angle);
|
||||
TriggerSignal s = new TriggerSignal(signalIndex, signalState, angle, gap);
|
||||
// System.out.println(s);
|
||||
signals.add(s);
|
||||
index++;
|
||||
|
|
|
@ -180,7 +180,8 @@ public class TriggerWheelInfo {
|
|||
private static List<TriggerSignal> compressAngle(List<TriggerSignal> wheel) {
|
||||
return wheel.stream().map(triggerSignal -> {
|
||||
double compressAngle = getCompressedAngle(triggerSignal.getAngle());
|
||||
return new TriggerSignal(triggerSignal.getWaveIndex(), triggerSignal.getState(), compressAngle);
|
||||
return new TriggerSignal(triggerSignal.getWaveIndex(), triggerSignal.getState(), compressAngle,
|
||||
triggerSignal.getGap());
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue