From bab6a8f1679145987add79505f7a426d9c0d4b8d Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 14 Nov 2014 11:03:39 -0600 Subject: [PATCH] auto-sync --- .../models/src/com/irnems/core/Sensor.java | 136 ++++++++++-------- .../src/com/irnems/core/SensorCategory.java | 18 +++ java_console/ui/src/com/irnems/Launcher.java | 2 +- .../com/rusefi/ui/widgets/SensorGauge.java | 28 ++-- 4 files changed, 114 insertions(+), 70 deletions(-) create mode 100644 java_console/models/src/com/irnems/core/SensorCategory.java diff --git a/java_console/models/src/com/irnems/core/Sensor.java b/java_console/models/src/com/irnems/core/Sensor.java index d2219c5af9..61661d37b6 100644 --- a/java_console/models/src/com/irnems/core/Sensor.java +++ b/java_console/models/src/com/irnems/core/Sensor.java @@ -2,107 +2,123 @@ package com.irnems.core; import eu.hansolo.steelseries.tools.BackgroundColor; +import java.util.ArrayList; + /** * @author Andrey Belomutskiy * 2/11/13 */ public enum Sensor { - RPM("RPM"), - MAP("MAP"), - MAP_RAW("MAP_RAW"), - BARO("Baro"), - TIMING("Timing Advance", "deg", -180, 180), + RPM("RPM", SensorCategory.SENSOR_INPUTS), + MAP("MAP", SensorCategory.SENSOR_INPUTS), + MAP_RAW("MAP_RAW", SensorCategory.SENSOR_INPUTS), + BARO("Baro", SensorCategory.SENSOR_INPUTS), + TIMING("Timing Advance", SensorCategory.OPERATIONS, "deg", -180, 180), /** * Please note that these enum names are used to make 'set_mock_XXX_voltage' commands */ - CLT("Coolant", "temperature, C", -40, 300), - IAT("Intake Air", "temperature, C", -40, 150), - AFR("A/F ratio", "", 0, 20), - MAF("MAF", "Volts", 4), - TPS("throttle", "%", 100), + CLT("Coolant", SensorCategory.SENSOR_INPUTS, "temperature, C", -40, 300), + IAT("Intake Air", SensorCategory.SENSOR_INPUTS, "temperature, C", -40, 150), + AFR("A/F ratio", SensorCategory.SENSOR_INPUTS, "", 0, 20), + MAF("MAF", SensorCategory.SENSOR_INPUTS, "Volts", 4), + TPS("throttle", SensorCategory.SENSOR_INPUTS, "%", 100), - TRG_0_DUTY("trg0 duty", "%", 100), - TRG_1_DUTY("trg1 duty", "%", 100), + TRG_0_DUTY("trg0 duty", SensorCategory.SENSOR_INPUTS, "%", 100), + TRG_1_DUTY("trg1 duty", SensorCategory.SENSOR_INPUTS, "%", 100), // COOLANT_WIDTH("c w", "", 30), // INTAKE_AIR_WIDTH("air w", "", 30), - TABLE_SPARK("table spark", "ms", -40, 40), - VREF("VRef", "Volts", 6), - VBATT("VBatt", "Volts", 18), - VREF_WIDTH("VRef w", "", 1), - DWELL0("Input dwl #1", "ms", 0, 30, BackgroundColor.BEIGE), - DWELL1("Input dwl #2", "ms", 0, 30, BackgroundColor.BEIGE), - DWELL2("Input dwl #3", "ms", 0, 30, BackgroundColor.BEIGE), - DWELL3("Input dwl #4", "ms", 0, 30, BackgroundColor.BEIGE), - DWELL0_SD("Input d #1", "std dev", 100), + TABLE_SPARK("table spark", SensorCategory.OPERATIONS, "ms", -40, 40), + VREF("VRef", SensorCategory.SENSOR_INPUTS, "Volts", 6), + VBATT("VBatt", SensorCategory.SENSOR_INPUTS, "Volts", 18), + VREF_WIDTH("VRef w", SensorCategory.OTHERS, "", 1), + DWELL0("Input dwl #1", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + DWELL1("Input dwl #2", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + DWELL2("Input dwl #3", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + DWELL3("Input dwl #4", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + DWELL0_SD("Input d #1", SensorCategory.SNIFFING, "std dev", 100), - TOTAL_DWELL0("Input tdwl #1", "ms", 0, 30, BackgroundColor.BEIGE), - TOTAL_DWELL1("Input tdwl #2", "ms", 0, 30, BackgroundColor.BEIGE), - TOTAL_DWELL2("Input tdwl #3", "ms", 0, 30, BackgroundColor.BEIGE), - TOTAL_DWELL3("Input tdwl #4", "ms", 0, 30, BackgroundColor.BEIGE), - ADVANCE0("Input Adv #1", "deg", -180, 180, BackgroundColor.BROWN), - ADVANCE1("Input Adv #2", "deg", -180, 180, BackgroundColor.BROWN), - ADVANCE2("Input Adv #3", "deg", -180, 180, BackgroundColor.BROWN), - ADVANCE3("Input Adv #4", "deg", -180, 180, BackgroundColor.BROWN), - PERIOD0("Period", "dg", 0, 400), - DUTY0("Duty0", "%", 0, 100, BackgroundColor.RED), - DUTY1("Duty1", "%", 0, 100, BackgroundColor.RED), - FUEL("Fuel", "ms", 0, 30), - FUEL_BASE("Fuel Base", "ms", 0, 30), - FUEL_IAT("F IAT", "", 0, 10), - FUEL_CLT("F CLT", "", 0, 10), - FUEL_LAG("F Lag", "", 0, 30), + TOTAL_DWELL0("Input tdwl #1", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + TOTAL_DWELL1("Input tdwl #2", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + TOTAL_DWELL2("Input tdwl #3", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + TOTAL_DWELL3("Input tdwl #4", SensorCategory.SNIFFING, "ms", 0, 30, BackgroundColor.BEIGE), + ADVANCE0("Input Adv #1", SensorCategory.SNIFFING, "deg", -180, 180, BackgroundColor.BROWN), + ADVANCE1("Input Adv #2", SensorCategory.SNIFFING, "deg", -180, 180, BackgroundColor.BROWN), + ADVANCE2("Input Adv #3", SensorCategory.SNIFFING, "deg", -180, 180, BackgroundColor.BROWN), + ADVANCE3("Input Adv #4", SensorCategory.SNIFFING, "deg", -180, 180, BackgroundColor.BROWN), + PERIOD0("Period", SensorCategory.SNIFFING, "dg", 0, 400), + DUTY0("Duty0", SensorCategory.SNIFFING, "%", 0, 100, BackgroundColor.RED), + DUTY1("Duty1", SensorCategory.SNIFFING, "%", 0, 100, BackgroundColor.RED), + FUEL("Fuel", SensorCategory.OPERATIONS, "ms", 0, 30), + FUEL_BASE("Fuel Base", SensorCategory.OPERATIONS, "ms", 0, 30), + FUEL_IAT("F IAT", SensorCategory.OPERATIONS, "", 0, 10), + FUEL_CLT("F CLT", SensorCategory.OPERATIONS, "", 0, 10), + FUEL_LAG("F Lag", SensorCategory.OPERATIONS, "", 0, 30), - IDLE_SWITCH("idle switch"), + IDLE_SWITCH("idle switch", SensorCategory.OTHERS), - DEFAULT_FUEL("map fuel", "ms", 0, 40), - T_CHARGE("T Charge", "f", 0, 200), + DEFAULT_FUEL("map fuel", SensorCategory.OPERATIONS, "ms", 0, 40), + T_CHARGE("T Charge", SensorCategory.OPERATIONS, "f", 0, 200), - CHARTSIZE("CHARTSIZE"), - CHART_STATUS("CHART_STATUS"), - ADC_STATUS("ADC_STATUS"), + CHARTSIZE("CHARTSIZE", SensorCategory.OTHERS), + CHART_STATUS("CHART_STATUS", SensorCategory.OTHERS), + ADC_STATUS("ADC_STATUS", SensorCategory.OTHERS), - ADC_FAST("ADC_FAST", "b", 4000), - ADC_FAST_AVG("ADC_FAST_AVG", "b", 4000), - INJECTOR_1_DWELL("inj #1"), - INJECTOR_2_DWELL("inj #2"), - INJECTOR_3_DWELL("inj #3"), - INJECTOR_4_DWELL("inj #4"), + ADC_FAST("ADC_FAST", SensorCategory.OTHERS, "b", 4000), + ADC_FAST_AVG("ADC_FAST_AVG", SensorCategory.OTHERS, "b", 4000), + INJECTOR_1_DWELL("inj #1", SensorCategory.SNIFFING), + INJECTOR_2_DWELL("inj #2", SensorCategory.SNIFFING), + INJECTOR_3_DWELL("inj #3", SensorCategory.SNIFFING), + INJECTOR_4_DWELL("inj #4", SensorCategory.SNIFFING), - INJ_1_2_DELTA("inj 1-2 delta"), - INJ_3_4_DELTA("inj 3-4 delta"), + INJ_1_2_DELTA("inj 1-2 delta", SensorCategory.SNIFFING), + INJ_3_4_DELTA("inj 3-4 delta", SensorCategory.SNIFFING), ; private final String name; + private final SensorCategory category; private final String units; private final double minValue; private final double maxValue; private final BackgroundColor color; - Sensor(String name) { - this(name, "", 255); + Sensor(String name, SensorCategory category) { + this(name, category, "", 255); } - Sensor(String name, String units, double maxValue) { - this(name, units, 0, maxValue); + Sensor(String name, SensorCategory category, String units, double maxValue) { + this(name, category, units, 0, maxValue); } - Sensor(String name, String units, double minValue, double maxValue) { - this(name, units, minValue, maxValue, BackgroundColor.LIGHT_GRAY); + Sensor(String name, SensorCategory category, String units, double minValue, double maxValue) { + this(name, category, units, minValue, maxValue, BackgroundColor.LIGHT_GRAY); } - Sensor(String name, String units, double minValue, double maxValue, BackgroundColor color) { + Sensor(String name, SensorCategory category, String units, double minValue, double maxValue, BackgroundColor color) { this.name = name; + this.category = category; this.units = units; this.minValue = minValue; this.maxValue = maxValue; this.color = color; } + public static ArrayList getSensorsForCategory(String category) { + final ArrayList sensors = new ArrayList(); + + for (final Sensor sensor : values()) { + if (sensor.category.getName().equals(category)) { + sensors.add(sensor); + } + } + + return sensors; + } + public static double processAdvance(double advance) { return advance > 360 ? advance - 720 : advance; } @@ -111,6 +127,10 @@ public enum Sensor { return name; } + public SensorCategory getCategory() { + return category; + } + public String getUnits() { return units; } diff --git a/java_console/models/src/com/irnems/core/SensorCategory.java b/java_console/models/src/com/irnems/core/SensorCategory.java new file mode 100644 index 0000000000..ddddde533c --- /dev/null +++ b/java_console/models/src/com/irnems/core/SensorCategory.java @@ -0,0 +1,18 @@ +package com.irnems.core; + +public enum SensorCategory { + OPERATIONS("Operations"), + SNIFFING("Sniffing"), + SENSOR_INPUTS("Sensor inputs"), + OTHERS("Others"); + + private final String name; + + private SensorCategory(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/java_console/ui/src/com/irnems/Launcher.java b/java_console/ui/src/com/irnems/Launcher.java index 21418c51eb..f78a5fc8fa 100644 --- a/java_console/ui/src/com/irnems/Launcher.java +++ b/java_console/ui/src/com/irnems/Launcher.java @@ -19,7 +19,7 @@ import javax.swing.*; * @see WavePanel */ public class Launcher extends FrameHelper { - public static final int CONSOLE_VERSION = 20141112; + public static final int CONSOLE_VERSION = 20141114; public static final boolean SHOW_STIMULATOR = true; private final String port; diff --git a/java_console/ui/src/com/rusefi/ui/widgets/SensorGauge.java b/java_console/ui/src/com/rusefi/ui/widgets/SensorGauge.java index 756cf55498..205a20241d 100644 --- a/java_console/ui/src/com/rusefi/ui/widgets/SensorGauge.java +++ b/java_console/ui/src/com/rusefi/ui/widgets/SensorGauge.java @@ -1,6 +1,7 @@ package com.rusefi.ui.widgets; import com.irnems.core.Sensor; +import com.irnems.core.SensorCategory; import com.irnems.core.SensorCentral; import eu.hansolo.steelseries.gauges.Radial; import eu.hansolo.steelseries.tools.ColorDef; @@ -77,17 +78,22 @@ public class SensorGauge { } private static void fillGaugeItems(JMenu gauges, final JPanel wrapper, final GaugeChangeListener listener) { - for (final Sensor s : Sensor.values()) { - JMenuItem mi = new JMenuItem(s.getName()); - mi.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - createGaugeBody(s, wrapper, listener); - if (listener != null) - listener.onChange(s); - } - }); - gauges.add(mi); + for (final SensorCategory sc : SensorCategory.values()) { + JMenuItem cmi = new JMenu(sc.getName()); + gauges.add(cmi); + + for (final Sensor s : Sensor.getSensorsForCategory(sc.getName())) { + JMenuItem mi = new JMenuItem(s.getName()); + mi.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + createGaugeBody(s, wrapper, listener); + if (listener != null) + listener.onChange(s); + } + }); + cmi.add(mi); + } } }