diff --git a/profile.dtd b/profile.dtd
new file mode 100644
index 00000000..d4d5a5b0
--- /dev/null
+++ b/profile.dtd
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/profile.xml b/profile.xml
new file mode 100644
index 00000000..e298190e
--- /dev/null
+++ b/profile.xml
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/enginuity/Settings.java b/src/enginuity/Settings.java
index ecef3640..7a95e80d 100644
--- a/src/enginuity/Settings.java
+++ b/src/enginuity/Settings.java
@@ -41,6 +41,7 @@ public class Settings implements Serializable {
private String loggerPort = "COM4";
private String loggerProtocol = "SSM";
private String loggerConfigFilePath = "./logger.xml";
+ private String loggerProfileFilePath = "./profile.xml";
private File loggerOutputDir = new File(".");
private Dimension loggerWindowSize = new Dimension(1000, 600);
@@ -317,4 +318,12 @@ public class Settings implements Serializable {
public void setLoggerWindowSize(Dimension loggerWindowSize) {
this.loggerWindowSize = loggerWindowSize;
}
+
+ public String getLoggerProfileFilePath() {
+ return loggerProfileFilePath;
+ }
+
+ public void setLoggerProfileFilePath(String loggerProfileFilePath) {
+ this.loggerProfileFilePath = loggerProfileFilePath;
+ }
}
\ No newline at end of file
diff --git a/src/enginuity/logger/EcuLogger.java b/src/enginuity/logger/EcuLogger.java
index 342964e2..84837078 100644
--- a/src/enginuity/logger/EcuLogger.java
+++ b/src/enginuity/logger/EcuLogger.java
@@ -15,6 +15,9 @@ import enginuity.logger.ui.ParameterListTableModel;
import enginuity.logger.ui.ParameterRegistrationBroker;
import enginuity.logger.ui.ParameterRegistrationBrokerImpl;
import enginuity.logger.ui.SerialPortComboBox;
+import enginuity.logger.ui.UserProfile;
+import enginuity.logger.ui.UserProfileLoader;
+import enginuity.logger.ui.UserProfileLoaderImpl;
import enginuity.logger.ui.handler.DashboardUpdateHandler;
import enginuity.logger.ui.handler.DataUpdateHandler;
import enginuity.logger.ui.handler.DataUpdateHandlerManager;
@@ -93,8 +96,8 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
initControllerListeners();
startPortRefresherThread();
initUserInterface();
- initParameterUpdateHandlers();
- loadEcuParamsFromConfig();
+ initDataUpdateHandlers();
+ loadEcuDataFromConfig(loadUserProfile(settings));
}
private void bootstrap(String title, Settings settings) {
@@ -151,24 +154,31 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
getContentPane().add(mainPanel);
}
- private void loadEcuParamsFromConfig() {
+ private UserProfile loadUserProfile(Settings settings) {
+ UserProfileLoader profileLoader = new UserProfileLoaderImpl();
+ return profileLoader.loadProfile(settings.getLoggerProfileFilePath());
+ }
+
+ private void loadEcuDataFromConfig(UserProfile profile) {
try {
EcuDataLoader dataLoader = new EcuDataLoaderImpl();
dataLoader.loadFromXml(settings.getLoggerConfigFilePath(), settings.getLoggerProtocol());
- loadEcuParams(dataLoader.getEcuParameters());
- loadEcuSwitches(dataLoader.getEcuSwitches());
+ loadEcuData(dataLoader, profile);
} catch (Exception e) {
e.printStackTrace();
reportError(e);
}
}
- private void loadEcuParams(List ecuParams) {
- sort(ecuParams, new EcuDataComparator());
+ private void loadEcuData(EcuDataLoader dataLoader, UserProfile profile) {
+ List ecuParams = dataLoader.getEcuParameters();
+ addConvertorUpdateListeners(ecuParams);
+ loadEcuParams(ecuParams, profile);
+ loadEcuSwitches(dataLoader.getEcuSwitches(), profile);
+ }
+
+ private void addConvertorUpdateListeners(List ecuParams) {
for (EcuParameter ecuParam : ecuParams) {
- dataTabParamListTableModel.addParam(ecuParam);
- graphTabParamListTableModel.addParam(ecuParam);
- dashboardTabParamListTableModel.addParam(ecuParam);
ecuParam.addConvertorUpdateListener(fileUpdateHandler);
ecuParam.addConvertorUpdateListener(liveDataUpdateHandler);
ecuParam.addConvertorUpdateListener(graphUpdateHandler);
@@ -176,16 +186,43 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
}
}
- private void loadEcuSwitches(List ecuSwitches) {
- sort(ecuSwitches, new EcuDataComparator());
- for (EcuSwitch ecuSwitch : ecuSwitches) {
- dataTabSwitchListTableModel.addParam(ecuSwitch);
- graphTabSwitchListTableModel.addParam(ecuSwitch);
- dashboardTabSwitchListTableModel.addParam(ecuSwitch);
+ private void loadEcuParams(List ecuParams, UserProfile profile) {
+ clearParamTableModels();
+ sort(ecuParams, new EcuDataComparator());
+ for (EcuParameter ecuParam : ecuParams) {
+ if (profile.contains(ecuParam)) {
+ dataTabParamListTableModel.addParam(ecuParam);
+ graphTabParamListTableModel.addParam(ecuParam);
+ dashboardTabParamListTableModel.addParam(ecuParam);
+ }
}
}
- private void initParameterUpdateHandlers() {
+ private void clearParamTableModels() {
+ dataTabParamListTableModel.clear();
+ graphTabParamListTableModel.clear();
+ dashboardTabParamListTableModel.clear();
+ }
+
+ private void loadEcuSwitches(List ecuSwitches, UserProfile profile) {
+ clearSwitchTableModels();
+ sort(ecuSwitches, new EcuDataComparator());
+ for (EcuSwitch ecuSwitch : ecuSwitches) {
+ if (profile.contains(ecuSwitch)) {
+ dataTabSwitchListTableModel.addParam(ecuSwitch);
+ graphTabSwitchListTableModel.addParam(ecuSwitch);
+ dashboardTabSwitchListTableModel.addParam(ecuSwitch);
+ }
+ }
+ }
+
+ private void clearSwitchTableModels() {
+ dataTabSwitchListTableModel.clear();
+ graphTabSwitchListTableModel.clear();
+ dashboardTabSwitchListTableModel.clear();
+ }
+
+ private void initDataUpdateHandlers() {
DataUpdateHandler threadedFileUpdateHandler = startHandlerInThread(fileUpdateHandler);
dataHandlerManager.addHandler(startHandlerInThread(liveDataUpdateHandler));
dataHandlerManager.addHandler(threadedFileUpdateHandler);
diff --git a/src/enginuity/logger/definition/EcuDataLoaderImpl.java b/src/enginuity/logger/definition/EcuDataLoaderImpl.java
index ec2863c3..9e8de4fc 100644
--- a/src/enginuity/logger/definition/EcuDataLoaderImpl.java
+++ b/src/enginuity/logger/definition/EcuDataLoaderImpl.java
@@ -1,10 +1,10 @@
package enginuity.logger.definition;
import enginuity.logger.exception.ConfigurationException;
+import static enginuity.logger.xml.SaxParserFactory.getSaxParser;
import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -21,7 +21,7 @@ public final class EcuDataLoaderImpl implements EcuDataLoader {
try {
InputStream inputStream = new BufferedInputStream(new FileInputStream(new File(loggerConfigFilePath)));
try {
- SAXParser parser = getSaxParserFactory().newSAXParser();
+ SAXParser parser = getSaxParser();
LoggerDefinitionHandler handler = new LoggerDefinitionHandler(protocol);
parser.parse(inputStream, handler);
ecuParameters = handler.getEcuParameters();
@@ -42,12 +42,4 @@ public final class EcuDataLoaderImpl implements EcuDataLoader {
return ecuSwitches;
}
- private SAXParserFactory getSaxParserFactory() {
- SAXParserFactory parserFactory = SAXParserFactory.newInstance();
- parserFactory.setNamespaceAware(false);
- parserFactory.setValidating(true);
- parserFactory.setXIncludeAware(false);
- return parserFactory;
- }
-
}
diff --git a/src/enginuity/logger/definition/LoggerDefinitionHandler.java b/src/enginuity/logger/definition/LoggerDefinitionHandler.java
index bd139303..49214482 100644
--- a/src/enginuity/logger/definition/LoggerDefinitionHandler.java
+++ b/src/enginuity/logger/definition/LoggerDefinitionHandler.java
@@ -1,6 +1,6 @@
package enginuity.logger.definition;
-import enginuity.util.ParamChecker;
+import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
@@ -50,7 +50,7 @@ public final class LoggerDefinitionHandler extends DefaultHandler {
private boolean parseProtocol;
public LoggerDefinitionHandler(String protocol) {
- ParamChecker.checkNotNullOrEmpty(protocol, "protocol");
+ checkNotNullOrEmpty(protocol, "protocol");
this.protocol = protocol;
}
diff --git a/src/enginuity/logger/ui/ParameterListTableModel.java b/src/enginuity/logger/ui/ParameterListTableModel.java
index 7e9bb65a..9e484721 100644
--- a/src/enginuity/logger/ui/ParameterListTableModel.java
+++ b/src/enginuity/logger/ui/ParameterListTableModel.java
@@ -77,4 +77,10 @@ public final class ParameterListTableModel extends AbstractTableModel {
fireTableDataChanged();
}
}
+
+ public synchronized void clear() {
+ paramRowMap.clear();
+ registeredEcuData.clear();
+ fireTableDataChanged();
+ }
}
diff --git a/src/enginuity/logger/ui/UserProfile.java b/src/enginuity/logger/ui/UserProfile.java
new file mode 100644
index 00000000..0a8fac3c
--- /dev/null
+++ b/src/enginuity/logger/ui/UserProfile.java
@@ -0,0 +1,12 @@
+package enginuity.logger.ui;
+
+import enginuity.logger.definition.EcuParameter;
+import enginuity.logger.definition.EcuSwitch;
+
+public interface UserProfile {
+
+ boolean contains(EcuParameter ecuParam);
+
+ boolean contains(EcuSwitch ecuSwitch);
+
+}
diff --git a/src/enginuity/logger/ui/UserProfileHandler.java b/src/enginuity/logger/ui/UserProfileHandler.java
new file mode 100644
index 00000000..0be34a8f
--- /dev/null
+++ b/src/enginuity/logger/ui/UserProfileHandler.java
@@ -0,0 +1,34 @@
+package enginuity.logger.ui;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public final class UserProfileHandler extends DefaultHandler {
+ private static final String TAG_PARAMETER = "parameter";
+ private static final String TAG_SWITCH = "switch";
+ private static final String ATTR_ID = "id";
+ private UserProfile profile;
+ private Set params;
+ private Set switches;
+
+ public void startDocument() {
+ params = new HashSet();
+ switches = new HashSet();
+ profile = new UserProfileImpl(params, switches);
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (TAG_PARAMETER.equals(qName)) {
+ params.add(attributes.getValue(ATTR_ID));
+ } else if (TAG_SWITCH.equals(qName)) {
+ switches.add(attributes.getValue(ATTR_ID));
+ }
+ }
+
+ public UserProfile getUserProfile() {
+ return profile;
+ }
+}
diff --git a/src/enginuity/logger/ui/UserProfileImpl.java b/src/enginuity/logger/ui/UserProfileImpl.java
new file mode 100644
index 00000000..d9f8615c
--- /dev/null
+++ b/src/enginuity/logger/ui/UserProfileImpl.java
@@ -0,0 +1,27 @@
+package enginuity.logger.ui;
+
+import enginuity.logger.definition.EcuParameter;
+import enginuity.logger.definition.EcuSwitch;
+import static enginuity.util.ParamChecker.checkNotNull;
+
+import java.util.Set;
+
+public final class UserProfileImpl implements UserProfile {
+ private final Set params;
+ private final Set switches;
+
+ public UserProfileImpl(Set params, Set switches) {
+ checkNotNull(params, "params");
+ checkNotNull(switches, "switches");
+ this.params = params;
+ this.switches = switches;
+ }
+
+ public boolean contains(EcuParameter ecuParam) {
+ return params.contains(ecuParam.getId());
+ }
+
+ public boolean contains(EcuSwitch ecuSwitch) {
+ return switches.contains(ecuSwitch.getId());
+ }
+}
diff --git a/src/enginuity/logger/ui/UserProfileLoader.java b/src/enginuity/logger/ui/UserProfileLoader.java
new file mode 100644
index 00000000..641669da
--- /dev/null
+++ b/src/enginuity/logger/ui/UserProfileLoader.java
@@ -0,0 +1,5 @@
+package enginuity.logger.ui;
+
+public interface UserProfileLoader {
+ UserProfile loadProfile(String filePath);
+}
diff --git a/src/enginuity/logger/ui/UserProfileLoaderImpl.java b/src/enginuity/logger/ui/UserProfileLoaderImpl.java
new file mode 100644
index 00000000..a27bd3a6
--- /dev/null
+++ b/src/enginuity/logger/ui/UserProfileLoaderImpl.java
@@ -0,0 +1,31 @@
+package enginuity.logger.ui;
+
+import enginuity.logger.exception.ConfigurationException;
+import static enginuity.logger.xml.SaxParserFactory.getSaxParser;
+import static enginuity.util.ParamChecker.checkNotNullOrEmpty;
+
+import javax.xml.parsers.SAXParser;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+public final class UserProfileLoaderImpl implements UserProfileLoader {
+
+ public UserProfile loadProfile(String userProfileFilePath) {
+ checkNotNullOrEmpty(userProfileFilePath, "userProfileFilePath");
+ try {
+ InputStream inputStream = new BufferedInputStream(new FileInputStream(new File(userProfileFilePath)));
+ try {
+ SAXParser parser = getSaxParser();
+ UserProfileHandler handler = new UserProfileHandler();
+ parser.parse(inputStream, handler);
+ return handler.getUserProfile();
+ } finally {
+ inputStream.close();
+ }
+ } catch (Exception e) {
+ throw new ConfigurationException(e);
+ }
+ }
+}
diff --git a/src/enginuity/logger/xml/SaxParserFactory.java b/src/enginuity/logger/xml/SaxParserFactory.java
new file mode 100644
index 00000000..16622402
--- /dev/null
+++ b/src/enginuity/logger/xml/SaxParserFactory.java
@@ -0,0 +1,21 @@
+package enginuity.logger.xml;
+
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+public final class SaxParserFactory {
+
+ private SaxParserFactory() {
+ }
+
+ public static SAXParser getSaxParser() throws ParserConfigurationException, SAXException {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ parserFactory.setNamespaceAware(false);
+ parserFactory.setValidating(true);
+ parserFactory.setXIncludeAware(false);
+ return parserFactory.newSAXParser();
+ }
+}