TS plugin progress

This commit is contained in:
rusefi 2020-06-03 17:22:46 -04:00
parent a96fb97a18
commit 8bfb2f5d89
8 changed files with 61 additions and 8 deletions

View File

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

View File

@ -9,5 +9,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="junit" level="project" />
<orderEntry type="library" exported="" name="annotations" level="project" />
<orderEntry type="module" module-name="models" exported="" />
</component>
</module>

View File

@ -17,6 +17,7 @@ import com.rusefi.io.*;
import com.rusefi.tune.xml.Msq;
import com.rusefi.ui.livedocs.LiveDocsRegistry;
import jssc.SerialPortException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.EOFException;
@ -76,7 +77,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
private boolean isCompositeLoggerEnabled;
private long lastLowRpmTime = System.currentTimeMillis();
private List<StreamFile> compositeLogs = Arrays.asList(new VcdStreamFile(), new TSHighSpeedLog());
private List<StreamFile> compositeLogs = Arrays.asList(new VcdStreamFile(getFileName("rusEFI_trigger_log_")), new TSHighSpeedLog(getFileName("rusEFI_trigger_log_")));
public boolean isClosed;
/**
@ -115,6 +116,11 @@ public class BinaryProtocol implements BinaryProtocolCommands {
}
}
@NotNull
public static String getFileName(String prefix) {
return FileLog.DIR + prefix + FileLog.getDate() + ".csv";
}
public void doSend(final String command, boolean fireEvent) throws InterruptedException {
FileLog.MAIN.logLine("Sending [" + command + "]");
if (fireEvent && LinkManager.LOG_LEVEL.isDebugEnabled()) {

View File

@ -7,6 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="inifile" />
<orderEntry type="module" module-name="logging" />
</component>
</module>

View File

@ -1,9 +1,7 @@
package com.rusefi.binaryprotocol;
import com.rusefi.FileLog;
import com.rusefi.composite.CompositeEvent;
import com.rusefi.rusEFIVersion;
import sun.misc.Launcher;
import java.io.FileWriter;
import java.io.IOException;
@ -11,8 +9,13 @@ import java.io.Writer;
import java.util.List;
public class TSHighSpeedLog extends StreamFile {
private final String fileName;
private int prevTime = 0;
public TSHighSpeedLog(String fileName) {
this.fileName = fileName;
}
private static void writeHeader(Writer writer) throws IOException {
writer.write("#Firmware: console" + rusEFIVersion.CONSOLE_VERSION + " firmware " + rusEFIVersion.firmwareVersion.get() + "\n");
writer.write("PriLevel,SecLevel,Trigger,Sync,Time,ToothTime\n" +
@ -23,7 +26,6 @@ public class TSHighSpeedLog extends StreamFile {
void append(List<CompositeEvent> events) {
try {
if (writer == null) {
String fileName = FileLog.DIR + "rusEFI_trigger_log_" + FileLog.getDate() + ".csv";
writer = new FileWriter(fileName);
writeHeader(writer);
}

View File

@ -1,6 +1,5 @@
package com.rusefi.binaryprotocol;
import com.rusefi.FileLog;
import com.rusefi.composite.CompositeEvent;
import java.io.FileWriter;
@ -21,6 +20,11 @@ public class VcdStreamFile extends StreamFile {
private static final String TAG_SYNC = "y";
private static final String TAG_COIL = "c";
private static final String TAG_INJ = "i";
private final String fileName;
public VcdStreamFile(String fileName) {
this.fileName = fileName;
}
private static void writeHeader(Writer writer, Date date) throws IOException {
writer.write("$date\n");
@ -70,7 +74,6 @@ public class VcdStreamFile extends StreamFile {
public void append(List<CompositeEvent> events) {
try {
if (writer == null) {
String fileName = FileLog.DIR + "rusEFI_trigger_log_" + FileLog.getDate() + ".vcd";
writer = new FileWriter(fileName);
writeHeader(writer, new Date());
}

View File

@ -5,11 +5,15 @@ import com.efiAnalytics.plugin.ecu.ControllerAccess;
import com.efiAnalytics.plugin.ecu.ControllerException;
import com.efiAnalytics.plugin.ecu.ControllerParameter;
import com.efiAnalytics.plugin.ecu.servers.ControllerParameterServer;
import com.rusefi.config.Field;
import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq;
import com.rusefi.ui.util.Misc;
import javax.swing.*;
import javax.xml.bind.JAXBException;
import java.awt.*;
import java.io.IOException;
public class TsPlugin implements ApplicationPlugin {
private ControllerAccess controllerAccess;
@ -46,6 +50,8 @@ public class TsPlugin implements ApplicationPlugin {
System.out.println("EcuConfigurationName " + config);
}
Msq msq = new Msq();
String configurationName = getConfigurationName();
ControllerParameterServer controllerParameterServer = controllerAccess.getControllerParameterServer();
String[] parameterNames = controllerParameterServer.getParameterNames(configurationName);
@ -53,15 +59,49 @@ public class TsPlugin implements ApplicationPlugin {
for (String parameterName : parameterNames) {
ControllerParameter cp = controllerParameterServer.getControllerParameter(configurationName, parameterName);
String type = cp.getParamClass();
String value;
if (ControllerParameter.PARAM_CLASS_BITS.equals(type)) {
value = cp.getStringValue();
System.out.println("bits " + parameterName + ": " + value);
} else if (ControllerParameter.PARAM_CLASS_SCALAR.equals(type)) {
value = cp.getStringValue();
System.out.println("scalar " + parameterName + ": " + cp.getScalarValue() + "/" + cp.getStringValue());
//new Constant(parameterName, cp.getUnits())
} else if (ControllerParameter.PARAM_CLASS_ARRAY.equals(type)) {
value = getArrayValue(cp.getArrayValues());
} else {
System.out.println("name=" + parameterName + " type " + type + "/" + cp.getStringValue());
value = cp.getStringValue();
}
msq.getPage().constant.add(new Constant(parameterName, cp.getUnits(), value));
}
try {
msq.writeXmlFile("plugin.xml");
} catch (JAXBException | IOException e) {
System.out.println("Error writing XML: " + e);
}
} catch (ControllerException e) {
e.printStackTrace();
}
}
private String getArrayValue(double[][] arrayValues) {
StringBuilder sb = new StringBuilder();
for (int rowIndex = 0; rowIndex < arrayValues.length; rowIndex++) {
double[] array = arrayValues[rowIndex];
sb.append("\n\t");
for (int colIndex = 0; colIndex < array.length; colIndex++) {
double value = array[colIndex];
sb.append(' ');
sb.append(value);
}
}
sb.append("\n");
}
public static String getConfigurationName() {
return ControllerAccess.getInstance().getEcuConfigurationNames()[0];
}