live data for wastegate and launch control #3588

progress
This commit is contained in:
rusefillc 2021-12-18 10:17:22 -05:00
parent c2d31cc7b0
commit c21b15ccaa
3 changed files with 32 additions and 11 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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<String, Object> 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());
}
}