Make hard-coded gap ratios visible on trigger documentation images #4172
This commit is contained in:
parent
250d8c4213
commit
5e89bbc4c3
|
@ -162,6 +162,7 @@ public class TriggerImage {
|
||||||
UiUtils.trueLayout(content);
|
UiUtils.trueLayout(content);
|
||||||
|
|
||||||
triggerPanel.tdcPosition = triggerWheelInfo.getTdcPosition();
|
triggerPanel.tdcPosition = triggerWheelInfo.getTdcPosition();
|
||||||
|
triggerPanel.gaps = triggerWheelInfo.getGaps();
|
||||||
|
|
||||||
EngineReport re0 = new EngineReport(waves.get(0).list, MIN_TIME, 720 * (1 + EXTRA_COUNT));
|
EngineReport re0 = new EngineReport(waves.get(0).list, MIN_TIME, 720 * (1 + EXTRA_COUNT));
|
||||||
System.out.println(re0);
|
System.out.println(re0);
|
||||||
|
@ -327,6 +328,7 @@ public class TriggerImage {
|
||||||
// angle
|
// angle
|
||||||
public double tdcPosition;
|
public double tdcPosition;
|
||||||
public UpDownImage image;
|
public UpDownImage image;
|
||||||
|
public TriggerWheelInfo.TriggerGaps gaps;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
@ -362,6 +364,12 @@ public class TriggerImage {
|
||||||
tdcMessage = "TDC at synchronization point";
|
tdcMessage = "TDC at synchronization point";
|
||||||
}
|
}
|
||||||
g.drawString(" " + tdcMessage, 0, tdcFontSize);
|
g.drawString(" " + tdcMessage, 0, tdcFontSize);
|
||||||
|
g.setColor(Color.darkGray);
|
||||||
|
for (int i = 0; i < gaps.gapFrom.length; i++) {
|
||||||
|
String message = "Sync " + (i + 1) + ": From " + gaps.gapFrom[i] + " to " + gaps.gapTo[i];
|
||||||
|
g.drawString(" " + message, 0, tdcFontSize * (2 + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
|
@ -369,7 +377,7 @@ public class TriggerImage {
|
||||||
g.drawLine(tdcX, 0, tdcX, h);
|
g.drawLine(tdcX, 0, tdcX, h);
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
g2.rotate(Math.PI / 2);
|
g2.rotate(Math.PI / 2);
|
||||||
g2.drawString("TDC", 60, -tdcX - 3);
|
g2.drawString("TDC", 160, -tdcX - 3);
|
||||||
g2.rotate(-Math.PI / 2);
|
g2.rotate(-Math.PI / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.config.generated.Fields;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -21,12 +22,13 @@ public class TriggerWheelInfo {
|
||||||
private final boolean isCrankBased;
|
private final boolean isCrankBased;
|
||||||
private final boolean hasSecondChannel;
|
private final boolean hasSecondChannel;
|
||||||
private final boolean hardcodedOperationMode;
|
private final boolean hardcodedOperationMode;
|
||||||
|
private final TriggerGaps gaps;
|
||||||
|
|
||||||
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, int gapTrackingLength) {
|
boolean hardcodedOperationMode, TriggerGaps gaps) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.isSecondWheelCam = isSecondWheelCam;
|
this.isSecondWheelCam = isSecondWheelCam;
|
||||||
this.tdcPosition = tdcPosition;
|
this.tdcPosition = tdcPosition;
|
||||||
|
@ -35,6 +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 = gaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TriggerWheelInfo readTriggerWheelInfo(String line, BufferedReader reader) throws IOException {
|
private static TriggerWheelInfo readTriggerWheelInfo(String line, BufferedReader reader) throws IOException {
|
||||||
|
@ -54,7 +57,7 @@ public class TriggerWheelInfo {
|
||||||
boolean isSecondWheelCam = false;
|
boolean isSecondWheelCam = false;
|
||||||
boolean hasSecondChannel = false;
|
boolean hasSecondChannel = false;
|
||||||
boolean hardcodedOperationMode = false;
|
boolean hardcodedOperationMode = false;
|
||||||
int gapTrackingLength = 0;
|
TriggerWheelInfo.TriggerGaps gaps = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
if (line == null || line.trim().startsWith("#"))
|
if (line == null || line.trim().startsWith("#"))
|
||||||
|
@ -63,16 +66,21 @@ public class TriggerWheelInfo {
|
||||||
if (keyValue.length != 2)
|
if (keyValue.length != 2)
|
||||||
throw new IllegalStateException("Key/value lines expected: [" + line + "]");
|
throw new IllegalStateException("Key/value lines expected: [" + line + "]");
|
||||||
String key = keyValue[0];
|
String key = keyValue[0];
|
||||||
|
String value = keyValue[1];
|
||||||
if (key.startsWith(TRIGGER_GAP_FROM)) {
|
if (key.startsWith(TRIGGER_GAP_FROM)) {
|
||||||
|
int index = getIndex(key);
|
||||||
|
gaps.gapFrom[index] = Double.parseDouble(value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key.startsWith(TRIGGER_GAP_TO)) {
|
if (key.startsWith(TRIGGER_GAP_TO)) {
|
||||||
|
int index = getIndex(key);
|
||||||
|
gaps.gapTo[index] = Double.parseDouble(value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String value = keyValue[1];
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case TRIGGER_GAPS_COUNT:
|
case TRIGGER_GAPS_COUNT:
|
||||||
gapTrackingLength = Integer.parseInt(value);
|
int gapTrackingLength = Integer.parseInt(value);
|
||||||
|
gaps = new TriggerGaps(gapTrackingLength);
|
||||||
break;
|
break;
|
||||||
case TRIGGER_IS_CRANK_KEY:
|
case TRIGGER_IS_CRANK_KEY:
|
||||||
isCrankBased = Boolean.parseBoolean(value);
|
isCrankBased = Boolean.parseBoolean(value);
|
||||||
|
@ -99,13 +107,17 @@ public class TriggerWheelInfo {
|
||||||
isSecondWheelCam,
|
isSecondWheelCam,
|
||||||
hasSecondChannel,
|
hasSecondChannel,
|
||||||
hardcodedOperationMode,
|
hardcodedOperationMode,
|
||||||
gapTrackingLength
|
gaps
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getIndex(String key) {
|
||||||
|
return Integer.parseInt(key.split("\\.")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
static void readWheels(String workingFolder, TriggerWheelInfoConsumer consumer) {
|
static void readWheels(String workingFolder, TriggerWheelInfoConsumer consumer) {
|
||||||
String fileName = workingFolder + File.separator + Fields.TRIGGERS_FILE_NAME;
|
String fileName = workingFolder + File.separator + Fields.TRIGGERS_FILE_NAME;
|
||||||
BufferedReader br = null;
|
BufferedReader br;
|
||||||
try {
|
try {
|
||||||
br = new BufferedReader(new FileReader(fileName));
|
br = new BufferedReader(new FileReader(fileName));
|
||||||
|
|
||||||
|
@ -205,7 +217,29 @@ public class TriggerWheelInfo {
|
||||||
return hardcodedOperationMode;
|
return hardcodedOperationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TriggerGaps getGaps() {
|
||||||
|
return gaps;
|
||||||
|
}
|
||||||
|
|
||||||
public interface TriggerWheelInfoConsumer {
|
public interface TriggerWheelInfoConsumer {
|
||||||
void onWheel(TriggerWheelInfo wheelInfo);
|
void onWheel(TriggerWheelInfo wheelInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class TriggerGaps {
|
||||||
|
public double[] gapFrom;
|
||||||
|
public double[] gapTo;
|
||||||
|
|
||||||
|
public TriggerGaps(int gapTrackingLength) {
|
||||||
|
gapFrom = new double[gapTrackingLength];
|
||||||
|
gapTo = new double[gapTrackingLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TriggerGaps{" +
|
||||||
|
"gapFrom=" + Arrays.toString(gapFrom) +
|
||||||
|
", gapTo=" + Arrays.toString(gapTo) +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue