one step back
This commit is contained in:
parent
428f37ca21
commit
f9d226f66a
|
@ -1,6 +1,7 @@
|
||||||
package com.rusefi.trigger;
|
package com.rusefi.trigger;
|
||||||
|
|
||||||
import com.rusefi.StartupFrame;
|
import com.rusefi.StartupFrame;
|
||||||
|
import com.rusefi.enums.trigger_type_e;
|
||||||
import com.rusefi.ui.engine.UpDownImage;
|
import com.rusefi.ui.engine.UpDownImage;
|
||||||
import com.rusefi.core.ui.FrameHelper;
|
import com.rusefi.core.ui.FrameHelper;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
|
@ -14,7 +15,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This utility produces images of trigger signals supported by rusEFI
|
* This utility produces images of trigger signals supported by rusEFI
|
||||||
|
@ -37,13 +37,14 @@ public class TriggerImage {
|
||||||
*/
|
*/
|
||||||
public static int EXTRA_COUNT = 1;
|
public static int EXTRA_COUNT = 1;
|
||||||
private static int sleepAtEnd;
|
private static int sleepAtEnd;
|
||||||
|
private static trigger_type_e onlyOneTrigger = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* todo: https://github.com/rusefi/rusefi/issues/2077
|
* todo: https://github.com/rusefi/rusefi/issues/2077
|
||||||
* @see TriggerWheelInfo#isCrankBased
|
* @see TriggerWheelInfo#isCrankBased
|
||||||
*/
|
*/
|
||||||
private static String getTriggerName(TriggerWheelInfo triggerName) {
|
private static String getTriggerName(TriggerWheelInfo triggerName) {
|
||||||
switch (TriggerWheelInfo.findByOrdinal(triggerName.getId())) {
|
switch (findByOrdinal(triggerName.getId())) {
|
||||||
case TT_FORD_ASPIRE:
|
case TT_FORD_ASPIRE:
|
||||||
return "Ford Aspire";
|
return "Ford Aspire";
|
||||||
case TT_VVT_BOSCH_QUICK_START:
|
case TT_VVT_BOSCH_QUICK_START:
|
||||||
|
@ -101,7 +102,7 @@ public class TriggerImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
TriggerWheelInfo.onlyOneTrigger = TriggerWheelInfo.findByOrdinal(Integer.parseInt(args[1]));
|
onlyOneTrigger = findByOrdinal(Integer.parseInt(args[1]));
|
||||||
|
|
||||||
if (args.length > 2)
|
if (args.length > 2)
|
||||||
sleepAtEnd = Integer.parseInt(args[2]);
|
sleepAtEnd = Integer.parseInt(args[2]);
|
||||||
|
@ -136,7 +137,7 @@ public class TriggerImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onWheel(TriggerPanel triggerPanel, JPanel topPanel, JPanel content, TriggerWheelInfo triggerWheelInfo) {
|
private static void onWheel(TriggerPanel triggerPanel, JPanel topPanel, JPanel content, TriggerWheelInfo triggerWheelInfo) {
|
||||||
if (TriggerWheelInfo.onlyOneTrigger != null && TriggerWheelInfo.findByOrdinal(triggerWheelInfo.getId()) != TriggerWheelInfo.onlyOneTrigger)
|
if (onlyOneTrigger != null && findByOrdinal(triggerWheelInfo.getId()) != onlyOneTrigger)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
topPanel.removeAll();
|
topPanel.removeAll();
|
||||||
|
@ -197,7 +198,7 @@ public class TriggerImage {
|
||||||
UiUtils.trueRepaint(triggerPanel);
|
UiUtils.trueRepaint(triggerPanel);
|
||||||
content.paintImmediately(content.getVisibleRect());
|
content.paintImmediately(content.getVisibleRect());
|
||||||
new File(OUTPUT_FOLDER).mkdir();
|
new File(OUTPUT_FOLDER).mkdir();
|
||||||
UiUtils.saveImage(OUTPUT_FOLDER + File.separator + "trigger_" + TriggerWheelInfo.findByOrdinal(triggerWheelInfo.getId()) + ".png", content);
|
UiUtils.saveImage(OUTPUT_FOLDER + File.separator + "trigger_" + findByOrdinal(triggerWheelInfo.getId()) + ".png", content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -310,6 +311,15 @@ public class TriggerImage {
|
||||||
return waves;
|
return waves;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static trigger_type_e findByOrdinal(int id) {
|
||||||
|
// todo: do we care about quicker implementation? probably not
|
||||||
|
for (trigger_type_e type : trigger_type_e.values()) {
|
||||||
|
if (type.ordinal() == id)
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("No type for " + id);
|
||||||
|
}
|
||||||
|
|
||||||
private static class TriggerPanel extends JPanel {
|
private static class TriggerPanel extends JPanel {
|
||||||
public String name = "";
|
public String name = "";
|
||||||
public String id;
|
public String id;
|
||||||
|
@ -353,7 +363,6 @@ public class TriggerImage {
|
||||||
}
|
}
|
||||||
g.drawString(" " + tdcMessage, 0, tdcFontSize);
|
g.drawString(" " + tdcMessage, 0, tdcFontSize);
|
||||||
g.setColor(Color.darkGray);
|
g.setColor(Color.darkGray);
|
||||||
Objects.requireNonNull(gaps.gapFrom, "gaps from " + name);
|
|
||||||
for (int i = 0; i < gaps.gapFrom.length; i++) {
|
for (int i = 0; i < gaps.gapFrom.length; i++) {
|
||||||
String message = "Sync " + (i + 1) + ": From " + gaps.gapFrom[i] + " to " + gaps.gapTo[i];
|
String message = "Sync " + (i + 1) + ": From " + gaps.gapFrom[i] + " to " + gaps.gapTo[i];
|
||||||
g.drawString(" " + message, 0, tdcFontSize * (2 + i));
|
g.drawString(" " + message, 0, tdcFontSize * (2 + i));
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.rusefi.trigger;
|
package com.rusefi.trigger;
|
||||||
|
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.enums.trigger_type_e;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.rusefi.config.generated.Fields.*;
|
import static com.rusefi.config.generated.Fields.*;
|
||||||
|
@ -15,7 +13,6 @@ import static com.rusefi.config.generated.Fields.*;
|
||||||
public class TriggerWheelInfo {
|
public class TriggerWheelInfo {
|
||||||
private static final String TRIGGERTYPE = "TRIGGERTYPE";
|
private static final String TRIGGERTYPE = "TRIGGERTYPE";
|
||||||
static final String DEFAULT_WORK_FOLDER = ".." + File.separator + "unit_tests";
|
static final String DEFAULT_WORK_FOLDER = ".." + File.separator + "unit_tests";
|
||||||
static trigger_type_e onlyOneTrigger = null;
|
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final boolean isSecondWheelCam;
|
private final boolean isSecondWheelCam;
|
||||||
|
@ -26,14 +23,12 @@ public class TriggerWheelInfo {
|
||||||
private final boolean hasSecondChannel;
|
private final boolean hasSecondChannel;
|
||||||
private final boolean hardcodedOperationMode;
|
private final boolean hardcodedOperationMode;
|
||||||
private final TriggerGaps gaps;
|
private final TriggerGaps gaps;
|
||||||
private final int cycleDuration;
|
|
||||||
|
|
||||||
public TriggerWheelInfo(int id, double tdcPosition, String triggerName, List<TriggerSignal> signals,
|
public TriggerWheelInfo(int id, double tdcPosition, String triggerName, List<TriggerSignal> signals,
|
||||||
boolean isCrankBased,
|
boolean isCrankBased,
|
||||||
boolean isSecondWheelCam,
|
boolean isSecondWheelCam,
|
||||||
boolean hasSecondChannel,
|
boolean hasSecondChannel,
|
||||||
boolean hardcodedOperationMode, TriggerGaps gaps,
|
boolean hardcodedOperationMode, TriggerGaps gaps) {
|
||||||
int cycleDuration) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.isSecondWheelCam = isSecondWheelCam;
|
this.isSecondWheelCam = isSecondWheelCam;
|
||||||
this.tdcPosition = tdcPosition;
|
this.tdcPosition = tdcPosition;
|
||||||
|
@ -42,19 +37,7 @@ public class TriggerWheelInfo {
|
||||||
this.isCrankBased = isCrankBased;
|
this.isCrankBased = isCrankBased;
|
||||||
this.hasSecondChannel = hasSecondChannel;
|
this.hasSecondChannel = hasSecondChannel;
|
||||||
this.hardcodedOperationMode = hardcodedOperationMode;
|
this.hardcodedOperationMode = hardcodedOperationMode;
|
||||||
this.gaps = Objects.requireNonNull(gaps, "gaps " + triggerName);
|
this.gaps = gaps;
|
||||||
this.cycleDuration = cycleDuration;
|
|
||||||
boolean crankCycled = cycleDuration == 360;
|
|
||||||
com.rusefi.enums.trigger_type_e ordinal = findByOrdinal(id);
|
|
||||||
if (ordinal == onlyOneTrigger) {
|
|
||||||
System.out.println("That's the one: " + ordinal);
|
|
||||||
}
|
|
||||||
if (id != trigger_type_e_TT_36_2_2_2) {
|
|
||||||
if (crankCycled && !isCrankBased)
|
|
||||||
throw new IllegalStateException("Not isCrankBased " + triggerName + " " + cycleDuration);
|
|
||||||
if (!crankCycled && isCrankBased)
|
|
||||||
throw new IllegalStateException("Not crankCycled " + triggerName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TriggerWheelInfo readTriggerWheelInfo(String line, BufferedReader reader) throws IOException {
|
private static TriggerWheelInfo readTriggerWheelInfo(String line, BufferedReader reader) throws IOException {
|
||||||
|
@ -128,8 +111,7 @@ public class TriggerWheelInfo {
|
||||||
isSecondWheelCam,
|
isSecondWheelCam,
|
||||||
hasSecondChannel,
|
hasSecondChannel,
|
||||||
hardcodedOperationMode,
|
hardcodedOperationMode,
|
||||||
gaps,
|
gaps
|
||||||
cycleDuration
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,15 +144,6 @@ public class TriggerWheelInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static com.rusefi.enums.trigger_type_e findByOrdinal(int id) {
|
|
||||||
// todo: do we care about quicker implementation? probably not
|
|
||||||
for (trigger_type_e type : com.rusefi.enums.trigger_type_e.values()) {
|
|
||||||
if (type.ordinal() == id)
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("No type for " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<TriggerSignal> getFirstWheeTriggerSignals() {
|
public List<TriggerSignal> getFirstWheeTriggerSignals() {
|
||||||
List<TriggerSignal> firstWheel = getTriggerSignals(0);
|
List<TriggerSignal> firstWheel = getTriggerSignals(0);
|
||||||
|
|
Loading…
Reference in New Issue