trigger images have misplaced TDC fix #4015
This commit is contained in:
parent
65fe21cf84
commit
9f3e7fc5d7
|
@ -68,8 +68,7 @@ public class EngineReport {
|
|||
return list;
|
||||
}
|
||||
|
||||
|
||||
private TimeAxisTranslator timeAxisTranslator = new TimeAxisTranslator() {
|
||||
private final TimeAxisTranslator timeAxisTranslator = new TimeAxisTranslator() {
|
||||
@Override
|
||||
public int getMaxTime() {
|
||||
return maxTime;
|
||||
|
@ -81,7 +80,7 @@ public class EngineReport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int timeToScreen(int time, int width) {
|
||||
public int timeToScreen(double time, int width) {
|
||||
// 0 = left side
|
||||
// 1 = right side
|
||||
double fraction = (time - minTime) * 1.0 / getDuration();
|
||||
|
|
|
@ -5,7 +5,7 @@ package com.rusefi.waves;
|
|||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
*/
|
||||
public interface TimeAxisTranslator {
|
||||
int timeToScreen(int time, int width);
|
||||
int timeToScreen(double time, int width);
|
||||
|
||||
double screenToTime(int screenX, int screenWidth);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public class TriggerImage {
|
|||
private static final int WHEEL_DIAMETER = 500;
|
||||
private static final int SMALL_DIAMETER = 420;
|
||||
private static final int _180 = 180;
|
||||
public static final int MIN_TIME = 720;
|
||||
|
||||
/**
|
||||
* number of extra frames
|
||||
|
@ -46,7 +47,7 @@ public class TriggerImage {
|
|||
|
||||
/**
|
||||
* todo: https://github.com/rusefi/rusefi/issues/2077
|
||||
* @see TriggerWheelInfo#isFirstCrankBased
|
||||
* @see TriggerWheelInfo#isCrankBased
|
||||
*/
|
||||
private static String getTriggerName(TriggerWheelInfo triggerName) {
|
||||
switch (triggerName.id) {
|
||||
|
@ -188,14 +189,15 @@ public class TriggerImage {
|
|||
triggerPanel.tdcPosition = triggerWheelInfo.tdcPosition;
|
||||
List<WaveState> waves = triggerWheelInfo.waves;
|
||||
|
||||
EngineReport re0 = new EngineReport(waves.get(0).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re0 = new EngineReport(waves.get(0).list, MIN_TIME, 720 * (1 + EXTRA_COUNT));
|
||||
System.out.println(re0);
|
||||
EngineReport re1 = new EngineReport(waves.get(1).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re2 = new EngineReport(waves.get(2).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re1 = new EngineReport(waves.get(1).list, MIN_TIME, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re2 = new EngineReport(waves.get(2).list, MIN_TIME, 720 * (1 + EXTRA_COUNT));
|
||||
|
||||
triggerPanel.removeAll();
|
||||
UpDownImage upDownImage0 = new UpDownImage(re0, "trigger");
|
||||
upDownImage0.setRenderText(false);
|
||||
triggerPanel.image = upDownImage0;
|
||||
|
||||
UpDownImage upDownImage1 = new UpDownImage(re1, "trigger");
|
||||
upDownImage1.setRenderText(false);
|
||||
|
@ -379,6 +381,7 @@ public class TriggerImage {
|
|||
public String name = "";
|
||||
public String id;
|
||||
public double tdcPosition;
|
||||
public UpDownImage image;
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
|
@ -415,7 +418,9 @@ public class TriggerImage {
|
|||
}
|
||||
g.drawString(" " + tdcMessage, 0, tdcFontSize);
|
||||
|
||||
int tdcX = (int) (w / 720.0 * tdcPosition);
|
||||
if (image == null)
|
||||
return;
|
||||
int tdcX = image.engineReport.getTimeAxisTranslator().timeToScreen(MIN_TIME + tdcPosition, w);
|
||||
g.drawLine(tdcX, 0, tdcX, h);
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.rotate(Math.PI / 2);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class UpDownImage extends JPanel {
|
|||
private static final BasicStroke ENGINE_CYCLE_STROKE = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f,
|
||||
new float[]{21.0f, 7.0f}, 0.0f);
|
||||
|
||||
private EngineReport engineReport;
|
||||
public EngineReport engineReport;
|
||||
private StringBuilder revolutions;
|
||||
private final String name;
|
||||
private TimeAxisTranslator translator;
|
||||
|
@ -96,7 +96,7 @@ public class UpDownImage extends JPanel {
|
|||
|
||||
private final TimeAxisTranslator _translator = new TimeAxisTranslator() {
|
||||
@Override
|
||||
public int timeToScreen(int time, int width) {
|
||||
public int timeToScreen(double time, int width) {
|
||||
return UpDownImage.this.engineReport.getTimeAxisTranslator().timeToScreen(time, width);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue