logging refactoring

This commit is contained in:
rusefi 2020-07-02 20:39:10 -04:00
parent 83833df6d9
commit 7224a8cb31
38 changed files with 162 additions and 141 deletions

View File

@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="AverageAnglesUtil" type="Application" factoryName="Application" nameIsGenerated="true"> <configuration default="false" name="AverageAnglesUtil" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.rusefi.AverageAnglesUtil" /> <option name="MAIN_CLASS_NAME" value="com.rusefi.AverageAnglesUtil" />
<module name="io" /> <module name="autotest" />
<option name="PROGRAM_PARAMETERS" value="a.csv" /> <option name="PROGRAM_PARAMETERS" value="a.csv" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<extension name="coverage"> <extension name="coverage">

View File

@ -9,5 +9,6 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="io" /> <orderEntry type="module" module-name="io" />
<orderEntry type="module" module-name="models" /> <orderEntry type="module" module-name="models" />
<orderEntry type="module" module-name="logging" />
</component> </component>
</module> </module>

View File

@ -8,7 +8,6 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="models" exported="" /> <orderEntry type="module" module-name="models" exported="" />
<orderEntry type="module" module-name="logging" exported="" />
<orderEntry type="library" exported="" name="jcip-annotations" level="project" /> <orderEntry type="library" exported="" name="jcip-annotations" level="project" />
<orderEntry type="library" name="jSerialComm" level="project" /> <orderEntry type="library" name="jSerialComm" level="project" />
<orderEntry type="module" module-name="opensr5" exported="" /> <orderEntry type="module" module-name="opensr5" exported="" />

View File

@ -5,7 +5,6 @@ import com.opensr5.Logger;
import com.opensr5.io.ConfigurationImageFile; import com.opensr5.io.ConfigurationImageFile;
import com.opensr5.io.DataListener; import com.opensr5.io.DataListener;
import com.rusefi.ConfigurationImageDiff; import com.rusefi.ConfigurationImageDiff;
import com.rusefi.FileLog;
import com.rusefi.Timeouts; import com.rusefi.Timeouts;
import com.rusefi.composite.CompositeEvent; import com.rusefi.composite.CompositeEvent;
import com.rusefi.composite.CompositeParser; import com.rusefi.composite.CompositeParser;
@ -143,7 +142,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
@NotNull @NotNull
public static String getFileName(String prefix, String fileType) { public static String getFileName(String prefix, String fileType) {
return FileLog.DIR + prefix + FileLog.getDate() + fileType; return Logger.DIR + prefix + Logger.getDate() + fileType;
} }
public void doSend(final String command, boolean fireEvent) throws InterruptedException { public void doSend(final String command, boolean fireEvent) throws InterruptedException {
@ -520,7 +519,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
Thread.sleep(100); Thread.sleep(100);
return new String(response, 1, response.length - 1); return new String(response, 1, response.length - 1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FileLog.MAIN.log(e); logger.error(e.toString());
return null; return null;
} }
} }

View File

@ -1,6 +1,6 @@
package com.rusefi.io; package com.rusefi.io;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -35,21 +35,7 @@ public class CommandQueue {
private final BlockingQueue<IMethodInvocation> pendingCommands = new LinkedBlockingQueue<>(); private final BlockingQueue<IMethodInvocation> pendingCommands = new LinkedBlockingQueue<>();
private final List<CommandQueueListener> commandListeners = new ArrayList<>(); private final List<CommandQueueListener> commandListeners = new ArrayList<>();
private final Runnable runnable = new Runnable() { private final Runnable runnable;
@SuppressWarnings("InfiniteLoopStatement")
@Override
public void run() {
MessagesCentral.getInstance().postMessage(COMMAND_QUEUE_CLASS, "SerialIO started");
while (true) {
try {
sendPendingCommand();
} catch (Throwable e) {
FileLog.MAIN.logException("CommandQueue error", e);
System.exit(-2);
}
}
}
};
private static boolean isSlowCommand(String cmd) { private static boolean isSlowCommand(String cmd) {
String lc = cmd.toLowerCase(); String lc = cmd.toLowerCase();
@ -114,8 +100,23 @@ public class CommandQueue {
MessagesCentral.getInstance().postMessage(CommandQueue.class, "Took " + counter + " attempts"); MessagesCentral.getInstance().postMessage(CommandQueue.class, "Took " + counter + " attempts");
} }
public CommandQueue(LinkManager linkManager) { public CommandQueue(LinkManager linkManager, Logger logger) {
this.linkManager = linkManager; this.linkManager = linkManager;
runnable = new Runnable() {
@SuppressWarnings("InfiniteLoopStatement")
@Override
public void run() {
MessagesCentral.getInstance().postMessage(COMMAND_QUEUE_CLASS, "SerialIO started");
while (true) {
try {
sendPendingCommand();
} catch (Throwable e) {
logger.error("CommandQueue error" + e);
System.exit(-2);
}
}
}
};
Thread thread = new Thread(runnable, "Commands Queue"); Thread thread = new Thread(runnable, "Commands Queue");
thread.setDaemon(true); thread.setDaemon(true);
thread.start(); thread.start();

View File

@ -2,7 +2,6 @@ package com.rusefi.io;
import com.fazecast.jSerialComm.SerialPort; import com.fazecast.jSerialComm.SerialPort;
import com.opensr5.Logger; import com.opensr5.Logger;
import com.rusefi.FileLog;
import com.rusefi.NamedThreadFactory; import com.rusefi.NamedThreadFactory;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.BinaryProtocolState; import com.rusefi.binaryprotocol.BinaryProtocolState;
@ -31,13 +30,21 @@ public class LinkManager {
}; };
public static final String LOG_VIEWER = "log viewer"; public static final String LOG_VIEWER = "log viewer";
private final CommandQueue commandQueue = new CommandQueue(this); private final CommandQueue commandQueue;
private final Logger logger; private final Logger logger;
private LinkConnector connector; private LinkConnector connector;
public LinkManager(Logger logger) { public LinkManager(Logger logger) {
this.logger = logger; this.logger = logger;
engineState = new EngineState(new EngineState.EngineStateListenerImpl() {
@Override
public void beforeLine(String fullLine) {
logger.info(fullLine);
HeartBeatListeners.onDataArrived();
}
});
commandQueue = new CommandQueue(this, logger);
} }
@NotNull @NotNull
@ -151,13 +158,7 @@ public class LinkManager {
// throw new IllegalStateException("Communication on wrong thread"); // throw new IllegalStateException("Communication on wrong thread");
} }
private EngineState engineState = new EngineState(new EngineState.EngineStateListenerImpl() { private EngineState engineState;
@Override
public void beforeLine(String fullLine) {
FileLog.MAIN.logLine(fullLine);
HeartBeatListeners.onDataArrived();
}
});
public EngineState getEngineState() { public EngineState getEngineState() {
return engineState; return engineState;
@ -176,14 +177,14 @@ public class LinkManager {
public void start(String port) { public void start(String port) {
Objects.requireNonNull(port, "port"); Objects.requireNonNull(port, "port");
FileLog.MAIN.logLine("LinkManager: Starting " + port); logger.info("LinkManager: Starting " + port);
if (isLogViewerMode(port)) { if (isLogViewerMode(port)) {
connector = LinkConnector.VOID; connector = LinkConnector.VOID;
} else if (TcpConnector.isTcpPort(port)) { } else if (TcpConnector.isTcpPort(port)) {
connector = new TcpConnector(this, port); connector = new TcpConnector(this, port, logger);
isSimulationMode = true; isSimulationMode = true;
} else { } else {
connector = new SerialConnector(this, port); connector = new SerialConnector(this, port, logger);
} }
} }

View File

@ -1,6 +1,6 @@
package com.rusefi.io.serial; package com.rusefi.io.serial;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.io.CommunicationLoggingHolder; import com.rusefi.io.CommunicationLoggingHolder;
import com.rusefi.io.ConnectionStateListener; import com.rusefi.io.ConnectionStateListener;
@ -20,6 +20,7 @@ import java.awt.*;
*/ */
public class PortHolder { public class PortHolder {
private final DataListener dataListener; private final DataListener dataListener;
private final Logger logger;
private final LinkManager linkManager; private final LinkManager linkManager;
public ConnectionStateListener listener; public ConnectionStateListener listener;
@ -28,9 +29,10 @@ public class PortHolder {
@Nullable @Nullable
private BinaryProtocol bp; private BinaryProtocol bp;
protected PortHolder(LinkManager linkManager) { protected PortHolder(LinkManager linkManager, Logger logger) {
this.linkManager = linkManager; this.linkManager = linkManager;
dataListener = freshData -> linkManager.getEngineState().processNewData(new String(freshData), LinkManager.ENCODER); dataListener = freshData -> linkManager.getEngineState().processNewData(new String(freshData), LinkManager.ENCODER);
this.logger = logger;
} }
public String port; public String port;
@ -41,9 +43,9 @@ public class PortHolder {
CommunicationLoggingHolder.communicationLoggingListener.onPortHolderMessage(getClass(), "Opening port: " + port); CommunicationLoggingHolder.communicationLoggingListener.onPortHolderMessage(getClass(), "Opening port: " + port);
IoStream stream = SerialIoStreamJSerialComm.openPort(port); IoStream stream = SerialIoStreamJSerialComm.openPort(port, logger);
synchronized (portLock) { synchronized (portLock) {
bp = new BinaryProtocol(linkManager, FileLog.LOGGER, stream); bp = new BinaryProtocol(linkManager, logger, stream);
portLock.notifyAll(); portLock.notifyAll();
} }

View File

@ -1,6 +1,6 @@
package com.rusefi.io.serial; package com.rusefi.io.serial;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.io.ConnectionStateListener; import com.rusefi.io.ConnectionStateListener;
@ -14,23 +14,25 @@ import com.rusefi.io.LinkManager;
public class SerialConnector implements LinkConnector { public class SerialConnector implements LinkConnector {
private final PortHolder portHolder; private final PortHolder portHolder;
private final Logger logger;
private final LinkManager linkManager; private final LinkManager linkManager;
public SerialConnector(LinkManager linkManager, String serialPort) { public SerialConnector(LinkManager linkManager, String serialPort, Logger logger) {
this.linkManager = linkManager; this.linkManager = linkManager;
portHolder = new PortHolder(linkManager); portHolder = new PortHolder(linkManager, logger);
this.logger = logger;
portHolder.port = serialPort; portHolder.port = serialPort;
} }
@Override @Override
public void connectAndReadConfiguration(ConnectionStateListener listener) { public void connectAndReadConfiguration(ConnectionStateListener listener) {
FileLog.MAIN.logLine("SerialConnector: connecting"); logger.info("SerialConnector: connecting");
portHolder.listener = listener; portHolder.listener = listener;
FileLog.MAIN.logLine("scheduleOpening"); logger.info("scheduleOpening");
linkManager.execute(new Runnable() { linkManager.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
FileLog.MAIN.logLine("scheduleOpening>openPort"); logger.info("scheduleOpening>openPort");
portHolder.connectAndReadConfiguration(); portHolder.connectAndReadConfiguration();
} }
}); });

View File

@ -3,8 +3,8 @@ package com.rusefi.io.serial;
import com.fazecast.jSerialComm.SerialPort; import com.fazecast.jSerialComm.SerialPort;
import com.fazecast.jSerialComm.SerialPortDataListener; import com.fazecast.jSerialComm.SerialPortDataListener;
import com.fazecast.jSerialComm.SerialPortEvent; import com.fazecast.jSerialComm.SerialPortEvent;
import com.opensr5.Logger;
import com.opensr5.io.DataListener; import com.opensr5.io.DataListener;
import com.rusefi.FileLog;
import com.rusefi.io.IoStream; import com.rusefi.io.IoStream;
/** /**
@ -17,13 +17,15 @@ public class SerialIoStreamJSerialComm implements IoStream {
private boolean isClosed; private boolean isClosed;
private SerialPort sp; private SerialPort sp;
private final String port; private final String port;
private final Logger logger;
/** /**
* @see #openPort(String) * @see #openPort(String, Logger)
*/ */
private SerialIoStreamJSerialComm(SerialPort sp, String port) { private SerialIoStreamJSerialComm(SerialPort sp, String port, Logger logger) {
this.sp = sp; this.sp = sp;
this.port = port; this.port = port;
this.logger = logger;
} }
@Override @Override
@ -59,10 +61,10 @@ public class SerialIoStreamJSerialComm implements IoStream {
@Override @Override
public void close() { public void close() {
FileLog.LOGGER.info(port + ": Closing port..."); logger.info(port + ": Closing port...");
isClosed = true; isClosed = true;
sp.closePort(); sp.closePort();
FileLog.LOGGER.info(port + ": Closed port."); logger.info(port + ": Closed port.");
} }
@Override @Override
@ -79,12 +81,12 @@ public class SerialIoStreamJSerialComm implements IoStream {
* Just open physical serial and not much more * Just open physical serial and not much more
* @see PortHolder#connectAndReadConfiguration() * @see PortHolder#connectAndReadConfiguration()
*/ */
public static IoStream openPort(String port) { public static IoStream openPort(String port, Logger logger) {
FileLog.LOGGER.info("[SerialIoStreamJSerialComm] openPort " + port); logger.info("[SerialIoStreamJSerialComm] openPort " + port);
SerialPort serialPort = SerialPort.getCommPort(port); SerialPort serialPort = SerialPort.getCommPort(port);
serialPort.setBaudRate(BaudRateHolder.INSTANCE.baudRate); serialPort.setBaudRate(BaudRateHolder.INSTANCE.baudRate);
serialPort.openPort(0); serialPort.openPort(0);
// FileLog.LOGGER.info("[SerialIoStreamJSerialComm] opened " + port); // FileLog.LOGGER.info("[SerialIoStreamJSerialComm] opened " + port);
return new SerialIoStreamJSerialComm(serialPort, port); return new SerialIoStreamJSerialComm(serialPort, port, logger);
} }
} }

View File

@ -1,7 +1,7 @@
package com.rusefi.io.tcp; package com.rusefi.io.tcp;
import com.opensr5.ConfigurationImage; import com.opensr5.ConfigurationImage;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.binaryprotocol.BinaryProtocolCommands; import com.rusefi.binaryprotocol.BinaryProtocolCommands;
import com.rusefi.binaryprotocol.BinaryProtocolState; import com.rusefi.binaryprotocol.BinaryProtocolState;
import com.rusefi.binaryprotocol.IoHelper; import com.rusefi.binaryprotocol.IoHelper;
@ -28,15 +28,20 @@ import static com.rusefi.config.generated.Fields.*;
public class BinaryProtocolServer implements BinaryProtocolCommands { public class BinaryProtocolServer implements BinaryProtocolCommands {
private static final int DEFAULT_PROXY_PORT = 2390; private static final int DEFAULT_PROXY_PORT = 2390;
private static final String TS_OK = "\0"; private static final String TS_OK = "\0";
private final Logger logger;
public AtomicInteger unknownCommands = new AtomicInteger(); public AtomicInteger unknownCommands = new AtomicInteger();
public BinaryProtocolServer(Logger logger) {
this.logger = logger;
}
public void start(LinkManager linkManager) { public void start(LinkManager linkManager) {
start(linkManager, DEFAULT_PROXY_PORT); start(linkManager, DEFAULT_PROXY_PORT);
} }
public void start(LinkManager linkManager, int port) { public void start(LinkManager linkManager, int port) {
FileLog.MAIN.logLine("BinaryProtocolServer on " + port); logger.info("BinaryProtocolServer on " + port);
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@SuppressWarnings("InfiniteLoopStatement") @SuppressWarnings("InfiniteLoopStatement")
@Override @Override
@ -45,7 +50,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
try { try {
serverSocket = new ServerSocket(port, 1); serverSocket = new ServerSocket(port, 1);
} catch (IOException e) { } catch (IOException e) {
FileLog.MAIN.logException("Error binding server socket", e); logger.error("Error binding server socket" + e);
return; return;
} }
@ -53,14 +58,14 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
while (true) { while (true) {
// Wait for a connection // Wait for a connection
final Socket clientSocket = serverSocket.accept(); final Socket clientSocket = serverSocket.accept();
FileLog.MAIN.logLine("Binary protocol proxy port connection"); logger.info("Binary protocol proxy port connection");
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
runProxy(linkManager, clientSocket); runProxy(linkManager, clientSocket);
} catch (IOException e) { } catch (IOException e) {
FileLog.MAIN.logLine("proxy connection: " + e); logger.info("proxy connection: " + e);
} }
} }
}, "proxy connection").start(); }, "proxy connection").start();
@ -108,27 +113,27 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
if (crc != IoHelper.getCrc32(packet)) if (crc != IoHelper.getCrc32(packet))
throw new IllegalStateException("CRC mismatch"); throw new IllegalStateException("CRC mismatch");
TcpIoStream stream = new TcpIoStream(linkManager, clientSocket); TcpIoStream stream = new TcpIoStream(logger, linkManager, clientSocket);
if (command == COMMAND_HELLO) { if (command == COMMAND_HELLO) {
stream.sendPacket((TS_OK + Fields.TS_SIGNATURE).getBytes(), FileLog.LOGGER); stream.sendPacket((TS_OK + Fields.TS_SIGNATURE).getBytes(), logger);
} else if (command == COMMAND_PROTOCOL) { } else if (command == COMMAND_PROTOCOL) {
// System.out.println("Ignoring crc F command"); // System.out.println("Ignoring crc F command");
stream.sendPacket((TS_OK + TS_PROTOCOL).getBytes(), FileLog.LOGGER); stream.sendPacket((TS_OK + TS_PROTOCOL).getBytes(), logger);
} else if (command == Fields.TS_GET_FIRMWARE_VERSION) { } else if (command == Fields.TS_GET_FIRMWARE_VERSION) {
stream.sendPacket((TS_OK + "rusEFI proxy").getBytes(), FileLog.LOGGER); stream.sendPacket((TS_OK + "rusEFI proxy").getBytes(), logger);
} else if (command == COMMAND_CRC_CHECK_COMMAND) { } else if (command == COMMAND_CRC_CHECK_COMMAND) {
handleCrc(linkManager, stream); handleCrc(linkManager, stream);
} else if (command == COMMAND_PAGE) { } else if (command == COMMAND_PAGE) {
stream.sendPacket(TS_OK.getBytes(), FileLog.LOGGER); stream.sendPacket(TS_OK.getBytes(), logger);
} else if (command == COMMAND_READ) { } else if (command == COMMAND_READ) {
handleRead(linkManager, dis, stream); handleRead(linkManager, dis, stream);
} else if (command == Fields.TS_CHUNK_WRITE_COMMAND) { } else if (command == Fields.TS_CHUNK_WRITE_COMMAND) {
handleWrite(linkManager, packet, dis, stream); handleWrite(linkManager, packet, dis, stream);
} else if (command == Fields.TS_BURN_COMMAND) { } else if (command == Fields.TS_BURN_COMMAND) {
stream.sendPacket(new byte[]{TS_RESPONSE_BURN_OK}, FileLog.LOGGER); stream.sendPacket(new byte[]{TS_RESPONSE_BURN_OK}, logger);
} else if (command == Fields.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY) { } else if (command == Fields.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY) {
// todo: relay command // todo: relay command
stream.sendPacket(TS_OK.getBytes(), FileLog.LOGGER); stream.sendPacket(TS_OK.getBytes(), logger);
} else if (command == Fields.TS_OUTPUT_COMMAND) { } else if (command == Fields.TS_OUTPUT_COMMAND) {
int offset = swap16(dis.readShort()); int offset = swap16(dis.readShort());
int count = swap16(dis.readShort()); int count = swap16(dis.readShort());
@ -140,31 +145,31 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
byte[] currentOutputs = binaryProtocolState.getCurrentOutputs(); byte[] currentOutputs = binaryProtocolState.getCurrentOutputs();
if (currentOutputs != null) if (currentOutputs != null)
System.arraycopy(currentOutputs, 1 + offset , response, 1, count); System.arraycopy(currentOutputs, 1 + offset , response, 1, count);
stream.sendPacket(response, FileLog.LOGGER); stream.sendPacket(response, logger);
} else { } else {
unknownCommands.incrementAndGet(); unknownCommands.incrementAndGet();
new IllegalStateException().printStackTrace(); new IllegalStateException().printStackTrace();
FileLog.MAIN.logLine("Error: unknown command " + (char) command + "/" + command); logger.info("Error: unknown command " + (char) command + "/" + command);
} }
} }
} }
private static void handleWrite(LinkManager linkManager, byte[] packet, DataInputStream dis, TcpIoStream stream) throws IOException { private void handleWrite(LinkManager linkManager, byte[] packet, DataInputStream dis, TcpIoStream stream) throws IOException {
dis.readShort(); // page dis.readShort(); // page
int offset = swap16(dis.readShort()); int offset = swap16(dis.readShort());
int count = swap16(dis.readShort()); int count = swap16(dis.readShort());
FileLog.MAIN.logLine("TS_CHUNK_WRITE_COMMAND: offset=" + offset + " count=" + count); logger.info("TS_CHUNK_WRITE_COMMAND: offset=" + offset + " count=" + count);
BinaryProtocolState bp = linkManager.getBinaryProtocolState(); BinaryProtocolState bp = linkManager.getBinaryProtocolState();
bp.setRange(packet, 7, offset, count); bp.setRange(packet, 7, offset, count);
stream.sendPacket(TS_OK.getBytes(), FileLog.LOGGER); stream.sendPacket(TS_OK.getBytes(), logger);
} }
private static void handleRead(LinkManager linkManager, DataInputStream dis, TcpIoStream stream) throws IOException { private void handleRead(LinkManager linkManager, DataInputStream dis, TcpIoStream stream) throws IOException {
short page = dis.readShort(); short page = dis.readShort();
int offset = swap16(dis.readShort()); int offset = swap16(dis.readShort());
int count = swap16(dis.readShort()); int count = swap16(dis.readShort());
if (count <= 0) { if (count <= 0) {
FileLog.MAIN.logLine("Error: negative read request " + offset + "/" + count); logger.info("Error: negative read request " + offset + "/" + count);
} else { } else {
System.out.println("read " + page + "/" + offset + "/" + count); System.out.println("read " + page + "/" + offset + "/" + count);
BinaryProtocolState bp = linkManager.getBinaryProtocolState(); BinaryProtocolState bp = linkManager.getBinaryProtocolState();
@ -174,11 +179,11 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
ConfigurationImage configurationImage = bp.getControllerConfiguration(); ConfigurationImage configurationImage = bp.getControllerConfiguration();
Objects.requireNonNull(configurationImage, "configurationImage"); Objects.requireNonNull(configurationImage, "configurationImage");
System.arraycopy(configurationImage.getContent(), offset, response, 1, count); System.arraycopy(configurationImage.getContent(), offset, response, 1, count);
stream.sendPacket(response, FileLog.LOGGER); stream.sendPacket(response, logger);
} }
} }
private static void handleCrc(LinkManager linkManager, TcpIoStream stream) throws IOException { private void handleCrc(LinkManager linkManager, TcpIoStream stream) throws IOException {
System.out.println("CRC check"); System.out.println("CRC check");
BinaryProtocolState bp = linkManager.getBinaryProtocolState(); BinaryProtocolState bp = linkManager.getBinaryProtocolState();
byte[] content = bp.getControllerConfiguration().getContent(); byte[] content = bp.getControllerConfiguration().getContent();
@ -186,6 +191,6 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
ByteArrayOutputStream response = new ByteArrayOutputStream(); ByteArrayOutputStream response = new ByteArrayOutputStream();
response.write(TS_OK.charAt(0)); response.write(TS_OK.charAt(0));
new DataOutputStream(response).writeInt(result); new DataOutputStream(response).writeInt(result);
stream.sendPacket(response.toByteArray(), FileLog.LOGGER); stream.sendPacket(response.toByteArray(), logger);
} }
} }

View File

@ -1,17 +1,14 @@
package com.rusefi.io.tcp; package com.rusefi.io.tcp;
import com.opensr5.Logger;
import com.opensr5.io.DataListener; import com.opensr5.io.DataListener;
import com.rusefi.FileLog;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.core.ResponseBuffer; import com.rusefi.core.ResponseBuffer;
import com.rusefi.io.ConnectionStateListener; import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.IoStream;
import com.rusefi.io.LinkConnector; import com.rusefi.io.LinkConnector;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -26,11 +23,13 @@ public class TcpConnector implements LinkConnector {
private final int port; private final int port;
private final String hostname; private final String hostname;
private final LinkManager linkManager; private final LinkManager linkManager;
private final Logger logger;
private BinaryProtocol bp; private BinaryProtocol bp;
public TcpConnector(LinkManager linkManager, String port) { public TcpConnector(LinkManager linkManager, String port, Logger logger) {
this.linkManager = linkManager; this.linkManager = linkManager;
this.logger = logger;
try { try {
this.port = getTcpPort(port); this.port = getTcpPort(port);
this.hostname = getHostname(port); this.hostname = getHostname(port);
@ -95,15 +94,15 @@ public class TcpConnector implements LinkConnector {
*/ */
@Override @Override
public void connectAndReadConfiguration(ConnectionStateListener listener) { public void connectAndReadConfiguration(ConnectionStateListener listener) {
FileLog.MAIN.logLine("Connecting to host=" + hostname + "/port=" + port); logger.info("Connecting to host=" + hostname + "/port=" + port);
TcpIoStream tcpIoStream; TcpIoStream tcpIoStream;
try { try {
Socket socket = new Socket(hostname, port); Socket socket = new Socket(hostname, port);
tcpIoStream = new TcpIoStream(linkManager, socket); tcpIoStream = new TcpIoStream(logger, linkManager, socket);
} catch (IOException e) { } catch (IOException e) {
listener.onConnectionFailed(); listener.onConnectionFailed();
FileLog.MAIN.logLine("Failed to connect to " + hostname + "/port=" + port); logger.error("Failed to connect to " + hostname + "/port=" + port);
return; return;
} }
@ -122,7 +121,7 @@ public class TcpConnector implements LinkConnector {
}; };
// ioStream.setInputListener(listener1); // ioStream.setInputListener(listener1);
bp = new BinaryProtocol(linkManager, FileLog.LOGGER, tcpIoStream); bp = new BinaryProtocol(linkManager, logger, tcpIoStream);
boolean result = bp.connectAndReadConfiguration(listener1); boolean result = bp.connectAndReadConfiguration(listener1);
if (result) { if (result) {
@ -139,7 +138,7 @@ public class TcpConnector implements LinkConnector {
@Override @Override
public void send(String command, boolean fireEvent) throws InterruptedException { public void send(String command, boolean fireEvent) throws InterruptedException {
if (bp == null) { if (bp == null) {
FileLog.MAIN.logLine("Not connected"); logger.info("Not connected");
return; return;
} }

View File

@ -1,6 +1,6 @@
package com.rusefi.io.tcp; package com.rusefi.io.tcp;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.opensr5.io.DataListener; import com.opensr5.io.DataListener;
import com.rusefi.io.IoStream; import com.rusefi.io.IoStream;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
@ -19,14 +19,16 @@ import java.util.Arrays;
public class TcpIoStream implements IoStream { public class TcpIoStream implements IoStream {
private final InputStream input; private final InputStream input;
private final OutputStream output; private final OutputStream output;
private final Logger logger;
private final LinkManager linkManager; private final LinkManager linkManager;
private boolean isClosed; private boolean isClosed;
public TcpIoStream(LinkManager linkManager, Socket socket) throws IOException { public TcpIoStream(Logger logger, LinkManager linkManager, Socket socket) throws IOException {
this(linkManager, new BufferedInputStream(socket.getInputStream()), socket.getOutputStream()); this(logger, linkManager, new BufferedInputStream(socket.getInputStream()), socket.getOutputStream());
} }
public TcpIoStream(LinkManager linkManager, InputStream input, OutputStream output) { private TcpIoStream(Logger logger, LinkManager linkManager, InputStream input, OutputStream output) {
this.logger = logger;
this.linkManager = linkManager; this.linkManager = linkManager;
if (input == null) if (input == null)
throw new NullPointerException("input"); throw new NullPointerException("input");
@ -58,7 +60,7 @@ public class TcpIoStream implements IoStream {
@Override @Override
public void run() { public void run() {
Thread.currentThread().setName("TCP connector loop"); Thread.currentThread().setName("TCP connector loop");
FileLog.MAIN.logLine("Running TCP connection loop"); logger.info("Running TCP connection loop");
byte inputBuffer[] = new byte[256]; byte inputBuffer[] = new byte[256];
while (true) { while (true) {

View File

@ -1,5 +1,6 @@
package com.opensr5; package com.opensr5;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
/** /**
@ -28,6 +29,12 @@ public interface Logger {
return false; return false;
} }
}; };
String DIR = "logs/";
String DATE_PATTERN = "yyyy-MM-dd_HH_mm_ss_SSS";
static String getDate() {
return new SimpleDateFormat(DATE_PATTERN).format(new Date());
}
void trace(String msg); void trace(String msg);

View File

@ -6,8 +6,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
* what the hell is this anyway? todo: migrate to log4j2 * what the hell is this anyway? todo: migrate to log4j2
@ -18,10 +16,8 @@ public enum FileLog {
MAIN, MAIN,
SIMULATOR_CONSOLE; SIMULATOR_CONSOLE;
public static final String DIR = "logs/"; public static final String LOG_INFO_TEXT = "Writing logs to '" + Logger.DIR + "'";
public static final String LOG_INFO_TEXT = "Writing logs to '" + DIR + "'";
public static final String OS_VERSION = "os.version"; public static final String OS_VERSION = "os.version";
public static final String DATE_PATTERN = "yyyy-MM-dd_HH_mm_ss_SSS";
private static final String WIKI_URL = "https://github.com/rusefi/rusefi/wiki/rusEFI-logs-folder"; private static final String WIKI_URL = "https://github.com/rusefi/rusefi/wiki/rusEFI-logs-folder";
public static String currentLogName; public static String currentLogName;
public static final String END_OF_TIMESTAND_TAG = "<EOT>: "; public static final String END_OF_TIMESTAND_TAG = "<EOT>: ";
@ -67,7 +63,7 @@ public enum FileLog {
} }
private static void writeReadmeFile() { private static void writeReadmeFile() {
LazyFile file = new LazyFile(DIR + "README.html"); LazyFile file = new LazyFile(Logger.DIR + "README.html");
file.write("<center>" + "<a href='" + WIKI_URL + "'>More info online<br/><img src=https://raw.githubusercontent.com/wiki/rusefi/rusefi/logo.gif></a>"); file.write("<center>" + "<a href='" + WIKI_URL + "'>More info online<br/><img src=https://raw.githubusercontent.com/wiki/rusefi/rusefi/logo.gif></a>");
try { try {
file.close(); file.close();
@ -90,29 +86,25 @@ public enum FileLog {
} }
private FileOutputStream openLog() throws FileNotFoundException { private FileOutputStream openLog() throws FileNotFoundException {
String date = getDate(); String date = Logger.getDate();
createFolderIfNeeded(); createFolderIfNeeded();
currentLogName = name() + "_rfi_report_" + date + ".csv"; currentLogName = name() + "_rfi_report_" + date + ".csv";
String fileName = DIR + currentLogName; String fileName = Logger.DIR + currentLogName;
rlog("Writing to " + fileName); rlog("Writing to " + fileName);
return new FileOutputStream(fileName, true); return new FileOutputStream(fileName, true);
} }
public static void createFolderIfNeeded() { public static void createFolderIfNeeded() {
File dir = new File(DIR); File dir = new File(Logger.DIR);
if (dir.exists()) if (dir.exists())
return; return;
boolean created = dir.mkdirs(); boolean created = dir.mkdirs();
if (!created) if (!created)
throw new IllegalStateException("Failed to create " + DIR + " folder"); throw new IllegalStateException("Failed to create " + Logger.DIR + " folder");
}
public static String getDate() {
return new SimpleDateFormat(DATE_PATTERN).format(new Date());
} }
public synchronized void logLine(String fullLine) { public synchronized void logLine(String fullLine) {
String withDate = getDate() + END_OF_TIMESTAND_TAG + fullLine; String withDate = Logger.getDate() + END_OF_TIMESTAND_TAG + fullLine;
System.out.println(withDate); System.out.println(withDate);
if (suspendLogging) if (suspendLogging)
return; return;

View File

@ -9,5 +9,6 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="inifile" /> <orderEntry type="module" module-name="inifile" />
<orderEntry type="module" module-name="logging" /> <orderEntry type="module" module-name="logging" />
<orderEntry type="module" module-name="logging-api" />
</component> </component>
</module> </module>

View File

@ -1,5 +1,6 @@
package com.rusefi.models; package com.rusefi.models;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -26,7 +27,7 @@ public class XYData {
private double maxYValue; private double maxYValue;
private double minYValue; private double minYValue;
String date = FileLog.getDate(); String date = Logger.getDate();
public XYData() { public XYData() {
clear(); clear();

View File

@ -33,7 +33,7 @@ public class TcpCommunicationIntegrationTest {
LinkManager linkManager = new LinkManager(FileLog.LOGGER); LinkManager linkManager = new LinkManager(FileLog.LOGGER);
linkManager.setConnector(LinkConnector.getDetachedConnector(state)); linkManager.setConnector(LinkConnector.getDetachedConnector(state));
BinaryProtocolServer server = new BinaryProtocolServer(); BinaryProtocolServer server = new BinaryProtocolServer(FileLog.LOGGER);
server.start(linkManager, port); server.start(linkManager, port);
CountDownLatch countDownLatch = new CountDownLatch(1); CountDownLatch countDownLatch = new CountDownLatch(1);

View File

@ -1,5 +1,6 @@
package com.rusefi; package com.rusefi;
import com.opensr5.Logger;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.tracing.Entry; import com.rusefi.tracing.Entry;
@ -72,7 +73,7 @@ public class BenchTestPane {
List<Entry> data = Entry.parseBuffer(packet); List<Entry> data = Entry.parseBuffer(packet);
int rpm = RpmModel.getInstance().getValue(); int rpm = RpmModel.getInstance().getValue();
String fileName = FileLog.getDate() + "_rpm_" + rpm + "_rusEfi_trace" + ".json"; String fileName = Logger.getDate() + "_rpm_" + rpm + "_rusEfi_trace" + ".json";
JsonOutput.writeToStream(data, new FileOutputStream(fileName)); JsonOutput.writeToStream(data, new FileOutputStream(fileName));

View File

@ -1,6 +1,7 @@
package com.rusefi; package com.rusefi;
import com.fathzer.soft.javaluator.DoubleEvaluator; import com.fathzer.soft.javaluator.DoubleEvaluator;
import com.opensr5.Logger;
import java.io.*; import java.io.*;
import java.util.List; import java.util.List;
@ -32,7 +33,7 @@ public class CompileTool {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(outputFileName))) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(outputFileName))) {
bw.write("// this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically" + NEWLINE); bw.write("// this https://en.wikipedia.org/wiki/Reverse_Polish_notation is generated automatically" + NEWLINE);
bw.write("// from " + inputFileName + NEWLINE); bw.write("// from " + inputFileName + NEWLINE);
bw.write("// on " + FileLog.getDate() + NEWLINE + "//" + NEWLINE); bw.write("// on " + Logger.getDate() + NEWLINE + "//" + NEWLINE);
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {

View File

@ -1,10 +1,10 @@
package com.rusefi; package com.rusefi;
import com.opensr5.Logger;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.file.TableGenerator; import com.rusefi.file.TableGenerator;
import com.rusefi.io.CommandQueue;
import com.rusefi.models.Point3D; import com.rusefi.models.Point3D;
import com.rusefi.models.Range; import com.rusefi.models.Range;
import com.rusefi.models.XYData; import com.rusefi.models.XYData;
@ -80,7 +80,7 @@ public class EcuStimulator {
// if (1 == 1) // if (1 == 1)
// return; // return;
String csvFileName = "table_" + inputs.getRpmStep() + "_" + inputs.getEngineLoadStep() + FileLog.getDate() + ".csv"; String csvFileName = "table_" + inputs.getRpmStep() + "_" + inputs.getEngineLoadStep() + Logger.getDate() + ".csv";
FileLog.MAIN.logLine("Wring to " + csvFileName); FileLog.MAIN.logLine("Wring to " + csvFileName);
final BufferedWriter csv; final BufferedWriter csv;
@ -121,7 +121,7 @@ public class EcuStimulator {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
TableGenerator.writeAsC(data, C_PREFIX, "map" + FileLog.getDate() + ".c"); TableGenerator.writeAsC(data, C_PREFIX, "map" + Logger.getDate() + ".c");
} }
private void buildTable(ResultListener listener, Sensor dwellSensor) { private void buildTable(ResultListener listener, Sensor dwellSensor) {

View File

@ -1,5 +1,6 @@
package com.rusefi; package com.rusefi;
import com.opensr5.Logger;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.ui.RpmLabel; import com.rusefi.ui.RpmLabel;
import com.rusefi.ui.RpmModel; import com.rusefi.ui.RpmModel;
@ -77,7 +78,7 @@ public class SensorSnifferPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int rpm = RpmModel.getInstance().getValue(); int rpm = RpmModel.getInstance().getValue();
String fileName = FileLog.getDate() + "_rpm_" + rpm + "_sensor" + ".png"; String fileName = Logger.getDate() + "_rpm_" + rpm + "_sensor" + ".png";
UiUtils.saveImageWithPrompt(fileName, upperPanel, canvas); UiUtils.saveImageWithPrompt(fileName, upperPanel, canvas);
} }

View File

@ -6,6 +6,7 @@ import com.rusefi.io.LinkManager;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -33,7 +34,7 @@ public class PortDetector {
CountDownLatch portFound = new CountDownLatch(1); CountDownLatch portFound = new CountDownLatch(1);
AtomicReference<String> result = new AtomicReference<>(); AtomicReference<String> result = new AtomicReference<>();
for (String serialPort : serialPorts) { for (String serialPort : serialPorts) {
Thread thread = new Thread(new SerialAutoChecker(serialPort, portFound, result, callback)); Thread thread = new Thread(new SerialAutoChecker(FileLog.LOGGER, serialPort, portFound, result, callback));
serialFinder.add(thread); serialFinder.add(thread);
thread.start(); thread.start();
} }

View File

@ -17,26 +17,28 @@ import java.util.function.Function;
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode; import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
public class SerialAutoChecker implements Runnable { public class SerialAutoChecker implements Runnable {
private final Logger logger;
private final String serialPort; private final String serialPort;
private final CountDownLatch portFound; private final CountDownLatch portFound;
private final AtomicReference<String> result; private final AtomicReference<String> result;
private final Function<IoStream, Void> callback; private final Function<IoStream, Void> callback;
public static String SIGNATURE; public static String SIGNATURE;
public SerialAutoChecker(String serialPort, CountDownLatch portFound, AtomicReference<String> result, Function<IoStream, Void> callback) { public SerialAutoChecker(Logger logger, String serialPort, CountDownLatch portFound, AtomicReference<String> result, Function<IoStream, Void> callback) {
this.logger = logger;
this.serialPort = serialPort; this.serialPort = serialPort;
this.portFound = portFound; this.portFound = portFound;
this.result = result; this.result = result;
this.callback = callback; this.callback = callback;
} }
public SerialAutoChecker(String serialPort, CountDownLatch portFound, AtomicReference<String> result) { public SerialAutoChecker(Logger logger, String serialPort, CountDownLatch portFound, AtomicReference<String> result) {
this(serialPort, portFound, result, null); this(logger, serialPort, portFound, result, null);
} }
@Override @Override
public void run() { public void run() {
IoStream stream = SerialIoStreamJSerialComm.openPort(serialPort); IoStream stream = SerialIoStreamJSerialComm.openPort(serialPort, logger);
Logger logger = FileLog.LOGGER; Logger logger = FileLog.LOGGER;
IncomingDataBuffer incomingData = BinaryProtocol.createDataBuffer(stream, logger); IncomingDataBuffer incomingData = BinaryProtocol.createDataBuffer(stream, logger);
try { try {

View File

@ -47,7 +47,7 @@ public class DfuFlasher {
if (!PortDetector.isAutoPort(port)) { if (!PortDetector.isAutoPort(port)) {
messages.append("Using selected " + port + "\n"); messages.append("Using selected " + port + "\n");
IoStream stream = SerialIoStreamJSerialComm.openPort(port); IoStream stream = SerialIoStreamJSerialComm.openPort(port, FileLog.LOGGER);
sendDfuRebootCommand(stream, messages); sendDfuRebootCommand(stream, messages);
} else { } else {
messages.append("Auto-detecting port...\n"); messages.append("Auto-detecting port...\n");

View File

@ -1,5 +1,6 @@
package com.rusefi.sensor_logs; package com.rusefi.sensor_logs;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.config.FieldType; import com.rusefi.config.FieldType;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
@ -54,7 +55,7 @@ public class BinarySensorLog implements SensorLog {
public void writeSensorLogLine() { public void writeSensorLogLine() {
if (stream == null) { if (stream == null) {
FileLog.createFolderIfNeeded(); FileLog.createFolderIfNeeded();
fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".mlg"; fileName = Logger.DIR + "rusEFI_gauges_" + Logger.getDate() + ".mlg";
try { try {
stream = new DataOutputStream(new FileOutputStream(fileName)); stream = new DataOutputStream(new FileOutputStream(fileName));

View File

@ -1,13 +1,13 @@
package com.rusefi.sensor_logs; package com.rusefi.sensor_logs;
import com.opensr5.ConfigurationImage; import com.opensr5.ConfigurationImage;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.Launcher; import com.rusefi.Launcher;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.io.LinkManager;
import com.rusefi.ui.UIContext; import com.rusefi.ui.UIContext;
import com.rusefi.ui.config.ConfigField; import com.rusefi.ui.config.ConfigField;
@ -41,14 +41,14 @@ public class PlainTextSensorLog implements SensorLog {
private void startSensorLogFile() { private void startSensorLogFile() {
FileLog.createFolderIfNeeded(); FileLog.createFolderIfNeeded();
String fileName = FileLog.DIR + "rusEFI_gauges_" + FileLog.getDate() + ".msl"; String fileName = Logger.DIR + "rusEFI_gauges_" + Logger.getDate() + ".msl";
fileStartTime = System.currentTimeMillis(); fileStartTime = System.currentTimeMillis();
try { try {
logFile = new FileWriter(fileName); logFile = new FileWriter(fileName);
logFile.write("\"rusEFI console" + Launcher.CONSOLE_VERSION + " firmware " + Launcher.firmwareVersion.get() + "\"\r\n"); logFile.write("\"rusEFI console" + Launcher.CONSOLE_VERSION + " firmware " + Launcher.firmwareVersion.get() + "\"\r\n");
logFile.write("Captured " + FileLog.getDate() + "\r\n"); logFile.write("Captured " + Logger.getDate() + "\r\n");
int debugMode = -1; int debugMode = -1;
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState(); BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();

View File

@ -134,7 +134,7 @@ public class ConsoleTools {
String autoDetectedPort = autoDetectPort(); String autoDetectedPort = autoDetectPort();
if (autoDetectedPort == null) if (autoDetectedPort == null)
return; return;
IoStream stream = SerialIoStreamJSerialComm.openPort(autoDetectedPort); IoStream stream = SerialIoStreamJSerialComm.openPort(autoDetectedPort, FileLog.LOGGER);
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(command); byte[] commandBytes = BinaryProtocol.getTextCommandBytes(command);
stream.sendPacket(commandBytes, FileLog.LOGGER); stream.sendPacket(commandBytes, FileLog.LOGGER);
} }
@ -199,7 +199,7 @@ public class ConsoleTools {
linkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() { linkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() {
@Override @Override
public void onConnectionEstablished() { public void onConnectionEstablished() {
new BinaryProtocolServer().start(linkManager); new BinaryProtocolServer(FileLog.LOGGER).start(linkManager);
} }
@Override @Override
@ -305,7 +305,7 @@ public class ConsoleTools {
System.out.println("rusEFI not detected"); System.out.println("rusEFI not detected");
return; return;
} }
IoStream stream = SerialIoStreamJSerialComm.openPort(autoDetectedPort); IoStream stream = SerialIoStreamJSerialComm.openPort(autoDetectedPort, FileLog.LOGGER);
Logger logger = FileLog.LOGGER; Logger logger = FileLog.LOGGER;
IncomingDataBuffer incomingData = BinaryProtocol.createDataBuffer(stream, logger); IncomingDataBuffer incomingData = BinaryProtocol.createDataBuffer(stream, logger);
byte[] commandBytes = BinaryProtocol.getTextCommandBytes("hello"); byte[] commandBytes = BinaryProtocol.getTextCommandBytes("hello");

View File

@ -1,6 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.models.Range; import com.rusefi.models.Range;
import com.rusefi.models.XYData; import com.rusefi.models.XYData;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
@ -40,7 +40,7 @@ public class ChartHelper {
saveImageButton.addActionListener(new ActionListener() { saveImageButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String fileName = FileLog.getDate() + "_3d.png"; String fileName = Logger.getDate() + "_3d.png";
UiUtils.saveImageWithPrompt(fileName, result, jsp); UiUtils.saveImageWithPrompt(fileName, result, jsp);
} }

View File

@ -1,6 +1,7 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.opensr5.ConfigurationImage; import com.opensr5.ConfigurationImage;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
@ -58,7 +59,7 @@ public class FormulasPane {
saveImage.addActionListener(new ActionListener() { saveImage.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String fileName = FileLog.getDate() + "_formulas.png"; String fileName = Logger.getDate() + "_formulas.png";
UiUtils.saveImageWithPrompt(fileName, formulaProxy, formulaProxy); UiUtils.saveImageWithPrompt(fileName, formulaProxy, formulaProxy);
} }

View File

@ -1,5 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.opensr5.Logger;
import com.romraider.Settings; import com.romraider.Settings;
import com.romraider.maps.Scale; import com.romraider.maps.Scale;
import com.romraider.maps.Table; import com.romraider.maps.Table;
@ -257,7 +258,7 @@ public class FuelTunePane {
private DataOutputStream getTuneLogStream() { private DataOutputStream getTuneLogStream() {
if (dos == null) { if (dos == null) {
String fileName = FileLog.DIR + "tune_" + FileLog.getDate() + ".txt"; String fileName = Logger.DIR + "tune_" + Logger.getDate() + ".txt";
try { try {
dos = new DataOutputStream(new FileOutputStream(fileName)); dos = new DataOutputStream(new FileOutputStream(fileName));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {

View File

@ -1,5 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.PaneSettings; import com.rusefi.PaneSettings;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
@ -236,7 +237,7 @@ public class GaugesPanel {
saveImageButton.addActionListener(new ActionListener() { saveImageButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String fileName = FileLog.getDate() + "_gauges.png"; String fileName = Logger.getDate() + "_gauges.png";
UiUtils.saveImageWithPrompt(fileName, content, gauges.panel); UiUtils.saveImageWithPrompt(fileName, content, gauges.panel);
} }

View File

@ -1,6 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.rusefi.FileLog; import com.opensr5.Logger;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
@ -16,7 +16,7 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class MessagesView { public class MessagesView {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(FileLog.DATE_PATTERN); private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(Logger.DATE_PATTERN);
private static final int MAX_SIZE = 50000; private static final int MAX_SIZE = 50000;
private final Style bold; private final Style bold;

View File

@ -7,7 +7,6 @@ import com.rusefi.core.EngineState;
import com.rusefi.io.*; import com.rusefi.io.*;
import com.rusefi.io.tcp.BinaryProtocolServer; import com.rusefi.io.tcp.BinaryProtocolServer;
import com.rusefi.maintenance.VersionChecker; import com.rusefi.maintenance.VersionChecker;
import com.rusefi.ui.GaugesPanel;
import com.rusefi.ui.storage.Node; import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.FrameHelper; import com.rusefi.ui.util.FrameHelper;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
@ -80,7 +79,7 @@ public class MainFrame {
tabbedPane.settingsTab.showContent(); tabbedPane.settingsTab.showContent();
tabbedPane.logsManager.showContent(); tabbedPane.logsManager.showContent();
tabbedPane.fuelTunePane.showContent(); tabbedPane.fuelTunePane.showContent();
new BinaryProtocolServer().start(linkManager); new BinaryProtocolServer(FileLog.LOGGER).start(linkManager);
} }
}); });

View File

@ -1,11 +1,11 @@
package com.rusefi.ui.engine; package com.rusefi.ui.engine;
import com.opensr5.Logger;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.io.LinkManager;
import com.rusefi.ui.*; import com.rusefi.ui.*;
import com.rusefi.ui.config.BitConfigField; import com.rusefi.ui.config.BitConfigField;
import com.rusefi.ui.config.ConfigField; import com.rusefi.ui.config.ConfigField;
@ -272,7 +272,7 @@ public class EngineSnifferPanel {
private void saveImage() { private void saveImage() {
int rpm = RpmModel.getInstance().getValue(); int rpm = RpmModel.getInstance().getValue();
double maf = SensorCentral.getInstance().getValue(Sensor.MAF); double maf = SensorCentral.getInstance().getValue(Sensor.MAF);
String fileName = FileLog.getDate() + "rpm_" + rpm + "_maf_" + maf + ".png"; String fileName = Logger.getDate() + "rpm_" + rpm + "_maf_" + maf + ".png";
UiUtils.saveImageWithPrompt(fileName, mainPanel, imagePanel); UiUtils.saveImageWithPrompt(fileName, mainPanel, imagePanel);
} }

View File

@ -1,8 +1,8 @@
package com.rusefi.ui.logview; package com.rusefi.ui.logview;
import com.opensr5.Logger;
import com.rusefi.ConsoleUI; import com.rusefi.ConsoleUI;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.Launcher;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.file.FileUtils; import com.rusefi.file.FileUtils;
import com.rusefi.ui.ChartRepository; import com.rusefi.ui.ChartRepository;
@ -10,7 +10,6 @@ import com.rusefi.ui.LogDownloader;
import com.rusefi.ui.UIContext; import com.rusefi.ui.UIContext;
import com.rusefi.ui.engine.EngineSnifferPanel; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.io.LinkManager;
import com.rusefi.waves.EngineReport; import com.rusefi.waves.EngineReport;
import javax.swing.*; import javax.swing.*;
@ -22,7 +21,6 @@ import java.awt.event.MouseEvent;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.util.Arrays; import java.util.Arrays;
import java.util.TreeMap;
/** /**
* This tab is the entry point of rusEfi own log browser * This tab is the entry point of rusEfi own log browser
@ -39,7 +37,7 @@ public class LogViewer extends JPanel {
return pathname.getName().contains("MAIN_rfi_report"); return pathname.getName().contains("MAIN_rfi_report");
} }
}; };
public static final String DEFAULT_LOG_LOCATION = FileLog.DIR; public static final String DEFAULT_LOG_LOCATION = Logger.DIR;
private final JLabel folderLabel = new JLabel(); private final JLabel folderLabel = new JLabel();
private final JLabel fileLabel = new JLabel(); private final JLabel fileLabel = new JLabel();
private final DefaultListModel<FileItem> fileListModel = new DefaultListModel<FileItem>(); private final DefaultListModel<FileItem> fileListModel = new DefaultListModel<FileItem>();

View File

@ -16,6 +16,6 @@ class BinaryProtocolServerSandbox {
LinkManager linkManager = new LinkManager(FileLog.LOGGER); LinkManager linkManager = new LinkManager(FileLog.LOGGER);
linkManager.setConnector(LinkConnector.getDetachedConnector(state)); linkManager.setConnector(LinkConnector.getDetachedConnector(state));
new BinaryProtocolServer().start(linkManager); new BinaryProtocolServer(FileLog.LOGGER).start(linkManager);
} }
} }