refactoring: extracting common magic constants
This commit is contained in:
parent
59daae8f5c
commit
db724568db
|
@ -389,7 +389,7 @@ static systime_t timeOfPreviousPrintVersion = (systime_t) -1;
|
|||
#if EFI_PROD_CODE
|
||||
static void printOutPin(const char *pinName, brain_pin_e hwPin) {
|
||||
if (hwPin != GPIO_UNASSIGNED) {
|
||||
appendPrintf(&logger, "outpin%s%s@%s%s", DELIMETER, pinName, hwPortname(hwPin), DELIMETER);
|
||||
appendPrintf(&logger, "%s%s%s@%s%s", PROTOCOL_OUTPIN, DELIMETER, pinName, hwPortname(hwPin), DELIMETER);
|
||||
}
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
|
|
@ -18,7 +18,4 @@ void writeLogLine(void);
|
|||
void setFullLog(int value);
|
||||
void printOverallStatus(systime_t nowSeconds);
|
||||
|
||||
// see RUS_EFI_VERSION_TAG in console source code
|
||||
#define RUS_EFI_VERSION_TAG "rusEfiVersion"
|
||||
|
||||
#endif /* CONSOLE_LOOP_H_ */
|
||||
|
|
|
@ -281,7 +281,7 @@ void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
#endif
|
||||
|
||||
void printCurrentState(Logging *logging, int seconds, const char *engineTypeName, const char *firmwareBuildId) {
|
||||
logging->appendPrintf("%s%s%d@%s%s %s %d%s", RUS_EFI_VERSION_TAG, DELIMETER,
|
||||
logging->appendPrintf("%s%s%d@%s%s %s %d%s", PROTOCOL_VERSION_TAG, DELIMETER,
|
||||
getRusEfiVersion(), VCS_VERSION,
|
||||
firmwareBuildId,
|
||||
engineTypeName,
|
||||
|
|
|
@ -1522,6 +1522,8 @@
|
|||
#define primingSquirtDurationMs_offset_hex 60
|
||||
#define PROTOCOL_ANALOG_CHART "analog_chart"
|
||||
#define PROTOCOL_ENGINE_SNIFFER "wave_chart"
|
||||
#define PROTOCOL_OUTPIN "outpin"
|
||||
#define PROTOCOL_VERSION_TAG "rusEfiVersion"
|
||||
#define RPM_1_BYTE_PACKING_MULT 50
|
||||
#define rpmHardLimit_offset 416
|
||||
#define rpmHardLimit_offset_hex 1a0
|
||||
|
|
|
@ -1232,8 +1232,10 @@ end_struct
|
|||
#define CMD_DISABLE "disable"
|
||||
#define CMD_TRIGGER_HW_INPUT "trigger_hw_input"
|
||||
|
||||
#define PROTOCOL_OUTPIN "outpin"
|
||||
#define PROTOCOL_ANALOG_CHART "analog_chart"
|
||||
#define PROTOCOL_ENGINE_SNIFFER "wave_chart"
|
||||
#define PROTOCOL_VERSION_TAG "rusEfiVersion"
|
||||
|
||||
#define GAUGE_NAME_DWELL_DUTY "dwell: coil duty cycle"
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Aug 16 19:24:07 EDT 2019
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Aug 18 12:04:36 EDT 2019
|
||||
|
||||
pageSize = 20000
|
||||
page = 1
|
||||
|
@ -2368,7 +2368,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
dialog = ignitionOutputs, "Ignition Outputs"
|
||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
|
||||
; I think this magic was generated by java somewhere, but not sure where?
|
||||
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
|
||||
; this section is auto-generated by FiringOrderTSLogic.java
|
||||
field = "Ignition Pin 2", ignitionPins2, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 1) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 2) || (firingOrder == 7) || (firingOrder == 9) || (firingOrder == 11) || (firingOrder == 12)))}
|
||||
field = "Ignition Pin 3", ignitionPins3, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 2) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 1) || (firingOrder == 3) || (firingOrder == 4) || (firingOrder == 5) || (firingOrder == 9)))}
|
||||
field = "Ignition Pin 4", ignitionPins4, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 3) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 5) || (firingOrder == 7) || (firingOrder == 12)))}
|
||||
|
|
|
@ -1390,7 +1390,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
dialog = ignitionOutputs, "Ignition Outputs"
|
||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
|
||||
; I think this magic was generated by java somewhere, but not sure where?
|
||||
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
|
||||
; this section is auto-generated by FiringOrderTSLogic.java
|
||||
field = "Ignition Pin 2", ignitionPins2, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 1) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 2) || (firingOrder == 7) || (firingOrder == 9) || (firingOrder == 11) || (firingOrder == 12)))}
|
||||
field = "Ignition Pin 3", ignitionPins3, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 2) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 1) || (firingOrder == 3) || (firingOrder == 4) || (firingOrder == 5) || (firingOrder == 9)))}
|
||||
field = "Ignition Pin 4", ignitionPins4, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 3) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 5) || (firingOrder == 7) || (firingOrder == 12)))}
|
||||
|
|
|
@ -82,7 +82,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Aug 16 19:24:12 EDT 2019
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Aug 18 12:04:42 EDT 2019
|
||||
|
||||
pageSize = 20000
|
||||
page = 1
|
||||
|
@ -2368,7 +2368,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
dialog = ignitionOutputs, "Ignition Outputs"
|
||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
|
||||
; I think this magic was generated by java somewhere, but not sure where?
|
||||
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
|
||||
; this section is auto-generated by FiringOrderTSLogic.java
|
||||
field = "Ignition Pin 2", ignitionPins2, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 1) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 2) || (firingOrder == 7) || (firingOrder == 9) || (firingOrder == 11) || (firingOrder == 12)))}
|
||||
field = "Ignition Pin 3", ignitionPins3, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 2) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 1) || (firingOrder == 3) || (firingOrder == 4) || (firingOrder == 5) || (firingOrder == 9)))}
|
||||
field = "Ignition Pin 4", ignitionPins4, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 3) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 5) || (firingOrder == 7) || (firingOrder == 12)))}
|
||||
|
|
|
@ -82,7 +82,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Aug 16 19:24:10 EDT 2019
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Aug 18 12:04:40 EDT 2019
|
||||
|
||||
pageSize = 20000
|
||||
page = 1
|
||||
|
@ -2361,7 +2361,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
dialog = ignitionOutputs, "Ignition Outputs"
|
||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
|
||||
; I think this magic was generated by java somewhere, but not sure where?
|
||||
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
|
||||
; this section is auto-generated by FiringOrderTSLogic.java
|
||||
field = "Ignition Pin 2", ignitionPins2, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 1) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 2) || (firingOrder == 7) || (firingOrder == 9) || (firingOrder == 11) || (firingOrder == 12)))}
|
||||
field = "Ignition Pin 3", ignitionPins3, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 2) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 1) || (firingOrder == 3) || (firingOrder == 4) || (firingOrder == 5) || (firingOrder == 9)))}
|
||||
field = "Ignition Pin 4", ignitionPins4, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 3) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 5) || (firingOrder == 7) || (firingOrder == 12)))}
|
||||
|
|
|
@ -82,7 +82,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; see PAGE_0_SIZE in C source code
|
||||
; CONFIG_DEFINITION_START
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Aug 16 19:24:14 EDT 2019
|
||||
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Aug 18 12:04:44 EDT 2019
|
||||
|
||||
pageSize = 20000
|
||||
page = 1
|
||||
|
@ -2364,7 +2364,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
dialog = ignitionOutputs, "Ignition Outputs"
|
||||
field = "Ignition Pin Mode", ignitionPinMode, {isIgnitionEnabled == 1}
|
||||
field = "Ignition Pin 1", ignitionPins1, {isIgnitionEnabled == 1}
|
||||
; I think this magic was generated by java somewhere, but not sure where?
|
||||
; see rusefi_config.txt comment next to 'ignitionPin2logic' which says
|
||||
; this section is auto-generated by FiringOrderTSLogic.java
|
||||
field = "Ignition Pin 2", ignitionPins2, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 1) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 2) || (firingOrder == 7) || (firingOrder == 9) || (firingOrder == 11) || (firingOrder == 12)))}
|
||||
field = "Ignition Pin 3", ignitionPins3, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 2) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 1) || (firingOrder == 3) || (firingOrder == 4) || (firingOrder == 5) || (firingOrder == 9)))}
|
||||
field = "Ignition Pin 4", ignitionPins4, {isIgnitionEnabled == 1 && (ignitionMode != 0 && cylindersCount > 3) && (ignitionMode !=2 || twoWireBatchIgnition == 1 || ((firingOrder == 5) || (firingOrder == 7) || (firingOrder == 12)))}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.EngineState;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -134,7 +135,7 @@ public class IoUtil {
|
|||
* TCP connector is blocking
|
||||
*/
|
||||
LinkManager.open();
|
||||
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
LinkManager.engineState.registerStringValueAction(Fields.PROTOCOL_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
waitForFirstResponse();
|
||||
}
|
||||
|
||||
|
@ -149,8 +150,8 @@ public class IoUtil {
|
|||
}
|
||||
|
||||
static void realHardwareConnect(String port) {
|
||||
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
LinkManager.engineState.registerStringValueAction(EngineState.OUTPIN_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
LinkManager.engineState.registerStringValueAction(Fields.PROTOCOL_VERSION_TAG, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
LinkManager.engineState.registerStringValueAction(Fields.PROTOCOL_OUTPIN, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
LinkManager.engineState.registerStringValueAction(AverageAnglesUtil.KEY, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
|
||||
|
||||
final CountDownLatch connected = LinkManager.connect(port);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.config.generated;
|
||||
|
||||
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Thu Aug 15 20:04:48 EDT 2019
|
||||
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Aug 18 12:09:19 EDT 2019
|
||||
|
||||
// by class com.rusefi.output.JavaFieldsConsumer
|
||||
import com.rusefi.config.*;
|
||||
|
@ -1000,6 +1000,8 @@ public class Fields {
|
|||
public static final int primingSquirtDurationMs_offset_hex = 60;
|
||||
public static final String PROTOCOL_ANALOG_CHART = "analog_chart";
|
||||
public static final String PROTOCOL_ENGINE_SNIFFER = "wave_chart";
|
||||
public static final String PROTOCOL_OUTPIN = "outpin";
|
||||
public static final String PROTOCOL_VERSION_TAG = "rusEfiVersion";
|
||||
public static final int RPM_1_BYTE_PACKING_MULT = 50;
|
||||
public static final int rpmHardLimit_offset = 416;
|
||||
public static final int runningLedPin_offset = 1813;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.rusefi.core;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.SensorConversion;
|
||||
import com.rusefi.io.LinkDecoder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -18,9 +17,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
public class EngineState {
|
||||
public static final String SEPARATOR = ",";
|
||||
public static final String PACKING_DELIMITER = ":";
|
||||
// see RUS_EFI_VERSION_TAG in firmware code
|
||||
public static final String RUS_EFI_VERSION_TAG = "rusEfiVersion";
|
||||
public static final String OUTPIN_TAG = "outpin";
|
||||
/**
|
||||
* If we get this tag we have probably connected to the wrong port
|
||||
*/
|
||||
|
|
|
@ -271,7 +271,7 @@ public class Launcher {
|
|||
}
|
||||
});
|
||||
|
||||
LinkManager.engineState.registerStringValueAction(EngineState.RUS_EFI_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
||||
LinkManager.engineState.registerStringValueAction(Fields.PROTOCOL_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
||||
@Override
|
||||
public void onUpdate(String firmwareVersion) {
|
||||
Launcher.firmwareVersion.set(firmwareVersion);
|
||||
|
|
|
@ -185,7 +185,7 @@ public class EngineSnifferPanel {
|
|||
}
|
||||
|
||||
public void setOutpinListener(EngineState engineState) {
|
||||
engineState.registerStringValueAction(EngineState.OUTPIN_TAG, new EngineState.ValueCallback<String>() {
|
||||
engineState.registerStringValueAction(Fields.PROTOCOL_OUTPIN, new EngineState.ValueCallback<String>() {
|
||||
@Override
|
||||
public void onUpdate(String value) {
|
||||
String pinInfo[] = value.split("@");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui.engine;
|
||||
|
||||
import com.rusefi.Launcher;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
@ -41,6 +42,9 @@ public class UpDownImage extends JPanel {
|
|||
private final String name;
|
||||
private TimeAxisTranslator translator;
|
||||
private RevolutionLog time2rpm = RevolutionLog.parseRevolutions(null);
|
||||
/**
|
||||
* firmware is sending {@link Fields#PROTOCOL_OUTPIN}
|
||||
*/
|
||||
private String pin = "NO PIN";
|
||||
private long mouseEnterTime;
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue