auto-sync
This commit is contained in:
parent
f77030123c
commit
4ee0e4ff79
|
@ -59,7 +59,7 @@ void setMazda626EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
|||
setCommonNTCSensor(&engineConfiguration->clt);
|
||||
// http://i.imgur.com/2hI67yW.jpg
|
||||
setThermistorConfiguration(&engineConfiguration->iat, 13, 56000, 50, 9000, 80.0, 2700);
|
||||
engineConfiguration->iat.config.bias_resistor = 18000;
|
||||
engineConfiguration->iat.config.bias_resistor = 18200;
|
||||
|
||||
commonFrankensoAnalogInputs(engineConfiguration);
|
||||
// engineConfiguration->map.sensor.hwChannel = EFI_ADC_4;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.config;
|
||||
|
||||
// this file was generated automatically by ConfigDefinition.jar Fri Jul 03 11:19:03 EDT 2015
|
||||
// this file was generated automatically by ConfigDefinition.jar Mon Jul 13 18:45:30 EDT 2015
|
||||
public class Fields {
|
||||
public static final Field ENGINETYPE = new Field("ENGINETYPE", 0, FieldType.INT);
|
||||
public static final Field HEADERMAGICVALUE = new Field("HEADERMAGICVALUE", 4, FieldType.INT);
|
||||
|
@ -175,6 +175,7 @@ public class Fields {
|
|||
public static final String[] ego_sensor_e = {"BPSX", "Innovate", "14Point7", "Narrow", "PLX"};
|
||||
public static final Field AFR_TYPE = new Field("AFR_TYPE", 900, FieldType.INT, ego_sensor_e);
|
||||
public static final Field ETBDT = new Field("ETBDT", 904, FieldType.INT);
|
||||
public static final Field HIP9011CSPINMODE = new Field("HIP9011CSPINMODE", 908, FieldType.INT, pin_output_mode_e);
|
||||
public static final String[] brain_input_pin_e = {"INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PA5", "INVALID", "INVALID", "PA8", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PC6", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PE5", "INVALID", "PE7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"};
|
||||
public static final Field TRIGGERINPUTPINS1 = new Field("TRIGGERINPUTPINS1", 920, FieldType.INT, brain_input_pin_e);
|
||||
public static final Field TRIGGERINPUTPINS2 = new Field("TRIGGERINPUTPINS2", 924, FieldType.INT, brain_input_pin_e);
|
||||
|
@ -410,6 +411,9 @@ public class Fields {
|
|||
public static final Field NOACCELAFTERHARDLIMITPERIODSECS = new Field("NOACCELAFTERHARDLIMITPERIODSECS", 1644, FieldType.FLOAT);
|
||||
public static final Field MAPAVERAGINGSCHEDULINGATINDEX = new Field("MAPAVERAGINGSCHEDULINGATINDEX", 1648, FieldType.INT);
|
||||
public static final Field BAROCORRTABLE = new Field("BAROCORRTABLE", 1684, FieldType.INT);
|
||||
public static final Field SPI2SCKMODE = new Field("SPI2SCKMODE", 1748, FieldType.INT);
|
||||
public static final Field SPI2MOSIMODE = new Field("SPI2MOSIMODE", 1752, FieldType.INT);
|
||||
public static final Field SPI2MISOMODE = new Field("SPI2MISOMODE", 1756, FieldType.INT);
|
||||
public static final Field TARGETVBATT = new Field("TARGETVBATT", 2156, FieldType.FLOAT);
|
||||
public static final Field ALTERNATOROFFABOVETPS = new Field("ALTERNATOROFFABOVETPS", 2160, FieldType.FLOAT);
|
||||
public static final Field ALTERNATORDT = new Field("ALTERNATORDT", 2164, FieldType.INT);
|
||||
|
|
|
@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see com.rusefi.StartupFrame
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20150713;
|
||||
public static final int CONSOLE_VERSION = 20150714;
|
||||
public static final boolean SHOW_STIMULATOR = false;
|
||||
private static final String TAB_INDEX = "main_tab";
|
||||
protected static final String PORT_KEY = "port";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.core.EngineTimeListener;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -10,13 +11,15 @@ import java.util.List;
|
|||
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;
|
||||
|
||||
public static ConnectionStatus INSTANCE = new ConnectionStatus();
|
||||
private List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private ConnectionStatus() {
|
||||
final Timer timer1 = new Timer(2000, new ActionListener() {
|
||||
final Timer timer = new Timer(2000, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setConnected(false);
|
||||
|
@ -26,13 +29,25 @@ public class ConnectionStatus {
|
|||
LinkManager.engineState.timeListeners.add(new EngineTimeListener() {
|
||||
@Override
|
||||
public void onTime(double time) {
|
||||
setConnected(true);
|
||||
/**
|
||||
* this timer will catch engine inactivity and display a warning
|
||||
*/
|
||||
timer1.restart();
|
||||
markConnected(timer);
|
||||
}
|
||||
});
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Class clazz, String message) {
|
||||
if (message.startsWith(FATAL_MESSAGE_PREFIX))
|
||||
markConnected(timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void markConnected(Timer timer1) {
|
||||
setConnected(true);
|
||||
/**
|
||||
* this timer will catch engine inactivity and display a warning
|
||||
*/
|
||||
timer1.restart();
|
||||
}
|
||||
|
||||
private void setConnected(boolean isConnected) {
|
||||
|
@ -47,6 +62,9 @@ public class ConnectionStatus {
|
|||
return isConnected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setConnected(boolean)
|
||||
*/
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
|
|
@ -1,42 +1,61 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.ConfigurationImage;
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.ui.ConnectionStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
abstract class BaseConfigField {
|
||||
protected final JLabel status = new JLabel("P");
|
||||
protected final JPanel panel = new JPanel(new BorderLayout());
|
||||
protected final Field field;
|
||||
|
||||
public BaseConfigField(final Field field) {
|
||||
this.field = field;
|
||||
status.setToolTipText("Pending...");
|
||||
}
|
||||
|
||||
protected void requestInitialValue(final Field field) {
|
||||
/**
|
||||
* This would request initial value
|
||||
*/
|
||||
if (ConnectionStatus.INSTANCE.isConnected()) {
|
||||
requestInitialValue(field);
|
||||
processInitialValue(field);
|
||||
} else {
|
||||
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
||||
@Override
|
||||
public void onConnectionStatus(boolean isConnected) {
|
||||
requestInitialValue(field);
|
||||
processInitialValue(field);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void requestInitialValue(Field field) {
|
||||
CommandQueue.getInstance().write(field.getCommand(),
|
||||
CommandQueue.DEFAULT_TIMEOUT,
|
||||
InvocationConfirmationListener.VOID,
|
||||
false);
|
||||
private void processInitialValue(Field field) {
|
||||
BinaryProtocol bp = BinaryProtocol.instance;
|
||||
if (bp == null)
|
||||
return;
|
||||
ConfigurationImage ci = bp.getController();
|
||||
if (ci == null)
|
||||
return;
|
||||
loadValue(ci);
|
||||
|
||||
// CommandQueue.getInstance().write(field.getCommand(),
|
||||
// CommandQueue.DEFAULT_TIMEOUT,
|
||||
// InvocationConfirmationListener.VOID,
|
||||
// false);
|
||||
}
|
||||
|
||||
protected abstract void loadValue(ConfigurationImage ci);
|
||||
|
||||
protected void onValueArrived() {
|
||||
status.setText("");
|
||||
status.setToolTipText(null);
|
||||
|
@ -71,4 +90,12 @@ abstract class BaseConfigField {
|
|||
public JPanel getContent() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ByteBuffer getByteBuffer(ConfigurationImage ci) {
|
||||
byte data[] = ci.getRange(field.getOffset(), 4);
|
||||
ByteBuffer wrapped = ByteBuffer.wrap(data);
|
||||
wrapped.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return wrapped;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.ConfigurationImage;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
|
||||
|
@ -13,8 +14,8 @@ public class BitConfigField extends BaseConfigField {
|
|||
|
||||
public BitConfigField(final Field field, String caption) {
|
||||
super(field);
|
||||
|
||||
createUi(caption, view);
|
||||
requestInitialValue(field); // this is not in base constructor so that view is created by the time we invoke it
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
@ -24,11 +25,7 @@ public class BitConfigField extends BaseConfigField {
|
|||
if (message.startsWith(expectedPrefix) && message.length() == expectedPrefix.length() + 1) {
|
||||
message = message.substring(expectedPrefix.length());
|
||||
Boolean value = message.equals("1");
|
||||
ec = true;
|
||||
view.setEnabled(true);
|
||||
view.setSelected(value);
|
||||
onValueArrived();
|
||||
ec = false;
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +40,19 @@ public class BitConfigField extends BaseConfigField {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setValue(boolean value) {
|
||||
ec = true;
|
||||
view.setEnabled(true);
|
||||
view.setSelected(value);
|
||||
onValueArrived();
|
||||
ec = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadValue(ConfigurationImage ci) {
|
||||
int bits = getByteBuffer(ci).getInt();
|
||||
boolean bit = ((bits >> field.getBitOffset()) & 1) == 1;
|
||||
setValue(bit);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,19 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.ConfigurationImage;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.config.FieldType;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.ui.util.JTextFieldWithWidth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class ConfigField extends BaseConfigField {
|
||||
private final JTextField view = new JTextFieldWithWidth(200);
|
||||
|
@ -16,6 +21,7 @@ public class ConfigField extends BaseConfigField {
|
|||
public ConfigField(final Field field, String topLabel) {
|
||||
super(field);
|
||||
createUi(topLabel, view);
|
||||
requestInitialValue(field); // this is not in base constructor so that view is created by the time we invoke it
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
@ -23,9 +29,8 @@ public class ConfigField extends BaseConfigField {
|
|||
if (Field.isIntValueMessage(message) || Field.isFloatValueMessage(message)) {
|
||||
Pair<Integer, ?> p = Field.parseResponse(message);
|
||||
if (p != null && p.first == field.getOffset()) {
|
||||
view.setEnabled(true);
|
||||
view.setText("" + p.second);
|
||||
onValueArrived();
|
||||
Object value = p.second;
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,4 +46,22 @@ public class ConfigField extends BaseConfigField {
|
|||
});
|
||||
}
|
||||
|
||||
private void setValue(Object value) {
|
||||
view.setEnabled(true);
|
||||
view.setText("" + value);
|
||||
onValueArrived();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadValue(ConfigurationImage ci) {
|
||||
Number value;
|
||||
ByteBuffer wrapped = getByteBuffer(ci);
|
||||
if (field.getType() == FieldType.INT) {
|
||||
value = wrapped.getInt();
|
||||
} else {
|
||||
value = wrapped.getFloat();
|
||||
}
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.ConfigurationImage;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Pair;
|
||||
|
@ -14,12 +15,13 @@ public class EnumConfigField extends BaseConfigField {
|
|||
private final JComboBox<String> view = new JComboBox<>();
|
||||
private boolean ec;
|
||||
private final Map<String, Integer> ordinals = new HashMap<>();
|
||||
private final String[] options = field.getOptions();
|
||||
|
||||
public EnumConfigField(final Field field, String caption) {
|
||||
super(field);
|
||||
final String[] options = field.getOptions();
|
||||
if (options == null)
|
||||
throw new NullPointerException("options for " + field);
|
||||
createUi(caption, view);
|
||||
|
||||
int ordinal = 0;
|
||||
for (String option : options) {
|
||||
|
@ -29,7 +31,7 @@ public class EnumConfigField extends BaseConfigField {
|
|||
view.addItem(option);
|
||||
}
|
||||
|
||||
createUi(caption, view);
|
||||
requestInitialValue(field); // this is not in base constructor so that view is created by the time we invoke it
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
@ -38,19 +40,7 @@ public class EnumConfigField extends BaseConfigField {
|
|||
Pair<Integer, ?> p = Field.parseResponse(message);
|
||||
if (p != null && p.first == field.getOffset()) {
|
||||
int ordinal = (Integer) p.second;
|
||||
String item;
|
||||
if (ordinal >= options.length) {
|
||||
item = "unexpected_" + ordinal;
|
||||
view.addItem(item);
|
||||
} else {
|
||||
item = options[ordinal];
|
||||
}
|
||||
|
||||
ec = true;
|
||||
view.setEnabled(true);
|
||||
view.setSelectedItem(item);
|
||||
onValueArrived();
|
||||
ec = false;
|
||||
setValue(ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,4 +57,26 @@ public class EnumConfigField extends BaseConfigField {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setValue(int ordinal) {
|
||||
String item;
|
||||
if (ordinal >= options.length) {
|
||||
item = "unexpected_" + ordinal;
|
||||
view.addItem(item);
|
||||
} else {
|
||||
item = options[ordinal];
|
||||
}
|
||||
|
||||
ec = true;
|
||||
view.setEnabled(true);
|
||||
view.setSelectedItem(item);
|
||||
onValueArrived();
|
||||
ec = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadValue(ConfigurationImage ci) {
|
||||
int ordinal = getByteBuffer(ci).getInt();
|
||||
setValue(ordinal);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue