From c21b15ccaa4bd13b0da469ff85c7a1e74cf3a988 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 18 Dec 2021 10:17:22 -0500 Subject: [PATCH] live data for wastegate and launch control #3588 progress --- .../java/com/rusefi/ui/util/FrameHelper.java | 9 +++++- .../livedata/LiveDataParserPanelSandbox.java | 28 +++++++++++++------ .../livedata/LiveDataParserSandbox.java | 6 +++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/java_console/autoupdate/src/main/java/com/rusefi/ui/util/FrameHelper.java b/java_console/autoupdate/src/main/java/com/rusefi/ui/util/FrameHelper.java index 5d881f35c9..aa046b5cbb 100644 --- a/java_console/autoupdate/src/main/java/com/rusefi/ui/util/FrameHelper.java +++ b/java_console/autoupdate/src/main/java/com/rusefi/ui/util/FrameHelper.java @@ -13,6 +13,14 @@ import java.util.Arrays; public class FrameHelper { private final JFrame frame = new JFrame(); + public FrameHelper() { + this(JDialog.DISPOSE_ON_CLOSE); + } + + public FrameHelper(int operation) { + frame.setDefaultCloseOperation(operation); + } + public JFrame getFrame() { return frame; } @@ -28,7 +36,6 @@ public class FrameHelper { public void initFrame(JComponent component, final boolean maximizeOnStart) { frame.setSize(800, 500); - frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { diff --git a/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserPanelSandbox.java b/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserPanelSandbox.java index 0cc2a62081..0582409429 100644 --- a/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserPanelSandbox.java +++ b/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserPanelSandbox.java @@ -1,27 +1,37 @@ package com.rusefi.livedata; -import com.rusefi.enums.live_data_e; +import com.rusefi.config.Field; +import com.rusefi.config.generated.BoostControl; +import com.rusefi.ldmp.StateDictionary; import com.rusefi.ui.UIContext; import com.rusefi.ui.livedocs.LiveDocsRegistry; import com.rusefi.ui.util.FrameHelper; import javax.swing.*; +/** + * TODO: not point in this class kill it? + * @see LiveDataParserSandbox + */ public class LiveDataParserPanelSandbox { + private final static LiveDataView liveDataView = LiveDataView.BOOST_CONTROL; + public static void main(String[] args) { UIContext context = new UIContext(); JPanel panel = LiveDataParserPanel.createLiveDataParserContent(context, - LiveDataView.BOOST_CONTROL); + liveDataView); - LiveDocsRegistry.INSTANCE.refresh(new LiveDocsRegistry.LiveDataProvider() { - @Override - public byte[] provide(live_data_e context) { - System.out.println("provide"); - return new byte[0]; - } - } + Field[] values = StateDictionary.INSTANCE.getFields(liveDataView.getLiveDataE()); + int size = Field.getStructureSize(values); + byte[] state = new byte[size]; + + + Field.findFieldOrNull(values, "", BoostControl.ISTPSVALID.getName()).setValue(state, true); + Field.findFieldOrNull(values, "", BoostControl.ISNOTCLOSEDLOOP.getName()).setValue(state, true); + + LiveDocsRegistry.INSTANCE.refresh(context1 -> state ); new FrameHelper().showFrame(panel); diff --git a/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserSandbox.java b/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserSandbox.java index a95827b3da..1cd27221e0 100644 --- a/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserSandbox.java +++ b/java_console/ui/src/test/java/com/rusefi/livedata/LiveDataParserSandbox.java @@ -4,9 +4,13 @@ import com.rusefi.ui.UIContext; import com.rusefi.ui.livedata.VariableValueSource; import com.rusefi.ui.util.FrameHelper; +import javax.swing.*; import java.util.Map; import java.util.TreeMap; +/** + * @see LiveDataParserPanelSandbox + */ public class LiveDataParserSandbox { public static void main(String[] args) { Map values = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); @@ -20,6 +24,6 @@ public class LiveDataParserSandbox { } }; - new FrameHelper().showFrame(new LiveDataParserPanel(new UIContext(), valueSource, "ac_control.cpp").getContent()); + new FrameHelper(JDialog.EXIT_ON_CLOSE).showFrame(new LiveDataParserPanel(new UIContext(), valueSource, "ac_control.cpp").getContent()); } }