more intellij inspection (#3910)
* first part * some more small ones * more inspect
This commit is contained in:
parent
3a3fab1882
commit
27b2032e25
|
@ -130,7 +130,7 @@ public class BinaryProtocol {
|
|||
|
||||
public boolean isClosed;
|
||||
|
||||
public CommunicationLoggingListener communicationLoggingListener = CommunicationLoggingListener.VOID;
|
||||
public CommunicationLoggingListener communicationLoggingListener;
|
||||
|
||||
public byte[] getCurrentOutputs() {
|
||||
return state.getCurrentOutputs();
|
||||
|
@ -282,7 +282,7 @@ public class BinaryProtocol {
|
|||
if (needCompositeLogger) {
|
||||
getComposite();
|
||||
} else if (isCompositeLoggerEnabled) {
|
||||
byte packet[] = new byte[2];
|
||||
byte[] packet = new byte[2];
|
||||
packet[0] = Fields.TS_SET_LOGGER_SWITCH;
|
||||
packet[1] = Fields.TS_COMPOSITE_DISABLE;
|
||||
executeCommand(packet, "disable composite");
|
||||
|
@ -614,7 +614,7 @@ public class BinaryProtocol {
|
|||
if (isClosed)
|
||||
return;
|
||||
|
||||
byte packet[] = new byte[1];
|
||||
byte[] packet = new byte[1];
|
||||
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
|
||||
// todo: actually if console gets disconnected composite logging might end up enabled in controller?
|
||||
|
|
|
@ -27,7 +27,7 @@ public interface ByteReader {
|
|||
threadExecutor.execute(() -> {
|
||||
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()) {
|
||||
try {
|
||||
int result = reader.read(inputBuffer);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class BinaryProtocolServer {
|
|||
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) {
|
||||
try {
|
||||
|
|
|
@ -17,7 +17,7 @@ public class IoHelperTest {
|
|||
|
||||
@Test
|
||||
public void testSwap16() throws IOException {
|
||||
byte packet[] = {-12, 0};
|
||||
byte[] packet = {-12, 0};
|
||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet));
|
||||
short a = dis.readShort();
|
||||
int x = IoHelper.swap16(a);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ConsoleUI {
|
|||
/**
|
||||
* 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() {
|
||||
return staticFrame;
|
||||
|
|
|
@ -29,8 +29,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
/**
|
||||
* Date: 3/24/13
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
*
|
||||
* @see EcuStimulatorSandbox
|
||||
*/
|
||||
public class EcuStimulator {
|
||||
private static final String DELIMITER = ",";
|
||||
|
@ -308,7 +306,7 @@ public class EcuStimulator {
|
|||
return result;
|
||||
}
|
||||
|
||||
private class MultipleMeasurements {
|
||||
private static class MultipleMeasurements {
|
||||
private List<Double> dwells = new ArrayList<>(MEASURES);
|
||||
private List<Double> advances = new ArrayList<>(MEASURES);
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ public final class Histograms {
|
|||
@NotNull
|
||||
public List<String> dumpStats() {
|
||||
Collection<StatisticsGroup> values = takeAndResetSnapshot();
|
||||
List<StatisticsGroup> al = new ArrayList<>();
|
||||
al.addAll(values);
|
||||
List<StatisticsGroup> al = new ArrayList<>(values);
|
||||
|
||||
synchronized (total_stats) {
|
||||
for (StatisticsGroup source : values) {
|
||||
String type = source.type + ".TOTAL";
|
||||
|
@ -368,7 +368,7 @@ public final class Histograms {
|
|||
private String toString(StatisticsGroup sg, long duration) {
|
||||
StringBuffer sb = new StringBuffer(100 + sg.data.size() * 100);
|
||||
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);
|
||||
for (Statistics st : sts) {
|
||||
appendStatistics(sb, st, new ArrayList<>());
|
||||
|
|
|
@ -4,5 +4,5 @@ public enum KeyStrokeShortcut {
|
|||
PREVIOUS_PAGE,
|
||||
NEXT_PAGE,
|
||||
ZOOM_IN,
|
||||
ZOOM_OUT;
|
||||
ZOOM_OUT
|
||||
}
|
||||
|
|
|
@ -134,10 +134,10 @@ public class ReportReader {
|
|||
// System.out.println(line);
|
||||
Matcher m = LINE_PATTERN.matcher(line);
|
||||
if (m.matches()) {
|
||||
int time = Integer.valueOf(m.group(1));
|
||||
int time = Integer.parseInt(m.group(1));
|
||||
MafValue maf = MafValue.valueOf(m.group(2));
|
||||
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) {
|
||||
// System.out.println("All the same...");
|
||||
|
|
|
@ -130,8 +130,7 @@ public class SensorSnifferPane {
|
|||
maxX = keys.get(keys.size() - 1);
|
||||
FileLog.MAIN.logLine("Analog chart from " + minX + " to " + maxX);
|
||||
|
||||
TreeSet<Double> sortedValues = new TreeSet<>();
|
||||
sortedValues.addAll(values.values());
|
||||
TreeSet<Double> sortedValues = new TreeSet<>(values.values());
|
||||
List<Double> values = new ArrayList<>(sortedValues);
|
||||
|
||||
minY = values.get(0);
|
||||
|
|
|
@ -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 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) {
|
||||
|
||||
|
@ -32,7 +30,9 @@ public class StimulationInputs {
|
|||
content.add(rpmRange.getContent());
|
||||
content.add(elRange.getContent());
|
||||
content.add(cltRange.getContent());
|
||||
ValueRangeControl iatRange = new ValueRangeControl("IAT r", 100, 100, 9900);
|
||||
content.add(iatRange.getContent());
|
||||
ValueRangeControl tpsRange = new ValueRangeControl("TPS", 1, 0.1, 4.5);
|
||||
content.add(tpsRange.getContent());
|
||||
|
||||
content.add(new JLabel("EL resistance"));
|
||||
|
|
|
@ -239,7 +239,7 @@ public class TriggerImage {
|
|||
@NotNull
|
||||
private static JPanel createWheelPanel(List<TriggerSignal> wheel, boolean showTdc,
|
||||
TriggerWheelInfo shape) {
|
||||
JPanel clock = new JPanel() {
|
||||
return new JPanel() {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
|
@ -297,8 +297,6 @@ public class TriggerImage {
|
|||
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) {
|
||||
|
|
|
@ -139,21 +139,15 @@ public class GaugesPanel {
|
|||
JPanel rightUpperPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||
|
||||
final JPopupMenu selectorMenu = new JPopupMenu();
|
||||
selectorMenu.add(new SizeSelectorPanel(new SizeSelectorPanel.SizeSelectorListener() {
|
||||
@Override
|
||||
public void onSelected(int row, int column) {
|
||||
System.out.println("new size " + row + "/" + column);
|
||||
setSensorGridDimensions(row, column);
|
||||
}
|
||||
selectorMenu.add(new SizeSelectorPanel((row, column) -> {
|
||||
System.out.println("new size " + row + "/" + column);
|
||||
setSensorGridDimensions(row, column);
|
||||
}));
|
||||
|
||||
JButton selector = new JButton("O");
|
||||
selector.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Component c = (Component) e.getSource();
|
||||
selectorMenu.show(c, -1, c.getHeight());
|
||||
}
|
||||
selector.addActionListener(e -> {
|
||||
Component c = (Component) e.getSource();
|
||||
selectorMenu.show(c, -1, c.getHeight());
|
||||
});
|
||||
rightUpperPanel.add(selector);
|
||||
|
||||
|
@ -166,29 +160,23 @@ public class GaugesPanel {
|
|||
private JPopupMenu createMenu(final Node config) {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
final JCheckBoxMenuItem saveDetailedLogs = new JCheckBoxMenuItem("Save detailed logs");
|
||||
saveDetailedLogs.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileLog.suspendLogging = !saveDetailedLogs.isSelected();
|
||||
getConfig().getRoot().setBoolProperty(DISABLE_LOGS, FileLog.suspendLogging);
|
||||
}
|
||||
saveDetailedLogs.addActionListener(e -> {
|
||||
FileLog.suspendLogging = !saveDetailedLogs.isSelected();
|
||||
getConfig().getRoot().setBoolProperty(DISABLE_LOGS, FileLog.suspendLogging);
|
||||
});
|
||||
saveDetailedLogs.setSelected(!FileLog.suspendLogging);
|
||||
|
||||
final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM");
|
||||
final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands");
|
||||
showRpmItem.setSelected(showRpmPanel);
|
||||
ActionListener showCheckboxListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showRpmPanel = showRpmItem.isSelected();
|
||||
showMessagesPanel = showCommandsItem.isSelected();
|
||||
config.setProperty(SHOW_RPM, showRpmPanel);
|
||||
config.setProperty(SHOW_MESSAGES, showMessagesPanel);
|
||||
applyShowFlags();
|
||||
// todo: this is not needed if we show/hide RPM panel. TODO: split into two different listeners
|
||||
middleSplitPanel.setDividerLocation(0.5);
|
||||
}
|
||||
ActionListener showCheckboxListener = e -> {
|
||||
showRpmPanel = showRpmItem.isSelected();
|
||||
showMessagesPanel = showCommandsItem.isSelected();
|
||||
config.setProperty(SHOW_RPM, showRpmPanel);
|
||||
config.setProperty(SHOW_MESSAGES, showMessagesPanel);
|
||||
applyShowFlags();
|
||||
// todo: this is not needed if we show/hide RPM panel. TODO: split into two different listeners
|
||||
middleSplitPanel.setDividerLocation(0.5);
|
||||
};
|
||||
showRpmItem.addActionListener(showCheckboxListener);
|
||||
showCommandsItem.addActionListener(showCheckboxListener);
|
||||
|
@ -232,13 +220,10 @@ public class GaugesPanel {
|
|||
@NotNull
|
||||
private JButton createSaveImageButton() {
|
||||
JButton saveImageButton = UiUtils.createSaveImageButton();
|
||||
saveImageButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String fileName = Logger.getDate() + "_gauges.png";
|
||||
saveImageButton.addActionListener(e -> {
|
||||
String fileName = Logger.getDate() + "_gauges.png";
|
||||
|
||||
UiUtils.saveImageWithPrompt(fileName, content, gauges.panel);
|
||||
}
|
||||
UiUtils.saveImageWithPrompt(fileName, content, gauges.panel);
|
||||
});
|
||||
return saveImageButton;
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ public class Live3DReport {
|
|||
if (v.length != 3)
|
||||
return;
|
||||
|
||||
int rpm = Integer.valueOf(v[0]);
|
||||
float key = Integer.valueOf(v[1]) / 100.0f;
|
||||
float value = Integer.valueOf(v[2]) / 100.0f;
|
||||
int rpm = Integer.parseInt(v[0]);
|
||||
float key = Integer.parseInt(v[1]) / 100.0f;
|
||||
float value = Integer.parseInt(v[2]) / 100.0f;
|
||||
|
||||
primary.setPoint(new Point3D(rpm, key, value));
|
||||
primary.saveToFile("_mult.csv");
|
||||
|
|
|
@ -185,8 +185,7 @@ public class RecentCommands {
|
|||
});
|
||||
|
||||
synchronized (entries) {
|
||||
Set<Entry> sorted = new TreeSet<>();
|
||||
sorted.addAll(entries.keySet());
|
||||
Set<Entry> sorted = new TreeSet<>(entries.keySet());
|
||||
|
||||
for (Entry entry : sorted) {
|
||||
content.add(createButton(uiContext, reentrant, entry.command));
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SensorLiveGraph extends JPanel {
|
|||
private final Node config;
|
||||
private final JMenuItem extraItem;
|
||||
@NotNull
|
||||
private ChangePeriod period = ChangePeriod._100;
|
||||
private ChangePeriod period;
|
||||
private Sensor sensor;
|
||||
private boolean autoScale;
|
||||
private double customUpper;
|
||||
|
|
|
@ -14,8 +14,6 @@ public class SizeSelectorPanel extends JPanel {
|
|||
public static final int WIDTH = 5;
|
||||
public static final int HEIGHT = 3;
|
||||
|
||||
private List<Element> elements = new ArrayList<>();
|
||||
|
||||
private int selectedRow = 1;
|
||||
private int selectedColumn = 1;
|
||||
|
||||
|
@ -41,12 +39,11 @@ public class SizeSelectorPanel extends JPanel {
|
|||
sizeSelectorListener.onSelected(selected.row, selected.column);
|
||||
}
|
||||
};
|
||||
// addMouseListener(listener);
|
||||
|
||||
for (int r = 1; r <= HEIGHT; r++) {
|
||||
for (int c = 1; c <= WIDTH; c++) {
|
||||
Element e = new Element(r, c);
|
||||
e.addMouseListener(listener);
|
||||
elements.add(e);
|
||||
add(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,17 +19,17 @@ public class StatusWindow implements StatusConsumer {
|
|||
private final JTextArea logTextArea = new JTextArea();
|
||||
private final JPanel content = new JPanel(new BorderLayout());
|
||||
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
|
||||
protected final FrameHelper frameHelper = new FrameHelper();
|
||||
|
||||
public StatusWindow() {
|
||||
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(bottomStatusLabel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class Wizard {
|
|||
Component getContent();
|
||||
}
|
||||
|
||||
abstract class WizardStepImpl implements WizardStep {
|
||||
abstract static class WizardStepImpl implements WizardStep {
|
||||
protected WizardStep nextStep;
|
||||
|
||||
public WizardStepImpl() {
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Date;
|
|||
*/
|
||||
public class UpDownImage extends JPanel {
|
||||
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;
|
||||
public static final Color TIME_SCALE_COLOR = Color.red;
|
||||
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 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;
|
||||
|
||||
public void setRenderText(boolean renderText) {
|
||||
|
@ -174,7 +166,6 @@ public class UpDownImage extends JPanel {
|
|||
g2.setColor(Color.black);
|
||||
|
||||
int line = 0;
|
||||
Font f = getFont();
|
||||
|
||||
if (!this.renderText) {
|
||||
return;
|
||||
|
@ -277,7 +268,7 @@ public class UpDownImage extends JPanel {
|
|||
return;
|
||||
}
|
||||
|
||||
int duration = upDown.getDuration();
|
||||
final int duration = upDown.getDuration();
|
||||
|
||||
// don't render duration for zero duration or for trigger
|
||||
if (duration != 0 && upDown.upTriggerCycleIndex == -1) {
|
||||
|
@ -286,13 +277,14 @@ public class UpDownImage extends JPanel {
|
|||
g.drawString(durationString, x1, 15);
|
||||
}
|
||||
|
||||
g.setColor(Color.darkGray);
|
||||
if (upDown.upTriggerCycleIndex != -1) {
|
||||
g.setColor(Color.darkGray);
|
||||
g.drawString("" + upDown.upTriggerCycleIndex, x1, (int) (0.25 * d.height));
|
||||
}
|
||||
|
||||
// Skip second index if invalid or equal to start index
|
||||
if (upDown.downTriggerCycleIndex != -1 && upDown.upTriggerCycleIndex != upDown.downTriggerCycleIndex) {
|
||||
g.setColor(Color.darkGray);
|
||||
g.drawString("" + upDown.downTriggerCycleIndex, x2, (int) (0.25 * d.height));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
public class DetachedSensor {
|
||||
private static final String NAME = "name";
|
||||
private static final String WIDTH = "width";
|
||||
/**
|
||||
* @see Fields#MOCK_IAT_COMMAND
|
||||
*/
|
||||
|
||||
private static final Collection<Sensor> MOCKABLE = Arrays.asList(
|
||||
Sensor.CLT,
|
||||
Sensor.Lambda,
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MafCommand extends JPanel {
|
|||
setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
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
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
|
|
|
@ -27,12 +27,11 @@ public class LiveDataParserSandbox {
|
|||
|
||||
@Nullable
|
||||
public static VariableValueSource getVariableValueSource(Map<String, Double> values) {
|
||||
VariableValueSource valueSource = name -> {
|
||||
return name -> {
|
||||
Double value = values.get(name);
|
||||
if (value == null)
|
||||
return null;
|
||||
return new VariableValueSource.VariableState(new Field(name, 0, FieldType.BIT), value);
|
||||
};
|
||||
return valueSource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,13 +69,13 @@ public class TuneReadWriteTest {
|
|||
assertEquals("2", flow.getDigits());
|
||||
|
||||
Constant nonEmptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas1");
|
||||
assertNotNull(nonEmptyFormula);;
|
||||
assertNotNull(nonEmptyFormula);
|
||||
|
||||
/**
|
||||
* Empty strings values should be omitted from the tune
|
||||
*/
|
||||
Constant emptyFormula = tuneFromBinary.findPage().findParameter("fsioFormulas2");
|
||||
assertNull(emptyFormula);;
|
||||
assertNull(emptyFormula);
|
||||
|
||||
Constant enumField = tuneFromBinary.findPage().findParameter("acRelayPin");
|
||||
// quotes are expected
|
||||
|
|
Loading…
Reference in New Issue