auto-sync
This commit is contained in:
parent
4466187798
commit
c300701348
|
@ -24,12 +24,12 @@ public enum FileLog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void info(String msg) {
|
public void info(String msg) {
|
||||||
rlog(msg);
|
MAIN.logLine(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String msg) {
|
public void error(String msg) {
|
||||||
rlog(msg);
|
MAIN.logLine(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ public enum FileLog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rlog(String msg) {
|
private static void rlog(String msg) {
|
||||||
System.out.println("r " + msg);
|
System.out.println("rlog " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(IllegalStateException exception) {
|
public void log(IllegalStateException exception) {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package com.rusefi.binaryprotocol;
|
package com.rusefi.binaryprotocol;
|
||||||
|
|
||||||
import com.rusefi.ConfigurationImage;
|
import com.rusefi.*;
|
||||||
import com.rusefi.ConfigurationImageDiff;
|
|
||||||
import com.rusefi.Logger;
|
|
||||||
import com.rusefi.Timeouts;
|
|
||||||
import com.rusefi.core.Pair;
|
import com.rusefi.core.Pair;
|
||||||
import com.rusefi.io.DataListener;
|
import com.rusefi.io.DataListener;
|
||||||
import com.rusefi.io.serial.SerialPortReader;
|
import com.rusefi.io.serial.SerialPortReader;
|
||||||
|
@ -102,7 +99,7 @@ public class BinaryProtocol {
|
||||||
}
|
}
|
||||||
} catch (SerialPortException | EOFException e) {
|
} catch (SerialPortException | EOFException e) {
|
||||||
close();
|
close();
|
||||||
System.out.println("exception: " + e);
|
FileLog.MAIN.logLine("exception: " + e);
|
||||||
return;
|
return;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
|
@ -113,9 +110,11 @@ public class BinaryProtocol {
|
||||||
|
|
||||||
private void dropPending() {
|
private void dropPending() {
|
||||||
synchronized (cbb) {
|
synchronized (cbb) {
|
||||||
|
if (isClosed)
|
||||||
|
return;
|
||||||
int pending = cbb.length();
|
int pending = cbb.length();
|
||||||
if (pending > 0) {
|
if (pending > 0) {
|
||||||
logger.error("Unexpected pending data: " + pending);
|
logger.error("Unexpected pending data: " + pending + " byte(s)");
|
||||||
cbb.get(new byte[pending]);
|
cbb.get(new byte[pending]);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -270,10 +269,12 @@ public class BinaryProtocol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close() {
|
public void close() {
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
try {
|
try {
|
||||||
|
FileLog.MAIN.logLine("CLOSING PORT...");
|
||||||
serialPort.closePort();
|
serialPort.closePort();
|
||||||
|
FileLog.MAIN.logLine("PORT CLOSED");
|
||||||
} catch (SerialPortException e) {
|
} catch (SerialPortException e) {
|
||||||
logger.error("Error closing port: " + e);
|
logger.error("Error closing port: " + e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ public class BaseMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XYData loadData(String filename, final String key, final String value) {
|
public static XYData loadData(String filename, final String key, final String value) {
|
||||||
FileLog.rlog("Loading from " + filename);
|
FileLog.MAIN.logLine("Loading from " + filename);
|
||||||
FileLog.rlog("Loading " + key + ">" + value);
|
FileLog.MAIN.logLine("Loading " + key + ">" + value);
|
||||||
final XYData data = new XYData();
|
final XYData data = new XYData();
|
||||||
|
|
||||||
EngineState.EngineStateListener listener = new EngineState.EngineStateListenerImpl() {
|
EngineState.EngineStateListener listener = new EngineState.EngineStateListenerImpl() {
|
||||||
|
|
|
@ -60,10 +60,10 @@ public class PortHolder {
|
||||||
setupPort(serialPort, BAUD_RATE);
|
setupPort(serialPort, BAUD_RATE);
|
||||||
// serialPort.addEventListener(new SerialPortReader(serialPort, portHolderListener));
|
// serialPort.addEventListener(new SerialPortReader(serialPort, portHolderListener));
|
||||||
} catch (SerialPortException e) {
|
} catch (SerialPortException e) {
|
||||||
FileLog.rlog("ERROR " + e.getMessage());
|
FileLog.MAIN.logLine("ERROR " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FileLog.rlog("PortHolder: Sleeping a bit");
|
FileLog.MAIN.logLine("PortHolder: Sleeping a bit");
|
||||||
try {
|
try {
|
||||||
// todo: why is this delay here? add a comment
|
// todo: why is this delay here? add a comment
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
|
@ -103,7 +103,7 @@ public class PortHolder {
|
||||||
}
|
}
|
||||||
sleep();
|
sleep();
|
||||||
}
|
}
|
||||||
FileLog.rlog("Stopping text pull");
|
FileLog.MAIN.logLine("Stopping text pull");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Thread tr = new Thread(textPull);
|
Thread tr = new Thread(textPull);
|
||||||
|
|
|
@ -24,11 +24,11 @@ class SerialManager {
|
||||||
|
|
||||||
public static void scheduleOpening(LinkManager.LinkStateListener listener) {
|
public static void scheduleOpening(LinkManager.LinkStateListener listener) {
|
||||||
SerialManager.listener = listener;
|
SerialManager.listener = listener;
|
||||||
FileLog.rlog("scheduleOpening");
|
FileLog.MAIN.logLine("scheduleOpening");
|
||||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FileLog.rlog("scheduleOpening>openPort");
|
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||||
PortHolder.getInstance().openPort(port, SerialManager.dataListener, SerialManager.listener);
|
PortHolder.getInstance().openPort(port, SerialManager.dataListener, SerialManager.listener);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class SerialPortReader implements SerialPortEventListener {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FileLog.rlog("less expected SerialPortReader serialEvent " + spe);
|
FileLog.MAIN.logLine("less expected SerialPortReader serialEvent " + spe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class TcpConnector implements LinkConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void connect(LinkManager.LinkStateListener listener) {
|
public void connect(LinkManager.LinkStateListener listener) {
|
||||||
FileLog.rlog("Connecting to " + port);
|
FileLog.MAIN.logLine("Connecting to " + port);
|
||||||
BufferedInputStream stream;
|
BufferedInputStream stream;
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket(LOCALHOST, port);
|
Socket socket = new Socket(LOCALHOST, port);
|
||||||
|
@ -101,7 +101,7 @@ public class TcpConnector implements LinkConnector {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Thread.currentThread().setName("TCP connector loop");
|
Thread.currentThread().setName("TCP connector loop");
|
||||||
FileLog.rlog("Running TCP connection loop");
|
FileLog.MAIN.logLine("Running TCP connection loop");
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
|
@ -134,7 +134,7 @@ public class TcpConnector implements LinkConnector {
|
||||||
@Override
|
@Override
|
||||||
public void send(String text) throws InterruptedException {
|
public void send(String text) throws InterruptedException {
|
||||||
String command = LinkManager.encodeCommand(text);
|
String command = LinkManager.encodeCommand(text);
|
||||||
FileLog.rlog("Writing " + command);
|
FileLog.MAIN.logLine("Writing " + command);
|
||||||
try {
|
try {
|
||||||
writer.write(command + "\r\n");
|
writer.write(command + "\r\n");
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
|
@ -120,7 +120,7 @@ public final class Histograms {
|
||||||
confidence_bounds = new double[]{0.5 - H_CONFIDENCE * 0.5, 0.5, 0.5 + H_CONFIDENCE * 0.5};
|
confidence_bounds = new double[]{0.5 - H_CONFIDENCE * 0.5, 0.5, 0.5 + H_CONFIDENCE * 0.5};
|
||||||
confidence_separators = new String[]{"(", " [", "-", "-", "] ", ")"};
|
confidence_separators = new String[]{"(", " [", "-", "-", "] ", ")"};
|
||||||
|
|
||||||
FileLog.rlog("BOUND_LENGTH=" + BOUND_LENGTH);
|
FileLog.MAIN.logLine("BOUND_LENGTH=" + BOUND_LENGTH);
|
||||||
|
|
||||||
bounds = new long[BOUND_LENGTH];
|
bounds = new long[BOUND_LENGTH];
|
||||||
bounds[0] = 0;
|
bounds[0] = 0;
|
||||||
|
|
|
@ -26,11 +26,11 @@ public class ReportReader {
|
||||||
|
|
||||||
public static TreeMap<Integer, TreeMap<Integer, ReportLine>> readMap(String filename) {
|
public static TreeMap<Integer, TreeMap<Integer, ReportLine>> readMap(String filename) {
|
||||||
if (!new File(filename).exists()) {
|
if (!new File(filename).exists()) {
|
||||||
FileLog.rlog("Error: not found " + filename);
|
FileLog.MAIN.logLine("Error: not found " + filename);
|
||||||
return new TreeMap<>();
|
return new TreeMap<>();
|
||||||
}
|
}
|
||||||
List<ReportLine> lines = read(filename);
|
List<ReportLine> lines = read(filename);
|
||||||
FileLog.rlog("Got " + lines.size() + " lines");
|
FileLog.MAIN.logLine("Got " + lines.size() + " lines");
|
||||||
|
|
||||||
lines = filter(Collections.unmodifiableList(lines));
|
lines = filter(Collections.unmodifiableList(lines));
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ public class ReportReader {
|
||||||
minRpm = Math.min(minRpm, cur.getRpm().getValue());
|
minRpm = Math.min(minRpm, cur.getRpm().getValue());
|
||||||
maxRpm = Math.max(maxRpm, cur.getRpm().getValue());
|
maxRpm = Math.max(maxRpm, cur.getRpm().getValue());
|
||||||
}
|
}
|
||||||
FileLog.rlog("MAF range from " + minMaf + " to " + maxMaf);
|
FileLog.MAIN.logLine("MAF range from " + minMaf + " to " + maxMaf);
|
||||||
FileLog.rlog("RPM range from " + minRpm + " to " + maxRpm);
|
FileLog.MAIN.logLine("RPM range from " + minRpm + " to " + maxRpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ReportLine> filter(List<ReportLine> lines) {
|
private static List<ReportLine> filter(List<ReportLine> lines) {
|
||||||
|
@ -93,7 +93,7 @@ public class ReportReader {
|
||||||
int timeDiff = cur.getTime() - prev.getTime();
|
int timeDiff = cur.getTime() - prev.getTime();
|
||||||
|
|
||||||
if (Math.abs(rpmDiff) > INVALID_RPM_DIFF) {
|
if (Math.abs(rpmDiff) > INVALID_RPM_DIFF) {
|
||||||
FileLog.rlog("Invalid diff: " + cur);
|
FileLog.MAIN.logLine("Invalid diff: " + cur);
|
||||||
removedCount++;
|
removedCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ public class ReportReader {
|
||||||
// System.out.println("value," + cur.getRpm().getValue() + "," + cur.getMaf().getValue() + "," + cur.getWave());
|
// System.out.println("value," + cur.getRpm().getValue() + "," + cur.getMaf().getValue() + "," + cur.getWave());
|
||||||
}
|
}
|
||||||
double percent = 100.0 * removedCount / originalCount;
|
double percent = 100.0 * removedCount / originalCount;
|
||||||
FileLog.rlog(removedCount + " out of " + originalCount + " record(s) removed. " + percent + "%");
|
FileLog.MAIN.logLine(removedCount + " out of " + originalCount + " record(s) removed. " + percent + "%");
|
||||||
FileLog.rlog("Max valid diff: " + maxValidDiff);
|
FileLog.MAIN.logLine("Max valid diff: " + maxValidDiff);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class EngineState {
|
||||||
response = handleStringActionPair(response, pair, listener);
|
response = handleStringActionPair(response, pair, listener);
|
||||||
}
|
}
|
||||||
if (originalResponse.length() == response.length()) {
|
if (originalResponse.length() == response.length()) {
|
||||||
FileLog.rlog("EngineState.unknown: " + response);
|
FileLog.MAIN.logLine("EngineState.unknown: " + response);
|
||||||
// discarding invalid line
|
// discarding invalid line
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class AverageData {
|
||||||
double minX = data.getMinXValue();
|
double minX = data.getMinXValue();
|
||||||
double xWidth = data.getMaxXValue() - minX;
|
double xWidth = data.getMaxXValue() - minX;
|
||||||
|
|
||||||
FileLog.rlog("From x" + minX + " w=" + xWidth);
|
FileLog.MAIN.logLine("From x" + minX + " w=" + xWidth);
|
||||||
|
|
||||||
XYData result = new XYData();
|
XYData result = new XYData();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class AverageData {
|
||||||
double fromX_ = minX + (xWidth * i) / divider;
|
double fromX_ = minX + (xWidth * i) / divider;
|
||||||
double toX_ = minX + (xWidth * (i + 1)) / divider;
|
double toX_ = minX + (xWidth * (i + 1)) / divider;
|
||||||
|
|
||||||
FileLog.rlog("from " + fromX_ + " to " + toX_);
|
FileLog.MAIN.logLine("from " + fromX_ + " to " + toX_);
|
||||||
|
|
||||||
// double fromX = data.findXfromSet(fromX_);
|
// double fromX = data.findXfromSet(fromX_);
|
||||||
// double toX = data.findXfromSet(toX_);
|
// double toX = data.findXfromSet(toX_);
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class XYData {
|
||||||
public void saveToFile(String filename) {
|
public void saveToFile(String filename) {
|
||||||
try {
|
try {
|
||||||
String name = date + filename;
|
String name = date + filename;
|
||||||
FileLog.rlog("Writing data to " + name);
|
FileLog.MAIN.logLine("Writing data to " + name);
|
||||||
Writer w = new FileWriter(name);
|
Writer w = new FileWriter(name);
|
||||||
for (YAxisData yAxisData : yDatas.values())
|
for (YAxisData yAxisData : yDatas.values())
|
||||||
yAxisData.write(w);
|
yAxisData.write(w);
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class XYDataReader {
|
||||||
Point3D xyz = Point3D.parseLine(line);
|
Point3D xyz = Point3D.parseLine(line);
|
||||||
data.addPoint(xyz);
|
data.addPoint(xyz);
|
||||||
}
|
}
|
||||||
FileLog.rlog("x range: " + data.getMinXValue() + " to " + data.getMaxXValue());
|
FileLog.MAIN.logLine("x range: " + data.getMinXValue() + " to " + data.getMaxXValue());
|
||||||
FileLog.rlog("y range: " + data.getMinYValue() + " to " + data.getMaxYValue());
|
FileLog.MAIN.logLine("y range: " + data.getMinYValue() + " to " + data.getMaxYValue());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class YAxisData {
|
||||||
|
|
||||||
float newAvg = holder.get();
|
float newAvg = holder.get();
|
||||||
if (newAvg != value && !Float.isNaN(newAvg)) {
|
if (newAvg != value && !Float.isNaN(newAvg)) {
|
||||||
FileLog.rlog("new " + value + " avg " + newAvg + " for x=" + x + "/y=" + y);
|
FileLog.MAIN.logLine("new " + value + " avg " + newAvg + " for x=" + x + "/y=" + y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class WaveChartParser {
|
||||||
public static WaveChart unpackToMap(String value) {
|
public static WaveChart unpackToMap(String value) {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
throw new NullPointerException("value");
|
throw new NullPointerException("value");
|
||||||
FileLog.rlog(": " + value);
|
FileLog.MAIN.logLine(": " + value);
|
||||||
|
|
||||||
String[] array = value.split(DELI);
|
String[] array = value.split(DELI);
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class AnalogChartPanel {
|
||||||
List<Double> keys = new ArrayList<>(values.keySet());
|
List<Double> keys = new ArrayList<>(values.keySet());
|
||||||
minX = keys.get(0);
|
minX = keys.get(0);
|
||||||
maxX = keys.get(keys.size() - 1);
|
maxX = keys.get(keys.size() - 1);
|
||||||
FileLog.rlog("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<>();
|
||||||
sortedValues.addAll(values.values());
|
sortedValues.addAll(values.values());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.core.EngineState;
|
import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
@ -53,8 +54,14 @@ public class Launcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onWindowClosed() {
|
protected void onWindowClosed() {
|
||||||
super.onWindowClosed();
|
/**
|
||||||
|
* here we would close the port and log a message about it
|
||||||
|
*/
|
||||||
windowClosedHandler();
|
windowClosedHandler();
|
||||||
|
/**
|
||||||
|
* here we would close the log file
|
||||||
|
*/
|
||||||
|
super.onWindowClosed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,6 +147,9 @@ public class Launcher {
|
||||||
root.setProperty("version", CONSOLE_VERSION);
|
root.setProperty("version", CONSOLE_VERSION);
|
||||||
root.setProperty(TAB_INDEX, tabbedPane.getSelectedIndex());
|
root.setProperty(TAB_INDEX, tabbedPane.getSelectedIndex());
|
||||||
getConfig().save();
|
getConfig().save();
|
||||||
|
BinaryProtocol bp = BinaryProtocol.instance;
|
||||||
|
if (bp != null && !bp.isClosed)
|
||||||
|
bp.close();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class LogViewer extends JPanel {
|
||||||
engineState.registerStringValueAction("wave_chart", new EngineState.ValueCallback<String>() {
|
engineState.registerStringValueAction("wave_chart", new EngineState.ValueCallback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(String value) {
|
public void onUpdate(String value) {
|
||||||
FileLog.rlog("Got wave_chart: " + value);
|
FileLog.MAIN.logLine("Got wave_chart: " + value);
|
||||||
|
|
||||||
ChartRepository.getInstance().addChart(value);
|
ChartRepository.getInstance().addChart(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class PersistentConfiguration {
|
||||||
config = (Map<String, Object>) e.readObject();
|
config = (Map<String, Object>) e.readObject();
|
||||||
e.close();
|
e.close();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
FileLog.rlog("Error reading from " + CONFIG_FILE_NAME);
|
FileLog.MAIN.logLine("Error reading from " + CONFIG_FILE_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class PersistentConfiguration {
|
||||||
e.close();
|
e.close();
|
||||||
System.out.println("Saved to " + CONFIG_FILE_NAME);
|
System.out.println("Saved to " + CONFIG_FILE_NAME);
|
||||||
} catch (FileNotFoundException e1) {
|
} catch (FileNotFoundException e1) {
|
||||||
FileLog.rlog("Error saving " + CONFIG_FILE_NAME);
|
FileLog.MAIN.logLine("Error saving " + CONFIG_FILE_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,11 @@ public class FrameHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onWindowOpened() {
|
protected void onWindowOpened() {
|
||||||
FileLog.rlog("onWindowOpened");
|
FileLog.MAIN.logLine("onWindowOpened");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onWindowClosed() {
|
protected void onWindowClosed() {
|
||||||
FileLog.rlog("onWindowClosed");
|
FileLog.MAIN.logLine("onWindowClosed");
|
||||||
FileLog.MAIN.close();
|
FileLog.MAIN.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue