mirror of https://github.com/FOME-Tech/fome-fw.git
java inspection pass
This commit is contained in:
parent
abce347ad2
commit
ddc5400dc2
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.rusefi.core.ui;
|
||||
package com.rusefi.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue