auto-sync
This commit is contained in:
parent
e351b7dd5a
commit
3b96cfc360
|
@ -0,0 +1,20 @@
|
|||
package com.rusefi;
|
||||
|
||||
/**
|
||||
* 1/18/2015
|
||||
*/
|
||||
public enum OutputChannel {
|
||||
WaveChartCurrentSize(11),
|
||||
RunningTriggerError(12),
|
||||
RunningOrderingTriggerError(13),
|
||||
;
|
||||
private final int protocolId;
|
||||
|
||||
OutputChannel(int protocolId) {
|
||||
this.protocolId = protocolId;
|
||||
}
|
||||
|
||||
public int getProtocolId() {
|
||||
return protocolId;
|
||||
}
|
||||
}
|
|
@ -19,10 +19,12 @@ import javax.swing.*;
|
|||
* @see WavePanel
|
||||
*/
|
||||
public class Launcher extends FrameHelper {
|
||||
public static final int CONSOLE_VERSION = 20150112;
|
||||
public static final int CONSOLE_VERSION = 20150118;
|
||||
public static final boolean SHOW_STIMULATOR = true;
|
||||
private final String port;
|
||||
|
||||
public static int defaultFontSize;
|
||||
|
||||
public Launcher(String port) {
|
||||
this.port = port;
|
||||
FileLog.MAIN.start();
|
||||
|
@ -51,6 +53,7 @@ public class Launcher extends FrameHelper {
|
|||
}
|
||||
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
||||
tabbedPane.add("Messages", new MsgPanel(true).getContent());
|
||||
tabbedPane.add("Wizards", new Wizard().createPane());
|
||||
|
||||
|
||||
if (!LinkManager.isLogViewerMode(port))
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.awt.event.WindowEvent;
|
|||
*/
|
||||
public class FrameHelper {
|
||||
protected final JFrame frame = new JFrame();
|
||||
public static int defaultFontSize;
|
||||
|
||||
protected void showFrame(JComponent component) {
|
||||
frame.setSize(800, 500);
|
||||
|
@ -29,6 +30,12 @@ public class FrameHelper {
|
|||
}
|
||||
});
|
||||
frame.add(component);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
defaultFontSize = frame.getFont().getSize();
|
||||
}
|
||||
});
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -40,4 +47,8 @@ public class FrameHelper {
|
|||
FileLog.rlog("onWindowClosed");
|
||||
FileLog.MAIN.close();
|
||||
}
|
||||
|
||||
public int getDefaultFontSize() {
|
||||
return defaultFontSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.irnems.core.Sensor;
|
||||
import com.irnems.core.SensorCentral;
|
||||
import com.rusefi.OutputChannel;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.trigger.TriggerShapeHolder;
|
||||
import com.rusefi.ui.widgets.UpDownImage;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* 1/17/2015
|
||||
*/
|
||||
public class Wizard {
|
||||
private final JPanel content = new JPanel();
|
||||
private final JButton button = new JButton("Trigger Wizard");
|
||||
|
||||
interface WizardStep {
|
||||
Component getContent();
|
||||
}
|
||||
|
||||
abstract class WizardStepImpl implements WizardStep {
|
||||
protected WizardStep nextStep;
|
||||
|
||||
public WizardStepImpl() {
|
||||
}
|
||||
|
||||
public WizardStepImpl setNext(WizardStepImpl nextStep) {
|
||||
this.nextStep = nextStep;
|
||||
return nextStep;
|
||||
}
|
||||
}
|
||||
|
||||
class SendCommand extends WizardStepImpl {
|
||||
private final String command;
|
||||
|
||||
SendCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getContent() {
|
||||
CommandQueue.getInstance().write(command, CommandQueue.DEFAULT_TIMEOUT, new InvocationConfirmationListener() {
|
||||
@Override
|
||||
public void onCommandConfirmation() {
|
||||
applyStep(nextStep);
|
||||
}
|
||||
});
|
||||
|
||||
return new JLabel("Sending " + command);
|
||||
}
|
||||
}
|
||||
|
||||
private final WizardStepImpl TRIGGER_WIZARD_HELLO = new WizardStepImpl() {
|
||||
@Override
|
||||
public Component getContent() {
|
||||
JButton button = new JButton("Hello, let's test trigger. Click this to process");
|
||||
button.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
applyStep(nextStep);
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
TRIGGER_WIZARD_HELLO.setNext(new SendCommand("disable injection"))
|
||||
.setNext(new SendCommand("disable ignition"))
|
||||
.setNext(new SendCommand("chartsize " + (10 * TriggerShapeHolder.CURRENT.getTotalToothCount() * 2)))
|
||||
.setNext(new SendCommand("subscribe " + OutputChannel.WaveChartCurrentSize.getProtocolId()))
|
||||
.setNext(new SendCommand("subscribe " + OutputChannel.RunningTriggerError.getProtocolId()))
|
||||
.setNext(new SendCommand("subscribe " + OutputChannel.RunningOrderingTriggerError.getProtocolId()))
|
||||
.setNext(new SendCommand("set_analog_chart_freq " + 1))
|
||||
.setNext(new WaitForZeroRpm())
|
||||
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public Component createPane() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(button, BorderLayout.NORTH);
|
||||
|
||||
panel.add(content, BorderLayout.CENTER);
|
||||
|
||||
button.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
button.setEnabled(false);
|
||||
|
||||
applyStep(Wizard.this.TRIGGER_WIZARD_HELLO);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void applyStep(WizardStep step) {
|
||||
Component newContent = getNextContent(step);
|
||||
content.removeAll();
|
||||
this.content.add(newContent);
|
||||
UpDownImage.trueRepaint(content);
|
||||
}
|
||||
|
||||
private Component getNextContent(WizardStep step) {
|
||||
Component newContent;
|
||||
if (step == null) {
|
||||
newContent = new JLabel("Wizard is done!");
|
||||
button.setEnabled(true);
|
||||
} else {
|
||||
newContent = step.getContent();
|
||||
}
|
||||
return newContent;
|
||||
}
|
||||
|
||||
private class WaitForZeroRpm extends WizardStepImpl {
|
||||
public WaitForZeroRpm() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getContent() {
|
||||
double rpm = SensorCentral.getInstance().getValue(Sensor.RPM);
|
||||
if (rpm == 0) {
|
||||
return getNextContent(nextStep);
|
||||
}
|
||||
|
||||
|
||||
if (rpm != 0) {
|
||||
return new JLabel("Current RPM: " + rpm + ", please stop the engine");
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue