rusEfi console: refactoring & minor engine sniffer cleanup

This commit is contained in:
rusefi 2019-05-01 09:55:53 -04:00
parent 1ad0df904e
commit 4622bdd6ac
8 changed files with 32 additions and 22 deletions

View File

@ -112,7 +112,7 @@ public class LinkManager {
/**
* This flag controls if mock controls are needed
*/
public static boolean isStimulationMode;
public static boolean isSimulationMode;
public static void start(String port) {
FileLog.MAIN.logLine("LinkManager: Starting " + port);
@ -120,7 +120,7 @@ public class LinkManager {
connector = LinkConnector.VOID;
} else if (TcpConnector.isTcpPort(port)) {
connector = new TcpConnector(port);
isStimulationMode = true;
isSimulationMode = true;
} else {
connector = new SerialConnector(port);
}

View File

@ -13,7 +13,7 @@ import java.util.List;
* Date: 6/23/13
* (c) Andrey Belomutskiy
*
* @see com.rusefi.ui.engine.EngineSnifferPanel.AnalogChart
* @see SensorSnifferPane
*/
public class EngineReport implements TimeAxisTranslator {
public static final String ENGINE_CHART = "wave_chart";
@ -136,7 +136,7 @@ public class EngineReport implements TimeAxisTranslator {
}
/**
* @return Length of this chart ini systicks
* @return Length of this chart in systicks
*/
public int getDuration() {
return maxTime - minTime;

View File

@ -174,7 +174,7 @@ public class Launcher {
// tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
// tabbedPane.addTab("ADC", new AdcPanel(new BooleanInputsModel()).createAdcPanel());
if (SHOW_STIMULATOR && !LinkManager.isStimulationMode && !LinkManager.isLogViewerMode(port)) {
if (SHOW_STIMULATOR && !LinkManager.isSimulationMode && !LinkManager.isLogViewerMode(port)) {
// todo: rethink this UI? special command line key to enable it?
EcuStimulator stimulator = EcuStimulator.getInstance();
tabbedPane.add("ECU stimulation", stimulator.getPanel());

View File

@ -22,7 +22,7 @@ public class SimulatorHelper {
* todo: unify with the code which starts simulator for auto tests?
*/
private static void startSimulator() {
LinkManager.isStimulationMode = true;
LinkManager.isSimulationMode = true;
FileLog.MAIN.logLine("Executing " + BINARY);
new Thread(new Runnable() {

View File

@ -3,6 +3,7 @@ package com.rusefi.ui.engine;
import com.rusefi.Launcher;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.io.LinkManager;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.waves.EngineReport;
import com.rusefi.waves.RevolutionLog;
@ -35,7 +36,7 @@ public class UpDownImage extends JPanel {
public static final Color ENGINE_CYCLE_COLOR = Color.green;
private long lastUpdateTime;
private EngineReport wr;
private EngineReport engineReport;
private StringBuilder revolutions;
private final String name;
private TimeAxisTranslator translator;
@ -78,7 +79,9 @@ public class UpDownImage extends JPanel {
}
public void setToolTip() {
UiUtils.setTwoLineToolTip(this, "Channel " + NameUtil.getUiName(name), "Physical pin: " + pin);
// no physical pin information in simulator
String secondLine = LinkManager.isSimulationMode ? "" : "Physical pin: " + pin;
UiUtils.setToolTip(this, "Channel " + NameUtil.getUiName(name), secondLine);
}
public void setZoomProvider(ZoomProvider zoomProvider) {
@ -115,22 +118,22 @@ public class UpDownImage extends JPanel {
return new TimeAxisTranslator() {
@Override
public int timeToScreen(int time, int width) {
return UpDownImage.this.wr.timeToScreen(time, width);
return UpDownImage.this.engineReport.timeToScreen(time, width);
}
@Override
public double screenToTime(int screen, int width) {
return UpDownImage.this.wr.screenToTime(screen, width);
return UpDownImage.this.engineReport.screenToTime(screen, width);
}
@Override
public int getMaxTime() {
return UpDownImage.this.wr.getMaxTime();
return UpDownImage.this.engineReport.getMaxTime();
}
@Override
public int getMinTime() {
return UpDownImage.this.wr.getMinTime();
return UpDownImage.this.engineReport.getMinTime();
}
@Override
@ -141,7 +144,7 @@ public class UpDownImage extends JPanel {
}
public void setWaveReport(EngineReport wr, StringBuilder revolutions) {
this.wr = wr;
this.engineReport = wr;
propagateDwellIntoSensor(wr);
this.revolutions = revolutions;
lastUpdateTime = System.currentTimeMillis();
@ -168,13 +171,13 @@ public class UpDownImage extends JPanel {
g.setColor(getBackground());
g.fillRect(0, 0, d.width, d.height);
for (EngineReport.UpDown upDown : wr.getList())
for (EngineReport.UpDown upDown : engineReport.getList())
paintUpDown(d, upDown, g);
if (showMouseOverText)
paintScaleLines(g2, d);
int duration = wr.getDuration();
int duration = engineReport.getDuration();
g2.setColor(Color.black);
int line = 0;
@ -197,8 +200,9 @@ public class UpDownImage extends JPanel {
}
if (showMouseOverText) {
g.drawString("Tick length: " + duration + "; count=" + wr.getList().size(), 5, ++line * LINE_SIZE);
g.drawString("Total seconds: " + (duration / EngineReport.SYS_TICKS_PER_MS / 000.0), 5, ++line * LINE_SIZE);
g.drawString("Showing " + engineReport.getList().size() + " events", 5, ++line * LINE_SIZE);
// todo: this has to be broken in case of real engine since 'SYS_TICKS_PER_MS' here is not correct?
// g.drawString("Total seconds: " + (duration / EngineReport.SYS_TICKS_PER_MS / 1000.0), 5, ++line * LINE_SIZE);
g.drawString(FORMAT.format(new Date(lastUpdateTime)), 5, ++line * LINE_SIZE);
}

View File

@ -100,8 +100,14 @@ public class UiUtils {
component.repaint();
}
public static void setTwoLineToolTip(JComponent component, String line1, String line2) {
component.setToolTipText("<html>" + line1 + "<br>" + line2 + "</html>");
public static void setToolTip(JComponent component, String... lines) {
StringBuilder sb = new StringBuilder();
for (String line : lines) {
if (sb.length() != 0)
sb.append("<br>");
sb.append(line);
}
component.setToolTipText("<html>" + sb + "</html>");
}
public static JComponent wrap(JComponent component) {

View File

@ -119,7 +119,7 @@ public class DetachedSensor {
}
private boolean isMockable() {
return MOCKABLE.contains(sensor) && LinkManager.isStimulationMode;
return MOCKABLE.contains(sensor) && LinkManager.isSimulationMode;
}
private static Component createMockVoltageSlider(final Sensor sensor) {

View File

@ -48,8 +48,8 @@ public class SensorGauge {
final JMenuItem extraMenuItem) {
final Radial gauge = createRadial(sensor.getName(), sensor.getUnits(), sensor.getMaxValue(), sensor.getMinValue());
UiUtils.setTwoLineToolTip(gauge, HINT_LINE_1, HINT_LINE_2);
UiUtils.setTwoLineToolTip(wrapper, HINT_LINE_1, HINT_LINE_2);
UiUtils.setToolTip(gauge, HINT_LINE_1, HINT_LINE_2);
UiUtils.setToolTip(wrapper, HINT_LINE_1, HINT_LINE_2);
gauge.setBackgroundColor(sensor.getColor());