From f1547b782f27c1cf63b41ebdb1e1301e33dec44a Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 11 Apr 2016 23:02:23 -0400 Subject: [PATCH] auto-sync --- firmware/console/status_loop.cpp | 10 ++++++++-- firmware/rusefi.cpp | 2 +- java_console/ui/src/com/rusefi/Launcher.java | 17 +++++++++++++++- .../ui/src/com/rusefi/ui/WarningPanel.java | 20 +++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index c8374bccef..dff284f2ba 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -471,13 +471,19 @@ static void initStatisLeds() { * This method would blink all the LEDs just to test them */ static void initialLedsBlink(void) { + if (hasFirmwareError()) { + // make sure we do not turn the fatal LED off if already have + // fatal error by now + return; + } int size = sizeof(leds) / sizeof(leds[0]); - for (int i = 0; i < size; i++) + for (int i = 0; i < size && !hasFirmwareError(); i++) leds[i]->setValue(1); chThdSleepMilliseconds(100); - for (int i = 0; i < size; i++) + // re-checking in case the error has happened while we were sleeping + for (int i = 0; i < size && !hasFirmwareError(); i++) leds[i]->setValue(0); } diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 844985cbc3..17644219ca 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -292,5 +292,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20160409; + return 20160411; } diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 6cd86982c3..a84e0ca2a7 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -36,12 +36,15 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20160402; + public static final int CONSOLE_VERSION = 20160411; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; protected static final String SPEED_KEY = "speed"; + public static final String FATAL_ERROR_PREFIX = "FATAL"; private final String port; + // todo: the logic around 'fatalError' could be implemented nicer + private String fatalError; private final JTabbedPane tabbedPane = new JTabbedPane() { @Override public void paint(Graphics g) { @@ -64,6 +67,10 @@ public class Launcher { default: text = ""; } + if (fatalError != null) { + text = fatalError; + g.setColor(Color.red); + } int labelWidth = g.getFontMetrics().stringWidth(text); g.drawString(text, (d.width - labelWidth) / 2, d.height / 2); } @@ -106,6 +113,14 @@ public class Launcher { LinkManager.start(port); + MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() { + @Override + public void onMessage(Class clazz, String message) { + if (message.startsWith(FATAL_ERROR_PREFIX)) + fatalError = message; + } + }); + EngineSnifferPanel engineSnifferPanel = new EngineSnifferPanel(getConfig().getRoot().getChild("digital_sniffer")); if (LinkManager.isLogViewerMode(port)) tabbedPane.add("Log Viewer", new LogViewer(engineSnifferPanel)); diff --git a/java_console/ui/src/com/rusefi/ui/WarningPanel.java b/java_console/ui/src/com/rusefi/ui/WarningPanel.java index 4ea5709840..fc2840b8bb 100644 --- a/java_console/ui/src/com/rusefi/ui/WarningPanel.java +++ b/java_console/ui/src/com/rusefi/ui/WarningPanel.java @@ -1,6 +1,8 @@ package com.rusefi.ui; +import com.rusefi.Launcher; import com.rusefi.core.MessagesCentral; +import com.rusefi.ui.util.UiUtils; import javax.swing.*; import java.awt.*; @@ -15,6 +17,13 @@ public class WarningPanel { private final JLabel label = new JLabel(); private final JButton reset = new JButton("clear warning"); + private final Timer fatalBlinking = new Timer(1000, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + label.setVisible(!label.isVisible()); + UiUtils.trueRepaint(label); + } + }); public WarningPanel() { label.setForeground(Color.red); @@ -33,8 +42,19 @@ public class WarningPanel { }); MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() { + boolean haveFatalError; + @Override public void onMessage(Class clazz, String message) { + if (haveFatalError) + return; + + if (message.startsWith(Launcher.FATAL_ERROR_PREFIX)) { + haveFatalError = true; + fatalBlinking.start(); + label.setText(message); + return; + } if (message.startsWith(WARNING) || message.startsWith(ERROR)) { label.setText(message); reset.setEnabled(true);