basic updater logo right click menu to upload calibrations (panama UI part) #7418
only:uaefi
This commit is contained in:
parent
61763d3377
commit
5faae7de1d
|
@ -21,6 +21,8 @@ public interface IniFileModel {
|
|||
@Deprecated // always use 'Field' generated parameter with code-generated name?
|
||||
IniField getIniField(String key);
|
||||
|
||||
IniField getOutputChannel(String key);
|
||||
|
||||
Map<String, String> getProtocolMeta();
|
||||
|
||||
IniFileMetaInfo getMetaInfo();
|
||||
|
|
|
@ -32,12 +32,14 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
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 TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private Map<String, IniField> allIniFields = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
private Map<String, IniField> allOutputChannels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
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 boolean isOutputChannelsSection;
|
||||
private String currentYBins;
|
||||
private String currentXBins;
|
||||
private final Map<String, String> xBinsByZBins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
@ -93,6 +95,12 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
return Objects.requireNonNull(result, () -> key + " field not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IniField getOutputChannel(String key) {
|
||||
IniField result = allOutputChannels.get(key);
|
||||
return Objects.requireNonNull(result, () -> key + " field not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProtocolMeta() {
|
||||
return protocolMeta;
|
||||
|
@ -224,18 +232,22 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
if (first.startsWith("[") && first.endsWith("]")) {
|
||||
log.info("Section " + first);
|
||||
isConstantsSection = first.equals("[Constants]");
|
||||
isOutputChannelsSection = first.equals("[OutputChannels]");
|
||||
}
|
||||
|
||||
if (isConstantsSection) {
|
||||
if (isInsidePageDefinition) {
|
||||
if (list.size() > 1)
|
||||
handleFieldDefinition(list, line);
|
||||
handleConstantFieldDefinition(list, line);
|
||||
return;
|
||||
} else {
|
||||
if (list.size() > 1) {
|
||||
protocolMeta.put(list.get(0), list.get(1));
|
||||
}
|
||||
}
|
||||
} else if (isOutputChannelsSection) {
|
||||
handleOutputChannelDefinition(list);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,6 +279,21 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleOutputChannelDefinition(LinkedList<String> list) {
|
||||
if (list.size() < 2)
|
||||
return;
|
||||
String name = list.get(0);
|
||||
String channelType = list.get(1);
|
||||
switch (channelType) {
|
||||
case FIELD_TYPE_SCALAR: {
|
||||
String scalarType = list.get(2);
|
||||
int offset = Integer.parseInt(list.get(3));
|
||||
// todo: reuse ScalarIniField#parse but would need changes?
|
||||
allOutputChannels.put(name, new ScalarIniField(name, offset, scalarType, null, 1, "0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleZBins(LinkedList<String> list) {
|
||||
list.removeFirst();
|
||||
String zBins = list.removeFirst();
|
||||
|
@ -314,7 +341,7 @@ public class IniFileModelImpl implements IniFileModel {
|
|||
String tableName = list.removeFirst();
|
||||
}
|
||||
|
||||
private void handleFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
||||
private void handleConstantFieldDefinition(LinkedList<String> list, RawIniFile.Line line) {
|
||||
switch (list.get(1)) {
|
||||
case FIELD_TYPE_SCALAR:
|
||||
registerField(ScalarIniField.parse(list));
|
||||
|
|
|
@ -11,11 +11,13 @@ import com.rusefi.io.LinkManager;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* basic protocol client
|
||||
*
|
||||
* @see BinaryProtocolServerSandbox
|
||||
*/
|
||||
public class SerialSandbox {
|
||||
|
@ -33,8 +35,8 @@ public class SerialSandbox {
|
|||
});
|
||||
|
||||
LinkManager linkManager = new LinkManager()
|
||||
.setNeedPullText(textPull) // todo: open issue #2
|
||||
.setNeedPullLiveData(true);
|
||||
.setNeedPullText(textPull) // todo: open issue #2
|
||||
.setNeedPullLiveData(true);
|
||||
|
||||
try {
|
||||
linkManager.connect(port).await(60, TimeUnit.SECONDS);
|
||||
|
@ -42,16 +44,18 @@ public class SerialSandbox {
|
|||
throw new IllegalStateException("Not connected in time");
|
||||
}
|
||||
|
||||
IniField mcuSerialField = linkManager.getBinaryProtocol().getIniFile().getIniField(TsOutputs.MCUSERIAL);
|
||||
IniField mcuSerialField = linkManager.getBinaryProtocol().getIniFile().getOutputChannel(TsOutputs.MCUSERIAL.getName());
|
||||
if (mcuSerialField == null) {
|
||||
throw new IllegalStateException("Older unit without MCUSERIAL?");
|
||||
}
|
||||
Objects.requireNonNull(mcuSerialField);
|
||||
|
||||
SensorCentral.getInstance().addListener(() -> {
|
||||
|
||||
ByteBuffer bb = ISensorHolder.getByteBuffer(SensorCentral.getInstance().getResponse(), "error", mcuSerialField.getOffset());
|
||||
int mcuSerial = bb.getInt();
|
||||
System.out.println("mcuSerial " + mcuSerial);
|
||||
});
|
||||
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
linkManager.execute(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -179,8 +179,8 @@ public class TuneUploadTab {
|
|||
|
||||
private void subscribeToUpdates(String configurationName, ControllerAccess controllerAccess) {
|
||||
IniFileModelImpl model = IniFileModelImpl.readIniFile(TsTuneReader.getProjectModeFileName(configurationName));
|
||||
Map<String, IniField> allIniFields = model.allIniFields;
|
||||
if (model.allIniFields == null)
|
||||
Map<String, IniField> allIniFields = model.getAllIniFields();
|
||||
if (model.getAllIniFields() == null)
|
||||
return;
|
||||
for (Map.Entry<String, IniField> field : allIniFields.entrySet()) {
|
||||
boolean isOnlineTuneField = field.getValue().getOffset() >= VariableRegistryValues.engine_configuration_s_size;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PluginBodySandbox {
|
|||
String iniFile = TsTuneReader.getProjectModeFileName(PROJECT_NAME);
|
||||
IniFileModelImpl model = IniFileModelImpl.readIniFile(iniFile);
|
||||
Objects.requireNonNull(model, "model");
|
||||
java.util.List<String> fieldNamesList = new ArrayList<>(model.allIniFields.keySet());
|
||||
java.util.List<String> fieldNamesList = new ArrayList<>(model.getAllIniFields().keySet());
|
||||
String[] parameterNames = fieldNamesList.toArray(new String[0]);
|
||||
|
||||
ControllerParameterServer controllerParameterServer = mock(ControllerParameterServer.class, NEGATIVE_ANSWER);
|
||||
|
|
|
@ -2,9 +2,11 @@ package com.rusefi.tune;
|
|||
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.opensr5.ini.IniFileModelImpl;
|
||||
import com.opensr5.ini.field.ScalarIniField;
|
||||
import com.opensr5.ini.field.StringIniField;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.config.generated.TsOutputs;
|
||||
import com.rusefi.tools.tune.TuneCanTool;
|
||||
import com.rusefi.tools.tune.TuneTools;
|
||||
import com.rusefi.tune.xml.Msq;
|
||||
|
@ -150,7 +152,9 @@ public class LoadOlderTuneTest {
|
|||
@Test
|
||||
public void findFieldByName() {
|
||||
IniFileModel ini = IniFileModelImpl.readIniFile(TuneReadWriteTest.TEST_INI);
|
||||
StringIniField field = (StringIniField) ini.getIniField(Fields.ENGINEMAKE);
|
||||
assertNotNull(field);
|
||||
StringIniField make = (StringIniField) ini.getIniField(Fields.ENGINEMAKE);
|
||||
assertNotNull(make);
|
||||
ScalarIniField tps = (ScalarIniField) ini.getOutputChannel(TsOutputs.RPMVALUE.getName());
|
||||
assertNotNull(tps);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue