Console should get much smarter around compatibility with older units #6845
only:progress
This commit is contained in:
parent
2a71cd9c1b
commit
234cdca08a
|
@ -15,7 +15,7 @@ task simulatorFunctionalTestLauncherWithSimulator(type: Exec) {
|
|||
group = "Execution"
|
||||
description = "Run the main class with ExecTask"
|
||||
workingDir = rootProject.projectDir
|
||||
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), "com.rusefi.SimulatorFunctionalTestLauncher", "start"
|
||||
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), "com.rusefi.SimulatorFunctionalTestLauncher", "../firmware/tunerstudio/generated/rusefi_f407-discovery.ini", "start"
|
||||
}
|
||||
|
||||
task simulatorFunctionalTestLauncherAssumungSimulatorWasStartedExternally(type: Exec) {
|
||||
|
@ -23,5 +23,5 @@ task simulatorFunctionalTestLauncherAssumungSimulatorWasStartedExternally(type:
|
|||
group = "Execution"
|
||||
description = "Run the main class with ExecTask"
|
||||
workingDir = rootProject.projectDir
|
||||
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), "com.rusefi.SimulatorFunctionalTestLauncher"
|
||||
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), "com.rusefi.SimulatorFunctionalTestLauncher", "../firmware/tunerstudio/generated/rusefi_f407-discovery.ini"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.simulator.SimulatorFunctionalTest;
|
||||
|
||||
|
@ -16,7 +18,10 @@ public class SimulatorFunctionalTestLauncher {
|
|||
e.printStackTrace();
|
||||
System.exit(66);
|
||||
});
|
||||
boolean startSimulator = args.length == 1 && args[0].equalsIgnoreCase("start");
|
||||
String iniFileName = args[0];
|
||||
IniFileModelImpl ini = new IniFileModelImpl().readIniFile(iniFileName);
|
||||
BinaryProtocol.iniFileProvider = signature -> ini;
|
||||
boolean startSimulator = args.length > 1 && args[1].equalsIgnoreCase("start");
|
||||
|
||||
// if (startSimulator) {
|
||||
// buildSimulator();
|
||||
|
|
|
@ -1,76 +1,17 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
public interface IniFileMetaInfo {
|
||||
int getTotalSize();
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 3/1/2017
|
||||
*/
|
||||
public class IniFileMetaInfo {
|
||||
public static final int DEFAULT_BLOCKING_FACTOR = 16000;
|
||||
private final int nPages;
|
||||
private final String signature;
|
||||
private final List<String> pageReadCommands;
|
||||
int getnPages();
|
||||
|
||||
private int totalSize;
|
||||
private final List<Integer> pageSizes = new ArrayList<>();
|
||||
private int ochBlockSize;
|
||||
int getBlockingFactor();
|
||||
|
||||
/**
|
||||
* read maximum chunk size
|
||||
*/
|
||||
private final int blockingFactor; // todo: this is probably an optional property, come up with some default
|
||||
int getOchBlockSize();
|
||||
|
||||
public IniFileMetaInfo(RawIniFile file) {
|
||||
String getSignature();
|
||||
|
||||
nPages = file.getSimpleIntegerProperty("nPages", 1);
|
||||
ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize");
|
||||
String getPageReadCommand(int pageIndex);
|
||||
|
||||
blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR);
|
||||
|
||||
signature = file.getValues("signature").get(0);
|
||||
|
||||
List<String> individualPageSizes = file.getValues("pageSize");
|
||||
|
||||
if (individualPageSizes.size() != nPages)
|
||||
throw new IllegalStateException("Unexpected individual sizes: " + individualPageSizes);
|
||||
|
||||
for (String value : individualPageSizes) {
|
||||
int size = Integer.parseInt(value);
|
||||
pageSizes.add(size);
|
||||
totalSize += size;
|
||||
}
|
||||
|
||||
pageReadCommands = file.getValues("pageReadCommand");
|
||||
}
|
||||
|
||||
public int getnPages() {
|
||||
return nPages;
|
||||
}
|
||||
|
||||
public int getOchBlockSize() {
|
||||
return ochBlockSize;
|
||||
}
|
||||
|
||||
public int getBlockingFactor() {
|
||||
return blockingFactor;
|
||||
}
|
||||
|
||||
// also known as 'pageSize'
|
||||
public int getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String getPageReadCommand(int pageIndex) {
|
||||
return pageReadCommands.get(pageIndex);
|
||||
}
|
||||
|
||||
public int getPageSize(int pageIndex) {
|
||||
return pageSizes.get(pageIndex);
|
||||
}
|
||||
int getPageSize(int pageIndex);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 3/1/2017
|
||||
*/
|
||||
public class IniFileMetaInfoImpl implements IniFileMetaInfo {
|
||||
public static final int DEFAULT_BLOCKING_FACTOR = 16000;
|
||||
private final int nPages;
|
||||
private final String signature;
|
||||
private final List<String> pageReadCommands;
|
||||
|
||||
private int totalSize;
|
||||
private final List<Integer> pageSizes = new ArrayList<>();
|
||||
private int ochBlockSize;
|
||||
|
||||
/**
|
||||
* read maximum chunk size
|
||||
*/
|
||||
private final int blockingFactor; // todo: this is probably an optional property, come up with some default
|
||||
|
||||
public IniFileMetaInfoImpl(RawIniFile file) {
|
||||
|
||||
nPages = file.getSimpleIntegerProperty("nPages", 1);
|
||||
ochBlockSize = file.getSimpleIntegerProperty("ochBlockSize");
|
||||
|
||||
blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR);
|
||||
|
||||
signature = file.getValues("signature").get(0);
|
||||
|
||||
List<String> individualPageSizes = file.getValues("pageSize");
|
||||
|
||||
if (individualPageSizes.size() != nPages)
|
||||
throw new IllegalStateException("Unexpected individual sizes: " + individualPageSizes);
|
||||
|
||||
for (String value : individualPageSizes) {
|
||||
int size = Integer.parseInt(value);
|
||||
pageSizes.add(size);
|
||||
totalSize += size;
|
||||
}
|
||||
|
||||
pageReadCommands = file.getValues("pageReadCommand");
|
||||
}
|
||||
|
||||
public int getnPages() {
|
||||
return nPages;
|
||||
}
|
||||
|
||||
public int getOchBlockSize() {
|
||||
return ochBlockSize;
|
||||
}
|
||||
|
||||
public int getBlockingFactor() {
|
||||
return blockingFactor;
|
||||
}
|
||||
|
||||
// also known as 'pageSize'
|
||||
public int getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPageReadCommand(int pageIndex) {
|
||||
return pageReadCommands.get(pageIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageSize(int pageIndex) {
|
||||
return pageSizes.get(pageIndex);
|
||||
}
|
||||
}
|
|
@ -1,318 +1,31 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ini.field.*;
|
||||
import com.rusefi.core.FindFileHelper;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 12/23/2015.
|
||||
*/
|
||||
public class IniFileModel {
|
||||
private static final Logging log = Logging.getLogging(IniFileModel.class);
|
||||
public static final String RUSEFI_INI_PREFIX = "rusefi";
|
||||
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 FIELD_TYPE_SCALAR = "scalar";
|
||||
public static final String FIELD_TYPE_STRING = "string";
|
||||
private static final String FIELD_TYPE_ARRAY = "array";
|
||||
private static final String FIELD_TYPE_BITS = "bits";
|
||||
public interface IniFileModel {
|
||||
IniFileModelImpl findAndReadIniFile(String iniFilePath);
|
||||
|
||||
public Map<String, List<String>> defines = new TreeMap<>();
|
||||
Map<String, List<String>> getDefines();
|
||||
|
||||
private static IniFileModel INSTANCE;
|
||||
private String dialogId;
|
||||
private String dialogUiName;
|
||||
private final Map<String, DialogModel> dialogs = new TreeMap<>();
|
||||
// this is only used while reading model - TODO extract reader
|
||||
private final List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
|
||||
public Map<String, IniField> allIniFields = new LinkedHashMap<>();
|
||||
public final Map<String, DialogModel.Field> fieldsInUiOrder = new LinkedHashMap<>();
|
||||
Map<String, IniField> getAllIniFields();
|
||||
|
||||
public Map</*field name*/String, String> tooltips = new TreeMap<>();
|
||||
public Map<String, String> protocolMeta = new TreeMap<>();
|
||||
private boolean isConstantsSection;
|
||||
private String currentYBins;
|
||||
private String currentXBins;
|
||||
private final Map<String, String> xBinsByZBins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, String> yBinsByZBins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private IniFileMetaInfo metaInfo;
|
||||
Map<String, String> getProtocolMeta();
|
||||
|
||||
private boolean isInSettingContextHelp = false;
|
||||
private boolean isInsidePageDefinition;
|
||||
IniFileMetaInfo getMetaInfo();
|
||||
|
||||
public IniFileModel findAndReadIniFile(String iniFilePath) {
|
||||
String fileName = findMetaInfoFile(iniFilePath);
|
||||
return readIniFile(fileName);
|
||||
}
|
||||
Map<String, String> getTooltips();
|
||||
|
||||
public IniFileMetaInfo getMetaInfo() {
|
||||
// pageSize lives inside!
|
||||
return Objects.requireNonNull(metaInfo, "metaInfo");
|
||||
}
|
||||
Map<String, DialogModel.Field> getFieldsInUiOrder();
|
||||
|
||||
public IniFileModel readIniFile(String fileName) {
|
||||
Objects.requireNonNull(fileName, "fileName");
|
||||
log.info("Reading " + fileName);
|
||||
File input = new File(fileName);
|
||||
RawIniFile content = IniFileReader.read(input);
|
||||
metaInfo = new IniFileMetaInfo(content);
|
||||
String getXBin(String tableName);
|
||||
|
||||
readIniFile(content);
|
||||
return this;
|
||||
}
|
||||
Set<String> getTables();
|
||||
|
||||
public IniFileModel readIniFile(RawIniFile content) {
|
||||
for (RawIniFile.Line line : content.getLines()) {
|
||||
handleLine(line);
|
||||
}
|
||||
finishDialog();
|
||||
return this;
|
||||
}
|
||||
String getYBin(String tableName);
|
||||
|
||||
private static String findMetaInfoFile(String iniFilePath) {
|
||||
return FindFileHelper.findFile(iniFilePath, RUSEFI_INI_PREFIX, RUSEFI_INI_SUFFIX);
|
||||
}
|
||||
|
||||
private void finishDialog() {
|
||||
if (fieldsOfCurrentDialog.isEmpty())
|
||||
return;
|
||||
if (dialogUiName == null)
|
||||
dialogUiName = dialogId;
|
||||
dialogs.put(dialogUiName, new DialogModel(dialogId, dialogUiName, fieldsOfCurrentDialog));
|
||||
|
||||
dialogId = null;
|
||||
fieldsOfCurrentDialog.clear();
|
||||
}
|
||||
|
||||
private void handleLine(RawIniFile.Line line) {
|
||||
|
||||
String rawText = line.getRawText();
|
||||
try {
|
||||
LinkedList<String> list = new LinkedList<>(Arrays.asList(line.getTokens()));
|
||||
if (!list.isEmpty() && list.get(0).equals("#define")) {
|
||||
defines.put(list.get(1), list.subList(2, list.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!list.isEmpty() && list.get(0).equals(SECTION_PAGE)) {
|
||||
isInsidePageDefinition = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// todo: use TSProjectConsumer constant
|
||||
if (isInSettingContextHelp) {
|
||||
// todo: use TSProjectConsumer constant
|
||||
if (rawText.contains("SettingContextHelpEnd")) {
|
||||
isInSettingContextHelp = false;
|
||||
}
|
||||
if (list.size() == 2)
|
||||
tooltips.put(list.get(0), list.get(1));
|
||||
return;
|
||||
} else if (rawText.contains("SettingContextHelp")) {
|
||||
isInsidePageDefinition = false;
|
||||
isInSettingContextHelp = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (RawIniFile.Line.isCommentLine(rawText))
|
||||
return;
|
||||
|
||||
if (RawIniFile.Line.isPreprocessorDirective(rawText))
|
||||
return;
|
||||
|
||||
trim(list);
|
||||
|
||||
if (list.isEmpty())
|
||||
return;
|
||||
|
||||
String first = list.getFirst();
|
||||
|
||||
if (first.startsWith("[") && first.endsWith("]")) {
|
||||
log.info("Section " + first);
|
||||
isConstantsSection = first.equals("[Constants]");
|
||||
}
|
||||
|
||||
if (isConstantsSection) {
|
||||
if (isInsidePageDefinition) {
|
||||
if (list.size() > 1)
|
||||
handleFieldDefinition(list, line);
|
||||
return;
|
||||
} else {
|
||||
if (list.size() > 1) {
|
||||
protocolMeta.put(list.get(0), list.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (first) {
|
||||
case "field":
|
||||
handleField(list);
|
||||
break;
|
||||
case "slider":
|
||||
handleSlider(list);
|
||||
break;
|
||||
case "dialog":
|
||||
handleDialog(list);
|
||||
break;
|
||||
case "table":
|
||||
handleTable(list);
|
||||
break;
|
||||
case "xBins":
|
||||
handleXBins(list);
|
||||
break;
|
||||
case "yBins":
|
||||
handleYBins(list);
|
||||
break;
|
||||
case "zBins":
|
||||
handleZBins(list);
|
||||
break;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
throw new IllegalStateException("Failed to handle [" + rawText + "]: " + e, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleZBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String zBins = list.removeFirst();
|
||||
addField(zBins);
|
||||
if (currentXBins == null || currentYBins == null)
|
||||
throw new IllegalStateException("X or Y missing for " + zBins);
|
||||
xBinsByZBins.put(zBins, currentXBins);
|
||||
yBinsByZBins.put(zBins, currentYBins);
|
||||
}
|
||||
|
||||
public String getXBin(String tableName) {
|
||||
return xBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
public Set<String> getTables() {
|
||||
return xBinsByZBins.keySet();
|
||||
}
|
||||
|
||||
public String getYBin(String tableName) {
|
||||
return yBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
private void handleYBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentYBins = list.removeFirst();
|
||||
addField(currentYBins);
|
||||
}
|
||||
|
||||
private void handleXBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentXBins = list.removeFirst();
|
||||
addField(currentXBins);
|
||||
}
|
||||
|
||||
private void addField(String key) {
|
||||
DialogModel.Field field = new DialogModel.Field(key, key);
|
||||
fieldsInUiOrder.put(key, field);
|
||||
}
|
||||
|
||||
private void handleTable(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String tableName = list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
||||
switch (list.get(1)) {
|
||||
case FIELD_TYPE_SCALAR:
|
||||
registerField(ScalarIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_STRING:
|
||||
registerField(StringIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_ARRAY:
|
||||
registerField(ArrayIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_BITS:
|
||||
registerField(EnumIniField.parse(list, line, this));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected " + list);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerField(IniField field) {
|
||||
if (allIniFields.containsKey(field.getName()))
|
||||
return;
|
||||
allIniFields.put(field.getName(), field);
|
||||
}
|
||||
|
||||
private void handleSlider(LinkedList<String> list) {
|
||||
list.removeFirst(); // "slider"
|
||||
|
||||
String uiFieldName = list.isEmpty() ? "" : list.removeFirst();
|
||||
|
||||
String key = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
registerUiField(key, uiFieldName);
|
||||
log.debug("IniFileModel: Slider label=[" + uiFieldName + "] : key=[" + key + "]");
|
||||
}
|
||||
|
||||
private void handleField(LinkedList<String> list) {
|
||||
list.removeFirst(); // "field"
|
||||
|
||||
String uiFieldName = list.isEmpty() ? "" : list.removeFirst();
|
||||
|
||||
String key = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
registerUiField(key, uiFieldName);
|
||||
log.debug("IniFileModel: Field label=[" + uiFieldName + "] : key=[" + key + "]");
|
||||
}
|
||||
|
||||
private void registerUiField(String key, String uiFieldName) {
|
||||
DialogModel.Field field = new DialogModel.Field(key, uiFieldName);
|
||||
|
||||
if (key != null) {
|
||||
fieldsOfCurrentDialog.add(field);
|
||||
fieldsInUiOrder.put(key, field);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDialog(LinkedList<String> list) {
|
||||
finishDialog();
|
||||
list.removeFirst(); // "dialog"
|
||||
// trim(list);
|
||||
String keyword = list.removeFirst();
|
||||
// trim(list);
|
||||
String name = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
dialogId = keyword;
|
||||
dialogUiName = name;
|
||||
log.debug("IniFileModel: Dialog key=" + keyword + ": name=[" + name + "]");
|
||||
}
|
||||
|
||||
private void trim(LinkedList<String> list) {
|
||||
while (!list.isEmpty() && list.getFirst().isEmpty())
|
||||
list.removeFirst();
|
||||
}
|
||||
|
||||
public IniField findByOffset(int i) {
|
||||
for (IniField field : allIniFields.values()) {
|
||||
if (i >= field.getOffset() && i < field.getOffset() + field.getSize())
|
||||
return field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static synchronized IniFileModel getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new IniFileModel();
|
||||
INSTANCE.findAndReadIniFile(INI_FILE_PATH);
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Map<String, DialogModel> getDialogs() {
|
||||
return dialogs;
|
||||
}
|
||||
Map<String, DialogModel> getDialogs();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,350 @@
|
|||
package com.opensr5.ini;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ini.field.*;
|
||||
import com.rusefi.core.FindFileHelper;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 12/23/2015.
|
||||
*/
|
||||
public class IniFileModelImpl implements IniFileModel {
|
||||
private static final Logging log = Logging.getLogging(IniFileModelImpl.class);
|
||||
public static final String RUSEFI_INI_PREFIX = "rusefi";
|
||||
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 FIELD_TYPE_SCALAR = "scalar";
|
||||
public static final String FIELD_TYPE_STRING = "string";
|
||||
private static final String FIELD_TYPE_ARRAY = "array";
|
||||
private static final String FIELD_TYPE_BITS = "bits";
|
||||
|
||||
private final Map<String, List<String>> defines = new TreeMap<>();
|
||||
|
||||
private static IniFileModelImpl INSTANCE;
|
||||
private String dialogId;
|
||||
private String dialogUiName;
|
||||
private final Map<String, DialogModel> dialogs = new TreeMap<>();
|
||||
// this is only used while reading model - TODO extract reader
|
||||
private final List<DialogModel.Field> fieldsOfCurrentDialog = new ArrayList<>();
|
||||
public Map<String, IniField> allIniFields = new LinkedHashMap<>();
|
||||
public final Map<String, DialogModel.Field> fieldsInUiOrder = new LinkedHashMap<>();
|
||||
|
||||
public Map</*field name*/String, String> tooltips = new TreeMap<>();
|
||||
public Map<String, String> protocolMeta = new TreeMap<>();
|
||||
private boolean isConstantsSection;
|
||||
private String currentYBins;
|
||||
private String currentXBins;
|
||||
private final Map<String, String> xBinsByZBins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, String> yBinsByZBins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private IniFileMetaInfo metaInfo;
|
||||
|
||||
private boolean isInSettingContextHelp = false;
|
||||
private boolean isInsidePageDefinition;
|
||||
|
||||
@Override
|
||||
public IniFileModelImpl findAndReadIniFile(String iniFilePath) {
|
||||
String fileName = findMetaInfoFile(iniFilePath);
|
||||
return readIniFile(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getDefines() {
|
||||
return defines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IniField> getAllIniFields() {
|
||||
return allIniFields;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProtocolMeta() {
|
||||
return protocolMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IniFileMetaInfo getMetaInfo() {
|
||||
// pageSize lives inside!
|
||||
return Objects.requireNonNull(metaInfo, "metaInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTooltips() {
|
||||
return tooltips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DialogModel.Field> getFieldsInUiOrder() {
|
||||
return fieldsInUiOrder;
|
||||
}
|
||||
|
||||
public IniFileModelImpl readIniFile(String fileName) {
|
||||
Objects.requireNonNull(fileName, "fileName");
|
||||
log.info("Reading " + fileName);
|
||||
File input = new File(fileName);
|
||||
RawIniFile content = IniFileReader.read(input);
|
||||
metaInfo = new IniFileMetaInfoImpl(content);
|
||||
|
||||
readIniFile(content);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IniFileModelImpl readIniFile(RawIniFile content) {
|
||||
for (RawIniFile.Line line : content.getLines()) {
|
||||
handleLine(line);
|
||||
}
|
||||
finishDialog();
|
||||
return this;
|
||||
}
|
||||
|
||||
private static String findMetaInfoFile(String iniFilePath) {
|
||||
return FindFileHelper.findFile(iniFilePath, RUSEFI_INI_PREFIX, RUSEFI_INI_SUFFIX);
|
||||
}
|
||||
|
||||
private void finishDialog() {
|
||||
if (fieldsOfCurrentDialog.isEmpty())
|
||||
return;
|
||||
if (dialogUiName == null)
|
||||
dialogUiName = dialogId;
|
||||
dialogs.put(dialogUiName, new DialogModel(dialogId, dialogUiName, fieldsOfCurrentDialog));
|
||||
|
||||
dialogId = null;
|
||||
fieldsOfCurrentDialog.clear();
|
||||
}
|
||||
|
||||
private void handleLine(RawIniFile.Line line) {
|
||||
|
||||
String rawText = line.getRawText();
|
||||
try {
|
||||
LinkedList<String> list = new LinkedList<>(Arrays.asList(line.getTokens()));
|
||||
if (!list.isEmpty() && list.get(0).equals("#define")) {
|
||||
defines.put(list.get(1), list.subList(2, list.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!list.isEmpty() && list.get(0).equals(SECTION_PAGE)) {
|
||||
isInsidePageDefinition = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// todo: use TSProjectConsumer constant
|
||||
if (isInSettingContextHelp) {
|
||||
// todo: use TSProjectConsumer constant
|
||||
if (rawText.contains("SettingContextHelpEnd")) {
|
||||
isInSettingContextHelp = false;
|
||||
}
|
||||
if (list.size() == 2)
|
||||
tooltips.put(list.get(0), list.get(1));
|
||||
return;
|
||||
} else if (rawText.contains("SettingContextHelp")) {
|
||||
isInsidePageDefinition = false;
|
||||
isInSettingContextHelp = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (RawIniFile.Line.isCommentLine(rawText))
|
||||
return;
|
||||
|
||||
if (RawIniFile.Line.isPreprocessorDirective(rawText))
|
||||
return;
|
||||
|
||||
trim(list);
|
||||
|
||||
if (list.isEmpty())
|
||||
return;
|
||||
|
||||
String first = list.getFirst();
|
||||
|
||||
if (first.startsWith("[") && first.endsWith("]")) {
|
||||
log.info("Section " + first);
|
||||
isConstantsSection = first.equals("[Constants]");
|
||||
}
|
||||
|
||||
if (isConstantsSection) {
|
||||
if (isInsidePageDefinition) {
|
||||
if (list.size() > 1)
|
||||
handleFieldDefinition(list, line);
|
||||
return;
|
||||
} else {
|
||||
if (list.size() > 1) {
|
||||
protocolMeta.put(list.get(0), list.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (first) {
|
||||
case "field":
|
||||
handleField(list);
|
||||
break;
|
||||
case "slider":
|
||||
handleSlider(list);
|
||||
break;
|
||||
case "dialog":
|
||||
handleDialog(list);
|
||||
break;
|
||||
case "table":
|
||||
handleTable(list);
|
||||
break;
|
||||
case "xBins":
|
||||
handleXBins(list);
|
||||
break;
|
||||
case "yBins":
|
||||
handleYBins(list);
|
||||
break;
|
||||
case "zBins":
|
||||
handleZBins(list);
|
||||
break;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
throw new IllegalStateException("Failed to handle [" + rawText + "]: " + e, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleZBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String zBins = list.removeFirst();
|
||||
addField(zBins);
|
||||
if (currentXBins == null || currentYBins == null)
|
||||
throw new IllegalStateException("X or Y missing for " + zBins);
|
||||
xBinsByZBins.put(zBins, currentXBins);
|
||||
yBinsByZBins.put(zBins, currentYBins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getXBin(String tableName) {
|
||||
return xBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getTables() {
|
||||
return xBinsByZBins.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getYBin(String tableName) {
|
||||
return yBinsByZBins.get(tableName);
|
||||
}
|
||||
|
||||
private void handleYBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentYBins = list.removeFirst();
|
||||
addField(currentYBins);
|
||||
}
|
||||
|
||||
private void handleXBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
currentXBins = list.removeFirst();
|
||||
addField(currentXBins);
|
||||
}
|
||||
|
||||
private void addField(String key) {
|
||||
DialogModel.Field field = new DialogModel.Field(key, key);
|
||||
fieldsInUiOrder.put(key, field);
|
||||
}
|
||||
|
||||
private void handleTable(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String tableName = list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
||||
switch (list.get(1)) {
|
||||
case FIELD_TYPE_SCALAR:
|
||||
registerField(ScalarIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_STRING:
|
||||
registerField(StringIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_ARRAY:
|
||||
registerField(ArrayIniField.parse(list));
|
||||
break;
|
||||
case FIELD_TYPE_BITS:
|
||||
registerField(EnumIniField.parse(list, line, this));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected " + list);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerField(IniField field) {
|
||||
if (allIniFields.containsKey(field.getName()))
|
||||
return;
|
||||
allIniFields.put(field.getName(), field);
|
||||
}
|
||||
|
||||
private void handleSlider(LinkedList<String> list) {
|
||||
list.removeFirst(); // "slider"
|
||||
|
||||
String uiFieldName = list.isEmpty() ? "" : list.removeFirst();
|
||||
|
||||
String key = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
registerUiField(key, uiFieldName);
|
||||
log.debug("IniFileModel: Slider label=[" + uiFieldName + "] : key=[" + key + "]");
|
||||
}
|
||||
|
||||
private void handleField(LinkedList<String> list) {
|
||||
list.removeFirst(); // "field"
|
||||
|
||||
String uiFieldName = list.isEmpty() ? "" : list.removeFirst();
|
||||
|
||||
String key = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
registerUiField(key, uiFieldName);
|
||||
log.debug("IniFileModel: Field label=[" + uiFieldName + "] : key=[" + key + "]");
|
||||
}
|
||||
|
||||
private void registerUiField(String key, String uiFieldName) {
|
||||
DialogModel.Field field = new DialogModel.Field(key, uiFieldName);
|
||||
|
||||
if (key != null) {
|
||||
fieldsOfCurrentDialog.add(field);
|
||||
fieldsInUiOrder.put(key, field);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDialog(LinkedList<String> list) {
|
||||
finishDialog();
|
||||
list.removeFirst(); // "dialog"
|
||||
// trim(list);
|
||||
String keyword = list.removeFirst();
|
||||
// trim(list);
|
||||
String name = list.isEmpty() ? null : list.removeFirst();
|
||||
|
||||
dialogId = keyword;
|
||||
dialogUiName = name;
|
||||
log.debug("IniFileModel: Dialog key=" + keyword + ": name=[" + name + "]");
|
||||
}
|
||||
|
||||
private void trim(LinkedList<String> list) {
|
||||
while (!list.isEmpty() && list.getFirst().isEmpty())
|
||||
list.removeFirst();
|
||||
}
|
||||
|
||||
public IniField findByOffset(int i) {
|
||||
for (IniField field : allIniFields.values()) {
|
||||
if (i >= field.getOffset() && i < field.getOffset() + field.getSize())
|
||||
return field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static synchronized IniFileModelImpl getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new IniFileModelImpl();
|
||||
INSTANCE.findAndReadIniFile(INI_FILE_PATH);
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DialogModel> getDialogs() {
|
||||
return dialogs;
|
||||
}
|
||||
}
|
|
@ -182,7 +182,7 @@ public class EnumIniField extends IniField {
|
|||
String trimmed = firstValue.trim();
|
||||
if (trimmed.startsWith("$")) {
|
||||
String key = trimmed.substring(1);
|
||||
List<String> elements = iniFileModel.defines.get(key);
|
||||
List<String> elements = iniFileModel.getDefines().get(key);
|
||||
Objects.requireNonNull(elements, "Elements for " + key);
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
keyValues.put(i, elements.get(i));
|
||||
|
|
|
@ -35,7 +35,7 @@ public class Msq {
|
|||
@NotNull
|
||||
public static Msq valueOf(ConfigurationImage image, int totalConfigSize, String tsSignature, IniFileModel ini) {
|
||||
Msq tune = create(totalConfigSize, tsSignature);
|
||||
for (String key : ini.allIniFields.keySet())
|
||||
for (String key : ini.getAllIniFields().keySet())
|
||||
tune.loadConstant(ini, key, image);
|
||||
return tune;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class Msq {
|
|||
if (constant.getName().startsWith("UNALLOCATED_SPACE")) {
|
||||
continue;
|
||||
}
|
||||
IniField field = instance.allIniFields.get(constant.getName());
|
||||
IniField field = instance.getAllIniFields().get(constant.getName());
|
||||
Objects.requireNonNull(field, "Field for " + constant.getName());
|
||||
log.debug("Setting " + field);
|
||||
field.setValue(ci, constant);
|
||||
|
@ -82,7 +82,7 @@ public class Msq {
|
|||
}
|
||||
|
||||
public void loadConstant(IniFileModel ini, String key, ConfigurationImage image) {
|
||||
IniField field = ini.allIniFields.get(key);
|
||||
IniField field = ini.getAllIniFields().get(key);
|
||||
String value = field.getValue(image);
|
||||
Page page = findPage();
|
||||
if (page == null) {
|
||||
|
|
|
@ -6,8 +6,8 @@ public class IniFileModelSandbox {
|
|||
private static final Logging log = Logging.getLogging(IniFileModelSandbox.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
IniFileModel iniFile = new IniFileModel();
|
||||
iniFile.findAndReadIniFile(IniFileModel.INI_FILE_PATH);
|
||||
IniFileModel iniFile = new IniFileModelImpl();
|
||||
iniFile.findAndReadIniFile(IniFileModelImpl.INI_FILE_PATH);
|
||||
log.info("Dialogs: " + iniFile.getDialogs());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,10 +97,10 @@ public class IniFileReaderTest {
|
|||
" pageSize = 288, 64, 288\n";
|
||||
|
||||
|
||||
IniFileMetaInfo meta = new IniFileMetaInfo(fromString(string));
|
||||
IniFileMetaInfo meta = new IniFileMetaInfoImpl(fromString(string));
|
||||
|
||||
assertEquals(3, meta.getnPages());
|
||||
assertEquals(IniFileMetaInfo.DEFAULT_BLOCKING_FACTOR, meta.getBlockingFactor());
|
||||
assertEquals(IniFileMetaInfoImpl.DEFAULT_BLOCKING_FACTOR, meta.getBlockingFactor());
|
||||
assertEquals(640, meta.getTotalSize());
|
||||
assertEquals("unit test", meta.getSignature());
|
||||
|
||||
|
@ -128,9 +128,9 @@ public class IniFileReaderTest {
|
|||
"\t\tyBins\t\t= scriptCurve1\n" +
|
||||
"\t\tshowTextValues = true\n";
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
assertEquals(2, model.allIniFields.size());
|
||||
assertEquals(2, model.fieldsInUiOrder.size());
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
assertEquals(2, model.getAllIniFields().size());
|
||||
assertEquals(2, model.getFieldsInUiOrder().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -147,12 +147,12 @@ public class IniFileReaderTest {
|
|||
"\t\tyBins\t\t= tpsTpsAccelToRpmBins, TPSValue\n" +
|
||||
"\t\tzBins\t\t= tpsTpsAccelTable";
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
assertEquals(3, model.allIniFields.size());
|
||||
assertEquals(3, model.fieldsInUiOrder.size());
|
||||
assertTrue(model.fieldsInUiOrder.containsKey("tpsTpsAccelToRpmBins"));
|
||||
assertFalse(model.fieldsInUiOrder.containsKey("tpsTpsAccelTbl"));
|
||||
assertTrue(model.fieldsInUiOrder.containsKey("tpsTpsAccelTable"));
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
assertEquals(3, model.getAllIniFields().size());
|
||||
assertEquals(3, model.getFieldsInUiOrder().size());
|
||||
assertTrue(model.getFieldsInUiOrder().containsKey("tpsTpsAccelToRpmBins"));
|
||||
assertFalse(model.getFieldsInUiOrder().containsKey("tpsTpsAccelTbl"));
|
||||
assertTrue(model.getFieldsInUiOrder().containsKey("tpsTpsAccelTable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -165,10 +165,10 @@ public class IniFileReaderTest {
|
|||
"\tlambdaTable\t\t\t\t\t = array, U08, 18592, [16x16],\"deg\", 0.1, 0, 0, 25.0, 1\n" +
|
||||
"#endif\n";
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
|
||||
assertEquals(1, model.allIniFields.size());
|
||||
assertEquals(0, model.fieldsInUiOrder.size()); // no UI for the field
|
||||
assertEquals(1, model.getAllIniFields().size());
|
||||
assertEquals(0, model.getFieldsInUiOrder().size()); // no UI for the field
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -180,10 +180,10 @@ public class IniFileReaderTest {
|
|||
"primingSquirtDurationMs\t\t\t= scalar, F32,\t96,\t\"*C\", 1.0, 0, -40, 200, 1\n" +
|
||||
"";
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
assertEquals(1, model.allIniFields.size());
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
assertEquals(1, model.getAllIniFields().size());
|
||||
|
||||
String crcProtocol = model.protocolMeta.get("crc32CheckCommand");
|
||||
String crcProtocol = model.getProtocolMeta().get("crc32CheckCommand");
|
||||
assertEquals("k\\x00\\x00\\x00\\x00\\x00\\x00", crcProtocol);
|
||||
|
||||
byte[] expected = {'k', 0, 0, 0, 0, 0, 0};
|
||||
|
@ -199,9 +199,9 @@ public class IniFileReaderTest {
|
|||
"\tiat_adcChannel\t\t\t\t = bits, U08, 312, [0:7] \"PA0\", \"PA1\", \"PA2\", \"PA3\", \"PA4\", \"PA5\", \"PA6\", \"PA7\", \"PB0\", \"PB1\", \"PC0\", \"PC1\", \"PC2\", \"PC3\", \"PC4\", \"PC5\", \"Disabled\", \"PB12\", \"PB13\", \"PC14\", \"PC15\", \"PC16\", \"PC17\", \"PD3\", \"PD4\", \"PE2\", \"PE6\", \"INVALID\", \"INVALID\", \"INVALID\", \"INVALID\", \"INVALID\"\n";
|
||||
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
|
||||
assertEquals(2, model.allIniFields.size());
|
||||
assertEquals(2, model.getAllIniFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -213,12 +213,12 @@ public class IniFileReaderTest {
|
|||
"\tiat_adcChannel\t\t\t\t = bits, U08, 312, [0:7] $gpio_list\n";
|
||||
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
assertEquals(1, model.defines.size());
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
assertEquals(1, model.getDefines().size());
|
||||
|
||||
EnumIniField field = (EnumIniField) model.allIniFields.get("iat_adcChannel");
|
||||
EnumIniField field = (EnumIniField) model.getAllIniFields().get("iat_adcChannel");
|
||||
assertEquals(7, field.getEnums().size());
|
||||
assertEquals(2, model.allIniFields.size());
|
||||
assertEquals(2, model.getAllIniFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -254,11 +254,11 @@ public class IniFileReaderTest {
|
|||
"\tname\t= bits, U32, \t744, [3:5], \"false\", \"true\"";
|
||||
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
|
||||
assertEquals(1, model.allIniFields.size());
|
||||
assertEquals(1, model.getAllIniFields().size());
|
||||
|
||||
EnumIniField field = (EnumIniField) model.allIniFields.get("name");
|
||||
EnumIniField field = (EnumIniField) model.getAllIniFields().get("name");
|
||||
assertEquals(3, field.getBitPosition());
|
||||
assertEquals(2, field.getBitSize0());
|
||||
assertEquals(2, field.getEnums().size());
|
||||
|
@ -274,10 +274,10 @@ public class IniFileReaderTest {
|
|||
" \tname3\t\t\t= array, F32,\t108,\t[8],\t\"\", 1, 0, 0.0, 18000, 2\n";
|
||||
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
|
||||
assertEquals(1, model.allIniFields.size());
|
||||
ArrayIniField field = (ArrayIniField) model.allIniFields.get("name");
|
||||
assertEquals(1, model.getAllIniFields().size());
|
||||
ArrayIniField field = (ArrayIniField) model.getAllIniFields().get("name");
|
||||
assertNotNull(field);
|
||||
assertEquals(1, field.getCols());
|
||||
assertEquals(8, field.getRows());
|
||||
|
@ -294,11 +294,11 @@ public class IniFileReaderTest {
|
|||
"#endif";
|
||||
|
||||
RawIniFile lines = IniFileReader.read(new ByteArrayInputStream(string.getBytes()));
|
||||
IniFileModel model = new IniFileModel().readIniFile(lines);
|
||||
IniFileModel model = new IniFileModelImpl().readIniFile(lines);
|
||||
|
||||
assertEquals(1, model.allIniFields.size());
|
||||
assertEquals(1, model.getAllIniFields().size());
|
||||
|
||||
EnumIniField field = (EnumIniField) model.allIniFields.get("name");
|
||||
EnumIniField field = (EnumIniField) model.getAllIniFields().get("name");
|
||||
assertEquals(0, field.getBitPosition());
|
||||
assertEquals(2, field.getBitSize0());
|
||||
assertEquals(1, field.getEnums().size());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.opensr5;
|
||||
|
||||
import com.opensr5.ini.IniFileMetaInfo;
|
||||
import com.opensr5.ini.IniFileMetaInfoImpl;
|
||||
import com.opensr5.ini.IniFileReader;
|
||||
import com.opensr5.ini.RawIniFile;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class Main {
|
|||
|
||||
RawIniFile content = IniFileReader.read(new File(projectIniFileName));
|
||||
|
||||
IniFileMetaInfo meta = new IniFileMetaInfo(content);
|
||||
IniFileMetaInfo meta = new IniFileMetaInfoImpl(content);
|
||||
|
||||
System.out.println("nPages = " + meta.getnPages());
|
||||
System.out.println("blockingFactor = " + meta.getBlockingFactor());
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.opensr5.ConfigurationImageMetaVersion0_0;
|
|||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ConfigurationImageWithMeta;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.io.ConfigurationImageFile;
|
||||
import com.opensr5.io.DataListener;
|
||||
import com.rusefi.ConfigurationImageDiff;
|
||||
|
@ -382,7 +383,7 @@ public class BinaryProtocol {
|
|||
if (ConnectionAndMeta.saveSettingsToFile()) {
|
||||
ConfigurationImageFile.saveToFile(image, CONFIGURATION_RUSEFI_BINARY);
|
||||
}
|
||||
Msq tune = MsqFactory.valueOf(image, IniFileModel.getInstance());
|
||||
Msq tune = MsqFactory.valueOf(image, IniFileModelImpl.getInstance());
|
||||
tune.writeXmlFile(CONFIGURATION_RUSEFI_XML);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Ignoring " + e);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.binaryprotocol;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.core.SignatureHelper;
|
||||
|
||||
public class RealIniFileProvider implements IniFileProvider {
|
||||
|
@ -9,6 +10,6 @@ public class RealIniFileProvider implements IniFileProvider {
|
|||
String localIniFile = SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(signature));
|
||||
if (localIniFile == null)
|
||||
throw new IllegalStateException("Failed to download for " + signature);
|
||||
return new IniFileModel().readIniFile(localIniFile);
|
||||
return new IniFileModelImpl().readIniFile(localIniFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.binaryprotocol.test;
|
|||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.rusefi.TestHelper;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
|
@ -24,7 +25,7 @@ class BinaryProtocolServerSandbox {
|
|||
// if (!f.exists())
|
||||
// throw new IllegalStateException("File not found: " + BinaryProtocolServer.TEST_FILE);
|
||||
|
||||
IniFileModel model = IniFileModel.getInstance();
|
||||
IniFileModel model = IniFileModelImpl.getInstance();
|
||||
|
||||
BinaryProtocolState state = new BinaryProtocolState();
|
||||
ConfigurationImage controller = new ConfigurationImage(new byte[model.getMetaInfo().getTotalSize()]);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi.binaryprotocol.test;
|
|||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||
|
@ -67,7 +68,7 @@ public class SandboxCommon {
|
|||
linkManager.COMMUNICATION_EXECUTOR.submit(() -> {
|
||||
if (tsStream.getDataBuffer().dropPending() != 0)
|
||||
log.info("ERROR Extra data before CRC");
|
||||
bp.getCrcFromController(IniFileModel.getInstance().getMetaInfo().getTotalSize());
|
||||
bp.getCrcFromController(IniFileModelImpl.getInstance().getMetaInfo().getTotalSize());
|
||||
// bp.getCrcFromController(Fields.TOTAL_CONFIG_SIZE);
|
||||
// bp.getCrcFromController(Fields.TOTAL_CONFIG_SIZE);
|
||||
if (tsStream.getDataBuffer().dropPending() != 0)
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.binaryprotocol.test;
|
|||
|
||||
import com.macfaq.io.LittleEndianOutputStream;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.CompatibleFunction;
|
||||
import com.rusefi.Listener;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
|
@ -33,7 +34,7 @@ import static com.rusefi.io.tcp.BinaryProtocolServer.getOutputCommandResponse;
|
|||
* @see BinaryProtocolServerSandbox what's the difference?
|
||||
*/
|
||||
public class TcpServerSandbox {
|
||||
private final static byte[] TOTALLY_EMPTY_CONFIGURATION = new byte[IniFileModel.getInstance().getMetaInfo().getTotalSize()];
|
||||
private final static byte[] TOTALLY_EMPTY_CONFIGURATION = new byte[IniFileModelImpl.getInstance().getMetaInfo().getTotalSize()];
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Listener serverSocketCreationCallback = parameter -> System.out.println("serverSocketCreationCallback");
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
|
@ -48,7 +49,7 @@ public class TestHelper extends MockitoTestHelper {
|
|||
|
||||
@NotNull
|
||||
public static ConfigurationImage prepareImage(int input, ScalarIniField scalarIniField) {
|
||||
ConfigurationImage ci = new ConfigurationImage(Fields.TOTAL_CONFIG_SIZE);
|
||||
ConfigurationImage ci = new ConfigurationImage(BinaryProtocol.iniFileProvider.provide(null).getMetaInfo().getTotalSize());
|
||||
|
||||
scalarIniField.setValue(ci, new Constant(scalarIniField.getName(), "", Integer.toString(input), scalarIniField.getDigits()));
|
||||
return ci;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi.tools;
|
|||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.io.ConfigurationImageFile;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.autodetect.PortDetector;
|
||||
|
@ -154,7 +155,7 @@ public class ConsoleTools {
|
|||
private static void calcXmlImageTuneCrc(String... args) throws Exception {
|
||||
String fileName = args[1];
|
||||
Msq msq = Msq.readTune(fileName);
|
||||
ConfigurationImage image = msq.asImage(IniFileModel.getInstance());
|
||||
ConfigurationImage image = msq.asImage(IniFileModelImpl.getInstance());
|
||||
printCrc(image);
|
||||
}
|
||||
|
||||
|
@ -293,7 +294,7 @@ public class ConsoleTools {
|
|||
Msq msq = Msq.readTune(fileName);
|
||||
|
||||
startAndConnect(linkManager -> {
|
||||
ConfigurationImage ci = msq.asImage(IniFileModel.getInstance());
|
||||
ConfigurationImage ci = msq.asImage(IniFileModelImpl.getInstance());
|
||||
linkManager.getConnector().getBinaryProtocol().uploadChanges(ci);
|
||||
|
||||
//System.exit(0);
|
||||
|
@ -349,7 +350,7 @@ public class ConsoleTools {
|
|||
ConfigurationImage image = ConfigurationImageFile.readFromFile(inputBinaryFileName);
|
||||
System.out.println("Got " + image.getSize() + " of configuration from " + inputBinaryFileName);
|
||||
|
||||
Msq tune = MsqFactory.valueOf(image, IniFileModel.getInstance());
|
||||
Msq tune = MsqFactory.valueOf(image, IniFileModelImpl.getInstance());
|
||||
tune.writeXmlFile(Online.outputXmlFileName);
|
||||
String authToken = AuthTokenPanel.getAuthToken();
|
||||
System.out.println("Using " + authToken);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.SensorSnifferCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
@ -25,6 +26,6 @@ public class UIContext {
|
|||
}
|
||||
|
||||
public IniFileModel getIni() {
|
||||
return IniFileModel.getInstance();
|
||||
return IniFileModelImpl.getInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.opensr5.ini.IniFileModel.RUSEFI_INI_PREFIX;
|
||||
import static com.opensr5.ini.IniFileModel.RUSEFI_INI_SUFFIX;
|
||||
import static com.opensr5.ini.IniFileModelImpl.RUSEFI_INI_PREFIX;
|
||||
import static com.opensr5.ini.IniFileModelImpl.RUSEFI_INI_SUFFIX;
|
||||
|
||||
/**
|
||||
* @see EnumConfigField
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.parse.TypesHelper;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public abstract class JavaFieldsConsumer implements ConfigurationConsumer {
|
|||
|
||||
private boolean isStringField(ConfigField configField) {
|
||||
String custom = state.getTsCustomLine().get(configField.getTypeName());
|
||||
return custom != null && custom.toLowerCase().startsWith(IniFileModel.FIELD_TYPE_STRING);
|
||||
return custom != null && custom.toLowerCase().startsWith(IniFileModelImpl.FIELD_TYPE_STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,4 +16,5 @@ dependencies {
|
|||
|
||||
testImplementation testFixtures(project(':ecu_io'))
|
||||
testImplementation ts_plugin_libs.httpcore
|
||||
}
|
||||
testImplementation global_libs.mockito
|
||||
}
|
||||
|
|
|
@ -1,12 +1,29 @@
|
|||
package com.rusefi.proxy;
|
||||
|
||||
import com.opensr5.ini.IniFileMetaInfo;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.binaryprotocol.IniFileProvider;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class MockIniFileProvider {
|
||||
|
||||
public static IniFileProvider create() {
|
||||
IniFileProvider mock = Mockito.mock(IniFileProvider.class);
|
||||
return mock;
|
||||
IniFileMetaInfo mockMeta = mock(IniFileMetaInfo.class);
|
||||
|
||||
when(mockMeta.getTotalSize()).thenReturn(22972);
|
||||
|
||||
IniFileModelImpl mockModel = mock(IniFileModelImpl.class);
|
||||
when(mockModel.getMetaInfo()).thenReturn(mockMeta);
|
||||
|
||||
|
||||
|
||||
return new IniFileProvider() {
|
||||
@Override
|
||||
public IniFileModelImpl provide(String signature) {
|
||||
return mockModel;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class NetworkConnectorTest {
|
|||
|
||||
@BeforeEach
|
||||
public void setup() throws MalformedURLException {
|
||||
//BinaryProtocol.iniFileProvider = MockIniFileProvider.create();
|
||||
BinaryProtocol.iniFileProvider = MockIniFileProvider.create();
|
||||
BackendTestHelper.commonServerTest();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class NetworkConnectorTest {
|
|||
|
||||
// create virtual controller to which "rusEFI network connector" connects to
|
||||
int controllerPort = 7502;
|
||||
ConfigurationImage controllerImage = new ConfigurationImage(Fields.TOTAL_CONFIG_SIZE);
|
||||
ConfigurationImage controllerImage = new ConfigurationImage(BinaryProtocol.iniFileProvider.provide(null).getMetaInfo().getTotalSize());
|
||||
BinaryProtocolServer.Context patientController = new BinaryProtocolServer.Context() {
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ts_plugin;
|
||||
|
||||
import com.opensr5.ini.IniFileMetaInfo;
|
||||
import com.opensr5.ini.IniFileMetaInfoImpl;
|
||||
import com.opensr5.ini.RawIniFile;
|
||||
import com.rusefi.TsTuneReader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -23,7 +24,7 @@ public class MetaDataCache {
|
|||
System.out.println("Reading meta " + projectName);
|
||||
String modeFileName = TsTuneReader.getProjectModeFileName(projectName);
|
||||
try {
|
||||
cache = new IniFileMetaInfo(RawIniFile.read(modeFileName));
|
||||
cache = new IniFileMetaInfoImpl(RawIniFile.read(modeFileName));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("No luck reading " + modeFileName + ": " + e);
|
||||
return null;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.efiAnalytics.plugin.ecu.ControllerAccess;
|
|||
import com.efiAnalytics.plugin.ecu.ControllerException;
|
||||
import com.efiAnalytics.plugin.ecu.ControllerParameterChangeListener;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.NamedThreadFactory;
|
||||
import com.rusefi.TsTuneReader;
|
||||
|
@ -176,7 +177,7 @@ public class TuneUploadTab {
|
|||
}
|
||||
|
||||
private void subscribeToUpdates(String configurationName, ControllerAccess controllerAccess) {
|
||||
IniFileModel model = new IniFileModel().readIniFile(TsTuneReader.getProjectModeFileName(configurationName));
|
||||
IniFileModelImpl model = new IniFileModelImpl().readIniFile(TsTuneReader.getProjectModeFileName(configurationName));
|
||||
Map<String, IniField> allIniFields = model.allIniFields;
|
||||
if (model.allIniFields == null)
|
||||
return;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.efiAnalytics.plugin.ecu.ControllerAccess;
|
|||
import com.efiAnalytics.plugin.ecu.ControllerException;
|
||||
import com.efiAnalytics.plugin.ecu.servers.ControllerParameterServer;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.TsTuneReader;
|
||||
import com.rusefi.core.ui.FrameHelper;
|
||||
|
||||
|
@ -26,7 +27,7 @@ public class PluginBodySandbox {
|
|||
|
||||
public static void main(String[] args) throws ControllerException {
|
||||
String iniFile = TsTuneReader.getProjectModeFileName(PROJECT_NAME);
|
||||
IniFileModel model = new IniFileModel().readIniFile(iniFile);
|
||||
IniFileModelImpl model = new IniFileModelImpl().readIniFile(iniFile);
|
||||
Objects.requireNonNull(model, "model");
|
||||
java.util.List<String> fieldNamesList = new ArrayList<>(model.allIniFields.keySet());
|
||||
String[] parameterNames = fieldNamesList.toArray(new String[0]);
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.tools;
|
|||
|
||||
import com.opensr5.ini.DialogModel;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.RootHolder;
|
||||
import com.rusefi.tools.tune.WriteSimulatorConfiguration;
|
||||
|
@ -13,7 +14,7 @@ public class ExportTooltipsForDocumentation {
|
|||
public static void main(String[] args) throws IOException {
|
||||
// RootHolder.ROOT = "../firmware/";
|
||||
|
||||
IniFileModel ini = new IniFileModel().readIniFile(WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR);
|
||||
IniFileModel ini = new IniFileModelImpl().readIniFile(WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR);
|
||||
|
||||
try (FileWriter fw = new FileWriter("all_fields.md")) {
|
||||
|
||||
|
@ -22,11 +23,11 @@ public class ExportTooltipsForDocumentation {
|
|||
}
|
||||
|
||||
private static void writeAllFields(FileWriter fw, IniFileModel ini) throws IOException {
|
||||
for (DialogModel.Field f : ini.fieldsInUiOrder.values()) {
|
||||
for (DialogModel.Field f : ini.getFieldsInUiOrder().values()) {
|
||||
// String fieldName = f.getKey();
|
||||
// IniField iniField = ini.allIniFields.get(f.getKey());
|
||||
|
||||
String toolTip = ini.tooltips.get(f.getKey());
|
||||
String toolTip = ini.getTooltips().get(f.getKey());
|
||||
|
||||
if (toolTip != null) {
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class CurveData implements CannableEntity {
|
|||
|
||||
@Nullable
|
||||
public static CurveData valueOf(String msqFileName, String curveName, IniFileModel model) throws IOException {
|
||||
IniField iniField = model.allIniFields.get(curveName);
|
||||
IniField iniField = model.getAllIniFields().get(curveName);
|
||||
if (!(iniField instanceof ArrayIniField))
|
||||
return null;
|
||||
ArrayIniField field = (ArrayIniField) iniField;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.tools.tune;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -52,7 +53,7 @@ public class TS2C {
|
|||
String rpmSectionName = args[2];
|
||||
String tableName = args.length == 3 ? "none" : args[3];
|
||||
|
||||
IniFileModel model = IniFileModel.getInstance();
|
||||
IniFileModel model = IniFileModelImpl.getInstance();
|
||||
|
||||
String entityName = tableName.equalsIgnoreCase("none") ? loadSectionName : tableName;
|
||||
String methodName = getMethodName(entityName);
|
||||
|
|
|
@ -27,7 +27,7 @@ public class TableData implements CannableEntity {
|
|||
|
||||
@Nullable
|
||||
public static TableData readTable(String msqFileName, String tableName, IniFileModel model) throws IOException {
|
||||
IniField iniField = model.allIniFields.get(tableName);
|
||||
IniField iniField = model.getAllIniFields().get(tableName);
|
||||
if (!(iniField instanceof ArrayIniField)) {
|
||||
// this could happen if older tune is not compatible with newer .ini
|
||||
return null;
|
||||
|
|
|
@ -186,7 +186,7 @@ public class TuneCanTool {
|
|||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (DialogModel.Field f : ini.fieldsInUiOrder.values()) {
|
||||
for (DialogModel.Field f : ini.getFieldsInUiOrder().values()) {
|
||||
String fieldName = f.getKey();
|
||||
Constant customValue = customTune.getConstantsAsMap().get(fieldName);
|
||||
Constant defaultValue = defaultTune.getConstantsAsMap().get(fieldName);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.tools.tune;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.RootHolder;
|
||||
import com.rusefi.enums.engine_type_e;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class TuneCanToolRunner extends TuneCanTool {
|
|||
}
|
||||
|
||||
protected static void initialize(String iniFileForSimulator) {
|
||||
ini = new IniFileModel().readIniFile(iniFileForSimulator);
|
||||
ini = new IniFileModelImpl().readIniFile(iniFileForSimulator);
|
||||
if (ini == null)
|
||||
throw new IllegalStateException("Not found " + iniFileForSimulator);
|
||||
/*
|
||||
|
|
|
@ -2,7 +2,10 @@ package com.rusefi.tools.tune;
|
|||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.*;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.binaryprotocol.IniFileProvider;
|
||||
import com.rusefi.binaryprotocol.MsqFactory;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.enums.engine_type_e;
|
||||
|
@ -13,6 +16,8 @@ import javax.xml.bind.JAXBException;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
@ -31,11 +36,13 @@ public class WriteSimulatorConfiguration {
|
|||
if (args.length != 1)
|
||||
throw new IllegalArgumentException("One argument expected: .ini file name");
|
||||
String iniFileName = args[0];
|
||||
IniFileModelImpl ini = new IniFileModelImpl().readIniFile(iniFileName);
|
||||
BinaryProtocol.iniFileProvider = signature -> ini;
|
||||
|
||||
System.out.println("ROOT_FOLDER=" + ROOT_FOLDER);
|
||||
try {
|
||||
try {
|
||||
readBinaryWriteXmlTune(iniFileName, Fields.SIMULATOR_TUNE_BIN_FILE_NAME, TuneCanTool.DEFAULT_TUNE);
|
||||
readBinaryWriteXmlTune(iniFileName, Fields.SIMULATOR_TUNE_BIN_FILE_NAME, TuneCanTool.DEFAULT_TUNE, ini);
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("White default tune", e);
|
||||
}
|
||||
|
@ -59,7 +66,7 @@ public class WriteSimulatorConfiguration {
|
|||
engine_type_e.POLARIS_RZR,
|
||||
engine_type_e.HARLEY,
|
||||
}) {
|
||||
writeSpecificEngineType(iniFileName, type);
|
||||
writeSpecificEngineType(iniFileName, type, ini);
|
||||
}
|
||||
TuneCanToolRunner.runPopular();
|
||||
} catch (Throwable e) {
|
||||
|
@ -71,20 +78,19 @@ public class WriteSimulatorConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
private static void writeSpecificEngineType(String iniFileName, engine_type_e engineType) {
|
||||
private static void writeSpecificEngineType(String iniFileName, engine_type_e engineType, IniFileModelImpl ini) {
|
||||
try {
|
||||
String in = Fields.SIMULATOR_TUNE_BIN_FILE_NAME_PREFIX + "_" + engineType.ordinal() + Fields.SIMULATOR_TUNE_BIN_FILE_NAME_SUFFIX;
|
||||
readBinaryWriteXmlTune(iniFileName, in,
|
||||
TuneCanTool.getDefaultTuneName(engineType));
|
||||
TuneCanTool.getDefaultTuneName(engineType), ini);
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("With " + engineType, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void readBinaryWriteXmlTune(String iniFileName, String inputBinaryTuneFileName, String outputXmlFileName) throws JAXBException, IOException {
|
||||
private static void readBinaryWriteXmlTune(String iniFileName, String inputBinaryTuneFileName, String outputXmlFileName, IniFileModel ini) throws JAXBException, IOException {
|
||||
// we have to use board-specific .ini to account for all the board-specific offsets
|
||||
// INI_FILE_FOR_SIMULATOR is just not universal enough
|
||||
IniFileModel ini = new IniFileModel().readIniFile(iniFileName);
|
||||
if (ini == null)
|
||||
throw new IllegalStateException("Not found " + iniFileName);
|
||||
byte[] fileContent = Files.readAllBytes(new File(ROOT_FOLDER + inputBinaryTuneFileName).toPath());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.tune;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.tools.tune.TuneCanTool;
|
||||
import com.rusefi.tools.tune.TuneTools;
|
||||
|
@ -21,8 +22,8 @@ public class LoadOlderTuneTest {
|
|||
|
||||
Msq lessOldDefaultTune = Msq.readTune(LoadOlderTuneTest.class.getResource("/simulator_tune-2023-06.xml").getFile());
|
||||
|
||||
IniFileModel ini = new IniFileModel().readIniFile(TuneReadWriteTest.TEST_INI);
|
||||
assertFalse(ini.fieldsInUiOrder.isEmpty());
|
||||
IniFileModel ini = new IniFileModelImpl().readIniFile(TuneReadWriteTest.TEST_INI);
|
||||
assertFalse(ini.getFieldsInUiOrder().isEmpty());
|
||||
|
||||
RootHolder.ROOT = "../../firmware/";
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.tune;
|
||||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.rusefi.tools.tune.WriteSimulatorConfiguration;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -8,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
|||
public class ReadCurrentIniTest {
|
||||
@Test
|
||||
public void test() {
|
||||
IniFileModel ini = new IniFileModel().readIniFile("../" + WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR);
|
||||
IniFileModel ini = new IniFileModelImpl().readIniFile("../" + WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR);
|
||||
Assertions.assertNotNull(ini);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.opensr5.ConfigurationImageMeta;
|
|||
import com.opensr5.ConfigurationImageMetaVersion0_0;
|
||||
import com.opensr5.ConfigurationImageWithMeta;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.field.IniField;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.opensr5.io.ConfigurationImageFile;
|
||||
|
@ -28,7 +29,7 @@ public class TuneReadWriteTest {
|
|||
private static final String TEST_BINARY_FILE = PATH + "current_configuration.binary_image";
|
||||
private static final int LEGACY_TOTAL_CONFIG_SIZE = 20000;
|
||||
|
||||
private final IniFileModel model = new IniFileModel().readIniFile(TEST_INI);
|
||||
private final IniFileModelImpl model = new IniFileModelImpl().readIniFile(TEST_INI);
|
||||
|
||||
@Test
|
||||
public void testIniReader() throws IOException {
|
||||
|
@ -216,7 +217,7 @@ public class TuneReadWriteTest {
|
|||
Files.delete(path);
|
||||
}
|
||||
|
||||
private static int compareImages(ConfigurationImage image1, ConfigurationImage fileData, IniFileModel ini) {
|
||||
private static int compareImages(ConfigurationImage image1, ConfigurationImage fileData, IniFileModelImpl ini) {
|
||||
byte[] tsBinaryDataContent = image1.getContent();
|
||||
byte[] fileBinaryDataContent = fileData.getContent();
|
||||
|
||||
|
|
Loading…
Reference in New Issue