mirror of https://github.com/rusefi/RomRaider.git
Refactor EcuData classes to include new fields parsed from logger.xml
for new DS2 protocol
This commit is contained in:
parent
2d9bbf4b97
commit
c4961b8159
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2014 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,4 +23,9 @@ public interface EcuData extends LoggerData {
|
|||
|
||||
EcuAddress getAddress();
|
||||
|
||||
String getGroup();
|
||||
|
||||
String getSubgroup();
|
||||
|
||||
int getGroupSize();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2014 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -50,30 +50,37 @@ public final class EcuDerivedParameterImpl implements EcuParameter {
|
|||
setEcuDatas(ecuDatas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor getSelectedConvertor() {
|
||||
return convertors[selectedConvertorIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor[] getConvertors() {
|
||||
return convertors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectConvertor(EcuDataConvertor convertor) {
|
||||
if (convertor != getSelectedConvertor()) {
|
||||
for (int i = 0; i < convertors.length; i++) {
|
||||
|
@ -86,23 +93,42 @@ public final class EcuDerivedParameterImpl implements EcuParameter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataType getDataType() {
|
||||
return PARAMETER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConvertorUpdateListener(ConvertorUpdateListener listener) {
|
||||
checkNotNull(listener, "listener");
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubgroup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private EcuAddress buildCombinedAddress(EcuData[] ecuDatas) {
|
||||
String[] addresses = new String[0];
|
||||
for (EcuData ecuData : ecuDatas) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2014 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,6 +22,7 @@ package com.romraider.logger.ecu.definition;
|
|||
import static com.romraider.logger.ecu.definition.EcuDataType.PARAMETER;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import static com.romraider.util.ParamChecker.checkNotNullOrEmpty;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -30,12 +31,18 @@ public final class EcuParameterImpl implements EcuParameter {
|
|||
private final String name;
|
||||
private final String description;
|
||||
private final EcuAddress address;
|
||||
private final String group;
|
||||
private final String subgroup;
|
||||
private final int groupsize;
|
||||
private final EcuDataConvertor[] convertors;
|
||||
private final Set<ConvertorUpdateListener> listeners = new HashSet<ConvertorUpdateListener>();
|
||||
private int selectedConvertorIndex;
|
||||
private boolean selected;
|
||||
|
||||
public EcuParameterImpl(String id, String name, String description, EcuAddress address, EcuDataConvertor[] convertors) {
|
||||
public EcuParameterImpl(
|
||||
String id, String name, String description, EcuAddress address,
|
||||
String group, String subgroup, String groupsize,
|
||||
EcuDataConvertor[] convertors) {
|
||||
checkNotNullOrEmpty(id, "id");
|
||||
checkNotNullOrEmpty(name, "name");
|
||||
checkNotNull(description, "description");
|
||||
|
@ -45,33 +52,58 @@ public final class EcuParameterImpl implements EcuParameter {
|
|||
this.name = name;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.group = group == null ? null : group.toLowerCase();
|
||||
this.subgroup = subgroup == null ? null : subgroup.toLowerCase();
|
||||
this.groupsize = groupsize == null ? 0 : Integer.parseInt(groupsize);
|
||||
this.convertors = convertors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubgroup() {
|
||||
return subgroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupSize() {
|
||||
return groupsize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor getSelectedConvertor() {
|
||||
return convertors[selectedConvertorIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor[] getConvertors() {
|
||||
return convertors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectConvertor(EcuDataConvertor convertor) {
|
||||
if (convertor != getSelectedConvertor()) {
|
||||
for (int i = 0; i < convertors.length; i++) {
|
||||
|
@ -84,18 +116,22 @@ public final class EcuParameterImpl implements EcuParameter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataType getDataType() {
|
||||
return PARAMETER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConvertorUpdateListener(ConvertorUpdateListener listener) {
|
||||
checkNotNull(listener, "listener");
|
||||
listeners.add(listener);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2014 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,12 +28,18 @@ public final class EcuSwitchImpl implements EcuSwitch {
|
|||
private final String name;
|
||||
private final String description;
|
||||
private final EcuAddress address;
|
||||
private final String group;
|
||||
private final String subgroup;
|
||||
private final int groupsize;
|
||||
private final EcuDataConvertor[] convertors;
|
||||
private int selectedConvertorIndex;
|
||||
private boolean fileLogController;
|
||||
private boolean selected;
|
||||
|
||||
public EcuSwitchImpl(String id, String name, String description, EcuAddress address, EcuDataConvertor[] convertors) {
|
||||
public EcuSwitchImpl(
|
||||
String id, String name, String description, EcuAddress address,
|
||||
String group, String subgroup, String groupsize,
|
||||
EcuDataConvertor[] convertors) {
|
||||
checkNotNullOrEmpty(id, "id");
|
||||
checkNotNullOrEmpty(name, "name");
|
||||
checkNotNull(description, "description");
|
||||
|
@ -43,33 +49,58 @@ public final class EcuSwitchImpl implements EcuSwitch {
|
|||
this.name = name;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.group = group;
|
||||
this.subgroup = subgroup;
|
||||
this.groupsize = groupsize == null ? 0 : Integer.parseInt(groupsize);
|
||||
this.convertors = convertors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubgroup() {
|
||||
return subgroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupSize() {
|
||||
return groupsize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor getSelectedConvertor() {
|
||||
return convertors[selectedConvertorIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataConvertor[] getConvertors() {
|
||||
return convertors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectConvertor(EcuDataConvertor convertor) {
|
||||
for (int i = 0; i < convertors.length; i++) {
|
||||
EcuDataConvertor dataConvertor = convertors[i];
|
||||
|
@ -79,14 +110,17 @@ public final class EcuSwitchImpl implements EcuSwitch {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EcuDataType getDataType() {
|
||||
return SWITCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
private static final String ATTR_LENGTH = "length";
|
||||
private static final String ATTR_ECUBIT = "ecubit";
|
||||
private static final String ATTR_UNITS = "units";
|
||||
private static final String ATTR_GROUP = "group";
|
||||
private static final String ATTR_SUBGROUP = "subgroup";
|
||||
private static final String ATTR_GROUPSIZE = "groupsize";
|
||||
private static final String ATTR_EXPRESSION = "expr";
|
||||
private static final String ATTR_FORMAT = "format";
|
||||
private static final String ATTR_BYTE = "byte";
|
||||
|
@ -119,6 +122,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
private String desc;
|
||||
private String ecuByteIndex;
|
||||
private String ecuBit;
|
||||
private String group;
|
||||
private String subgroup;
|
||||
private String groupsize;
|
||||
private String ecuIds;
|
||||
private List<String> addrStrings = new ArrayList<String>();
|
||||
private boolean EcuAddressCreated;
|
||||
|
@ -144,6 +150,7 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
private String testerAddr;
|
||||
private List<Module> moduleList;
|
||||
private Map<String, Collection<Module>> transportList;
|
||||
|
||||
public LoggerDefinitionHandler(String protocol, String fileLoggingControllerSwitchId, EcuInit ecuInit) {
|
||||
checkNotNullOrEmpty(protocol, "protocol");
|
||||
checkNotNullOrEmpty(fileLoggingControllerSwitchId, "fileLoggingControllerSwitchId");
|
||||
|
@ -179,6 +186,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
desc = attributes.getValue(ATTR_DESC);
|
||||
ecuByteIndex = attributes.getValue(ATTR_ECUBYTEINDEX);
|
||||
ecuBit = attributes.getValue(ATTR_ECUBIT);
|
||||
group = attributes.getValue(ATTR_GROUP);
|
||||
subgroup = attributes.getValue(ATTR_SUBGROUP);
|
||||
groupsize = attributes.getValue(ATTR_GROUPSIZE);
|
||||
target = attributes.getValue(ATTR_TARGET);
|
||||
resetLists();
|
||||
} else if (TAG_ADDRESS.equals(qName)) {
|
||||
|
@ -214,6 +224,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
desc = attributes.getValue(ATTR_DESC);
|
||||
ecuByteIndex = attributes.getValue(ATTR_ECUBYTEINDEX);
|
||||
ecuBit = attributes.getValue(ATTR_BIT);
|
||||
group = attributes.getValue(ATTR_GROUP);
|
||||
subgroup = attributes.getValue(ATTR_SUBGROUP);
|
||||
groupsize = attributes.getValue(ATTR_GROUPSIZE);
|
||||
target = attributes.getValue(ATTR_TARGET);
|
||||
address = new EcuAddressImpl(attributes.getValue(ATTR_BYTE), 1, Integer.valueOf(attributes.getValue(ATTR_BIT)));
|
||||
resetLists();
|
||||
|
@ -221,6 +234,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
id = attributes.getValue(ATTR_ID);
|
||||
name = attributes.getValue(ATTR_NAME);
|
||||
desc = attributes.getValue(ATTR_DESC);
|
||||
group = attributes.getValue(ATTR_GROUP);
|
||||
subgroup = attributes.getValue(ATTR_SUBGROUP);
|
||||
groupsize = attributes.getValue(ATTR_GROUPSIZE);
|
||||
target = attributes.getValue(ATTR_TARGET);
|
||||
resetLists();
|
||||
ecuAddressMap = new HashMap<String, EcuAddress>();
|
||||
|
@ -286,7 +302,8 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
if (convertorList.isEmpty()) {
|
||||
convertorList.add(new EcuParameterConvertorImpl());
|
||||
}
|
||||
EcuParameter param = new EcuParameterImpl(id, name, desc, address,
|
||||
EcuParameter param = new EcuParameterImpl(
|
||||
id, name, desc, address, group, subgroup, groupsize,
|
||||
convertorList.toArray(new EcuDataConvertor[convertorList.size()]));
|
||||
params.add(param);
|
||||
ecuDataMap.put(param.getId(), param);
|
||||
|
@ -305,7 +322,9 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
if (convertorList.isEmpty()) {
|
||||
convertorList.add(new EcuParameterConvertorImpl());
|
||||
}
|
||||
EcuParameter param = new EcuParameterImpl(id, name, desc, ecuAddressMap.get(ecuInit.getEcuId()),
|
||||
EcuParameter param = new EcuParameterImpl(
|
||||
id, name, desc, ecuAddressMap.get(ecuInit.getEcuId()),
|
||||
group, subgroup, groupsize,
|
||||
convertorList.toArray(new EcuDataConvertor[convertorList.size()]));
|
||||
params.add(param);
|
||||
ecuDataMap.put(param.getId(), param);
|
||||
|
@ -321,16 +340,22 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
|
|||
if (ecuByteIndex == null || ecuBit == null || ecuInit == null || isSupportedParameter(ecuInit,
|
||||
ecuByteIndex, ecuBit)) {
|
||||
EcuDataConvertor[] convertors = new EcuDataConvertor[]{new EcuSwitchConvertorImpl(address.getBit())};
|
||||
EcuSwitch ecuSwitch = new EcuSwitchImpl(id, name, desc, address, convertors);
|
||||
EcuSwitch ecuSwitch = new EcuSwitchImpl(
|
||||
id, name, desc, address,
|
||||
group, subgroup, groupsize, convertors);
|
||||
switches.add(ecuSwitch);
|
||||
ecuDataMap.put(ecuSwitch.getId(), ecuSwitch);
|
||||
if (id.equalsIgnoreCase(fileLoggingControllerSwitchId)) {
|
||||
fileLoggingControllerSwitch = new EcuSwitchImpl(id, name, desc, address, convertors);
|
||||
fileLoggingControllerSwitch = new EcuSwitchImpl(
|
||||
id, name, desc, address,
|
||||
group, subgroup, groupsize, convertors);
|
||||
}
|
||||
}
|
||||
} else if (TAG_DTCODE.equals(qName)) {
|
||||
final EcuDataConvertor[] convertors = new EcuDataConvertor[]{new EcuDtcConvertorImpl(address.getBit())};
|
||||
final EcuSwitch ecuSwitch = new EcuSwitchImpl(id, name, desc, address, convertors);
|
||||
final EcuSwitch ecuSwitch = new EcuSwitchImpl(
|
||||
id, name, desc, address,
|
||||
group, subgroup, groupsize, convertors);
|
||||
dtcodes.add(ecuSwitch);
|
||||
ecuDataMap.put(ecuSwitch.getId(), ecuSwitch);
|
||||
} else if (TAG_TRANSPORT.equals(qName)) {
|
||||
|
|
Loading…
Reference in New Issue