diff --git a/logger.dtd b/logger.dtd index df591038..32ea47f4 100644 --- a/logger.dtd +++ b/logger.dtd @@ -2,10 +2,14 @@ - + + + + - + + @@ -33,7 +37,14 @@ - + + + + + + + + diff --git a/logger.xml b/logger.xml index 7b1debc0..6247f9be 100644 --- a/logger.xml +++ b/logger.xml @@ -1,9 +1,10 @@ - + + @@ -818,7 +819,7 @@ - +
0x020C60
@@ -827,7 +828,7 @@
- +
0x020C61
@@ -836,7 +837,8 @@
- +
0x020C65
@@ -852,8 +854,8 @@ - - + + @@ -864,18 +866,19 @@ - - + + - + - - + + @@ -885,6 +888,7 @@
+ @@ -957,6 +961,57 @@ + + + + + +
+ + 0xFFFFFF + + + 0xEEEEEE + +
+ + + +
+ + +
+ + 0xFFFFFF + +
+ + + +
+ + +
+ + 0xFFFFFE + 0xFFFFFF + + + 0xFFFFFE + 0xFFFFFF + + + 0xFFFFFE + 0xFFFFFF + +
+ + + +
+ +
+
diff --git a/src/enginuity/logger/EcuLogger.java b/src/enginuity/logger/EcuLogger.java index 90010fef..ade27fa6 100644 --- a/src/enginuity/logger/EcuLogger.java +++ b/src/enginuity/logger/EcuLogger.java @@ -95,8 +95,9 @@ TODO: Clean up this class! So much to do, so little time.... Autoconnect Stuff: -TODO: Add reconnect/refresh connection button/menu item. -TODO: Finish ecu init callback - parse it, etc +TODO: Finish ecu init callback +TODO: Add extra ecu init parsing & only display parameters supported by ecu, or all if unknown ecu. +TODO: Finish ecu specific parameters (IAM, Engine Load) */ public final class EcuLogger extends JFrame implements WindowListener, PropertyChangeListener, MessageListener { @@ -104,6 +105,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC private static final String HEADING_PARAMETERS = "Parameters"; private static final String HEADING_SWITCHES = "Switches"; private Settings settings; + private String ecuId; private LoggerController controller; private JLabel statusBarLabel; private JTabbedPane tabbedPane; @@ -146,7 +148,8 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC // TODO: Do something useful with this!! EcuInitCallback ecuInitCallback = new EcuInitCallback() { public void callback(EcuInit ecuInit) { - System.out.println("ECU ID = " + ecuInit.getEcuId()); + ecuId = ecuInit.getEcuId(); + System.out.println("ECU ID = " + ecuId); } }; @@ -204,7 +207,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC public void reloadUserProfile(String profileFilePath) { try { EcuDataLoader dataLoader = new EcuDataLoaderImpl(); - dataLoader.loadFromXml(settings.getLoggerConfigFilePath(), settings.getLoggerProtocol()); + dataLoader.loadFromXml(settings.getLoggerConfigFilePath(), settings.getLoggerProtocol(), ecuId); loadUserProfile(dataLoader, profileFilePath); File profileFile = new File(profileFilePath); if (profileFile.exists()) { diff --git a/src/enginuity/logger/definition/EcuDataLoader.java b/src/enginuity/logger/definition/EcuDataLoader.java index e324166d..72a3974f 100644 --- a/src/enginuity/logger/definition/EcuDataLoader.java +++ b/src/enginuity/logger/definition/EcuDataLoader.java @@ -25,7 +25,7 @@ import java.util.List; public interface EcuDataLoader { - void loadFromXml(String loggerConfigFilePath, String protocol); + void loadFromXml(String loggerConfigFilePath, String protocol, String ecuId); List getEcuParameters(); diff --git a/src/enginuity/logger/definition/EcuDataLoaderImpl.java b/src/enginuity/logger/definition/EcuDataLoaderImpl.java index b8df3055..7174dbe3 100644 --- a/src/enginuity/logger/definition/EcuDataLoaderImpl.java +++ b/src/enginuity/logger/definition/EcuDataLoaderImpl.java @@ -37,12 +37,13 @@ public final class EcuDataLoaderImpl implements EcuDataLoader { private List ecuParameters = new ArrayList(); private List ecuSwitches = new ArrayList(); - public void loadFromXml(String loggerConfigFilePath, String protocol) { + public void loadFromXml(String loggerConfigFilePath, String protocol, String ecuId) { checkNotNullOrEmpty(loggerConfigFilePath, "loggerConfigFilePath"); + checkNotNullOrEmpty(protocol, "protocol"); try { InputStream inputStream = new BufferedInputStream(new FileInputStream(new File(loggerConfigFilePath))); try { - LoggerDefinitionHandler handler = new LoggerDefinitionHandler(protocol); + LoggerDefinitionHandler handler = new LoggerDefinitionHandler(protocol, ecuId); getSaxParser().parse(inputStream, handler); ecuParameters = handler.getEcuParameters(); ecuSwitches = handler.getEcuSwitches(); diff --git a/src/enginuity/logger/definition/xml/LoggerDefinitionHandler.java b/src/enginuity/logger/definition/xml/LoggerDefinitionHandler.java index 2a0f4434..42f3b908 100644 --- a/src/enginuity/logger/definition/xml/LoggerDefinitionHandler.java +++ b/src/enginuity/logger/definition/xml/LoggerDefinitionHandler.java @@ -55,6 +55,8 @@ public final class LoggerDefinitionHandler extends DefaultHandler { private static final String TAG_BYTE = "byte"; private static final String TAG_REF = "ref"; private static final String TAG_SWITCH = "switch"; + private static final String TAG_ECUPARAM = "ecuparam"; + private static final String TAG_ECU = "ecu"; private static final String ATTR_ID = "id"; private static final String ATTR_NAME = "name"; private static final String ATTR_DESC = "desc"; @@ -63,27 +65,32 @@ public final class LoggerDefinitionHandler extends DefaultHandler { private static final String ATTR_FORMAT = "format"; private static final String ATTR_BYTE = "byte"; private static final String ATTR_BIT = "bit"; + private static final String ATTR_PARAMETER = "parameter"; private static final String ATTR_FILELOGCONTROLLER = "filelogcontroller"; + private final String protocol; + private final String ecuId; private List params; private List switches; private Map ecuDataMap; private String id; private String name; private String desc; + private String ecuIds; private Set addressList; private Set dependsList; + private Map ecuAddressMap; private boolean derived; private int bit; private boolean fileLogController; private Set convertorList; private Set derivedConvertorList; private StringBuilder charBuffer; - private String protocol; private boolean parseProtocol; - public LoggerDefinitionHandler(String protocol) { + public LoggerDefinitionHandler(String protocol, String ecuId) { checkNotNullOrEmpty(protocol, "protocol"); this.protocol = protocol; + this.ecuId = ecuId; } public void startDocument() { @@ -102,12 +109,13 @@ public final class LoggerDefinitionHandler extends DefaultHandler { desc = attributes.getValue(ATTR_DESC); } else if (TAG_ADDRESS.equals(qName)) { addressList = new LinkedHashSet(); + ecuAddressMap = new HashMap(); derived = false; } else if (TAG_DEPENDS.equals(qName)) { dependsList = new LinkedHashSet(); derived = true; } else if (TAG_REF.equals(qName)) { - dependsList.add(attributes.getValue(ATTR_ID)); + dependsList.add(attributes.getValue(ATTR_PARAMETER)); } else if (TAG_CONVERSIONS.equals(qName)) { convertorList = new LinkedHashSet(); derivedConvertorList = new LinkedHashSet(); @@ -127,6 +135,13 @@ public final class LoggerDefinitionHandler extends DefaultHandler { addressList.add(attributes.getValue(ATTR_BYTE)); bit = Integer.valueOf(attributes.getValue(ATTR_BIT)); fileLogController = YES.equals(attributes.getValue(ATTR_FILELOGCONTROLLER)); + } else if (TAG_ECUPARAM.equals(qName)) { + id = attributes.getValue(ATTR_ID); + name = attributes.getValue(ATTR_NAME); + desc = attributes.getValue(ATTR_DESC); + } else if (TAG_ECU.equals(qName)) { + ecuIds = attributes.getValue(ATTR_ID); + addressList = new LinkedHashSet(); } } charBuffer = new StringBuilder(); @@ -154,18 +169,26 @@ public final class LoggerDefinitionHandler extends DefaultHandler { param = new EcuDerivedParameterImpl(id, name, desc, dependencies.toArray(new EcuData[dependencies.size()]), derivedConvertorList.toArray(new EcuDerivedParameterConvertor[derivedConvertorList.size()])); } else { - String[] addresses = new String[addressList.size()]; - addressList.toArray(addresses); + String[] addresses = toArray(addressList); param = new EcuParameterImpl(id, name, desc, addresses, convertorList.toArray(new EcuDataConvertor[convertorList.size()])); } params.add(param); ecuDataMap.put(param.getId(), param); } else if (TAG_SWITCH.equals(qName)) { - String[] addresses = new String[addressList.size()]; - addressList.toArray(addresses); - EcuSwitch ecuSwitch = new EcuSwitchImpl(id, name, desc, addresses, new EcuDataConvertor[]{new EcuSwitchConvertorImpl(bit)}, fileLogController); + EcuSwitch ecuSwitch = new EcuSwitchImpl(id, name, desc, toArray(addressList), new EcuDataConvertor[]{new EcuSwitchConvertorImpl(bit)}, fileLogController); switches.add(ecuSwitch); ecuDataMap.put(ecuSwitch.getId(), ecuSwitch); + } else if (TAG_ECUPARAM.equals(qName)) { + if (ecuId != null && ecuAddressMap.containsKey(ecuId)) { + EcuParameter param = new EcuParameterImpl(id, name, desc, ecuAddressMap.get(ecuId), convertorList.toArray(new EcuDataConvertor[convertorList.size()])); + params.add(param); + ecuDataMap.put(param.getId(), param); + } + } else if (TAG_ECU.equals(qName)) { + String[] addresses = toArray(addressList); + for (String ecuId : ecuIds.split(",")) { + ecuAddressMap.put(ecuId, addresses); + } } } } @@ -177,4 +200,11 @@ public final class LoggerDefinitionHandler extends DefaultHandler { public List getEcuSwitches() { return switches; } + + private String[] toArray(Set set) { + String[] addresses = new String[set.size()]; + set.toArray(addresses); + return addresses; + } + } diff --git a/src/enginuity/util/ParamChecker.java b/src/enginuity/util/ParamChecker.java index 75fbcff5..2ee8091e 100644 --- a/src/enginuity/util/ParamChecker.java +++ b/src/enginuity/util/ParamChecker.java @@ -22,6 +22,7 @@ package enginuity.util; import java.util.Collection; +import java.util.Map; public final class ParamChecker { @@ -58,6 +59,12 @@ public final class ParamChecker { } } + public static void checkNotNullOrEmpty(Map param, String paramName) { + if (param == null || param.isEmpty()) { + throw new IllegalArgumentException("Parameter " + paramName + " must not be null or empty"); + } + } + public static void checkGreaterThanZero(int param, String paramName) { if (param <= 0) { throw new IllegalArgumentException("Parameter " + paramName + " must be > 0"); @@ -73,4 +80,5 @@ public final class ParamChecker { public static boolean isNullOrEmpty(String param) { return param == null || param.length() == 0; } + }