mirror of https://github.com/rusefi/RomRaider.git
log overlay stuff updated
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@303 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
e226e4ac12
commit
77f62b4a51
File diff suppressed because it is too large
Load Diff
20492
ecu_defs/ecu_defs.xml
20492
ecu_defs/ecu_defs.xml
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -168,7 +168,7 @@
|
|||
</conversions>
|
||||
</parameter>
|
||||
|
||||
<parameter id="P18" name="Air Flow Sensor Voltage" desc="">
|
||||
<parameter id="P18" name="Mass Air Flow Sensor Voltage" desc="">
|
||||
<address>
|
||||
<byte>0x00001D</byte>
|
||||
</address>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package enginuity.logger.ui.handler;
|
||||
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuDataConvertor;
|
||||
import enginuity.maps.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -9,11 +8,10 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public final class TableUpdateHandler implements DataUpdateHandler {
|
||||
private static final TableUpdateHandler INSTANCE = new TableUpdateHandler();
|
||||
private final Map<String, List<TableWrapper>> tables = Collections.synchronizedMap(new HashMap<String, List<TableWrapper>>());
|
||||
private final Map<String, List<Table>> tableMap = Collections.synchronizedMap(new HashMap<String, List<Table>>());
|
||||
|
||||
private TableUpdateHandler() {
|
||||
}
|
||||
|
@ -22,16 +20,11 @@ public final class TableUpdateHandler implements DataUpdateHandler {
|
|||
}
|
||||
|
||||
public void handleDataUpdate(EcuData ecuData, byte[] value, long timestamp) {
|
||||
List<TableWrapper> wrappers = tables.get(ecuData.getId());
|
||||
if (wrappers != null && !wrappers.isEmpty()) {
|
||||
EcuDataConvertor[] convertors = ecuData.getConvertors();
|
||||
for (TableWrapper wrapper : wrappers) {
|
||||
try {
|
||||
EcuDataConvertor convertor = convertors[wrapper.getLogParamConvertorIndex()];
|
||||
wrapper.getTable().setLiveValue(convertor.convert(value));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<Table> tables = tableMap.get(ecuData.getId());
|
||||
if (tables != null && !tables.isEmpty()) {
|
||||
double liveValue = ecuData.getSelectedConvertor().convert(value);
|
||||
for (Table table : tables) {
|
||||
table.setLiveValue(liveValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,52 +36,18 @@ public final class TableUpdateHandler implements DataUpdateHandler {
|
|||
}
|
||||
|
||||
public void registerTable(Table table) {
|
||||
TableWrapper wrapper = new TableWrapper(table);
|
||||
String logParamId = wrapper.getLogParamId();
|
||||
if (!tables.containsKey(logParamId)) {
|
||||
tables.put(logParamId, new ArrayList<TableWrapper>());
|
||||
String logParam = table.getLogParam();
|
||||
if (!tableMap.containsKey(logParam)) {
|
||||
tableMap.put(logParam, new ArrayList<Table>());
|
||||
}
|
||||
List<Table> tables = tableMap.get(logParam);
|
||||
if (!tables.contains(table)) {
|
||||
tables.add(table);
|
||||
}
|
||||
tables.get(logParamId).add(wrapper);
|
||||
}
|
||||
|
||||
public static TableUpdateHandler getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private static final class TableWrapper {
|
||||
private final Table table;
|
||||
private String logParamId;
|
||||
private int logParamConvertorIndex;
|
||||
|
||||
public TableWrapper(Table table) {
|
||||
this.table = table;
|
||||
if (table.getLogParam() != null) {
|
||||
StringTokenizer st = new StringTokenizer(table.getLogParam(), ":");
|
||||
if (st.hasMoreTokens()) {
|
||||
logParamId = st.nextToken();
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
logParamConvertorIndex = Integer.parseInt(st.nextToken());
|
||||
} catch (NumberFormatException e) {
|
||||
logParamConvertorIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public String getLogParamId() {
|
||||
return logParamId;
|
||||
}
|
||||
|
||||
public int getLogParamConvertorIndex() {
|
||||
return logParamConvertorIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue