console auto-save MSQ configuration
This commit is contained in:
parent
db2e6ec60f
commit
780a613ba5
|
@ -12,6 +12,7 @@ import com.rusefi.core.Pair;
|
|||
import com.rusefi.core.Sensor;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.*;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
import com.rusefi.ui.livedocs.LiveDocsRegistry;
|
||||
import jssc.SerialPortException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -43,6 +44,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
private static final String USE_PLAIN_PROTOCOL_PROPERTY = "protocol.plain";
|
||||
private static final int TEXT_PULL_PERIOD = 100;
|
||||
private static final String CONFIGURATION_RUSEFI_BINARY = "current_configuration.rusefi_binary";
|
||||
private static final String CONFIGURATION_RUSEFI_XML = "current_configuration.msq";
|
||||
/**
|
||||
* This properly allows to switch to non-CRC32 mode
|
||||
* todo: finish this feature, assuming we even need it.
|
||||
|
@ -264,7 +266,9 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
}
|
||||
try {
|
||||
ConfigurationImageFile.saveToFile(image, CONFIGURATION_RUSEFI_BINARY);
|
||||
} catch (IOException e) {
|
||||
Msq tune = Msq.toMsq(image);
|
||||
tune.writeXmlFile(CONFIGURATION_RUSEFI_XML);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Ignoring " + e);
|
||||
}
|
||||
return image;
|
||||
|
|
|
@ -3,10 +3,14 @@ package com.rusefi.tune.xml;
|
|||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.xml.XmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.IOException;
|
||||
|
||||
@XmlRootElement
|
||||
public class Msq {
|
||||
|
@ -20,6 +24,19 @@ public class Msq {
|
|||
versionInfo = new VersionInfo("rusEFI+2020");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Msq toMsq(ConfigurationImage image) {
|
||||
IniFileModel ini = IniFileModel.getInstance();
|
||||
Msq tune = new Msq();
|
||||
for (String key : ini.allIniFields.keySet())
|
||||
tune.loadConstant(ini, key, image);
|
||||
return tune;
|
||||
}
|
||||
|
||||
public void writeXmlFile(String outputXmlFileName) throws JAXBException, IOException {
|
||||
XmlUtil.writeXml(this, Msq.class, outputXmlFileName);
|
||||
}
|
||||
|
||||
public void loadConstant(IniFileModel ini, String key, ConfigurationImage image) {
|
||||
IniField field = ini.allIniFields.get(key);
|
||||
String value = field.getValue(image);
|
|
@ -42,7 +42,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see EngineSnifferPanel
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20200521;
|
||||
public static final int CONSOLE_VERSION = 20200522;
|
||||
public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", "..");
|
||||
public static final String TOOLS_PATH = System.getProperty("tools_path", ".");
|
||||
public static final String TAB_INDEX = "main_tab";
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.rusefi.tools;
|
|||
|
||||
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.io.ConfigurationImageFile;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.autodetect.PortDetector;
|
||||
|
@ -16,8 +15,6 @@ import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
|||
import com.rusefi.maintenance.ExecHelper;
|
||||
import com.rusefi.tools.online.Online;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
import com.rusefi.xml.XmlUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
@ -212,20 +209,11 @@ public class ConsoleTools {
|
|||
ConfigurationImage image = ConfigurationImageFile.readFromFile(inputBinaryFileName);
|
||||
System.out.println("Got " + image.getSize() + " of configuration from " + inputBinaryFileName);
|
||||
|
||||
Msq tune = toMsq(image);
|
||||
XmlUtil.writeXml(tune, Msq.class, Msq.outputXmlFileName);
|
||||
Msq tune = Msq.toMsq(image);
|
||||
tune.writeXmlFile(Msq.outputXmlFileName);
|
||||
Online.upload(new File(Msq.outputXmlFileName), "x");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Msq toMsq(ConfigurationImage image) {
|
||||
IniFileModel ini = IniFileModel.getInstance();
|
||||
Msq tune = new Msq();
|
||||
for (String key : ini.allIniFields.keySet())
|
||||
tune.loadConstant(ini, key, image);
|
||||
return tune;
|
||||
}
|
||||
|
||||
interface ConsoleTool {
|
||||
void runTool(String args[]) throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.tools.ConsoleTools;
|
||||
import com.rusefi.tools.online.Online;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
import com.rusefi.xml.XmlUtil;
|
||||
import org.putgemin.VerticalFlowLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -44,9 +42,9 @@ public class OnlineTab {
|
|||
upload.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Msq tune = ConsoleTools.toMsq(LinkManager.connector.getBinaryProtocol().getControllerConfiguration());
|
||||
Msq tune = Msq.toMsq(LinkManager.connector.getBinaryProtocol().getControllerConfiguration());
|
||||
try {
|
||||
XmlUtil.writeXml(tune, Msq.class, Msq.outputXmlFileName);
|
||||
tune.writeXmlFile(Msq.outputXmlFileName);
|
||||
// todo: network upload should not happen on UI thread
|
||||
Online.upload(new File(Msq.outputXmlFileName), textField.getText());
|
||||
} catch (JAXBException | IOException ex) {
|
||||
|
|
Loading…
Reference in New Issue