more intellij inspection (#3910)

* first part

* some more small ones

* more inspect
This commit is contained in:
Matthew Kennedy 2022-02-10 15:56:59 -08:00 committed by GitHub
parent 3a3fab1882
commit 27b2032e25
24 changed files with 59 additions and 94 deletions

View File

@ -130,7 +130,7 @@ public class BinaryProtocol {
public boolean isClosed; public boolean isClosed;
public CommunicationLoggingListener communicationLoggingListener = CommunicationLoggingListener.VOID; public CommunicationLoggingListener communicationLoggingListener;
public byte[] getCurrentOutputs() { public byte[] getCurrentOutputs() {
return state.getCurrentOutputs(); return state.getCurrentOutputs();
@ -282,7 +282,7 @@ public class BinaryProtocol {
if (needCompositeLogger) { if (needCompositeLogger) {
getComposite(); getComposite();
} else if (isCompositeLoggerEnabled) { } else if (isCompositeLoggerEnabled) {
byte packet[] = new byte[2]; byte[] packet = new byte[2];
packet[0] = Fields.TS_SET_LOGGER_SWITCH; packet[0] = Fields.TS_SET_LOGGER_SWITCH;
packet[1] = Fields.TS_COMPOSITE_DISABLE; packet[1] = Fields.TS_COMPOSITE_DISABLE;
executeCommand(packet, "disable composite"); executeCommand(packet, "disable composite");
@ -614,7 +614,7 @@ public class BinaryProtocol {
if (isClosed) if (isClosed)
return; return;
byte packet[] = new byte[1]; byte[] packet = new byte[1];
packet[0] = Fields.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY; packet[0] = Fields.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY;
// get command would enable composite logging in controller but we need to turn it off from our end // get command would enable composite logging in controller but we need to turn it off from our end
// todo: actually if console gets disconnected composite logging might end up enabled in controller? // todo: actually if console gets disconnected composite logging might end up enabled in controller?

View File

@ -27,7 +27,7 @@ public interface ByteReader {
threadExecutor.execute(() -> { threadExecutor.execute(() -> {
log.info(loggingPrefix + "Running TCP connection loop"); log.info(loggingPrefix + "Running TCP connection loop");
byte inputBuffer[] = new byte[Fields.BLOCKING_FACTOR * 2]; byte[] inputBuffer = new byte[Fields.BLOCKING_FACTOR * 2];
while (!ioStream.isClosed()) { while (!ioStream.isClosed()) {
try { try {
int result = reader.read(inputBuffer); int result = reader.read(inputBuffer);

View File

@ -60,7 +60,7 @@ public class BinaryProtocolServer {
return serverSocket; return serverSocket;
}; };
private static ConcurrentHashMap<String, ThreadFactory> THREAD_FACTORIES_BY_NAME = new ConcurrentHashMap<>(); private final static ConcurrentHashMap<String, ThreadFactory> THREAD_FACTORIES_BY_NAME = new ConcurrentHashMap<>();
public void start(LinkManager linkManager) { public void start(LinkManager linkManager) {
try { try {

View File

@ -17,7 +17,7 @@ public class IoHelperTest {
@Test @Test
public void testSwap16() throws IOException { public void testSwap16() throws IOException {
byte packet[] = {-12, 0}; byte[] packet = {-12, 0};
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet)); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet));
short a = dis.readShort(); short a = dis.readShort();
int x = IoHelper.swap16(a); int x = IoHelper.swap16(a);

View File

@ -56,7 +56,7 @@ public class ConsoleUI {
/** /**
* We can listen to tab activation event if we so desire * We can listen to tab activation event if we so desire
*/ */
private final Map<JComponent, ActionListener> tabSelectedListeners = new HashMap<>(); private final Map<Component, ActionListener> tabSelectedListeners = new HashMap<>();
public static Frame getFrame() { public static Frame getFrame() {
return staticFrame; return staticFrame;

View File

@ -29,8 +29,6 @@ import java.util.concurrent.CountDownLatch;
/** /**
* Date: 3/24/13 * Date: 3/24/13
* Andrey Belomutskiy, (c) 2013-2020 * Andrey Belomutskiy, (c) 2013-2020
*
* @see EcuStimulatorSandbox
*/ */
public class EcuStimulator { public class EcuStimulator {
private static final String DELIMITER = ","; private static final String DELIMITER = ",";
@ -308,7 +306,7 @@ public class EcuStimulator {
return result; return result;
} }
private class MultipleMeasurements { private static class MultipleMeasurements {
private List<Double> dwells = new ArrayList<>(MEASURES); private List<Double> dwells = new ArrayList<>(MEASURES);
private List<Double> advances = new ArrayList<>(MEASURES); private List<Double> advances = new ArrayList<>(MEASURES);

View File

@ -34,8 +34,8 @@ public final class Histograms {
@NotNull @NotNull
public List<String> dumpStats() { public List<String> dumpStats() {
Collection<StatisticsGroup> values = takeAndResetSnapshot(); Collection<StatisticsGroup> values = takeAndResetSnapshot();
List<StatisticsGroup> al = new ArrayList<>(); List<StatisticsGroup> al = new ArrayList<>(values);
al.addAll(values);
synchronized (total_stats) { synchronized (total_stats) {
for (StatisticsGroup source : values) { for (StatisticsGroup source : values) {
String type = source.type + ".TOTAL"; String type = source.type + ".TOTAL";
@ -368,7 +368,7 @@ public final class Histograms {
private String toString(StatisticsGroup sg, long duration) { private String toString(StatisticsGroup sg, long duration) {
StringBuffer sb = new StringBuffer(100 + sg.data.size() * 100); StringBuffer sb = new StringBuffer(100 + sg.data.size() * 100);
appendHeader(sb, sg, duration); appendHeader(sb, sg, duration);
Statistics[] sts = sg.data.values().toArray(new Statistics[sg.data.size()]); Statistics[] sts = sg.data.values().toArray(new Statistics[0]);
sortStatistics(sg, sts); sortStatistics(sg, sts);
for (Statistics st : sts) { for (Statistics st : sts) {
appendStatistics(sb, st, new ArrayList<>()); appendStatistics(sb, st, new ArrayList<>());

View File

@ -4,5 +4,5 @@ public enum KeyStrokeShortcut {
PREVIOUS_PAGE, PREVIOUS_PAGE,
NEXT_PAGE, NEXT_PAGE,
ZOOM_IN, ZOOM_IN,
ZOOM_OUT; ZOOM_OUT
} }

View File

@ -134,10 +134,10 @@ public class ReportReader {
// System.out.println(line); // System.out.println(line);
Matcher m = LINE_PATTERN.matcher(line); Matcher m = LINE_PATTERN.matcher(line);
if (m.matches()) { if (m.matches()) {
int time = Integer.valueOf(m.group(1)); int time = Integer.parseInt(m.group(1));
MafValue maf = MafValue.valueOf(m.group(2)); MafValue maf = MafValue.valueOf(m.group(2));
RpmValue rpm = RpmValue.valueOf(m.group(3)); RpmValue rpm = RpmValue.valueOf(m.group(3));
int wave = Integer.valueOf(m.group(4)); int wave = Integer.parseInt(m.group(4));
if (prevMaf == maf.getValue() && prevRpm == rpm.getValue() && prevWave == wave) { if (prevMaf == maf.getValue() && prevRpm == rpm.getValue() && prevWave == wave) {
// System.out.println("All the same..."); // System.out.println("All the same...");

View File

@ -130,8 +130,7 @@ public class SensorSnifferPane {
maxX = keys.get(keys.size() - 1); maxX = keys.get(keys.size() - 1);
FileLog.MAIN.logLine("Analog chart from " + minX + " to " + maxX); FileLog.MAIN.logLine("Analog chart from " + minX + " to " + maxX);
TreeSet<Double> sortedValues = new TreeSet<>(); TreeSet<Double> sortedValues = new TreeSet<>(values.values());
sortedValues.addAll(values.values());
List<Double> values = new ArrayList<>(sortedValues); List<Double> values = new ArrayList<>(sortedValues);
minY = values.get(0); minY = values.get(0);

View File

@ -19,8 +19,6 @@ public class StimulationInputs {
private final ValueRangeControl rpmRange = new ValueRangeControl("RPM", DEFAULT_RPM_MIN, 413.333374, DEFAULT_RPM_MAX); private final ValueRangeControl rpmRange = new ValueRangeControl("RPM", DEFAULT_RPM_MIN, 413.333374, DEFAULT_RPM_MAX);
private final ValueRangeControl cltRange = new ValueRangeControl("CLR r", 100, 100, 100); private final ValueRangeControl cltRange = new ValueRangeControl("CLR r", 100, 100, 100);
private final ValueRangeControl iatRange = new ValueRangeControl("IAT r", 100, 100, 9900);
private final ValueRangeControl tpsRange = new ValueRangeControl("TPS", 1, 0.1, 4.5);
public StimulationInputs(EcuStimulator ecuStimulator) { public StimulationInputs(EcuStimulator ecuStimulator) {
@ -32,7 +30,9 @@ public class StimulationInputs {
content.add(rpmRange.getContent()); content.add(rpmRange.getContent());
content.add(elRange.getContent()); content.add(elRange.getContent());
content.add(cltRange.getContent()); content.add(cltRange.getContent());
ValueRangeControl iatRange = new ValueRangeControl("IAT r", 100, 100, 9900);
content.add(iatRange.getContent()); content.add(iatRange.getContent());
ValueRangeControl tpsRange = new ValueRangeControl("TPS", 1, 0.1, 4.5);
content.add(tpsRange.getContent()); content.add(tpsRange.getContent());
content.add(new JLabel("EL resistance")); content.add(new JLabel("EL resistance"));

View File

@ -239,7 +239,7 @@ public class TriggerImage {
@NotNull @NotNull
private static JPanel createWheelPanel(List<TriggerSignal> wheel, boolean showTdc, private static JPanel createWheelPanel(List<TriggerSignal> wheel, boolean showTdc,
TriggerWheelInfo shape) { TriggerWheelInfo shape) {
JPanel clock = new JPanel() { return new JPanel() {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
@ -297,8 +297,6 @@ public class TriggerImage {
return new Dimension(WHEEL_DIAMETER + 2 * WHEEL_BORDER, WHEEL_DIAMETER + 2 * WHEEL_BORDER); return new Dimension(WHEEL_DIAMETER + 2 * WHEEL_BORDER, WHEEL_DIAMETER + 2 * WHEEL_BORDER);
} }
}; };
// clock.setBackground(Color.orange);
return clock;
} }
private static double arcToRusEFI(double angle) { private static double arcToRusEFI(double angle) {

View File

@ -139,21 +139,15 @@ public class GaugesPanel {
JPanel rightUpperPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); JPanel rightUpperPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
final JPopupMenu selectorMenu = new JPopupMenu(); final JPopupMenu selectorMenu = new JPopupMenu();
selectorMenu.add(new SizeSelectorPanel(new SizeSelectorPanel.SizeSelectorListener() { selectorMenu.add(new SizeSelectorPanel((row, column) -> {
@Override System.out.println("new size " + row + "/" + column);
public void onSelected(int row, int column) { setSensorGridDimensions(row, column);
System.out.println("new size " + row + "/" + column);
setSensorGridDimensions(row, column);
}
})); }));
JButton selector = new JButton("O"); JButton selector = new JButton("O");
selector.addActionListener(new ActionListener() { selector.addActionListener(e -> {
@Override Component c = (Component) e.getSource();
public void actionPerformed(ActionEvent e) { selectorMenu.show(c, -1, c.getHeight());
Component c = (Component) e.getSource();
selectorMenu.show(c, -1, c.getHeight());
}
}); });
rightUpperPanel.add(selector); rightUpperPanel.add(selector);
@ -166,29 +160,23 @@ public class GaugesPanel {
private JPopupMenu createMenu(final Node config) { private JPopupMenu createMenu(final Node config) {
JPopupMenu menu = new JPopupMenu(); JPopupMenu menu = new JPopupMenu();
final JCheckBoxMenuItem saveDetailedLogs = new JCheckBoxMenuItem("Save detailed logs"); final JCheckBoxMenuItem saveDetailedLogs = new JCheckBoxMenuItem("Save detailed logs");
saveDetailedLogs.addActionListener(new ActionListener() { saveDetailedLogs.addActionListener(e -> {
@Override FileLog.suspendLogging = !saveDetailedLogs.isSelected();
public void actionPerformed(ActionEvent e) { getConfig().getRoot().setBoolProperty(DISABLE_LOGS, FileLog.suspendLogging);
FileLog.suspendLogging = !saveDetailedLogs.isSelected();
getConfig().getRoot().setBoolProperty(DISABLE_LOGS, FileLog.suspendLogging);
}
}); });
saveDetailedLogs.setSelected(!FileLog.suspendLogging); saveDetailedLogs.setSelected(!FileLog.suspendLogging);
final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM"); final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM");
final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands"); final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands");
showRpmItem.setSelected(showRpmPanel); showRpmItem.setSelected(showRpmPanel);
ActionListener showCheckboxListener = new ActionListener() { ActionListener showCheckboxListener = e -> {
@Override showRpmPanel = showRpmItem.isSelected();
public void actionPerformed(ActionEvent e) { showMessagesPanel = showCommandsItem.isSelected();
showRpmPanel = showRpmItem.isSelected(); config.setProperty(SHOW_RPM, showRpmPanel);
showMessagesPanel = showCommandsItem.isSelected(); config.setProperty(SHOW_MESSAGES, showMessagesPanel);
config.setProperty(SHOW_RPM, showRpmPanel); applyShowFlags();
config.setProperty(SHOW_MESSAGES, showMessagesPanel); // todo: this is not needed if we show/hide RPM panel. TODO: split into two different listeners
applyShowFlags(); middleSplitPanel.setDividerLocation(0.5);
// todo: this is not needed if we show/hide RPM panel. TODO: split into two different listeners
middleSplitPanel.setDividerLocation(0.5);
}
}; };
showRpmItem.addActionListener(showCheckboxListener); showRpmItem.addActionListener(showCheckboxListener);
showCommandsItem.addActionListener(showCheckboxListener); showCommandsItem.addActionListener(showCheckboxListener);
@ -232,13 +220,10 @@ public class GaugesPanel {
@NotNull @NotNull
private JButton createSaveImageButton() { private JButton createSaveImageButton() {
JButton saveImageButton = UiUtils.createSaveImageButton(); JButton saveImageButton = UiUtils.createSaveImageButton();
saveImageButton.addActionListener(new ActionListener() { saveImageButton.addActionListener(e -> {
@Override String fileName = Logger.getDate() + "_gauges.png";
public void actionPerformed(ActionEvent e) {
String fileName = Logger.getDate() + "_gauges.png";
UiUtils.saveImageWithPrompt(fileName, content, gauges.panel); UiUtils.saveImageWithPrompt(fileName, content, gauges.panel);
}
}); });
return saveImageButton; return saveImageButton;
} }

View File

@ -49,9 +49,9 @@ public class Live3DReport {
if (v.length != 3) if (v.length != 3)
return; return;
int rpm = Integer.valueOf(v[0]); int rpm = Integer.parseInt(v[0]);
float key = Integer.valueOf(v[1]) / 100.0f; float key = Integer.parseInt(v[1]) / 100.0f;
float value = Integer.valueOf(v[2]) / 100.0f; float value = Integer.parseInt(v[2]) / 100.0f;
primary.setPoint(new Point3D(rpm, key, value)); primary.setPoint(new Point3D(rpm, key, value));
primary.saveToFile("_mult.csv"); primary.saveToFile("_mult.csv");

View File

@ -185,8 +185,7 @@ public class RecentCommands {
}); });
synchronized (entries) { synchronized (entries) {
Set<Entry> sorted = new TreeSet<>(); Set<Entry> sorted = new TreeSet<>(entries.keySet());
sorted.addAll(entries.keySet());
for (Entry entry : sorted) { for (Entry entry : sorted) {
content.add(createButton(uiContext, reentrant, entry.command)); content.add(createButton(uiContext, reentrant, entry.command));

View File

@ -32,7 +32,7 @@ public class SensorLiveGraph extends JPanel {
private final Node config; private final Node config;
private final JMenuItem extraItem; private final JMenuItem extraItem;
@NotNull @NotNull
private ChangePeriod period = ChangePeriod._100; private ChangePeriod period;
private Sensor sensor; private Sensor sensor;
private boolean autoScale; private boolean autoScale;
private double customUpper; private double customUpper;

View File

@ -14,8 +14,6 @@ public class SizeSelectorPanel extends JPanel {
public static final int WIDTH = 5; public static final int WIDTH = 5;
public static final int HEIGHT = 3; public static final int HEIGHT = 3;
private List<Element> elements = new ArrayList<>();
private int selectedRow = 1; private int selectedRow = 1;
private int selectedColumn = 1; private int selectedColumn = 1;
@ -41,12 +39,11 @@ public class SizeSelectorPanel extends JPanel {
sizeSelectorListener.onSelected(selected.row, selected.column); sizeSelectorListener.onSelected(selected.row, selected.column);
} }
}; };
// addMouseListener(listener);
for (int r = 1; r <= HEIGHT; r++) { for (int r = 1; r <= HEIGHT; r++) {
for (int c = 1; c <= WIDTH; c++) { for (int c = 1; c <= WIDTH; c++) {
Element e = new Element(r, c); Element e = new Element(r, c);
e.addMouseListener(listener); e.addMouseListener(listener);
elements.add(e);
add(e); add(e);
} }
} }

View File

@ -19,17 +19,17 @@ public class StatusWindow implements StatusConsumer {
private final JTextArea logTextArea = new JTextArea(); private final JTextArea logTextArea = new JTextArea();
private final JPanel content = new JPanel(new BorderLayout()); private final JPanel content = new JPanel(new BorderLayout());
private final JLabel bottomStatusLabel = new JLabel(); private final JLabel bottomStatusLabel = new JLabel();
private final JScrollPane messagesScroll = new JScrollPane(logTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
@Override
public Dimension getPreferredSize() {
return new Dimension(400, 400);
}
};
@NotNull @NotNull
protected final FrameHelper frameHelper = new FrameHelper(); protected final FrameHelper frameHelper = new FrameHelper();
public StatusWindow() { public StatusWindow() {
logTextArea.setLineWrap(true); logTextArea.setLineWrap(true);
JScrollPane messagesScroll = new JScrollPane(logTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
@Override
public Dimension getPreferredSize() {
return new Dimension(400, 400);
}
};
content.add(messagesScroll, BorderLayout.CENTER); content.add(messagesScroll, BorderLayout.CENTER);
content.add(bottomStatusLabel, BorderLayout.SOUTH); content.add(bottomStatusLabel, BorderLayout.SOUTH);
} }

View File

@ -27,7 +27,7 @@ public class Wizard {
Component getContent(); Component getContent();
} }
abstract class WizardStepImpl implements WizardStep { abstract static class WizardStepImpl implements WizardStep {
protected WizardStep nextStep; protected WizardStep nextStep;
public WizardStepImpl() { public WizardStepImpl() {

View File

@ -30,7 +30,6 @@ import java.util.Date;
*/ */
public class UpDownImage extends JPanel { public class UpDownImage extends JPanel {
private static final int TIMESCALE_MULT = (int) (20 * EngineReport.ENGINE_SNIFFER_TICKS_PER_MS); // 20ms private static final int TIMESCALE_MULT = (int) (20 * EngineReport.ENGINE_SNIFFER_TICKS_PER_MS); // 20ms
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
private static final int LINE_SIZE = 20; private static final int LINE_SIZE = 20;
public static final Color TIME_SCALE_COLOR = Color.red; public static final Color TIME_SCALE_COLOR = Color.red;
public static final Color ENGINE_CYCLE_COLOR = new Color(0, 153, 0); public static final Color ENGINE_CYCLE_COLOR = new Color(0, 153, 0);
@ -55,13 +54,6 @@ public class UpDownImage extends JPanel {
private Color signalBody = Color.lightGray; private Color signalBody = Color.lightGray;
private Color signalBorder = Color.GRAY; private Color signalBorder = Color.GRAY;
private final Timer repaintTimer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UiUtils.trueRepaint(UpDownImage.this);
}
});
private boolean renderText = true; private boolean renderText = true;
public void setRenderText(boolean renderText) { public void setRenderText(boolean renderText) {
@ -174,7 +166,6 @@ public class UpDownImage extends JPanel {
g2.setColor(Color.black); g2.setColor(Color.black);
int line = 0; int line = 0;
Font f = getFont();
if (!this.renderText) { if (!this.renderText) {
return; return;
@ -277,7 +268,7 @@ public class UpDownImage extends JPanel {
return; return;
} }
int duration = upDown.getDuration(); final int duration = upDown.getDuration();
// don't render duration for zero duration or for trigger // don't render duration for zero duration or for trigger
if (duration != 0 && upDown.upTriggerCycleIndex == -1) { if (duration != 0 && upDown.upTriggerCycleIndex == -1) {
@ -286,13 +277,14 @@ public class UpDownImage extends JPanel {
g.drawString(durationString, x1, 15); g.drawString(durationString, x1, 15);
} }
g.setColor(Color.darkGray);
if (upDown.upTriggerCycleIndex != -1) { if (upDown.upTriggerCycleIndex != -1) {
g.setColor(Color.darkGray);
g.drawString("" + upDown.upTriggerCycleIndex, x1, (int) (0.25 * d.height)); g.drawString("" + upDown.upTriggerCycleIndex, x1, (int) (0.25 * d.height));
} }
// Skip second index if invalid or equal to start index // Skip second index if invalid or equal to start index
if (upDown.downTriggerCycleIndex != -1 && upDown.upTriggerCycleIndex != upDown.downTriggerCycleIndex) { if (upDown.downTriggerCycleIndex != -1 && upDown.upTriggerCycleIndex != upDown.downTriggerCycleIndex) {
g.setColor(Color.darkGray);
g.drawString("" + upDown.downTriggerCycleIndex, x2, (int) (0.25 * d.height)); g.drawString("" + upDown.downTriggerCycleIndex, x2, (int) (0.25 * d.height));
} }

View File

@ -29,9 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class DetachedSensor { public class DetachedSensor {
private static final String NAME = "name"; private static final String NAME = "name";
private static final String WIDTH = "width"; private static final String WIDTH = "width";
/**
* @see Fields#MOCK_IAT_COMMAND
*/
private static final Collection<Sensor> MOCKABLE = Arrays.asList( private static final Collection<Sensor> MOCKABLE = Arrays.asList(
Sensor.CLT, Sensor.CLT,
Sensor.Lambda, Sensor.Lambda,

View File

@ -17,7 +17,7 @@ public class MafCommand extends JPanel {
setBorder(BorderFactory.createLineBorder(Color.BLACK)); setBorder(BorderFactory.createLineBorder(Color.BLACK));
setLayout(new FlowLayout(FlowLayout.LEFT)); setLayout(new FlowLayout(FlowLayout.LEFT));
add(new JLabel("MAF: ")); add(new JLabel("MAF: "));
final JSpinner maf = new JSpinner(new SpinnerNumberModel(Double.valueOf(1.5), null, null, Double.valueOf(0.11))) { final JSpinner maf = new JSpinner(new SpinnerNumberModel(1.5, null, null, 0.11)) {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize(); Dimension size = super.getPreferredSize();

View File

@ -27,12 +27,11 @@ public class LiveDataParserSandbox {
@Nullable @Nullable
public static VariableValueSource getVariableValueSource(Map<String, Double> values) { public static VariableValueSource getVariableValueSource(Map<String, Double> values) {
VariableValueSource valueSource = name -> { return name -> {
Double value = values.get(name); Double value = values.get(name);
if (value == null) if (value == null)
return null; return null;
return new VariableValueSource.VariableState(new Field(name, 0, FieldType.BIT), value); return new VariableValueSource.VariableState(new Field(name, 0, FieldType.BIT), value);
}; };
return valueSource;
} }
} }

View File

@ -69,13 +69,13 @@ public class TuneReadWriteTest {
assertEquals("2", flow.getDigits()); assertEquals("2", flow.getDigits());
Constant nonEmptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas1"); Constant nonEmptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas1");
assertNotNull(nonEmptyFormula);; assertNotNull(nonEmptyFormula);
/** /**
* Empty strings values should be omitted from the tune * Empty strings values should be omitted from the tune
*/ */
Constant emptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas2"); Constant emptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas2");
assertNull(emptyFormula);; assertNull(emptyFormula);
Constant enumField = tuneFromBinary.findPage().findParameter("acRelayPin"); Constant enumField = tuneFromBinary.findPage().findParameter("acRelayPin");
// quotes are expected // quotes are expected