From a4f4e79991fc2f89c22566cda254b75bbdb18803 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 2 Jul 2023 11:58:58 -0400 Subject: [PATCH] only:live data fix --- firmware/integration/LiveData.yaml | 1 + .../rusefi/enums/StateDictionaryFactory.java | 40 +++++++++++++++++++ .../java/com/rusefi/ldmp/StateDictionary.java | 36 ++--------------- 3 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 java_console/io/src/main/java/com/rusefi/enums/StateDictionaryFactory.java diff --git a/firmware/integration/LiveData.yaml b/firmware/integration/LiveData.yaml index a9147d21b6..504b7cea39 100644 --- a/firmware/integration/LiveData.yaml +++ b/firmware/integration/LiveData.yaml @@ -11,6 +11,7 @@ # # see gen_live_documentation.sh which is the main generation script # todo: what is sequence of events in terms of 'live_data_e' code generation? +# todo: code generate StateDictionaryFactory.java # Usages: # output_channels always goes first at least because it has protocol version at well-known offset diff --git a/java_console/io/src/main/java/com/rusefi/enums/StateDictionaryFactory.java b/java_console/io/src/main/java/com/rusefi/enums/StateDictionaryFactory.java new file mode 100644 index 0000000000..c3be4ddbc1 --- /dev/null +++ b/java_console/io/src/main/java/com/rusefi/enums/StateDictionaryFactory.java @@ -0,0 +1,40 @@ +package com.rusefi.enums; + +import com.rusefi.config.generated.*; +import com.rusefi.ldmp.StateDictionary; + +public class StateDictionaryFactory { + public static void initialize(StateDictionary stateDictionary) { + //register(live_data_e.LDS_ETB_PID, PidState.VALUES); // 7 + //register(live_data_e.LDS_IDLE_PID, PidState.VALUES); + //register(live_data_e.LDS_ALTERNATOR_PID, + // LDS_CJ125_PID + //register(live_data_e.LDS_IDLE, IdleState.VALUES); + // todo: code generate this! + stateDictionary.register(live_data_e.LDS_output_channels, TsOutputs.VALUES, "status_loop"); + stateDictionary.register(live_data_e.LDS_engine_state, EngineState.VALUES, "engine"); + stateDictionary.register(live_data_e.LDS_trigger_central, TriggerCentral.VALUES, "trigger_central"); + stateDictionary.register(live_data_e.LDS_trigger_state, TriggerState.VALUES, "trigger_decoder"); + stateDictionary.register(live_data_e.LDS_ac_control, AcControl.VALUES, "ac_control"); + stateDictionary.register(live_data_e.LDS_fan_control, FuelPump.VALUES, "fan_control"); + stateDictionary.register(live_data_e.LDS_injector_model, InjectorModel.VALUES, "injector_model"); + stateDictionary.register(live_data_e.LDS_idle_state, IdleState.VALUES, "idle_thread"); + stateDictionary.register(live_data_e.LDS_fuel_pump_control, FuelPump.VALUES, "fuel_pump"); + stateDictionary.register(live_data_e.LDS_wall_fuel_state, WallFuelState.VALUES, "wall_fuel"); + stateDictionary.register(live_data_e.LDS_tps_accel_state, TpsAccelState.VALUES, "accel_enrichment"); + stateDictionary.register(live_data_e.LDS_main_relay, MainRelay.VALUES, "main_relay"); + stateDictionary.register(live_data_e.LDS_boost_control, BoostControl.VALUES, "boost_control"); + stateDictionary.register(live_data_e.LDS_launch_control_state, LaunchControl.VALUES, "launch_control"); + stateDictionary.register(live_data_e.LDS_high_pressure_fuel_pump, HighPressureFuelPump.VALUES, "high_pressure_fuel_pump"); + stateDictionary.register(live_data_e.LDS_ignition_state, IgnitionState.VALUES, "advance_map"); + stateDictionary.register(live_data_e.LDS_electronic_throttle, ElectronicThrottle.VALUES, "electronic_throttle"); + stateDictionary.register(live_data_e.LDS_knock_controller, KnockController.VALUES, "knock_controller"); + stateDictionary.register(live_data_e.LDS_wideband_state, WidebandController.VALUES, "AemXSeriesLambda"); + stateDictionary.register(live_data_e.LDS_trigger_state_primary, TriggerStatePrimary.VALUES, "trigger_decoder"); + stateDictionary.register(live_data_e.LDS_fuel_computer, FuelComputer.VALUES, "fuel_computer"); + stateDictionary.register(live_data_e.LDS_antilag_system_state, AntilagSystem.VALUES, "antilag_system"); + stateDictionary.register(live_data_e.LDS_dc_motors, DcMotors.VALUES, "dc_motors"); + stateDictionary.register(live_data_e.LDS_sent_state, SentState.VALUES, "sent"); + stateDictionary.register(live_data_e.LDS_throttle_model, ThrottleModel.VALUES, "throttle_model"); + } +} diff --git a/java_console/io/src/main/java/com/rusefi/ldmp/StateDictionary.java b/java_console/io/src/main/java/com/rusefi/ldmp/StateDictionary.java index e4e9ab5832..653121443e 100644 --- a/java_console/io/src/main/java/com/rusefi/ldmp/StateDictionary.java +++ b/java_console/io/src/main/java/com/rusefi/ldmp/StateDictionary.java @@ -1,7 +1,7 @@ package com.rusefi.ldmp; import com.rusefi.config.Field; -import com.rusefi.config.generated.*; +import com.rusefi.enums.StateDictionaryFactory; import com.rusefi.enums.live_data_e; import org.jetbrains.annotations.NotNull; @@ -17,37 +17,7 @@ public enum StateDictionary { private final Map fileNames = new HashMap<>(); StateDictionary() { - //register(live_data_e.LDS_ETB_PID, PidState.VALUES); // 7 - //register(live_data_e.LDS_IDLE_PID, PidState.VALUES); - //register(live_data_e.LDS_ALTERNATOR_PID, - // LDS_CJ125_PID - //register(live_data_e.LDS_IDLE, IdleState.VALUES); - // todo: code generate this! - register(live_data_e.LDS_output_channels, TsOutputs.VALUES, "status_loop"); - register(live_data_e.LDS_engine_state, EngineState.VALUES, "engine"); - register(live_data_e.LDS_trigger_central, TriggerCentral.VALUES, "trigger_central"); - register(live_data_e.LDS_trigger_state, TriggerState.VALUES, "trigger_decoder"); - register(live_data_e.LDS_ac_control, AcControl.VALUES, "ac_control"); - register(live_data_e.LDS_fan_control, FuelPump.VALUES, "fan_control"); - register(live_data_e.LDS_injector_model, InjectorModel.VALUES, "injector_model"); - register(live_data_e.LDS_idle_state, IdleState.VALUES, "idle_thread"); - register(live_data_e.LDS_fuel_pump_control, FuelPump.VALUES, "fuel_pump"); - register(live_data_e.LDS_wall_fuel_state, WallFuelState.VALUES, "wall_fuel"); - register(live_data_e.LDS_tps_accel_state, TpsAccelState.VALUES, "accel_enrichment"); - register(live_data_e.LDS_main_relay, MainRelay.VALUES, "main_relay"); - register(live_data_e.LDS_boost_control, BoostControl.VALUES, "boost_control"); - register(live_data_e.LDS_launch_control_state, LaunchControl.VALUES, "launch_control"); - register(live_data_e.LDS_high_pressure_fuel_pump, HighPressureFuelPump.VALUES, "high_pressure_fuel_pump"); - register(live_data_e.LDS_ignition_state, IgnitionState.VALUES, "advance_map"); - register(live_data_e.LDS_electronic_throttle, ElectronicThrottle.VALUES, "electronic_throttle"); - register(live_data_e.LDS_knock_controller, KnockController.VALUES, "knock_controller"); - register(live_data_e.LDS_wideband_state, WidebandController.VALUES, "AemXSeriesLambda"); - register(live_data_e.LDS_trigger_state_primary, TriggerStatePrimary.VALUES, "trigger_decoder"); - register(live_data_e.LDS_fuel_computer, FuelComputer.VALUES, "fuel_computer"); - register(live_data_e.LDS_antilag_system_state, AntilagSystem.VALUES, "antilag_system"); - register(live_data_e.LDS_dc_motors, DcMotors.VALUES, "dc_motors"); - register(live_data_e.LDS_sent_state, SentState.VALUES, "sent"); - register(live_data_e.LDS_throttle_model, ThrottleModel.VALUES, "throttle"); + StateDictionaryFactory.initialize(this); if (map.size() != live_data_e.values().length) { Set missing = new HashSet<>(Arrays.asList(live_data_e.values())); missing.removeAll(map.keySet()); @@ -69,7 +39,7 @@ public enum StateDictionary { return result; } - private void register(live_data_e ldsIndex, Field[] values, String fileName) { + public void register(live_data_e ldsIndex, Field[] values, String fileName) { map.put(ldsIndex, values); fileNames.put(ldsIndex, fileName); }