MAYBE this would even work?
This commit is contained in:
parent
b71403de7a
commit
bd8dd3f7a7
|
@ -13,6 +13,7 @@ import java.util.*;
|
||||||
public class IniFileModel {
|
public class IniFileModel {
|
||||||
public static final String RUSEFI_INI_PREFIX = "rusefi";
|
public static final String RUSEFI_INI_PREFIX = "rusefi";
|
||||||
public static final String RUSEFI_INI_SUFFIX = ".ini";
|
public static final String RUSEFI_INI_SUFFIX = ".ini";
|
||||||
|
public static final String INI_FILE_PATH = System.getProperty("ini_file_path", "..");
|
||||||
private static final String SECTION_PAGE = "page";
|
private static final String SECTION_PAGE = "page";
|
||||||
private static final String FIELD_TYPE_SCALAR = "scalar";
|
private static final String FIELD_TYPE_SCALAR = "scalar";
|
||||||
private static final String FIELD_TYPE_STRING = "string";
|
private static final String FIELD_TYPE_STRING = "string";
|
||||||
|
@ -31,7 +32,7 @@ public class IniFileModel {
|
||||||
public Map<String, String> tooltips = new TreeMap<>();
|
public Map<String, String> tooltips = new TreeMap<>();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(IniFileModel.getInstance("..").dialogs);
|
System.out.println(IniFileModel.getInstance().dialogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInSettingContextHelp = false;
|
private boolean isInSettingContextHelp = false;
|
||||||
|
@ -200,10 +201,10 @@ public class IniFileModel {
|
||||||
DIALOG
|
DIALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized IniFileModel getInstance(String iniFilePath) {
|
public static synchronized IniFileModel getInstance() {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
INSTANCE = new IniFileModel();
|
INSTANCE = new IniFileModel();
|
||||||
INSTANCE.readIniFile(iniFilePath);
|
INSTANCE.readIniFile(INI_FILE_PATH);
|
||||||
}
|
}
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static final int CONSOLE_VERSION = 20200520;
|
public static final int CONSOLE_VERSION = 20200520;
|
||||||
public static final String INI_FILE_PATH = System.getProperty("ini_file_path", "..");
|
|
||||||
public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", "..");
|
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 TOOLS_PATH = System.getProperty("tools_path", ".");
|
||||||
public static final String TAB_INDEX = "main_tab";
|
public static final String TAB_INDEX = "main_tab";
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.rusefi.tools;
|
||||||
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.opensr5.ini.IniFileModel;
|
import com.opensr5.ini.IniFileModel;
|
||||||
import com.opensr5.ini.field.IniField;
|
|
||||||
import com.opensr5.io.ConfigurationImageFile;
|
import com.opensr5.io.ConfigurationImageFile;
|
||||||
import com.rusefi.*;
|
import com.rusefi.*;
|
||||||
import com.rusefi.autodetect.PortDetector;
|
import com.rusefi.autodetect.PortDetector;
|
||||||
|
@ -16,9 +15,9 @@ import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||||
import com.rusefi.maintenance.ExecHelper;
|
import com.rusefi.maintenance.ExecHelper;
|
||||||
import com.rusefi.tools.online.Online;
|
import com.rusefi.tools.online.Online;
|
||||||
import com.rusefi.tune.xml.Constant;
|
|
||||||
import com.rusefi.tune.xml.Msq;
|
import com.rusefi.tune.xml.Msq;
|
||||||
import com.rusefi.xml.XmlUtil;
|
import com.rusefi.xml.XmlUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -204,7 +203,6 @@ public class ConsoleTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void convertBinaryToXml(String[] args) throws IOException, JAXBException {
|
private static void convertBinaryToXml(String[] args) throws IOException, JAXBException {
|
||||||
Msq tune = new Msq();
|
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
System.err.println("Binary file input expected");
|
System.err.println("Binary file input expected");
|
||||||
|
@ -214,28 +212,18 @@ public class ConsoleTools {
|
||||||
ConfigurationImage image = ConfigurationImageFile.readFromFile(inputBinaryFileName);
|
ConfigurationImage image = ConfigurationImageFile.readFromFile(inputBinaryFileName);
|
||||||
System.out.println("Got " + image.getSize() + " of configuration from " + inputBinaryFileName);
|
System.out.println("Got " + image.getSize() + " of configuration from " + inputBinaryFileName);
|
||||||
|
|
||||||
IniFileModel ini = IniFileModel.getInstance(Launcher.INI_FILE_PATH);
|
Msq tune = toMsq(image);
|
||||||
|
XmlUtil.writeXml(tune, Msq.class, 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())
|
for (String key : ini.allIniFields.keySet())
|
||||||
handle(tune, ini, key, image);
|
tune.loadConstant(ini, key, image);
|
||||||
|
return tune;
|
||||||
// handle(tune, ini, "injector_battLagCorrBins");
|
|
||||||
|
|
||||||
String outputXmlFile = "output.msq";
|
|
||||||
XmlUtil.writeXml(tune, Msq.class, outputXmlFile);
|
|
||||||
Online.upload(new File(outputXmlFile), "x");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handle(Msq tune, IniFileModel ini, String key, ConfigurationImage image) {
|
|
||||||
IniField field = ini.allIniFields.get(key);
|
|
||||||
tune.getPage().constant.add(prepareConstant(field, image));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Constant prepareConstant(IniField field, ConfigurationImage image) {
|
|
||||||
|
|
||||||
String value = field.getValue(image);
|
|
||||||
|
|
||||||
return new Constant(field.getName(), field.getUnits(), value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConsoleTool {
|
interface ConsoleTool {
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package com.rusefi.tune.xml;
|
package com.rusefi.tune.xml;
|
||||||
|
|
||||||
|
import com.opensr5.ConfigurationImage;
|
||||||
|
import com.opensr5.ini.IniFileModel;
|
||||||
|
import com.opensr5.ini.field.IniField;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
public class Msq {
|
public class Msq {
|
||||||
|
public static final String outputXmlFileName = "output.msq";
|
||||||
|
|
||||||
private final Page page = new Page();
|
private final Page page = new Page();
|
||||||
|
|
||||||
private final VersionInfo versionInfo;
|
private final VersionInfo versionInfo;
|
||||||
|
@ -14,6 +20,12 @@ public class Msq {
|
||||||
versionInfo = new VersionInfo("rusEFI+2020");
|
versionInfo = new VersionInfo("rusEFI+2020");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadConstant(IniFileModel ini, String key, ConfigurationImage image) {
|
||||||
|
IniField field = ini.allIniFields.get(key);
|
||||||
|
String value = field.getValue(image);
|
||||||
|
getPage().constant.add(new Constant(field.getName(), field.getUnits(), value));
|
||||||
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
public String getXmlns() {
|
public String getXmlns() {
|
||||||
return "http://www.msefi.com/:msq";
|
return "http://www.msefi.com/:msq";
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package com.rusefi.ui;
|
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 org.putgemin.VerticalFlowLayout;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
|
@ -30,6 +38,23 @@ public class OnlineTab {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
content.add(save);
|
content.add(save);
|
||||||
|
|
||||||
|
|
||||||
|
JButton upload = new JButton("Upload");
|
||||||
|
upload.addActionListener(new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Msq tune = ConsoleTools.toMsq(LinkManager.connector.getBinaryProtocol().getControllerConfiguration());
|
||||||
|
try {
|
||||||
|
XmlUtil.writeXml(tune, Msq.class, Msq.outputXmlFileName);
|
||||||
|
// todo: network upload should not happen on UI thread
|
||||||
|
Online.upload(new File(Msq.outputXmlFileName), textField.getText());
|
||||||
|
} catch (JAXBException | IOException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
content.add(upload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getContent() {
|
public JPanel getContent() {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.rusefi.ui.console;
|
||||||
|
|
||||||
import com.opensr5.ini.DialogModel;
|
import com.opensr5.ini.DialogModel;
|
||||||
import com.opensr5.ini.IniFileModel;
|
import com.opensr5.ini.IniFileModel;
|
||||||
import com.rusefi.Launcher;
|
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
import com.rusefi.config.FieldType;
|
import com.rusefi.config.FieldType;
|
||||||
import com.rusefi.config.FieldsMap;
|
import com.rusefi.config.FieldsMap;
|
||||||
|
@ -40,7 +39,7 @@ public class SettingsTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showContent() {
|
public void showContent() {
|
||||||
final Map<String, DialogModel> dialogs = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getDialogs();
|
final Map<String, DialogModel> dialogs = IniFileModel.getInstance().getDialogs();
|
||||||
if (dialogs.isEmpty()) {
|
if (dialogs.isEmpty()) {
|
||||||
content.removeAll();
|
content.removeAll();
|
||||||
content.add(new JLabel("Meta data not found: " + RUSEFI_INI_PREFIX + "*" + RUSEFI_INI_SUFFIX));
|
content.add(new JLabel("Meta data not found: " + RUSEFI_INI_PREFIX + "*" + RUSEFI_INI_SUFFIX));
|
||||||
|
@ -132,7 +131,7 @@ public class SettingsTab {
|
||||||
dialog.setText(name);
|
dialog.setText(name);
|
||||||
dialogBody.removeAll();
|
dialogBody.removeAll();
|
||||||
|
|
||||||
DialogModel m = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getDialogs().get(name);
|
DialogModel m = IniFileModel.getInstance().getDialogs().get(name);
|
||||||
|
|
||||||
dialogBody.setLayout(new GridLayout(m.getFields().size(), 1));
|
dialogBody.setLayout(new GridLayout(m.getFields().size(), 1));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rusefi.ui.livedocs;
|
package com.rusefi.ui.livedocs;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.Launcher;
|
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.config.Field;
|
import com.rusefi.config.Field;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
|
@ -163,7 +162,7 @@ public class LiveDocPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTooltipText(String configurationFieldName) {
|
private static String getTooltipText(String configurationFieldName) {
|
||||||
DialogModel.Field dialogField = IniFileModel.getInstance(Launcher.INI_FILE_PATH).getField(configurationFieldName);
|
DialogModel.Field dialogField = IniFileModel.getInstance().getField(configurationFieldName);
|
||||||
if (dialogField == null) {
|
if (dialogField == null) {
|
||||||
return "Configuration " + configurationFieldName;
|
return "Configuration " + configurationFieldName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue