firing order tool integration
This commit is contained in:
parent
155ff25c22
commit
706b4ca5ef
|
@ -1,15 +1,15 @@
|
|||
/*
|
||||
* @file firing_order.h
|
||||
*
|
||||
* See also FiringOrderTSLogic.java
|
||||
*
|
||||
* @date Jul 20, 2016
|
||||
* @author Andrey Belomutskiy, (c) 2012-2017
|
||||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
*/
|
||||
|
||||
#include "rusefi_enums.h"
|
||||
|
||||
|
||||
#ifndef CONTROLLERS_ALGO_FIRING_ORDER_H_
|
||||
#define CONTROLLERS_ALGO_FIRING_ORDER_H_
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
FO_1 = 0,
|
||||
|
@ -53,6 +53,3 @@ typedef enum {
|
|||
|
||||
Force_4b_firing_order = ENUM_32_BITS,
|
||||
} firing_order_e;
|
||||
|
||||
|
||||
#endif /* CONTROLLERS_ALGO_FIRING_ORDER_H_ */
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
java -jar ../java_console_binary/rusefi_console.jar firing_order controllers/algo/firing_order.h
|
|
@ -15,17 +15,21 @@ public class FiringOrderTSLogic {
|
|||
|
||||
private static final String FIRING_ORDER_PREFIX = "FO_";
|
||||
private static final Map<Integer, String[]> ordinal2order = new HashMap<>();
|
||||
private static int maxOrdinal;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
readFiringOrders();
|
||||
|
||||
for (int i = 2; i <= 12; i++)
|
||||
processId(i);
|
||||
|
||||
invoke("../firmware/controllers/algo/firing_order.h");
|
||||
}
|
||||
|
||||
private static void readFiringOrders() throws IOException {
|
||||
BufferedReader br = new BufferedReader(new FileReader("../firmware/controllers/algo/firing_order.h"));
|
||||
public static void invoke(String fileName) throws IOException {
|
||||
readFiringOrders(fileName);
|
||||
|
||||
for (int i = 2; i <= maxOrdinal; i++)
|
||||
processId(i);
|
||||
}
|
||||
|
||||
private static void readFiringOrders(String fileName) throws IOException {
|
||||
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
@ -50,6 +54,7 @@ public class FiringOrderTSLogic {
|
|||
|
||||
System.out.println("order " + Arrays.toString(order) + ": " + ordinal);
|
||||
|
||||
maxOrdinal = Math.max(ordinal, maxOrdinal);
|
||||
ordinal2order.put(ordinal, order);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import javax.swing.event.ChangeEvent;
|
|||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -55,10 +56,13 @@ public class Launcher {
|
|||
private static final String TAB_INDEX = "main_tab";
|
||||
protected static final String PORT_KEY = "port";
|
||||
protected static final String SPEED_KEY = "speed";
|
||||
|
||||
private static final String TOOL_NAME_COMPILE_FSIO_FILE = "compile_fsio_file";
|
||||
private static final String TOOL_NAME_REBOOT_ECU = "reboot_ecu";
|
||||
private static final String TOOL_NAME_FIRING_ORDER = "firing_order";
|
||||
// todo: rename to something more FSIO-specific? would need to update documentation somewhere
|
||||
private static final String TOOL_NAME_COMPILE = "compile";
|
||||
|
||||
private final String port;
|
||||
// todo: the logic around 'fatalError' could be implemented nicer
|
||||
private String fatalError;
|
||||
|
@ -316,43 +320,32 @@ public class Launcher {
|
|||
*/
|
||||
public static void main(final String[] args) throws Exception {
|
||||
String toolName = args.length == 0 ? null : args[0];
|
||||
|
||||
if (TOOL_NAME_COMPILE_FSIO_FILE.equalsIgnoreCase(toolName)) {
|
||||
/**
|
||||
* re-packaging array which contains input and output file names
|
||||
*/
|
||||
int returnCode = CompileTool.run(Arrays.asList(args).subList(1, args.length));
|
||||
int returnCode = invokeCompileFileTool(args);
|
||||
System.exit(returnCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TOOL_NAME_COMPILE.equals(toolName)) {
|
||||
if (args.length != 2) {
|
||||
System.err.println("input expression parameter expected");
|
||||
System.exit(-1);
|
||||
return;
|
||||
}
|
||||
String input = args[1];
|
||||
System.out.println(DoubleEvaluator.process(input).getPosftfixExpression());
|
||||
invokeCompileExpressionTool(args);
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println("Optional tools: " + Arrays.asList(TOOL_NAME_COMPILE_FSIO_FILE, TOOL_NAME_COMPILE, TOOL_NAME_REBOOT_ECU));
|
||||
|
||||
if (TOOL_NAME_FIRING_ORDER.equals(toolName)) {
|
||||
FiringOrderTSLogic.invoke(args[1]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Optional tools: " + Arrays.asList(TOOL_NAME_COMPILE_FSIO_FILE,
|
||||
TOOL_NAME_COMPILE,
|
||||
TOOL_NAME_REBOOT_ECU,
|
||||
TOOL_NAME_FIRING_ORDER));
|
||||
System.out.println("Starting rusEfi UI console " + CONSOLE_VERSION);
|
||||
|
||||
FileLog.MAIN.start();
|
||||
|
||||
if (TOOL_NAME_REBOOT_ECU.equalsIgnoreCase(toolName)) {
|
||||
String autoDetectedPort = PortDetector.autoDetectPort(null);
|
||||
if (autoDetectedPort == null) {
|
||||
System.err.println("rusEfi not detected");
|
||||
return;
|
||||
}
|
||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke();
|
||||
if (!establishConnection.isConnected())
|
||||
return;
|
||||
IoStream stream = establishConnection.getStream();
|
||||
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(Fields.CMD_REBOOT);
|
||||
stream.sendPacket(commandBytes, FileLog.LOGGER);
|
||||
|
||||
invokeRebootTool();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -368,6 +361,36 @@ public class Launcher {
|
|||
});
|
||||
}
|
||||
|
||||
private static int invokeCompileFileTool(String[] args) throws IOException {
|
||||
/**
|
||||
* re-packaging array which contains input and output file names
|
||||
*/
|
||||
return CompileTool.run(Arrays.asList(args).subList(1, args.length));
|
||||
}
|
||||
|
||||
private static void invokeRebootTool() throws IOException {
|
||||
String autoDetectedPort = PortDetector.autoDetectPort(null);
|
||||
if (autoDetectedPort == null) {
|
||||
System.err.println("rusEfi not detected");
|
||||
return;
|
||||
}
|
||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke();
|
||||
if (!establishConnection.isConnected())
|
||||
return;
|
||||
IoStream stream = establishConnection.getStream();
|
||||
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(Fields.CMD_REBOOT);
|
||||
stream.sendPacket(commandBytes, FileLog.LOGGER);
|
||||
}
|
||||
|
||||
private static void invokeCompileExpressionTool(String[] args) {
|
||||
if (args.length != 2) {
|
||||
System.err.println("input expression parameter expected");
|
||||
System.exit(-1);
|
||||
}
|
||||
String expression = args[1];
|
||||
System.out.println(DoubleEvaluator.process(expression).getPosftfixExpression());
|
||||
}
|
||||
|
||||
private static void awtCode(String[] args) {
|
||||
if (JustOneInstance.isAlreadyRunning()) {
|
||||
int result = JOptionPane.showConfirmDialog(null, "Looks like another instance is already running. Do you really want to start another instance?",
|
||||
|
|
Loading…
Reference in New Issue