java inspection pass

This commit is contained in:
Matthew Kennedy 2023-11-25 17:34:11 -08:00
parent abce347ad2
commit ddc5400dc2
14 changed files with 17 additions and 45 deletions

View File

@ -105,17 +105,12 @@ public class TestingUtils {
}
public static EngineChart nextChart(CommandQueue commandQueue) {
long start = System.currentTimeMillis();
EngineChart chart = EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
// FileLog.MAIN.logLine("AUTOTEST nextChart() in " + (System.currentTimeMillis() - start));
return chart;
return EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
}
static String getNextWaveChart(CommandQueue commandQueue) {
IoUtil.sendBlockingCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
String result = getEngineChart(commandQueue);
// FileLog.MAIN.logLine("current chart: " + result);
return result;
return getEngineChart(commandQueue);
}
/**

View File

@ -97,10 +97,9 @@ public class Field {
public static String niceToString(Number value, int precision) {
// not enum field
Number number = value;
if (number instanceof Float)
return niceToString(number.floatValue(), precision);
return number.toString();
if (value instanceof Float)
return niceToString(value.floatValue(), precision);
return value.toString();
}
public static String niceToString(double value, int precision) {

View File

@ -58,7 +58,7 @@ public class AverageAnglesUtil {
continue;
line = line.substring(ANALOG_CHART.length());
String p[] = line.split(",");
String[] p = line.split(",");
line = p[0];
aa.add(currentRpm, line);

View File

@ -35,7 +35,7 @@ public class PortDetector {
if (rusEfiAddress != null) {
return getSignatureFromPorts(callback, new String[] {rusEfiAddress});
}
String[] serialPorts = getPortNames();
String[] serialPorts = LinkManager.getCommPorts();
if (serialPorts.length == 0) {
log.error("No serial ports detected");
return new SerialAutoChecker.AutoDetectResult(null, null);
@ -93,13 +93,6 @@ public class PortDetector {
return autoDetectResult;
}
private static String[] getPortNames() {
// long now = System.currentTimeMillis();
String[] portNames = LinkManager.getCommPorts();
// log.info("Took " + (System.currentTimeMillis() - now));
return portNames;
}
@Nullable
public static SerialAutoChecker.AutoDetectResult autoDetectPort(JFrame parent) {
SerialAutoChecker.AutoDetectResult autoDetectedPort = autoDetectSerial(null);

View File

@ -23,7 +23,7 @@ public class TcpClientSandbox {
for (int i = 0; i < 3; i++) {
// warm-up cycles just for fun
String signature = BinaryProtocol.getSignature(tsStream);
BinaryProtocol.getSignature(tsStream);
}
@ -32,7 +32,7 @@ public class TcpClientSandbox {
long startMs = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
// warm-up cycles just for fun
String signature = BinaryProtocol.getSignature(tsStream);
BinaryProtocol.getSignature(tsStream);
}
long time = System.currentTimeMillis() - startMs;
double timePerCommand = 1.0 * time / count;

View File

@ -76,7 +76,6 @@ public class TestHelper extends MockitoTestHelper {
}
public static BinaryProtocolServer createVirtualController(int controllerPort, ConfigurationImage controllerImage, BinaryProtocolServer.Context context) throws InterruptedException {
CountDownLatch controllerCreated = new CountDownLatch(1);
try {
return createVirtualController(controllerImage, controllerPort, context);
} catch (IOException e) {

View File

@ -65,7 +65,7 @@ public class AverageAngles {
count ++;
rpmAtPrevChart = rpm;
String v[] = line.split("\\|");
String[] v = line.split("\\|");
System.out.println("rpm " + rpm + ": " + v.length + " values");
List<AngleEvent> current = new ArrayList<>();
@ -102,7 +102,7 @@ public class AverageAngles {
for (Map.Entry<Integer, List<AngleEvent>> e : angleData.entrySet()) {
int k = e.getKey();
List<AngleEvent> v = e.getValue();
double values[] = new double[v.size()];
double[] values = new double[v.size()];
for (int i = 0; i < v.size(); i++)
values[i] = v.get(i).getAngle();

View File

@ -6,7 +6,7 @@ import java.util.Arrays;
* Fixed-size array backed buffer
*/
public class CyclicBuffer implements DataBuffer {
private final double values[];
private final double[] values;
private int size = 0;
private int pointer = 0;

View File

@ -125,8 +125,8 @@ public class EngineReport {
continue;
}
String upString[] = array[index].split("_");
String downString[] = array[index + 2].split("_");
String[] upString = array[index].split("_");
String[] downString = array[index + 2].split("_");
try {
int upTime = Integer.parseInt(array[index + 1]);
int downTime = Integer.parseInt(array[index + 3]);

View File

@ -284,7 +284,6 @@ public enum SerialPortScanner {
return false;
}
IncomingDataBuffer idb = stream.getDataBuffer();
stream.sendPacket(new byte[]{(byte) Fields.TS_QUERY_BOOTLOADER});
byte[] response = stream.getDataBuffer().getPacket(500, "fomeEcuHasOpenblt");

View File

@ -1,12 +0,0 @@
package com.rusefi.autodetect;
public class PortDetectorSandbox {
public static void main(String[] args) throws InterruptedException {
while (true) {
String port = PortDetector.autoDetectSerial(null).getSerialPort();
System.out.println("Detected " + port);
Thread.sleep(1000);
}
}
}

View File

@ -1,4 +1,4 @@
package com.rusefi.core.ui;
package com.rusefi.ui;
import javax.swing.*;
import java.awt.*;

View File

@ -54,7 +54,7 @@ public class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler
content.add(scrollPane, BorderLayout.CENTER);
JOptionPane.showConfirmDialog(findActiveFrame(), content, CONSOLE_VERSION + ": Exception Occurred", JOptionPane.DEFAULT_OPTION);
log.info("handleException: " + baos.toString());
log.info("handleException: " + baos);
}
private static Frame findActiveFrame() {

View File

@ -85,11 +85,10 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
@NotNull
static String wrapSwitchStatement(StringBuilder switchBody) {
String fullSwitch = switchBody.length() == 0 ? "" :
return switchBody.length() == 0 ? "" :
("\tint hash = djb2lowerCase(name);\n" +
"\tswitch(hash) {\n" + switchBody + "\t}\n");
return fullSwitch;
}
@NotNull