auto-sync
This commit is contained in:
parent
a216dcf812
commit
db36e63c34
|
@ -112,6 +112,13 @@ icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* as of Feb 2016, TIM1, TIM2, TIM3 and TIM4 are used for input capture
|
||||
* (that's the kind of event you need for shaft position sensor)
|
||||
* ChibiOS limitation is that only channels #1 and #2 could be used for input capture
|
||||
*
|
||||
* TODO: migrate slow ADC to software timer so that TIM8 is also available for input capture
|
||||
*/
|
||||
ICUDriver * getInputCaptureDriver(brain_pin_e hwPin) {
|
||||
#if STM32_ICU_USE_TIM1
|
||||
if (hwPin == GPIOA_8 ||
|
||||
|
@ -121,15 +128,25 @@ ICUDriver * getInputCaptureDriver(brain_pin_e hwPin) {
|
|||
}
|
||||
#endif
|
||||
#if STM32_ICU_USE_TIM2
|
||||
if (hwPin == GPIOA_5) {
|
||||
if (hwPin == GPIOA_1 ||
|
||||
hwPin == GPIOA_5 ||
|
||||
hwPin == GPIOB_3) {
|
||||
return &ICUD2;
|
||||
}
|
||||
#endif
|
||||
#if STM32_ICU_USE_TIM3
|
||||
if (hwPin == GPIOC_6) {
|
||||
if (hwPin == GPIOA_7 ||
|
||||
hwPin == GPIOC_6 ||
|
||||
hwPin == GPIOC_7) {
|
||||
return &ICUD3;
|
||||
}
|
||||
#endif
|
||||
#if STM32_ICU_USE_TIM8
|
||||
if (hwPin == GPIOC_6 ||
|
||||
hwPin == GPIOC_7) {
|
||||
return &ICUD9;
|
||||
}
|
||||
#endif
|
||||
#if STM32_ICU_USE_TIM9
|
||||
if (hwPin == GPIOA_2 ||
|
||||
hwPin == GPIOA_3 ||
|
||||
|
|
|
@ -177,8 +177,8 @@ public class AutoTest {
|
|||
x = 112;
|
||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
||||
x = 0;
|
||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.04666666666666654, x + 180, x + 540);
|
||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.04666666666666654, x, x + 360);
|
||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.13633333333333345, x + 180, x + 540);
|
||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_2, 0.13633333333333345, x, x + 360);
|
||||
}
|
||||
|
||||
private static void test1995DodgeNeon() {
|
||||
|
|
|
@ -6,11 +6,7 @@ import com.rusefi.core.MessagesCentral;
|
|||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.DataListener;
|
||||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.CommunicationLoggingHolder;
|
||||
import com.rusefi.io.*;
|
||||
import com.rusefi.io.serial.PortHolder;
|
||||
import com.rusefi.io.serial.SerialIoStream;
|
||||
import jssc.SerialPort;
|
||||
|
@ -324,11 +320,13 @@ public class BinaryProtocol {
|
|||
continue;
|
||||
}
|
||||
|
||||
ConnectionStatus.INSTANCE.markConnected();
|
||||
System.arraycopy(response, 1, image.getContent(), offset, requestSize);
|
||||
|
||||
offset += requestSize;
|
||||
}
|
||||
logger.info("Got configuration from controller.");
|
||||
ConnectionStatus.INSTANCE.setValue(ConnectionStatus.Value.CONNECTED);
|
||||
setController(image);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.rusefi.ui;
|
||||
package com.rusefi.io;
|
||||
|
||||
import com.rusefi.Timeouts;
|
||||
import com.rusefi.core.EngineTimeListener;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.ConnectionWatchdog;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -20,30 +19,38 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
public class ConnectionStatus {
|
||||
// todo: react to any message as connected? how to know if message from controller, not internal message?
|
||||
private static final String FATAL_MESSAGE_PREFIX = "FATAL";
|
||||
private boolean isConnected;
|
||||
@NotNull
|
||||
private Value value = Value.NOT_CONNECTED;
|
||||
|
||||
public enum Value {
|
||||
NOT_CONNECTED,
|
||||
LOADING,
|
||||
CONNECTED
|
||||
}
|
||||
|
||||
public static ConnectionStatus INSTANCE = new ConnectionStatus();
|
||||
private List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private final Timer timer = new Timer(Timeouts.CS_TIMEOUT, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setValue(Value.NOT_CONNECTED);
|
||||
}
|
||||
});
|
||||
|
||||
private ConnectionStatus() {
|
||||
final Timer timer = new Timer(Timeouts.CS_TIMEOUT, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setConnected(false);
|
||||
}
|
||||
});
|
||||
|
||||
LinkManager.engineState.timeListeners.add(new EngineTimeListener() {
|
||||
@Override
|
||||
public void onTime(double time) {
|
||||
markConnected(timer);
|
||||
markConnected();
|
||||
}
|
||||
});
|
||||
|
||||
SensorCentral.getInstance().addListener(Sensor.TIME_SECONDS, new SensorCentral.SensorListener() {
|
||||
@Override
|
||||
public void onSensorUpdate(double value) {
|
||||
setConnected(true);
|
||||
markConnected();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -51,33 +58,39 @@ public class ConnectionStatus {
|
|||
@Override
|
||||
public void onMessage(Class clazz, String message) {
|
||||
if (message.startsWith(FATAL_MESSAGE_PREFIX))
|
||||
markConnected(timer);
|
||||
markConnected();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void markConnected(Timer timer) {
|
||||
setConnected(true);
|
||||
public void markConnected() {
|
||||
if (value == Value.NOT_CONNECTED)
|
||||
setValue(Value.LOADING);
|
||||
/**
|
||||
* this timer will catch engine inactivity and display a warning
|
||||
*/
|
||||
timer.restart();
|
||||
}
|
||||
|
||||
private void setConnected(boolean isConnected) {
|
||||
if (isConnected == this.isConnected)
|
||||
public void setValue(@NotNull Value value) {
|
||||
if (value == this.value)
|
||||
return;
|
||||
this.isConnected = isConnected;
|
||||
this.value = value;
|
||||
for (Listener listener : listeners)
|
||||
listener.onConnectionStatus(isConnected);
|
||||
listener.onConnectionStatus(isConnected());
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return isConnected;
|
||||
return value != Value.NOT_CONNECTED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setConnected(boolean)
|
||||
* @see #setValue
|
||||
*/
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.core.EngineState;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.ConnectionStatus;
|
||||
import com.rusefi.io.ConnectionWatchdog;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.serial.PortHolder;
|
||||
|
@ -15,6 +16,7 @@ import com.rusefi.ui.storage.Node;
|
|||
import com.rusefi.ui.util.DefaultExceptionHandler;
|
||||
import com.rusefi.ui.util.FrameHelper;
|
||||
import com.rusefi.ui.util.JustOneInstance;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import jssc.SerialPortList;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -34,13 +36,38 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see EngineSnifferPanel
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20160213;
|
||||
public static final int CONSOLE_VERSION = 20160229;
|
||||
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";
|
||||
private final String port;
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane();
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane() {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
paintStatusText(g);
|
||||
}
|
||||
|
||||
private void paintStatusText(Graphics g) {
|
||||
Font f = g.getFont();
|
||||
g.setFont(new Font(f.getName(), f.getStyle(), f.getSize() * 4));
|
||||
Dimension d = getSize();
|
||||
String text;
|
||||
switch (ConnectionStatus.INSTANCE.getValue()) {
|
||||
case NOT_CONNECTED:
|
||||
text = "Not connected";
|
||||
break;
|
||||
case LOADING:
|
||||
text = "Loading";
|
||||
break;
|
||||
default:
|
||||
text = "";
|
||||
}
|
||||
int labelWidth = g.getFontMetrics().stringWidth(text);
|
||||
g.drawString(text, (d.width - labelWidth) / 2, d.height / 2);
|
||||
}
|
||||
};
|
||||
private static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
private static Frame staticFrame;
|
||||
|
@ -138,6 +165,7 @@ public class Launcher {
|
|||
@Override
|
||||
public void onConnectionStatus(boolean isConnected) {
|
||||
setTitle();
|
||||
UiUtils.trueRepaint(tabbedPane); // this would repaint status label
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui;
|
|||
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.ConnectionStatus;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.rusefi.FileLog;
|
|||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.ConnectionStatus;
|
||||
import com.rusefi.io.ConnectionStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
|
Loading…
Reference in New Issue