Live Data progress

This commit is contained in:
rusefi 2019-09-01 13:56:46 -04:00
parent 1bd4fb8f09
commit 1ffaa8eea2
40 changed files with 363 additions and 160 deletions

View File

@ -263,10 +263,14 @@ static const void * getStructAddr(int structId) {
case LDS_TRIGGER_STATE_INDEX:
return static_cast<trigger_central_s*>(&engine->triggerCentral);
#if EFI_ELECTRONIC_THROTTLE_BODY
case LDS_ETB_STATE_INDEX:
case LDS_ETB_PID_STATE_INDEX:
return static_cast<pid_state_s*>(&etbPid);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
#ifndef EFI_IDLE_CONTROL
// todo case LDS_IDLE_PID_STATE_INDEX:
#endif /* EFI_IDLE_CONTROL */
default:
return NULL;
}

View File

@ -256,6 +256,7 @@ class EtbController : public PeriodicTimerController {
etbPid.showPidStatus(&logger, "ETB");
}
DISPLAY_STATE(Engine)
DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor))
DISPLAY_TEXT(Electronic_Throttle);
DISPLAY_SENSOR(TPS)
@ -265,6 +266,7 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor))
DISPLAY_SENSOR(PPS);
DISPLAY_TEXT(eol);
DISPLAY_STATE(ETB_pid)
DISPLAY_TEXT(Output);
DISPLAY(DISPLAY_FIELD(output));
DISPLAY_TEXT(iTerm);

View File

@ -94,6 +94,7 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
// if tau is really small, we get div/0.
// you probably meant to disable wwae.
DISPLAY_STATE(wall_fuel)
float tau = CONFIG(DISPLAY_CONFIG(wwaeTau));
if (tau < 0.01f) {
return desiredFuel;

View File

@ -41,6 +41,8 @@ extern baroCorr_Map3D_t baroCorrMap;
#if EFI_ENGINE_CONTROL
DISPLAY_STATE(Engine)
DISPLAY(DISPLAY_IF(isCrankingState)) floatms_t getCrankingFuel3(float coolantTemperature,
uint32_t revolutionCounterSinceStart DECLARE_ENGINE_PARAMETER_SUFFIX) {
// these magic constants are in Celsius

View File

@ -1,44 +1,9 @@
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sat Aug 31 11:02:25 EDT 2019
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Sep 01 11:57:51 EDT 2019
// by class com.rusefi.output.CHeaderConsumer
// begin
#ifndef CONTROLLERS_GENERATED_ENGINE_STATE_GENERATED_H
#define CONTROLLERS_GENERATED_ENGINE_STATE_GENERATED_H
#include "rusefi_types.h"
// start of pid_state_s
struct pid_state_s {
/**
* offset 0
*/
float iTerm = (float)0;
/**
* we are remembering this only for debugging purposes
* offset 4
*/
float dTerm = (float)0;
/**
* only used for logging
* offset 8
*/
float target = (float)0;
/**
* only used for logging
* offset 12
*/
float input = (float)0;
/**
* only used for logging
* offset 16
*/
float output = (float)0;
/**
* offset 20
*/
float errorAmplificationCoef = (float)0;
/** total size 24*/
};
typedef struct pid_state_s pid_state_s;
// start of speed_density_s
struct speed_density_s {
/**
@ -248,4 +213,4 @@ typedef struct engine_state2_s engine_state2_s;
#endif
// end
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sat Aug 31 11:02:25 EDT 2019
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Sep 01 11:57:51 EDT 2019

View File

@ -0,0 +1,44 @@
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019
// by class com.rusefi.output.CHeaderConsumer
// begin
#ifndef CONTROLLERS_GENERATED_PID_STATE_GENERATED_H
#define CONTROLLERS_GENERATED_PID_STATE_GENERATED_H
#include "rusefi_types.h"
// start of pid_state_s
struct pid_state_s {
/**
* offset 0
*/
float iTerm = (float)0;
/**
* we are remembering this only for debugging purposes
* offset 4
*/
float dTerm = (float)0;
/**
* only used for logging
* offset 8
*/
float target = (float)0;
/**
* only used for logging
* offset 12
*/
float input = (float)0;
/**
* only used for logging
* offset 16
*/
float output = (float)0;
/**
* offset 20
*/
float errorAmplificationCoef = (float)0;
/** total size 24*/
};
typedef struct pid_state_s pid_state_s;
#endif
// end
// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019

View File

@ -1330,9 +1330,10 @@
#define lcdThreadPeriodMs_offset_hex 2d0
#define LDS_CLT_STATE_INDEX 0
#define LDS_ENGINE_STATE_INDEX 3
#define LDS_ETB_STATE_INDEX 7
#define LDS_ETB_PID_STATE_INDEX 7
#define LDS_FUEL_TRIM_STATE_INDEX 4
#define LDS_IAT_STATE_INDEX 1
#define LDS_IDLE_PID_STATE_INDEX 8
#define LDS_SPEED_DENSITY_STATE_INDEX 2
#define LDS_TPS_TPS_ENEICHMENT_STATE_INDEX 5
#define LDS_TRIGGER_STATE_INDEX 6

View File

@ -40,6 +40,7 @@ temperature_t getTCharge(int rpm, float tps, float coolantTemp, float airTemp DE
return coolantTemp;
}
DISPLAY_STATE(Engine)
if ((engine->engineState.sd.DISPLAY_IF(isTChargeAirModel) = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
const floatms_t gramsPerMsToKgPerHour = (3600.0f * 1000.0f) / 1000.0f;

View File

@ -79,6 +79,7 @@ float getTpsRateOfChange(void) {
* */
percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX) {
DISPLAY_STATE(Engine)
DISPLAY_TAG(TPS_SECTION);
DISPLAY_SENSOR(TPS)
DISPLAY_TEXT(EOL)

View File

@ -1,14 +1,4 @@
struct_no_prefix pid_state_s
float iTerm;
float dTerm;we are remembering this only for debugging purposes
float target;only used for logging
float input;only used for logging
float output;only used for logging
float errorAmplificationCoef;
end_struct
struct_no_prefix engine_state2_s

View File

@ -1155,7 +1155,8 @@ end_struct
#define LDS_FUEL_TRIM_STATE_INDEX 4
#define LDS_TPS_TPS_ENEICHMENT_STATE_INDEX 5
#define LDS_TRIGGER_STATE_INDEX 6
#define LDS_ETB_STATE_INDEX 7
#define LDS_ETB_PID_STATE_INDEX 7
#define LDS_IDLE_PID_STATE_INDEX 8

View File

@ -11,6 +11,7 @@
#include "global.h"
#include "engine_configuration_generated_structures.h"
#include "engine_state_generated.h"
#include "pid_state_generated.h"
#if EFI_PROD_CODE || EFI_SIMULATOR
#include "tunerstudio_configuration.h"

View File

@ -6,11 +6,11 @@ import com.rusefi.config.Field;
import java.util.List;
public abstract class LiveDocHolder {
private final int id;
private final StateId id;
private final List<RefreshActions> actions;
private final Field[] values;
public LiveDocHolder(int id, List<RefreshActions> actions, Field[] values) {
public LiveDocHolder(StateId id, List<RefreshActions> actions, Field[] values) {
this.id = id;
this.actions = actions;
this.values = values;
@ -23,7 +23,7 @@ public abstract class LiveDocHolder {
public abstract boolean isVisible();
public Integer getId() {
public StateId getId() {
return id;
}

View File

@ -1,12 +1,9 @@
package com.rusefi.ui.livedocs;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.rusefi.binaryprotocol.BinaryProtocolCommands.COMMAND_GET_STRUCT;
import static com.rusefi.binaryprotocol.BinaryProtocolCommands.RESPONSE_OK;
@ -26,28 +23,32 @@ public enum LiveDocsRegistry {
}
public void refresh(BinaryProtocol binaryProtocol) {
for (LiveDocHolder h : liveDocs) {
boolean visible = h.isVisible();
System.out.println(h + ": is_visible=" + visible);
for (LiveDocHolder holder : liveDocs) {
boolean visible = holder.isVisible();
System.out.println(holder + ": is_visible=" + visible);
if (visible) {
int liveDocRequestId = h.getId();
int size = h.getStructSize();
byte packet[] = new byte[5];
packet[0] = COMMAND_GET_STRUCT;
putShort(packet, 1, swap16(liveDocRequestId)); // offset
putShort(packet, 3, swap16(size));
byte[] responseWithCode = binaryProtocol.executeCommand(packet, "get LiveDoc", false);
if (responseWithCode == null || responseWithCode.length != (size + 1) || responseWithCode[0] != RESPONSE_OK)
continue;
byte [] response = new byte[size];
System.arraycopy(responseWithCode, 1, response, 0, size);
h.update(binaryProtocol, response);
refresh(binaryProtocol, holder);
}
}
}
private void refresh(BinaryProtocol binaryProtocol, LiveDocHolder holder) {
int liveDocRequestId = holder.getId().getId();
int size = holder.getStructSize();
byte packet[] = new byte[5];
packet[0] = COMMAND_GET_STRUCT;
putShort(packet, 1, swap16(liveDocRequestId)); // offset
putShort(packet, 3, swap16(size));
byte[] responseWithCode = binaryProtocol.executeCommand(packet, "get LiveDoc", false);
if (responseWithCode == null || responseWithCode.length != (size + 1) || responseWithCode[0] != RESPONSE_OK)
return;
byte[] response = new byte[size];
System.arraycopy(responseWithCode, 1, response, 0, size);
holder.update(binaryProtocol, response);
}
}

View File

@ -0,0 +1,40 @@
package com.rusefi.ui.livedocs;
import java.util.Objects;
/**
* Type-safe unique structure identifier
* <p>
* (c) Andrey Belomutskiy 2013-2019
*/
public class StateId {
private final int id;
public StateId(int id) {
this.id = id;
}
public int getId() {
return id;
}
@Override
public String toString() {
return "StateId{" +
"id=" + id +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StateId stateId = (StateId) o;
return id == stateId.id;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}

View File

@ -64,7 +64,7 @@ public class Field {
return f;
}
}
throw new IllegalStateException("No field " + fieldName);
throw new IllegalStateException("No field: " + fieldName);
}
public static int getStructureSize(Field[] values) {

View File

@ -1,17 +1,11 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sat Aug 31 11:02:25 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/engine_state.txt Sun Sep 01 11:57:51 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;
public class EngineState {
public static final Field ITERM = Field.create("ITERM", 0, FieldType.FLOAT);
public static final Field DTERM = Field.create("DTERM", 4, FieldType.FLOAT);
public static final Field TARGET = Field.create("TARGET", 8, FieldType.FLOAT);
public static final Field INPUT = Field.create("INPUT", 12, FieldType.FLOAT);
public static final Field OUTPUT = Field.create("OUTPUT", 16, FieldType.FLOAT);
public static final Field ERRORAMPLIFICATIONCOEF = Field.create("ERRORAMPLIFICATIONCOEF", 20, FieldType.FLOAT);
public static final Field ISTCHARGEAIRMODEL = Field.create("ISTCHARGEAIRMODEL", 0, FieldType.BIT, 0);
public static final Field AIRMASSINONECYLINDER = Field.create("AIRMASSINONECYLINDER", 4, FieldType.FLOAT);
public static final Field TCHARGE = Field.create("TCHARGE", 8, FieldType.FLOAT);
@ -48,12 +42,6 @@ public class EngineState {
public static final Field RUNNING_BASEFUEL = Field.create("RUNNING_BASEFUEL", 128, FieldType.FLOAT);
public static final Field RUNNING_FUEL = Field.create("RUNNING_FUEL", 132, FieldType.FLOAT);
public static final Field[] VALUES = {
ITERM,
DTERM,
TARGET,
INPUT,
OUTPUT,
ERRORAMPLIFICATIONCOEF,
ISTCHARGEAIRMODEL,
AIRMASSINONECYLINDER,
TCHARGE,

View File

@ -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 Sat Aug 31 23:31:57 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sun Sep 01 12:45:18 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;
@ -873,9 +873,10 @@ public class Fields {
public static final int lcdThreadPeriodMs_offset = 720;
public static final int LDS_CLT_STATE_INDEX = 0;
public static final int LDS_ENGINE_STATE_INDEX = 3;
public static final int LDS_ETB_STATE_INDEX = 7;
public static final int LDS_ETB_PID_STATE_INDEX = 7;
public static final int LDS_FUEL_TRIM_STATE_INDEX = 4;
public static final int LDS_IAT_STATE_INDEX = 1;
public static final int LDS_IDLE_PID_STATE_INDEX = 8;
public static final int LDS_SPEED_DENSITY_STATE_INDEX = 2;
public static final int LDS_TPS_TPS_ENEICHMENT_STATE_INDEX = 5;
public static final int LDS_TRIGGER_STATE_INDEX = 6;

View File

@ -0,0 +1,23 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;
public class PidState {
public static final Field ITERM = Field.create("ITERM", 0, FieldType.FLOAT);
public static final Field DTERM = Field.create("DTERM", 4, FieldType.FLOAT);
public static final Field TARGET = Field.create("TARGET", 8, FieldType.FLOAT);
public static final Field INPUT = Field.create("INPUT", 12, FieldType.FLOAT);
public static final Field OUTPUT = Field.create("OUTPUT", 16, FieldType.FLOAT);
public static final Field ERRORAMPLIFICATIONCOEF = Field.create("ERRORAMPLIFICATIONCOEF", 20, FieldType.FLOAT);
public static final Field[] VALUES = {
ITERM,
DTERM,
TARGET,
INPUT,
OUTPUT,
ERRORAMPLIFICATIONCOEF,
};
}

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/thermistor.txt Sat Jul 20 12:28:04 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/thermistor_state.txt Sat Jul 20 12:28:04 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger.txt Sat Jul 20 12:28:04 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Sat Jul 20 12:28:04 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/wall_fuel.txt Sat Jul 20 12:28:05 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/wall_fuel_state.txt Sat Jul 20 12:28:05 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;

View File

@ -0,0 +1,50 @@
package com.rusefi.ldmp;
import com.rusefi.config.Field;
import com.rusefi.config.generated.EngineState;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.PidState;
import com.rusefi.config.generated.TriggerState;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public enum StateDictionary {
INSTANCE;
private Map<Integer, Field[]> map = new HashMap<>();
StateDictionary() {
register(Fields.LDS_ETB_PID_STATE_INDEX, PidState.VALUES);
register(Fields.LDS_TRIGGER_STATE_INDEX, TriggerState.VALUES);
register(Fields.LDS_ENGINE_STATE_INDEX, EngineState.VALUES);
}
private void register(int ldsIndex, Field[] values) {
map.put(ldsIndex, values);
}
public Field[] getValue(String state) {
String indexFieldName = "LDS_" + state.toUpperCase() + "_STATE_INDEX";
java.lang.reflect.Field field = null;
try {
field = Fields.class.getField(indexFieldName);
} catch (NoSuchFieldException e) {
throw new IllegalStateException(e);
}
Objects.requireNonNull(field, "Field " + indexFieldName);
int indexValue;
try {
indexValue = (int) field.get(null);
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
}
Field[] result = map.get(indexValue);
if (result == null) {
throw new IllegalStateException("Nothing for " + indexFieldName + "/" + indexValue);
}
return result;
}
}

View File

@ -7,9 +7,9 @@ public class AccelEnrichmentMeta {
new ConfigRequest("wwaeTau"),
new ConfigRequest("wwaeBeta"),
new TextRequest("Current_Wall_Fuel_Film"),
new FieldRequest("","wallFuel"),
new FieldRequest("wall_fuel", "wallFuel"),
new TextRequest("Fuel"),
new FieldRequest("","wallFuelCorrection"),
new FieldRequest("wall_fuel", "wallFuelCorrection"),
new TextRequest("ms"),
};
}

View File

@ -4,17 +4,18 @@ import com.rusefi.ldmp.*;
public class ElectronicThrottleMeta {
public static final Request[] CONTENT = new Request[]{
new IfRequest("hasEtbPedalPositionSensor",
new IfRequest("Engine", "hasEtbPedalPositionSensor",
new Request[]{
new TextRequest("Electronic_Throttle"),
new SensorRequest("TPS"),
new TextRequest("eol"),
new TextRequest("Pedal"),
new SensorRequest("PPS"),
new TextRequest("eol"),
new TextRequest("Output"),
new FieldRequest("","output"),
new FieldRequest("ETB_pid", "output"),
new TextRequest("iTerm"),
new FieldRequest("","iTerm"),
new FieldRequest("ETB_pid", "iTerm"),
new TextRequest("eol"),
new TextRequest("Settings"),
new ConfigRequest("ETB_PFACTOR"),

View File

@ -4,43 +4,43 @@ import com.rusefi.ldmp.*;
public class FuelMathMeta {
public static final Request[] CONTENT = new Request[]{
new IfRequest("isCrankingState",
new IfRequest("Engine", "isCrankingState",
new Request[]{
new TextRequest("Duration_coef"),
new FieldRequest("","cranking_durationCoefficient"),
new FieldRequest("Engine", "cranking_durationCoefficient"),
new TextRequest("eol"),
new TextRequest("Coolant_coef"),
new FieldRequest("","cranking_coolantTemperatureCoefficient"),
new FieldRequest("Engine", "cranking_coolantTemperatureCoefficient"),
new SensorRequest("CLT"),
new TextRequest("eol"),
new TextRequest("TPS_coef"),
new FieldRequest("","cranking_tpsCoefficient"),
new FieldRequest("Engine", "cranking_tpsCoefficient"),
new SensorRequest("TPS"),
new TextRequest("eol"),
new TextRequest("Cranking_fuel"),
new FieldRequest("","cranking_fuel"),
new FieldRequest("Engine", "cranking_fuel"),
},
new Request[]{
new TextRequest("Base_fuel"),
new FieldRequest("","running_baseFuel"),
new FieldRequest("Engine", "running_baseFuel"),
new TextRequest("eol"),
new TextRequest("Intake_coef"),
new FieldRequest("","running_intakeTemperatureCoefficient"),
new FieldRequest("Engine", "running_intakeTemperatureCoefficient"),
new SensorRequest("IAT"),
new TextRequest("eol"),
new TextRequest("Coolant_coef"),
new FieldRequest("","running_coolantTemperatureCoefficient"),
new FieldRequest("Engine", "running_coolantTemperatureCoefficient"),
new SensorRequest("CLT"),
new TextRequest("eol"),
new TextRequest("Post_cranking_coef"),
new FieldRequest("","running_postCrankingFuelCorrection"),
new FieldRequest("Engine", "running_postCrankingFuelCorrection"),
new TextRequest("eol"),
new TextRequest("eol"),
new TextRequest("Running_fuel"),
new FieldRequest("","running_fuel"),
new FieldRequest("Engine", "running_fuel"),
new TextRequest("eol"),
new TextRequest("Injector_lag"),
new FieldRequest("","running_injectorLag"),
new FieldRequest("Engine", "running_injectorLag"),
new SensorRequest("VBATT"),
}),
};

View File

@ -5,18 +5,18 @@ import com.rusefi.ldmp.*;
public class IdleThreadMeta {
public static final Request[] CONTENT = new Request[]{
new TextRequest("Idle_State"),
new FieldRequest("Engine","idleState"),
new FieldRequest("Engine", "idleState"),
new TextRequest("EOL"),
new TextRequest("Base_Position"),
new FieldRequest("Engine","baseIdlePosition"),
new FieldRequest("Engine", "baseIdlePosition"),
new TextRequest("Position_with_Adjustments"),
new FieldRequest("Engine","currentIdlePosition"),
new FieldRequest("Engine", "currentIdlePosition"),
new TextRequest("EOL"),
new TextRequest("EOL"),
new SensorRequest("TPS"),
new TextRequest("EOL"),
new TextRequest("Throttle_Up_State"),
new FieldRequest("Engine","throttlePedalUpState"),
new FieldRequest("Engine", "throttlePedalUpState"),
new ConfigRequest("throttlePedalUpPin"),
};
}

View File

@ -4,10 +4,10 @@ import com.rusefi.ldmp.*;
public class SpeedDensityMeta {
public static final Request[] CONTENT = new Request[]{
new IfRequest("isTChargeAirModel",
new IfRequest("Engine", "isTChargeAirModel",
new Request[]{
new TextRequest("interpolate_Air_Flow"),
new FieldRequest("","airFlow"),
new FieldRequest("Engine", "airFlow"),
new TextRequest("Between"),
new ConfigRequest("tChargeAirCoefMin"),
new ConfigRequest("tChargeAirFlowMax"),

View File

@ -5,16 +5,16 @@ import com.rusefi.ldmp.*;
public class ThermistorsMeta {
public static final Request[] CONTENT = new Request[]{
new TextRequest("Analog_MCU_reads"),
new FieldRequest("","voltageMCU"),
new FieldRequest("", "voltageMCU"),
new TextRequest("from_pin"),
new ConfigRequest("adcChannel"),
new TextRequest("EOL"),
new TextRequest("Analog_ECU_reads"),
new FieldRequest("","voltageBoard"),
new FieldRequest("", "voltageBoard"),
new TextRequest("Rdivider"),
new ConfigRequest("analogInputDividerCoefficient"),
new TextRequest("EOL"),
new TextRequest("Measured_resistance"),
new FieldRequest("","resistance"),
new FieldRequest("", "resistance"),
};
}

View File

@ -11,18 +11,18 @@ public class TpsMeta {
new SensorRequest("TPS"),
new TextRequest("EOL"),
new TextRequest("Analog_MCU_reads"),
new FieldRequest("","tpsVoltageMCU"),
new FieldRequest("Engine", "tpsVoltageMCU"),
new TextRequest("Volts"),
new TextRequest("from_pin"),
new ConfigRequest("tps1_1AdcChannel"),
new TextRequest("EOL"),
new TextRequest("Analog_ECU_reads"),
new FieldRequest("","tpsVoltageBoard"),
new FieldRequest("Engine", "tpsVoltageBoard"),
new TextRequest("Rdivider"),
new ConfigRequest("analogInputDividerCoefficient"),
new TextRequest("EOL"),
new TextRequest("Current_ADC"),
new FieldRequest("","currentTpsAdc"),
new FieldRequest("Engine", "currentTpsAdc"),
new TextRequest("interpolate_between"),
new ConfigRequest("tpsMax"),
new TextRequest("and"),

View File

@ -6,14 +6,14 @@ public class TriggerDecoderMeta {
public static final Request[] CONTENT = new Request[]{
new ConfigRequest("TRIGGERINPUTPINS1"),
new TextRequest("Trigger_1_Fall"),
new FieldRequest("Trigger","HWEVENTCOUNTERS1"),
new FieldRequest("Trigger", "HWEVENTCOUNTERS1"),
new TextRequest("Rise"),
new FieldRequest("Trigger","HWEVENTCOUNTERS2"),
new FieldRequest("Trigger", "HWEVENTCOUNTERS2"),
new TextRequest("EOL"),
new ConfigRequest("TRIGGERINPUTPINS2"),
new TextRequest("Trigger_2_Fall"),
new FieldRequest("Trigger","HWEVENTCOUNTERS3"),
new FieldRequest("Trigger", "HWEVENTCOUNTERS3"),
new TextRequest("Rise"),
new FieldRequest("Trigger","HWEVENTCOUNTERS4"),
new FieldRequest("Trigger", "HWEVENTCOUNTERS4"),
};
}

View File

@ -7,6 +7,12 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* Multi-line horizontal flow panel.
*
*
* (c) Andrey Belomutskiy 2013-2019
*/
public class ActionPanel {
List<RefreshActions> actionsList = new ArrayList<>();
private final JPanel panel = new JPanel(new MigLayout());
@ -16,11 +22,6 @@ public class ActionPanel {
panel.setBorder(BorderFactory.createTitledBorder(title));
}
public ActionPanel(JPanel result, List<RefreshActions> combined) {
panel.add(result);
actionsList.addAll(combined);
}
public JPanel getPanel() {
return panel;
}
@ -30,15 +31,15 @@ public class ActionPanel {
currentLinePanel = null;
}
public void addControl(JComponent component) {
initIfNeeded();
currentLinePanel.add(component);
}
private void initIfNeeded() {
if (currentLinePanel == null) {
currentLinePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
panel.add(currentLinePanel, "wrap");
}
}
public void addControl(JComponent component) {
initIfNeeded();
currentLinePanel.add(component);
}
}

View File

@ -0,0 +1,30 @@
package com.rusefi.ui.livedocs;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
/**
* (c) Andrey Belomutskiy 2013-2019
*/
public class IfConditionPanel {
private final List<RefreshActions> actionsList = new ArrayList<>();
private final JPanel panel = new JPanel(new MigLayout());
public IfConditionPanel(JPanel result, List<RefreshActions> combined) {
// todo: do we really need this proxy panel or can we just use parameter value?
panel.add(result);
// todo: do we really need this list or can we just use parameter value?
actionsList.addAll(combined);
}
public List<RefreshActions> getActionsList() {
return actionsList;
}
public JPanel getPanel() {
return panel;
}
}

View File

@ -38,7 +38,8 @@ public class LiveDocPanel {
private static final int LIVE_DATA_PRECISION = 2;
@NotNull
static JPanel createPanel(String title, String settingsInstancePrefix, final int id, Field[] values, Request[] content) {
static JPanel createPanel(String title, String settingsInstancePrefix, final int integerId, Field[] values, Request[] content) {
StateId id = new StateId(integerId);
ActionPanel ap = createComponents(title, content, values, settingsInstancePrefix);
JPanel panel = ap.getPanel();
@ -73,7 +74,7 @@ public class LiveDocPanel {
}
} else if (r instanceof FieldRequest) {
FieldRequest request = (FieldRequest) r;
Field field = Field.findField(values, "", request.getField());
Field field = getField(values, request);
JLabel label = new JLabel("*");
label.setIcon(UiUtils.loadIcon("livedocs/variable.png"));
label.setToolTipText("Variable " + field.getName());
@ -127,9 +128,9 @@ public class LiveDocPanel {
} else if (r instanceof IfRequest) {
IfRequest request = (IfRequest) r;
ActionPanel panel = createIfRequestPanel(request, values);
IfConditionPanel panel = createIfRequestPanel(request, values);
result.actionsList.addAll(panel.actionsList);
result.actionsList.addAll(panel.getActionsList());
result.addControl(panel.getPanel());
} else {
@ -139,6 +140,16 @@ public class LiveDocPanel {
return result;
}
private static Field getField(Field[] defaultContext, FieldRequest request) {
Field[] context;
if (request.getStateContext().isEmpty()) {
context = defaultContext;
} else {
context = StateDictionary.INSTANCE.getValue(request.getStateContext());
}
return Field.findField(context, "", request.getField());
}
private static String getTooltipText(String configurationFieldName) {
DialogModel.Field dialogField = IniFileModel.getInstance().getField(configurationFieldName);
if (dialogField == null) {
@ -147,7 +158,7 @@ public class LiveDocPanel {
return "Configuration " + dialogField.getUiName() + " (" + configurationFieldName + ")";
}
private static ActionPanel createIfRequestPanel(IfRequest request, Field[] values) {
private static IfConditionPanel createIfRequestPanel(IfRequest request, Field[] values) {
Field conditionField = Field.findField(values, "", request.getVariable());
@ -187,7 +198,7 @@ public class LiveDocPanel {
}
});
return new ActionPanel(result, combined);
return new IfConditionPanel(result, combined);
}
@NotNull
@ -204,7 +215,7 @@ public class LiveDocPanel {
EngineState.VALUES, IdleThreadMeta.CONTENT), CONSTRAINTS);
// todo: fix the defect - we request ETB structure but decode it as EngineState
liveDocs.add(createPanel("ETB", "", Fields.LDS_ETB_STATE_INDEX,
liveDocs.add(createPanel("ETB", "", Fields.LDS_ETB_PID_STATE_INDEX,
EngineState.VALUES, ElectronicThrottleMeta.CONTENT), CONSTRAINTS);
return liveDocs;

View File

@ -0,0 +1,27 @@
package com.rusefi.ui.livedocs.test;
import com.rusefi.config.generated.Fields;
import com.rusefi.ui.livedocs.LiveDocPanel;
import org.junit.Test;
import java.lang.reflect.Field;
import static org.junit.Assert.assertNotNull;
public class LiveDocPanelTest {
@Test
public void testFindField() throws NoSuchFieldException {
Field reflectField = Fields.class.getField("LDS_CLT_STATE_INDEX");
assertNotNull(reflectField);
}
@Test
public void testValidDocumentationMetaInfo() {
assertNotNull(LiveDocPanel.createLiveDocumentationPanel());
}
@Test
public void testValidSensorsMetaInfo() {
assertNotNull(LiveDocPanel.createSensorsLiveDataPanel());
}
}

View File

@ -4,6 +4,9 @@ import java.util.Objects;
import static com.rusefi.ConfigDefinition.EOL;
/**
* (c) Andrey Belomutskiy 2013-2019
*/
public class FieldRequest extends Request {
private final String stateContext;
private final String field;
@ -13,6 +16,10 @@ public class FieldRequest extends Request {
this.field = field;
}
public String getStateContext() {
return stateContext;
}
public String getField() {
return field;
}
@ -43,7 +50,7 @@ public class FieldRequest extends Request {
public String getGeneratedJavaCode() {
return GLOBAL_PREFIX + "new " + getClass().getSimpleName() + "("
+ quoteString(stateContext)
+ ","
+ ", "
+ quoteString(field)
+ ")," + EOL;
}

View File

@ -7,16 +7,18 @@ import java.util.List;
import static com.rusefi.ConfigDefinition.EOL;
public class IfRequest extends Request {
private final String stateContext;
private final String variable;
public List<Request> trueBlock = new ArrayList<>();
public List<Request> falseBlock = new ArrayList<>();
public IfRequest(String variable) {
public IfRequest(String stateContext, String variable) {
this.stateContext = stateContext;
this.variable = variable;
}
public IfRequest(String variable, Request[] trueBlock, Request[] falseBlock) {
this(variable);
public IfRequest(String stateContext, String variable, Request[] trueBlock, Request[] falseBlock) {
this(stateContext, variable);
this.trueBlock.addAll(Arrays.asList(trueBlock));
this.falseBlock.addAll(Arrays.asList(falseBlock));
}
@ -40,7 +42,11 @@ public class IfRequest extends Request {
Request.GLOBAL_PREFIX = Request.GLOBAL_PREFIX + "\t";
result += "new IfRequest(" + quoteString(variable) + "," + EOL +
result += "new IfRequest("
+ quoteString(stateContext)
+ ", "
+ quoteString(variable)
+ "," + EOL +
Request.GLOBAL_PREFIX + "new Request[]{" + EOL +
Request.getGeneratedJavaCode(trueBlock) +
"}," + EOL +

View File

@ -87,7 +87,7 @@ public class LiveDocsMetaParser {
} else if (DISPLAY_TEXT.equalsIgnoreCase(token)) {
if (s.hasNext()) {
String config = s.next();
SystemOut.println("REQ TEXT " + config);
SystemOut.println("Display test " + config);
result.add(new TextRequest(config));
}
} else if (DISPLAY_TAG.equalsIgnoreCase(token)) {
@ -103,21 +103,19 @@ public class LiveDocsMetaParser {
}
} else if (DISPLAY_FIELD.equalsIgnoreCase(token)) {
if (s.hasNext()) {
String config = prefix + s.next();
SystemOut.println("REQ FIELD " + config);
result.add(new FieldRequest(meta.getStateContext(), config));
String fieldName = prefix + s.next();
SystemOut.println("REQ FIELD " + fieldName);
result.add(new FieldRequest(meta.getStateContext(), fieldName));
prefix.setLength(0);
}
} else if (DISPLAY_IF.equalsIgnoreCase(token)) {
if (s.hasNext()) {
stack.push(result);
String variable = s.next();
String conditionVariable = s.next();
String config = s.next();
SystemOut.println("REQ TEXT " + config);
IfRequest ifRequest = new IfRequest(variable);
SystemOut.println("if Condition " + conditionVariable);
IfRequest ifRequest = new IfRequest(meta.getStateContext(), conditionVariable);
result.add(ifRequest);
result = ifRequest.trueBlock;

View File

@ -16,8 +16,11 @@ public class MetaInfo {
}
public String getStateContext() {
if (stateStack.isEmpty())
return ""; // state context not defined, java code would have to explicitly provide that information
if (stateStack.isEmpty()) {
// state context not defined, java code would have to explicitly provide that information
// this is used if code does not know context, for instance thermistor code does not know if CLT or IAT usage
return "";
}
return stateStack.peek();
}
}

View File

@ -4,6 +4,9 @@ import java.util.List;
import static com.rusefi.ConfigDefinition.EOL;
/**
* (c) Andrey Belomutskiy 2013-2019
*/
public abstract class Request {
static String GLOBAL_PREFIX = "\t\t\t";