mirror of https://github.com/rusefi/RomRaider.git
updated ramtune test app
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@640 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
f767a98b7e
commit
d9c053ba87
|
@ -2,11 +2,13 @@ package enginuity.ramtune.test;
|
|||
|
||||
import enginuity.Settings;
|
||||
import enginuity.io.port.SerialPortRefresher;
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.io.protocol.SSMProtocol;
|
||||
import enginuity.logger.ecu.ui.SerialPortComboBox;
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.EcuInitCommand;
|
||||
import enginuity.ramtune.test.command.ReadCommand;
|
||||
import enginuity.ramtune.test.command.WriteCommand;
|
||||
import enginuity.ramtune.test.command.generator.CommandGenerator;
|
||||
import enginuity.ramtune.test.command.generator.EcuInitCommandGenerator;
|
||||
import enginuity.ramtune.test.command.generator.ReadCommandGenerator;
|
||||
import enginuity.ramtune.test.command.generator.WriteCommandGenerator;
|
||||
import enginuity.swing.LookAndFeelManager;
|
||||
import static enginuity.util.ThreadUtil.runAsDaemon;
|
||||
import static enginuity.util.ThreadUtil.sleep;
|
||||
|
@ -52,10 +54,11 @@ import java.io.Writer;
|
|||
* It borrows some functionality from the logger which should be rewritten/removed before being released!!
|
||||
*/
|
||||
public final class RamTuneTestApp extends JFrame implements WindowListener {
|
||||
private Settings settings = new Settings();
|
||||
private SerialPortComboBox portsComboBox = new SerialPortComboBox(settings);
|
||||
private JLabel messageLabel = new JLabel();
|
||||
private JLabel connectionStatusLabel = new JLabel();
|
||||
private final Protocol protocol = new SSMProtocol();
|
||||
private final Settings settings = new Settings();
|
||||
private final SerialPortComboBox portsComboBox = new SerialPortComboBox(settings);
|
||||
private final JLabel messageLabel = new JLabel();
|
||||
private final JLabel connectionStatusLabel = new JLabel();
|
||||
|
||||
public RamTuneTestApp(String title) {
|
||||
super(title);
|
||||
|
@ -168,7 +171,8 @@ public final class RamTuneTestApp extends JFrame implements WindowListener {
|
|||
}
|
||||
|
||||
private JComboBox buildCommandComboBox() {
|
||||
return new JComboBox(new Command[] {new EcuInitCommand(), new ReadCommand(), new WriteCommand()});
|
||||
return new JComboBox(new CommandGenerator[] {new EcuInitCommandGenerator(protocol),
|
||||
new ReadCommandGenerator(protocol), new WriteCommandGenerator(protocol)});
|
||||
}
|
||||
|
||||
private Component buildOutputPanel() {
|
||||
|
|
|
@ -2,5 +2,5 @@ package enginuity.ramtune.test.command;
|
|||
|
||||
public interface Command {
|
||||
|
||||
byte[] constructCommandRequest(byte[] address, byte[] data);
|
||||
byte[] getBytes();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
||||
public final class CommandImpl implements Command {
|
||||
private final byte[] bytes;
|
||||
|
||||
public CommandImpl(byte[] bytes) {
|
||||
checkNotNull(bytes, "bytes");
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
public interface CommandResult {
|
||||
|
||||
byte[] getResult();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
||||
public final class CommandResultImpl implements CommandResult {
|
||||
private final byte[] result;
|
||||
|
||||
public CommandResultImpl(byte[] result) {
|
||||
checkNotNull(result, "result");
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public byte[] getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.io.protocol.SSMProtocol;
|
||||
|
||||
public final class EcuInitCommand implements Command {
|
||||
private final Protocol protocol = new SSMProtocol();
|
||||
|
||||
public byte[] constructCommandRequest(byte[] address, byte[] data) {
|
||||
return protocol.constructEcuInitRequest();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ECU Init";
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.io.protocol.SSMProtocol;
|
||||
|
||||
public final class ReadCommand implements Command {
|
||||
private final Protocol protocol = new SSMProtocol();
|
||||
|
||||
public byte[] constructCommandRequest(byte[] address, byte[] data) {
|
||||
return protocol.constructReadAddressRequest(new byte[][] {address});
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Read";
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package enginuity.ramtune.test.command;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.io.protocol.SSMProtocol;
|
||||
|
||||
public final class WriteCommand implements Command {
|
||||
private final Protocol protocol = new SSMProtocol();
|
||||
|
||||
public byte[] constructCommandRequest(byte[] address, byte[] data) {
|
||||
return protocol.constructWriteMemoryRequest(address, data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Write";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package enginuity.ramtune.test.command.executor;
|
||||
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.CommandResult;
|
||||
|
||||
public interface CommandExecutor {
|
||||
|
||||
CommandResult executeCommand(Command command);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package enginuity.ramtune.test.command.executor;
|
||||
|
||||
import enginuity.io.connection.ConnectionProperties;
|
||||
import enginuity.io.connection.EcuConnection;
|
||||
import enginuity.io.connection.EcuConnectionImpl;
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.CommandResult;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
|
||||
|
||||
public final class CommandExecutorImpl implements CommandExecutor {
|
||||
private final EcuConnection ecuConnection;
|
||||
|
||||
public CommandExecutorImpl(ConnectionProperties connectionProperties, String port) {
|
||||
checkNotNull(connectionProperties);
|
||||
checkNotNullOrEmpty(port, "port");
|
||||
this.ecuConnection = new EcuConnectionImpl(connectionProperties, port);
|
||||
}
|
||||
|
||||
public CommandResult executeCommand(Command command) {
|
||||
ecuConnection.send(command.getBytes());
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package enginuity.ramtune.test.command.generator;
|
||||
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
|
||||
public interface CommandGenerator {
|
||||
|
||||
Command createCommand(byte[] address, byte[] data);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package enginuity.ramtune.test.command.generator;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.CommandImpl;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
||||
public final class EcuInitCommandGenerator implements CommandGenerator {
|
||||
private final Protocol protocol;
|
||||
|
||||
public EcuInitCommandGenerator(Protocol protocol) {
|
||||
checkNotNull(protocol, "protocol");
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public Command createCommand(byte[] address, byte[] data) {
|
||||
return new CommandImpl(protocol.constructEcuInitRequest());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ECU Init";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package enginuity.ramtune.test.command.generator;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.CommandImpl;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
|
||||
|
||||
public final class ReadCommandGenerator implements CommandGenerator {
|
||||
private final Protocol protocol;
|
||||
|
||||
public ReadCommandGenerator(Protocol protocol) {
|
||||
checkNotNull(protocol, "protocol");
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public Command createCommand(byte[] address, byte[] data) {
|
||||
checkNotNullOrEmpty(address, "address");
|
||||
return new CommandImpl(protocol.constructReadAddressRequest(new byte[][] {address}));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Read";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package enginuity.ramtune.test.command.generator;
|
||||
|
||||
import enginuity.io.protocol.Protocol;
|
||||
import enginuity.ramtune.test.command.Command;
|
||||
import enginuity.ramtune.test.command.CommandImpl;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
|
||||
|
||||
public final class WriteCommandGenerator implements CommandGenerator {
|
||||
private final Protocol protocol;
|
||||
|
||||
public WriteCommandGenerator(Protocol protocol) {
|
||||
checkNotNull(protocol, "protocol");
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public Command createCommand(byte[] address, byte[] data) {
|
||||
checkNotNullOrEmpty(address, "address");
|
||||
checkNotNullOrEmpty(data, "data");
|
||||
return new CommandImpl(protocol.constructWriteMemoryRequest(address, data));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Write";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue