diff --git a/src/enginuity/logger/ecu/EcuLogger.java b/src/enginuity/logger/ecu/EcuLogger.java index 627f7635..83967d3c 100644 --- a/src/enginuity/logger/ecu/EcuLogger.java +++ b/src/enginuity/logger/ecu/EcuLogger.java @@ -648,7 +648,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC } private JMenuBar buildMenubar() { - return new EcuLoggerMenuBar(this); + return new EcuLoggerMenuBar(this, externalDataSources); } private JPanel buildControlToolbar() { diff --git a/src/enginuity/logger/ecu/external/ExternalDataSource.java b/src/enginuity/logger/ecu/external/ExternalDataSource.java index fbc50e1f..4ec48b1c 100644 --- a/src/enginuity/logger/ecu/external/ExternalDataSource.java +++ b/src/enginuity/logger/ecu/external/ExternalDataSource.java @@ -1,5 +1,8 @@ package enginuity.logger.ecu.external; +import enginuity.logger.ecu.EcuLogger; + +import javax.swing.Action; import java.util.List; public interface ExternalDataSource { @@ -10,18 +13,21 @@ public interface ExternalDataSource { List getDataItems(); - + Action getMenuAction(EcuLogger logger); + + void setPort(String port); + + String getPort(); + // ***************************** // Suggested Methods of interest // ***************************** - - public void setPort(String portName); - + public void connect(); - + public void disconnect(); - + public void startLogging(); - + public void stopLogging(); } diff --git a/src/enginuity/logger/ecu/external/TestExternalDataSource.java b/src/enginuity/logger/ecu/external/TestExternalDataSource.java index 16056160..107e0ab6 100644 --- a/src/enginuity/logger/ecu/external/TestExternalDataSource.java +++ b/src/enginuity/logger/ecu/external/TestExternalDataSource.java @@ -1,5 +1,8 @@ package enginuity.logger.ecu.external; +import enginuity.logger.ecu.EcuLogger; + +import javax.swing.Action; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -38,16 +41,22 @@ public final class TestExternalDataSource implements ExternalDataSource { dataItems.add(dataItem); return dataItems; } - - + + public Action getMenuAction(EcuLogger logger) { + return null; + } + + public void setPort(String port) { + } + + public String getPort() { + return null; + } + // ***************************** // Suggested Methods of interest // ***************************** - - public void setPort(String commPort){ - - } - + public void connect(){ } diff --git a/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java b/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java index 3fc45588..88294a56 100644 --- a/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java +++ b/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuBar.java @@ -1,6 +1,7 @@ package enginuity.logger.ecu.ui.swing.menubar; import enginuity.logger.ecu.EcuLogger; +import enginuity.logger.ecu.external.ExternalDataSource; import enginuity.logger.ecu.ui.swing.menubar.action.AboutAction; import enginuity.logger.ecu.ui.swing.menubar.action.DisconnectAction; import enginuity.logger.ecu.ui.swing.menubar.action.ExitAction; @@ -13,6 +14,7 @@ import enginuity.logger.ecu.ui.swing.menubar.action.ResetConnectionAction; import enginuity.logger.ecu.ui.swing.menubar.action.SaveProfileAction; import enginuity.logger.ecu.ui.swing.menubar.action.SaveProfileAsAction; +import javax.swing.Action; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JSeparator; @@ -31,40 +33,51 @@ import static java.awt.event.KeyEvent.VK_R; import static java.awt.event.KeyEvent.VK_S; import static java.awt.event.KeyEvent.VK_T; import static java.awt.event.KeyEvent.VK_X; +import java.util.List; public class EcuLoggerMenuBar extends JMenuBar { - public EcuLoggerMenuBar(EcuLogger logger) { + public EcuLoggerMenuBar(EcuLogger logger, List externalDataSources) { // file menu items JMenu fileMenu = new EcuLoggerMenu("File", VK_F); - fileMenu.add(new EcuLoggerMenuItem("Load Profile...", VK_L, getKeyStroke(VK_L, CTRL_MASK), new LoadProfileAction(logger))); - fileMenu.add(new EcuLoggerMenuItem("Reload Profile", VK_P, getKeyStroke(VK_P, CTRL_MASK), new ReloadProfileAction(logger))); - fileMenu.add(new EcuLoggerMenuItem("Save Profile", VK_S, getKeyStroke(VK_S, CTRL_MASK), new SaveProfileAction(logger))); - fileMenu.add(new EcuLoggerMenuItem("Save Profile As...", VK_A, getKeyStroke(VK_S, CTRL_MASK | SHIFT_MASK), new SaveProfileAsAction(logger))); + fileMenu.add(new EcuLoggerMenuItem("Load Profile...", new LoadProfileAction(logger), VK_L, getKeyStroke(VK_L, CTRL_MASK))); + fileMenu.add(new EcuLoggerMenuItem("Reload Profile", new ReloadProfileAction(logger), VK_P, getKeyStroke(VK_P, CTRL_MASK))); + fileMenu.add(new EcuLoggerMenuItem("Save Profile", new SaveProfileAction(logger), VK_S, getKeyStroke(VK_S, CTRL_MASK))); + fileMenu.add(new EcuLoggerMenuItem("Save Profile As...", new SaveProfileAsAction(logger), VK_A, getKeyStroke(VK_S, CTRL_MASK | SHIFT_MASK))); fileMenu.add(new JSeparator()); - fileMenu.add(new EcuLoggerMenuItem("Exit", VK_X, new ExitAction(logger))); + fileMenu.add(new EcuLoggerMenuItem("Exit", new ExitAction(logger), VK_X)); add(fileMenu); // settings menu items JMenu settingsMenu = new EcuLoggerMenu("Settings", VK_S); - settingsMenu.add(new EcuLoggerMenuItem("Log File Output Location...", VK_O, getKeyStroke(VK_O, CTRL_MASK), new LogFileLocationAction(logger))); + settingsMenu.add(new EcuLoggerMenuItem("Log File Output Location...", new LogFileLocationAction(logger), VK_O, getKeyStroke(VK_O, CTRL_MASK))); settingsMenu.add(new JSeparator()); settingsMenu.add(new EcuLoggerRadioButtonMenuItem("Control File Logging With Defogger Switch", VK_C, getKeyStroke(VK_C, CTRL_MASK), new LogFileControllerSwitchAction(logger), logger.getSettings().isFileLoggingControllerSwitchActive())); settingsMenu.add(new EcuLoggerRadioButtonMenuItem("Use Absolute Timestamp In Log File", VK_T, getKeyStroke(VK_T, CTRL_MASK), new LogFileAbsoluteTimestampAction(logger), logger.getSettings().isFileLoggingAbsoluteTimestamp())); add(settingsMenu); + // plugins menu items + JMenu pluginsMenu = new EcuLoggerMenu("Plugins", VK_P); + pluginsMenu.setEnabled(!externalDataSources.isEmpty()); + for (ExternalDataSource dataSource : externalDataSources) { + Action action = dataSource.getMenuAction(logger); + if (action != null) { + pluginsMenu.add(new EcuLoggerMenuItem(dataSource.getName(), action)); + } + } + add(pluginsMenu); + // connection menu items JMenu connectionMenu = new EcuLoggerMenu("Connection", VK_C); - connectionMenu.add(new EcuLoggerMenuItem("Reset", VK_R, getKeyStroke(VK_R, CTRL_MASK), new ResetConnectionAction(logger))); - connectionMenu.add(new EcuLoggerMenuItem("Disconnect", VK_D, getKeyStroke(VK_D, CTRL_MASK), new DisconnectAction(logger))); + connectionMenu.add(new EcuLoggerMenuItem("Reset", new ResetConnectionAction(logger), VK_R, getKeyStroke(VK_R, CTRL_MASK))); + connectionMenu.add(new EcuLoggerMenuItem("Disconnect", new DisconnectAction(logger), VK_D, getKeyStroke(VK_D, CTRL_MASK))); add(connectionMenu); // help menu stuff JMenu helpMenu = new EcuLoggerMenu("Help", VK_H); - helpMenu.add(new EcuLoggerMenuItem("About", VK_A, new AboutAction(logger))); + helpMenu.add(new EcuLoggerMenuItem("About", new AboutAction(logger), VK_A)); add(helpMenu); } - } diff --git a/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuItem.java b/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuItem.java index 83b89f68..a18e5fce 100644 --- a/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuItem.java +++ b/src/enginuity/logger/ecu/ui/swing/menubar/EcuLoggerMenuItem.java @@ -6,14 +6,19 @@ import javax.swing.KeyStroke; public final class EcuLoggerMenuItem extends JMenuItem { - public EcuLoggerMenuItem(String text, int mnemonic, Action action) { + public EcuLoggerMenuItem(String text, Action action) { + super(action); + setText(text); + } + + public EcuLoggerMenuItem(String text, Action action, int mnemonic) { super(action); setText(text); setMnemonic(mnemonic); } - public EcuLoggerMenuItem(String text, int mnemonic, KeyStroke accelerator, Action action) { - this(text, mnemonic, action); + public EcuLoggerMenuItem(String text, Action action, int mnemonic, KeyStroke accelerator) { + this(text, action, mnemonic); setAccelerator(accelerator); } diff --git a/src/enginuity/logger/innovate/plugin/GenericPluginMenuAction.java b/src/enginuity/logger/innovate/plugin/GenericPluginMenuAction.java new file mode 100644 index 00000000..e6995e85 --- /dev/null +++ b/src/enginuity/logger/innovate/plugin/GenericPluginMenuAction.java @@ -0,0 +1,39 @@ +package enginuity.logger.innovate.plugin; + +import enginuity.io.port.SerialPortDiscoverer; +import enginuity.io.port.SerialPortDiscovererImpl; +import enginuity.logger.ecu.EcuLogger; +import enginuity.logger.ecu.external.ExternalDataSource; +import enginuity.logger.ecu.ui.swing.menubar.action.AbstractAction; +import gnu.io.CommPortIdentifier; + +import static javax.swing.JOptionPane.QUESTION_MESSAGE; +import static javax.swing.JOptionPane.showInputDialog; +import java.awt.event.ActionEvent; +import java.util.List; + +public final class GenericPluginMenuAction extends AbstractAction { + private final SerialPortDiscoverer portDiscoverer = new SerialPortDiscovererImpl(); + private final ExternalDataSource dataSource; + + public GenericPluginMenuAction(EcuLogger logger, ExternalDataSource dataSource) { + super(logger); + this.dataSource = dataSource; + } + + public void actionPerformed(ActionEvent actionEvent) { + String port = (String) showInputDialog(logger, "Select COM port:", dataSource.getName() + " Plugin Settings", QUESTION_MESSAGE, null, + getPorts(), dataSource.getPort()); + dataSource.setPort(port); + } + + private String[] getPorts() { + List portIdentifiers = portDiscoverer.listPorts(); + String[] ports = new String[portIdentifiers.size()]; + for (int i = 0; i < portIdentifiers.size(); i++) { + CommPortIdentifier identifier = portIdentifiers.get(i); + ports[i] = identifier.getName(); + } + return ports; + } +} diff --git a/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java b/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java index e72f8f38..abb14c8a 100644 --- a/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java +++ b/src/enginuity/logger/innovate/plugin/InnovateControllerImpl.java @@ -6,6 +6,9 @@ import static enginuity.util.ThreadUtil.runAsDaemon; public final class InnovateControllerImpl implements InnovateController { private Lc1DataItem dataItem = new Lc1DataItem(); + public InnovateControllerImpl() { + } + public InnovateControllerImpl(InnovateConnection connection) { runAsDaemon(new InnovateRunnerImpl(connection, dataItem)); } diff --git a/src/enginuity/logger/innovate/plugin/Lc1Connection.java b/src/enginuity/logger/innovate/plugin/Lc1Connection.java index 88be42fe..1fa12e4c 100644 --- a/src/enginuity/logger/innovate/plugin/Lc1Connection.java +++ b/src/enginuity/logger/innovate/plugin/Lc1Connection.java @@ -17,10 +17,7 @@ public final class Lc1Connection implements InnovateConnection { checkNotNull(connectionProperties, "connectionProperties"); checkNotNullOrEmpty(portName, "portName"); this.sendTimeout = connectionProperties.getSendTimeout(); - - // Use TestSSMConnectionImpl for testing!! serialConnection = new SerialConnectionImpl(connectionProperties, portName); -// serialConnection = new TestSSMConnectionImpl(connectionProperties, portName); } public byte[] read() { @@ -50,35 +47,3 @@ public final class Lc1Connection implements InnovateConnection { serialConnection.close(); } } - -/* -Adding logger: LC-1 -Read bytes = B2825313012EB2825313012EB2825313012EB2825313012EB2825313012EB2825313013EB2825313013EB2825313013EB2825313013EB2825313013EB2825313014AB2825313014AB2825313014AB2825313014AB2825313014AB28253130158B28253130158B28253130158B28253130158B28253130158B28253130162B28253130162B28253130162B28253130162B28253130162B28253130171B28253130171B28253130171B28253130171B28253130171B2825313017EB2825313017EB2825313017EB2825313017EB2825313017EB28253130208B28253130208B28253130208B28253130208B28253130208B28253130218B28253130218B28253130218B28253130218B28253130218B28253130226B28253130226B28253130226B28253130226B28253130226B2825313022EB2825313022EB2825313022EB2825313022EB2825313022EB28253130237B28253130237B28253130237B28253130237B28253130237B28253130244B28253130244B28253130244B28253130244B28253130244B28253130251B28253130251B28253130251B28253130251B28253130251B2825313025CB2825313025CB2825313025CB2825313025CB2825313025CB28253130261B28253130261B28253130261B28253130261 -Stale data read: B2 -Read bytes = 8253130261B2825313026FB2825313026FB2825313026FB2825313026FB2825313026FB2825313027BB2825313027BB2825313027B -Read bytes = B2825313027BB2825313027BB28253130308B28253130308B28253130308B28253130308B28253130308 -Read bytes = B28253130312B28253130312B28253130312B28253130312B28253130312B2825313031CB2825313031CB2825313031CB2825313031CB2825313031CB28253130327B28253130327B28253130327B28253130327B28253130327B2825313032AB2825313032A -Read bytes = B2825313032AB2825313032AB2825313032AB28253130339B28253130339B28253130339B28253130339B28253130339B28253130342B28253130342B28253130342B28253130342B28253130342B2825313034AB2825313034AB2825313034AB2825313034AB2825313034AB28253130358B28253130358B28253130358 -Read bytes = B28253130358B28253130358B2825313035DB2825313035DB2825313035DB2825313035DB2825313035DB28253130366B28253130366B28253130366B28253130366B28253130366B28253130372B28253130372B28253130372B28253130372B28253130372B28253130378B28253130378B28253130378B28253130378B28253130378B2825313037FB2825313037FB2825313037FB2825313037F -Read bytes = B2825313037F -Read bytes = B28253130406B28253130406B28253130406B28253130406B28253130406B28253130408B28253130408 -Read bytes = B28253130408B28253130408B28253130408B28253130411B28253130411B28253130411B28253130411B28253130411B28253130417 -Read bytes = B28253130417B28253130417B28253130417B28253130417B28253130417B28253130417B28253130417B28253130417B28253130417B28253130424B28253130424B28253130424B28253130424B28253130424B28253130424B28253130424B28253130424B28253130424B28253130424B2825313042DB2825313042DB2825313042DB2825313042DB2825313042DB28253130438 -Read bytes = B28253130438B28253130438B28253130438B28253130438B2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB2825313043BB28253130442B28253130442B28253130442B28253130442 -Read bytes = B28253130442B28253130449B28253130449B28253130449B28253130449B28253130449B2825313044BB2825313044BB2825313044BB2825313044BB2825313044BB28253130450B28253130450B28253130450B28253130450 -Read bytes = B28253130450 -Read bytes = B28253130454B28253130454B28253130454B28253130454B28253130454 -Read bytes = B28253130457B28253130457B28253130457B28253130457B28253130457B2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB2825313045E -Read bytes = B2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB2825313045EB28253130460B28253130460B28253130460B28253130460B28253130460B28253130465B28253130465B28253130465B28253130465B28253130465B2825313046AB2825313046AB2825313046AB2825313046AB2825313046AB2825313046DB2825313046DB2825313046DB2825313046DB2825313046DB2825313046DB2825313046DB2825313046D -Stale data read: B2 -Read bytes = 825313046DB2825313046DB28253130474B28253130474B28253130474B28253130474B28253130474B28253130474B28253130474B28253130474B28253130474B28253130474B2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB2825313047CB28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B28253130503B2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050B -Read bytes = B2825313050BB2825313050BB2825313050BB2825313050BB2825313050BB2825313050B -Read bytes = B2825313050BB28243131F62B28243131F40B28243131F31B28243131F24B28243131F1B -Read bytes = B28243131F08B28243131F07B28243131E6CB28243131E65B28243131E65B28243131E4AB28243131E47B28243131E44B28243131E25B28243131E32B28243131E16B28243131E02B28243131E03B28243131E00B28243131D76B28243131D5F -Read bytes = B28243131D59B28243131D41B28243131D46B28243131D3AB28243131D1AB28243131D26B28243131D22B28243131D07 -Read bytes = B28243131D09 -Read bytes = B28243131C7FB28243131C5FB28243131C6EB28243131C55B28243131C56B28243131C45B28243131C3FB28243131C42B28243131C21B28243131C24B28243131C16B28243131C08B28243131C04B28243131B75B28243131B74B28243131B6CB28243131B59B28243131B55B28243131B54B28243131B42B28243131B3BB28243131B3DB28243131B1CB28243131B1FB28243131B15B28243131B03B28243131B02B28243131A7AB28243131A6BB28243131A66B28243131A60B28243131A59B28243131A4CB28243131A47B28243131A2EB28243131A39B28243131A33B28243131A1CB28243131A20B28243131A14B2824313197FB28243131A07B2824313197AB28243131965B28243131969B28243131960B28243131952B2824313194FB2824313193FB28243131944B2824313193BB2824313192BB28243131927B2824313191CB28243131917B2824313190AB2824313190AB28243131876B28243131870B2824313186AB28243131866B28243131855B28243131852B28243131851B28243131846B28243131836B28243131832B2824313181E -Read bytes = B28243131827B28243131814B2824313180AB2824313180AB2824313177FB28243131771B28243131773B28243131761B28243131764B2824313175DB28243131749B28243131740B28243131738B2824313172F -Read bytes = -*/ - diff --git a/src/enginuity/logger/innovate/plugin/Lc1DataSource.java b/src/enginuity/logger/innovate/plugin/Lc1DataSource.java index c2bb8e92..2b1cfa15 100644 --- a/src/enginuity/logger/innovate/plugin/Lc1DataSource.java +++ b/src/enginuity/logger/innovate/plugin/Lc1DataSource.java @@ -1,17 +1,18 @@ package enginuity.logger.innovate.plugin; +import enginuity.logger.ecu.EcuLogger; import enginuity.logger.ecu.external.ExternalDataItem; import enginuity.logger.ecu.external.ExternalDataSource; -import enginuity.logger.innovate.io.InnovateConnectionProperties; +import javax.swing.Action; import static java.util.Arrays.asList; import java.util.List; public final class Lc1DataSource implements ExternalDataSource { - private String portName = "COM6"; + private String port; public String getName() { - return "Innovate LC-1 Datasource"; + return "Innovate LC-1"; } public String getVersion() { @@ -19,13 +20,22 @@ public final class Lc1DataSource implements ExternalDataSource { } public List getDataItems() { - Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), portName); - InnovateController controller = new InnovateControllerImpl(connection); +// Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), port); +// InnovateController controller = new InnovateControllerImpl(connection); + InnovateController controller = new InnovateControllerImpl(); return asList(controller.getDataItem()); } - public void setPort(String portName) { - this.portName = portName; + public Action getMenuAction(EcuLogger logger) { + return new GenericPluginMenuAction(logger, this); + } + + public void setPort(String port) { + this.port = port; + } + + public String getPort() { + return port; } public void connect() { diff --git a/src/enginuity/logger/utec/gui/JutecGUI.java b/src/enginuity/logger/utec/gui/JutecGUI.java index 5aeb77aa..3adafdeb 100755 --- a/src/enginuity/logger/utec/gui/JutecGUI.java +++ b/src/enginuity/logger/utec/gui/JutecGUI.java @@ -6,23 +6,41 @@ */ package enginuity.logger.utec.gui; -import java.awt.event.*; -import java.util.*; -import java.io.*; -import javax.swing.*; - -import java.awt.*; - import enginuity.Settings; -import enginuity.logger.utec.gui.mapTabs.UtecDataManager; -import enginuity.logger.utec.gui.mapTabs.MapJPanel; -import enginuity.logger.utec.gui.realtimeData.*; -import enginuity.logger.utec.gui.bottomControl.*; -import enginuity.logger.utec.mapData.GetMapFromUtecListener; -import enginuity.logger.utec.mapData.UtecMapData; -import enginuity.logger.utec.properties.UtecProperties; -import enginuity.tts.SpeakString; import enginuity.logger.utec.commInterface.UtecInterface; +import enginuity.logger.utec.gui.bottomControl.BottomUtecControl; +import enginuity.logger.utec.gui.mapTabs.MapJPanel; +import enginuity.logger.utec.gui.mapTabs.UtecDataManager; +import enginuity.logger.utec.gui.realtimeData.RealTimeData; +import enginuity.logger.utec.mapData.UtecMapData; +import enginuity.tts.SpeakString; + +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JLayeredPane; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.Vector; /** * @author botman diff --git a/src/enginuity/logger/utec/plugin/UtecDataSource.java b/src/enginuity/logger/utec/plugin/UtecDataSource.java index 275a78d7..978ffe39 100644 --- a/src/enginuity/logger/utec/plugin/UtecDataSource.java +++ b/src/enginuity/logger/utec/plugin/UtecDataSource.java @@ -1,24 +1,27 @@ package enginuity.logger.utec.plugin; +import enginuity.logger.ecu.EcuLogger; import enginuity.logger.ecu.external.ExternalDataItem; import enginuity.logger.ecu.external.ExternalDataSource; +import enginuity.logger.innovate.plugin.GenericPluginMenuAction; import enginuity.logger.utec.commInterface.UtecInterface; +import javax.swing.Action; import java.util.ArrayList; import java.util.List; //NOTE: This class is instantiated via a no-args constructor. public final class UtecDataSource implements ExternalDataSource { - private ArrayList externalDataItems = new ArrayList(); - - public UtecDataSource(){ - externalDataItems.add(new AfrExternalDataItem()); - externalDataItems.add(new PsiExternalDataItem()); - externalDataItems.add(new KnockExternalDataItem()); - } - + private ArrayList externalDataItems = new ArrayList(); + + public UtecDataSource() { + externalDataItems.add(new AfrExternalDataItem()); + externalDataItems.add(new PsiExternalDataItem()); + externalDataItems.add(new KnockExternalDataItem()); + } + public String getName() { - return "UTEC Datasource"; + return "UTEC"; } public String getVersion() { @@ -27,31 +30,38 @@ public final class UtecDataSource implements ExternalDataSource { public List getDataItems() { System.out.println("External TXS data items requested."); - return externalDataItems; } - + + public Action getMenuAction(EcuLogger logger) { + return new GenericPluginMenuAction(logger, this); + } + + public void setPort(String port) { + UtecInterface.setPortChoice(port); + } + + public String getPort() { + return UtecInterface.getPortChoiceUsed(); + } + // ***************************** // Suggested Methods of interest // ***************************** - - public void setPort(String commPort){ - UtecInterface.setPortChoice(commPort); + + public void connect() { + UtecInterface.openConnection(); } - - public void connect(){ - UtecInterface.openConnection(); + + public void disconnect() { + UtecInterface.closeConnection(); } - - public void disconnect(){ - UtecInterface.closeConnection(); + + public void startLogging() { + UtecInterface.startLoggerDataFlow(); } - - public void startLogging(){ - UtecInterface.startLoggerDataFlow(); - } - - public void stopLogging(){ - UtecInterface.resetUtec(); + + public void stopLogging() { + UtecInterface.resetUtec(); } }