4 added + 10 removed + 50 modified, total 64 files
java/trunk/monitoring-app
--- java/trunk/monitoring-app/pom.xml 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/pom.xml 2014-08-01 22:25:18 UTC (rev 833)
@@ -31,7 +31,7 @@
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.hps.monitoring.MonitoringApplicationMain</mainClass>
+ <mainClass>org.hps.monitoring.gui.Main</mainClass>
</transformer>
</transformers>
<artifactSet>
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplicationMain.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplicationMain.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,70 +0,0 @@
-package org.hps.monitoring;
-
-import java.io.File;
-
-import javax.swing.SwingUtilities;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.hps.monitoring.config.Configuration;
-import org.hps.monitoring.gui.MonitoringApplication;
-
-/**
- * This is the front-end for running the monitoring app via a
- * {@link #main(String[])} method.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class MonitoringApplicationMain {
-
- /**
- * Run the monitoring application from the command line.
- * @param args The command line arguments.
- */
- public static void main(String[] args) {
-
- // Set up command line parsing.
- Options options = new Options();
- options.addOption(new Option("h", false, "Print help."));
- options.addOption(new Option("c", true, "Load a properties file with configuration parameters."));
- CommandLineParser parser = new PosixParser();
-
- // Parse command line arguments.
- final CommandLine cl;
- try {
- cl = parser.parse(options, args);
- } catch (ParseException e) {
- throw new RuntimeException("Problem parsing command line options.", e);
- }
-
- // Print help and exit.
- if (cl.hasOption("h")) {
- HelpFormatter help = new HelpFormatter();
- help.printHelp(" ", options);
- System.exit(1);
- }
-
- // Run the application on the Swing EDT.
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
-
- // Create the application class.
- MonitoringApplication app = new MonitoringApplication();
-
- // Load the connection settings.
- if (cl.hasOption("c")) {
- app.set(new Configuration(new File(cl.getOptionValue("c"))));
- }
-
- app.initialize();
-
- // Set the app to be visible.
- app.setVisible(true);
- }
- });
- }
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configurable.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configurable.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,45 +0,0 @@
-package org.hps.monitoring.config;
-
-/**
- * This is an interface for object's that have a {@link Configuration}
- * which can be set, saved, loaded and reset. The exact meaning of
- * these operations may vary by type of object.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-// FIXME: This should probably be removed once ConfigurationModel is being used instead.
-public interface Configurable {
-
- /**
- * Load configuration into the object.
- * @param config The configuration to load.
- */
- void load(Configuration config);
-
- /**
- * Push values from object into the configuration.
- * @param config The configuration to save.
- */
- void save(Configuration config);
-
- /**
- * Get the current configuration.
- * @return The current configuration.
- */
- Configuration getConfiguration();
-
- /**
- * Save values from the object into the current configuration.
- */
- void save();
-
- /**
- * Set the current configuration.
- * @param config The current configuration.
- */
- void set(Configuration config);
-
- /**
- * Reset the object from the current configuration.
- */
- void reset();
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configuration.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configuration.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,145 +0,0 @@
-package org.hps.monitoring.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * This class provides a list of key, value pairs backed by a <code>Properties</code> object.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class Configuration {
-
- Properties properties;
- File file;
- String resourcePath;
-
- public Configuration() {
- properties = new Properties();
- }
-
- /**
- * Load a configuration from a properties file.
- * @param file The properties file.
- */
- public Configuration(File file) {
- this.file = file;
- try {
- properties = new Properties();
- properties.load(new FileInputStream(this.file));
- } catch (IOException e) {
- throw new RuntimeException("Error parsing properties file.", e);
- }
- }
-
- /**
- * Load a configuration from a resource path pointing to a properties file.
- * @param resourcePath The resource path to the properties file.
- */
- public Configuration(String resourcePath) {
- this.resourcePath = resourcePath;
- InputStream is = this.getClass().getResourceAsStream(this.resourcePath);
- try {
- properties = new Properties();
- properties.load(is);
- } catch (IOException e) {
- throw new RuntimeException("Error parsing properties resource.", e);
- }
- }
-
- /**
- * Get the file associated with this configuration or <code>null</code>
- * if not set.
- * @return The file associated with the configuration.
- */
- public File getFile() {
- return file;
- }
-
- /**
- * Get the resource path associated with this configuration or <code>null</code>
- * if not applicable.
- * @return The resource path of this configuration.
- */
- public String getResourcePath() {
- return resourcePath;
- }
-
- /**
- * True if configuration has value for the key.
- * @param key The key.
- * @return True if configuration has value for the key.
- */
- public boolean hasKey(String key) {
- return properties.getProperty(key) != null;
- }
-
- /**
- * Get a key value as a string.
- * @param key The key to lookup.
- * @return The value or null if does not exist.
- */
- public String get(String key) {
- return properties.getProperty(key);
- }
-
- /**
- * Get a key value as a boolean.
- * @param key The key to lookup.
- * @return The value or null if does not exist.
- */
- public Boolean getBoolean(String key) {
- return Boolean.parseBoolean(properties.getProperty(key));
- }
-
- /**
- * Get a key value as a double.
- * @param key The key to lookup.
- * @return The value or null if does not exist.
- */
- public Double getDouble(String key) {
- return Double.parseDouble(properties.getProperty(key));
- }
-
- /**
- * Get a key value as an integer.
- * @param key The key to lookup.
- * @return The value or null if does not exist.
- */
- public Integer getInteger(String key) {
- return Integer.parseInt(properties.getProperty(key));
- }
-
- /**
- * Write this configuration to a file and set that file
- * as the current one.
- * @param file The output file.
- */
- public void writeToFile(File file) {
- this.file = file;
- try {
- properties.store(new FileOutputStream(this.file), null);
- } catch (IOException e) {
- throw new RuntimeException("Error saving properties file.", e);
- }
- }
-
- /**
- * Set a configuration value.
- * @param key The key for lookup.
- * @param value The value to assign to that key.
- */
- public void set(String key, Object value) {
- properties.put(key, String.valueOf(value));
- }
-
- /**
- * Convert this object to a string by printing out its properties list.
- */
- public String toString() {
- return properties.toString();
- }
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,17 +0,0 @@
-package org.hps.monitoring.enums;
-
-/**
- * Status of the connection to the ET server from the monitoring client.
- */
-public enum ConnectionStatus {
-
- DISCONNECTED,
- CONNECTED,
- CONNECTING,
- TIMED_OUT,
- SLEEPING,
- DISCONNECTING,
- ERROR,
- CONNECTION_REQUESTED,
- DISCONNECT_REQUESTED;
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -0,0 +1,13 @@
+package org.hps.monitoring.enums;
+
+/**
+ * Status of the connection to the ET server from the monitoring client.
+ */
+public enum ConnectionStatus {
+ DISCONNECTED,
+ DISCONNECTING,
+ ERROR,
+ CONNECTION_REQUESTED,
+ CONNECTED,
+ PAUSED
+}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/DataSourceType.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/DataSourceType.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,25 +0,0 @@
-package org.hps.monitoring.enums;
-
-/**
- * The type of data source that will supply events to the app.
- */
-public enum DataSourceType {
-
- ET_SERVER("ET Server"),
- EVIO_FILE("EVIO File"),
- LCIO_FILE("LCIO File");
-
- String description;
-
- private DataSourceType(String description) {
- this.description = description;
- }
-
- public String description() {
- return description;
- }
-
- public boolean isFile() {
- return this.ordinal() > ET_SERVER.ordinal();
- }
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/DataSourceType.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/DataSourceType.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -0,0 +1,25 @@
+package org.hps.monitoring.enums;
+
+/**
+ * The type of data source that will supply events to the app.
+ */
+public enum DataSourceType {
+
+ ET_SERVER("ET Server"),
+ EVIO_FILE("EVIO File"),
+ LCIO_FILE("LCIO File");
+
+ String description;
+
+ private DataSourceType(String description) {
+ this.description = description;
+ }
+
+ public String description() {
+ return description;
+ }
+
+ public boolean isFile() {
+ return this.ordinal() > ET_SERVER.ordinal();
+ }
+}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/StatusCode.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/StatusCode.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,16 +0,0 @@
-package org.hps.monitoring.enums;
-
-/**
- * Code that represents a sub-system status.
- */
-public enum StatusCode {
- OKAY,
- UNKNOWN,
- CLEARED,
- OFFLINE,
- INFO,
- WARNING,
- ERROR,
- ALARM,
- HALT;
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,9 +0,0 @@
-package org.hps.monitoring.enums;
-
-/**
- * The type of steering to use for event processing.
- */
-public enum SteeringType {
- RESOURCE,
- FILE;
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -0,0 +1,9 @@
+package org.hps.monitoring.enums;
+
+/**
+ * The type of steering to use for event processing.
+ */
+public enum SteeringType {
+ RESOURCE,
+ FILE;
+}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/Subsystem.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/Subsystem.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,11 +0,0 @@
-package org.hps.monitoring.enums;
-
-/**
- * Names of valid subsystems that can be monitored.
- */
-public enum Subsystem {
- ET,
- ECAL,
- SVT,
- TRIGGER;
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -5,6 +5,7 @@
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
@@ -14,12 +15,16 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
+import org.hps.monitoring.gui.model.HasConfigurationModel;
+
/**
* A <code>JPanel</code> which has a number of fields with the labels
* in the first column and the components for showing/editing the fields
* in the second. It uses <code>GridBagConstraints</code> for layout.
*/
-abstract class AbstractFieldsPanel extends JPanel {
+// TODO: This should use features of JFormattedTextField instead of plain JTextField.
+abstract class AbstractFieldsPanel extends JPanel
+ implements PropertyChangeListener, HasConfigurationModel, ActionListener {
private int currY = 0;
private Insets insets;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -0,0 +1,45 @@
+package org.hps.monitoring.gui;
+
+/**
+ * These strings are used to identify ActionEvents in the MonitoringApplication.
+ * A few commands handled only by sub-components are not listed here.
+ */
+final class Commands {
+
+ static final String DISCONNECT_ON_ERROR_CHANGED = "disconnectOnErrorChanged";
+ static final String STEERING_TYPE_CHANGED = "steeringTypeChanged";
+ static final String STEERING_RESOURCE_CHANGED = "steeringResourceChanged";
+ static final String LOG_TO_FILE_CHANGED = "logToFileChanged";
+ static final String AIDA_AUTO_SAVE_CHANGED = "aidaAutoSaveChanged";
+ static final String LOG_LEVEL_CHANGED = "logLevelChanged";
+
+ static final String BLOCKING_CHANGED = "blockingChanged";
+ static final String VERBOSE_CHANGED = "verboseChanged";
+ static final String WAIT_MODE_CHANGED = "waitModeChanged";
+
+ static final String DATA_SOURCE_TYPE_CHANGED = "dataSourceTypeChanged";
+
+ static final String AIDA_AUTO_SAVE = "aidaAutoSave";
+ static final String CLEAR_LOG_TABLE = "clearLogTable";
+ static final String CHOOSE_LOG_FILE = "chooseLogFile";
+ static final String CHOOSE_STEERING_FILE = "chooseSteeringFile";
+ static final String CONNECT = "connect";
+ static final String DISCONNECT = "disconnect";
+ static final String EXIT = "exit";
+ static final String LOAD_DEFAULT_CONFIG_FILE = "loadDefaultConfigFile";
+ static final String LOG_TO_FILE = "logToFile";
+ static final String LOG_TO_TERMINAL = "logToTerminal";
+ static final String NEXT = "next";
+ static final String PAUSE = "pause";
+ static final String RESUME = "resume";
+ static final String SAVE_LOG_TABLE = "saveLogTable";
+ static final String SAVE_PLOTS = "savePlots";
+ static final String SCREENSHOT = "screenshot";
+ static final String SAVE_CONFIG_FILE = "saveConfigFile";
+ static final String SET_EVENT_BUILDER = "setEventBuilder";
+
+ static final String SET_STEERING_RESOURCE = "setSteeringResource";
+ static final String SELECT_CONFIG_FILE = "selectConfigFile";
+ static final String SELECT_LOG_FILE = "logToFile";
+ static final String SHOW_SETTINGS = "showSettings";
+}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,31 +1,36 @@
package org.hps.monitoring.gui;
+import static org.hps.monitoring.gui.Commands.*;
+import static org.hps.monitoring.gui.model.ConfigurationModel.*;
+
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTextField;
-import org.hps.monitoring.config.Configurable;
-import org.hps.monitoring.config.Configuration;
+import org.hps.monitoring.gui.model.ConfigurationModel;
import org.jlab.coda.et.enums.Mode;
/**
* Connection settings panel.
*/
-class ConnectionSettingsPanel extends AbstractFieldsPanel implements Configurable {
+class ConnectionSettingsPanel extends AbstractFieldsPanel {
private JTextField etNameField;
private JTextField hostField;
private JTextField portField;
private JCheckBox blockingCheckBox;
private JCheckBox verboseCheckBox;
- private JTextField statNameField;
- private JTextField chunkField;
- private JTextField qSizeField;
- private JTextField positionField;
- private JComboBox<?> waitComboBox;
+ private JTextField stationNameField;
+ private JTextField chunkSizeField;
+ private JTextField queueSizeField;
+ private JTextField stationPositionField;
+ private JComboBox<?> waitModeComboBox;
private JTextField waitTimeField;
private JTextField prescaleField;
@@ -35,7 +40,7 @@
Mode.ASYNC.name()
};
- Configuration config;
+ ConfigurationModel configurationModel;
/**
* Class constructor.
@@ -46,51 +51,47 @@
setLayout(new GridBagLayout());
- // Define fields.
- etNameField = addField("ET Name", "", 20);
+ etNameField = addField("ET Name", "", 20);
+ etNameField.addPropertyChangeListener("value", this);
+
hostField = addField("Host", 20);
+ hostField.addPropertyChangeListener("value", this);
+
portField = addField("Port", 5);
+ portField.addPropertyChangeListener("value", this);
+
blockingCheckBox = addCheckBox("Blocking", false, true);
- verboseCheckBox = addCheckBox("Verbose", false, true);
- statNameField = addField("Station Name", 10);
- chunkField = addField("Chunk Size", 3);
- qSizeField = addField("Queue Size", 3);
- positionField = addField("Station Position", 3);
- waitComboBox = addComboBox("Wait Mode", waitModes);
+ blockingCheckBox.setActionCommand(BLOCKING_CHANGED);
+ blockingCheckBox.addActionListener(this);
+
+ verboseCheckBox = addCheckBox("Verbose", false, true);
+ verboseCheckBox.setActionCommand(VERBOSE_CHANGED);
+ verboseCheckBox.addActionListener(this);
+
+ stationNameField = addField("Station Name", 10);
+ stationNameField.addPropertyChangeListener("value", this);
+
+ chunkSizeField = addField("Chunk Size", 3);
+ chunkSizeField.addPropertyChangeListener("value", this);
+
+ queueSizeField = addField("Queue Size", 3);
+ queueSizeField.addPropertyChangeListener("value", this);
+
+ stationPositionField = addField("Station Position", 3);
+ stationPositionField.addPropertyChangeListener("value", this);
+
+ waitModeComboBox = addComboBox("Wait Mode", waitModes);
+ waitModeComboBox.setActionCommand(WAIT_MODE_CHANGED);
+ waitModeComboBox.addActionListener(this);
+
waitTimeField = addField("Wait Time [microseconds]", 8);
+ waitTimeField.addPropertyChangeListener(this);
+
prescaleField = addField("Prescale", 8);
+ prescaleField.addPropertyChangeListener(this);
}
-
+
/**
- * Get the current wait mode from the GUI selection.
- * @return The wait mode.
- */
- private Mode getWaitMode() {
- return Mode.valueOf((String) waitComboBox.getSelectedItem());
- }
-
- /**
- * Set the wait mode and push to the GUI.
- * @param waitMode The wait mode.
- */
- private void setWaitMode(Mode waitMode) {
- waitComboBox.setSelectedIndex(waitMode.ordinal());
- }
-
- private void setWaitMode(String s) {
- Mode mode = null;
- if (s.equals(Mode.SLEEP.name()))
- mode = Mode.SLEEP;
- else if (s.equals(Mode.TIMED.name()))
- mode = Mode.TIMED;
- else if (s.equals(Mode.ASYNC.name()))
- mode = Mode.ASYNC;
- else
- throw new IllegalArgumentException("Invalid mode string.");
- setWaitMode(mode);
- }
-
- /**
* Enable or disable the connection panel GUI elements.
* @param e Set to true for enabled; false to disable.
*/
@@ -100,65 +101,112 @@
portField.setEnabled(e);
blockingCheckBox.setEnabled(e);
verboseCheckBox.setEnabled(e);
- statNameField.setEnabled(e);
- chunkField.setEnabled(e);
- qSizeField.setEnabled(e);
- positionField.setEnabled(e);
- waitComboBox.setEnabled(e);
+ stationNameField.setEnabled(e);
+ chunkSizeField.setEnabled(e);
+ queueSizeField.setEnabled(e);
+ stationPositionField.setEnabled(e);
+ waitModeComboBox.setEnabled(e);
waitTimeField.setEnabled(e);
prescaleField.setEnabled(e);
}
-
- @Override
- public void load(Configuration config) {
- etNameField.setText(config.get("bufferName"));
- hostField.setText(config.get("host"));
- portField.setText(config.get("port"));
- blockingCheckBox.setSelected(config.getBoolean("blocking"));
- verboseCheckBox.setSelected(config.getBoolean("verbose"));
- statNameField.setText(config.get("statName"));
- chunkField.setText(config.get("chunk"));
- qSizeField.setText(config.get("qSize"));
- positionField.setText(config.get("position"));
- setWaitMode(config.get("waitMode"));
- waitTimeField.setText(config.get("waitTime"));
- prescaleField.setText(config.get("prescale"));
+
+ /**
+ * Updates the GUI from changes in the ConfigurationModel.
+ */
+ public class ConfigurationSettingsChangeListener implements PropertyChangeListener {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ Object value = evt.getNewValue();
+
+ if (evt.getPropertyName().equals(ET_NAME_PROPERTY)) {
+ etNameField.setText((String) value);
+ } else if (evt.getPropertyName().equals(HOST_PROPERTY)) {
+ hostField.setText((String) value);
+ } else if (evt.getPropertyName().equals(PORT_PROPERTY)) {
+ portField.setText(value.toString());
+ } else if (evt.getPropertyName().equals(BLOCKING_PROPERTY)) {
+ blockingCheckBox.setSelected((Boolean) value);
+ } else if (evt.getPropertyName().equals(VERBOSE_PROPERTY)) {
+ verboseCheckBox.setSelected((Boolean) value);
+ } else if (evt.getPropertyName().equals(STATION_NAME_PROPERTY)) {
+ stationNameField.setText((String) value);
+ } else if (evt.getPropertyName().equals(CHUNK_SIZE_PROPERTY)) {
+ chunkSizeField.setText(value.toString());
+ } else if (evt.getPropertyName().equals(QUEUE_SIZE_PROPERTY)) {
+ queueSizeField.setText(value.toString());
+ } else if (evt.getPropertyName().equals(STATION_POSITION_PROPERTY)) {
+ stationPositionField.setText(value.toString());
+ } else if (evt.getPropertyName().equals(WAIT_MODE_PROPERTY)) {
+ waitModeComboBox.setSelectedItem(((Mode)value).name());
+ } else if (evt.getPropertyName().equals(WAIT_TIME_PROPERTY)) {
+ waitTimeField.setText(value.toString());
+ } else if (evt.getPropertyName().equals(PRESCALE_PROPERTY)) {
+ prescaleField.setText(value.toString());
+ }
+ }
}
+ /**
+ * Updates ConfigurationModel from changes in the GUI components.
+ */
@Override
- public void save(Configuration config) {
- config.set("bufferName", etNameField.getText());
- config.set("host", hostField.getText());
- config.set("port", portField.getText());
- config.set("blocking", blockingCheckBox.isSelected());
- config.set("verbose", verboseCheckBox.isSelected());
- config.set("statName", statNameField.getText());
- config.set("chunk", chunkField.getText());
- config.set("qSize", qSizeField.getText());
- config.set("position", positionField.getText());
- config.set("waitMode", (String) waitComboBox.getSelectedItem());
- config.set("waitTime", waitTimeField.getText());
- config.set("prescale", prescaleField.getText());
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (evt.getPropertyName().equals("ancestor"))
+ return;
+
+ Object source = evt.getSource();
+
+ if (source.equals(etNameField)) {
+ configurationModel.setEtName(etNameField.getText());
+ } else if (source.equals(hostField)) {
+ configurationModel.setHost(hostField.getText());
+ } else if (source.equals(portField)) {
+ configurationModel.setPort(Integer.parseInt(portField.getText()));
+ } else if (source.equals(stationNameField)) {
+ configurationModel.setStationName(stationNameField.getText());
+ } else if (source.equals(chunkSizeField)) {
+ configurationModel.setChunkSize(Integer.parseInt(chunkSizeField.getText()));
+ } else if (source.equals(queueSizeField)) {
+ configurationModel.setQueueSize(Integer.parseInt(queueSizeField.getText()));
+ } else if (source.equals(stationPositionField)) {
+ configurationModel.setStationPosition(Integer.parseInt(stationPositionField.getText()));
+ } else if (source.equals(waitTimeField)) {
+ configurationModel.setWaitTime(Integer.parseInt(waitTimeField.getText()));
+ } else if (source.equals(prescaleField)) {
+ configurationModel.setPrescale(Integer.parseInt(prescaleField.getText()));
+ }
}
-
+
+ /**
+ * Used to update the ConfigurationModel from GUI components.
+ */
@Override
- public void set(Configuration config) {
- load(config);
- this.config = config;
- }
+ public void actionPerformed(ActionEvent e) {
+ if (WAIT_MODE_CHANGED.equals(e.getActionCommand())) {
+ configurationModel.setWaitMode(Mode.valueOf((String) waitModeComboBox.getSelectedItem()));
+ } else if (BLOCKING_CHANGED.equals(e.getActionCommand())) {
+ configurationModel.setBlocking(blockingCheckBox.isSelected());
+ } else if (VERBOSE_CHANGED.equals(e.getActionCommand())) {
+ configurationModel.setVerbose(verboseCheckBox.isSelected());
+ }
+ }
@Override
- public void reset() {
- load(config);
+ public void setConfigurationModel(ConfigurationModel configurationModel) {
+ // Set the ConfigurationModel reference.
+ this.configurationModel = configurationModel;
+
+ // This listener pushes GUI values into the configuration.
+ this.configurationModel.addPropertyChangeListener(this);
+
+ // This listener updates the GUI from changes in the configuration.
+ this.configurationModel.addPropertyChangeListener(new ConfigurationSettingsChangeListener());
}
-
- @Override
- public void save() {
- save(config);
- }
@Override
- public Configuration getConfiguration() {
- return config;
+ public ConfigurationModel getConfigurationModel() {
+ return configurationModel;
}
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -108,25 +108,7 @@
c.insets = new Insets(10, 0, 0, 0);
add(new JSeparator(SwingConstants.HORIZONTAL), c);
}
-
- /**
- * Set the connection status.
- * @param status The status code.
- */
- /*
- void setStatus(final int status) {
- if (status < 0 || status > (ConnectionStatus.values().length - 1)) {
- throw new IllegalArgumentException("Invalid status argument: " + status);
- }
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- statusField.setText(ConnectionStatus.values()[status].name());
- dateField.setText(dateFormat.format(new Date()));
- }
- });
- }
- */
-
+
void setConnectionStatus(final ConnectionStatus status) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,28 +1,27 @@
package org.hps.monitoring.gui;
+import static org.hps.monitoring.gui.Commands.*;
+import static org.hps.monitoring.gui.model.ConfigurationModel.*;
+
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
-import java.io.IOException;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
-import org.hps.monitoring.config.Configurable;
-import org.hps.monitoring.config.Configuration;
import org.hps.monitoring.enums.DataSourceType;
-import org.jlab.coda.jevio.EvioException;
-import org.jlab.coda.jevio.EvioReader;
-import org.lcsim.lcio.LCIOReader;
+import org.hps.monitoring.gui.model.ConfigurationModel;
/**
* A sub-panel of the settings window for selecting a data source,
* e.g. an ET server, an LCIO file, or an EVIO file.
*/
-public class DataSourcePanel extends AbstractFieldsPanel implements ActionListener, Configurable {
+class DataSourcePanel extends AbstractFieldsPanel {
static String[] dataSourceTypes = {
DataSourceType.ET_SERVER.description(),
@@ -30,23 +29,24 @@
DataSourceType.LCIO_FILE.description()
};
- JComboBox dataSourceCombo;
- JTextField fileField;
- String DATA_SOURCE_COMMAND = "dataSourceChanged";
- ErrorHandler errorHandler;
+ JComboBox<?> dataSourceTypeComboBox;
+ JTextField dataSourcePathField;
- Configuration config;
+ ConfigurationModel configurationModel;
DataSourcePanel() {
setLayout(new GridBagLayout());
- dataSourceCombo = addComboBox("Data Source", dataSourceTypes);
- dataSourceCombo.setSelectedIndex(0);
- dataSourceCombo.setActionCommand(DATA_SOURCE_COMMAND);
- dataSourceCombo.addActionListener(this);
- fileField = addField("File Path", 40);
- fileField.setEditable(false);
+ dataSourceTypeComboBox = addComboBox("Data Source", dataSourceTypes);
+ dataSourceTypeComboBox.setSelectedIndex(0);
+ dataSourceTypeComboBox.setActionCommand(DATA_SOURCE_TYPE_CHANGED);
+ dataSourceTypeComboBox.addActionListener(this);
+
+ dataSourcePathField = addField("Data Source Path", 40);
+ dataSourcePathField.setEditable(false);
+ dataSourcePathField.addPropertyChangeListener("value", this);
}
+ /*
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(DATA_SOURCE_COMMAND)) {
int selectedIndex = dataSourceCombo.getSelectedIndex();
@@ -58,6 +58,7 @@
}
}
}
+ */
private void chooseFile() {
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
@@ -69,17 +70,18 @@
final String filePath = file.getPath();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- fileField.setText(filePath);
+ dataSourcePathField.setText(filePath);
}
});
}
}
+ /*
void checkFile() throws IOException {
- DataSourceType dataSourceType = DataSourceType.values()[this.dataSourceCombo.getSelectedIndex()];
+ DataSourceType dataSourceType = DataSourceType.values()[this.dataSourceTypeComboBox.getSelectedIndex()];
if (!dataSourceType.isFile())
return;
- File file = new File(fileField.getText());
+ File file = new File(dataSourcePathField.getText());
if (!file.exists()) {
throw new IOException("File " + file + " does not exist!");
}
@@ -93,60 +95,54 @@
new LCIOReader(file);
}
}
-
-
- String getFilePath() {
- if (getDataSourceType().isFile()) {
- return this.fileField.getText();
- } else {
- return null;
- }
- }
-
- DataSourceType getDataSourceType() {
- return DataSourceType.values()[this.dataSourceCombo.getSelectedIndex()];
- }
-
- void setDataSourceType(DataSourceType dataSourceType) {
- this.dataSourceCombo.setSelectedIndex(dataSourceType.ordinal());
- }
-
- void setFilePath(String filePath) {
- this.fileField.setText(filePath);
- }
+ */
@Override
- public void load(Configuration config) {
- this.dataSourceCombo.removeActionListener(this);
- this.setDataSourceType(DataSourceType.valueOf(config.get("dataSourceType")));
- this.dataSourceCombo.addActionListener(this);
- this.setFilePath(config.get("dataSourcePath"));
+ public void setConfigurationModel(ConfigurationModel configurationModel) {
+ this.configurationModel = configurationModel;
}
@Override
- public void save(Configuration config) {
- config.set("dataSourceType", getDataSourceType().name());
- config.set("dataSourcePath", getFilePath());
+ public ConfigurationModel getConfigurationModel() {
+ return configurationModel;
}
@Override
- public Configuration getConfiguration() {
- return config;
+ public void actionPerformed(ActionEvent e) {
+ if (DATA_SOURCE_TYPE_CHANGED.equals(e.getActionCommand())) {
+ DataSourceType dataSourceType = DataSourceType.values()[dataSourceTypeComboBox.getSelectedIndex()];
+ configurationModel.setDataSourceType(dataSourceType);
+ if (dataSourceType.isFile()) {
+ chooseFile();
+ }
+ }
}
-
+
+ /**
+ * Updates the configuration with changes from the GUI component values.
+ * The changes from the GUI are distinguishable by their component object.
+ */
@Override
- public void save() {
- save(config);
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (dataSourcePathField.equals(evt.getSource())) {
+ configurationModel.setDataSourcePath(dataSourcePathField.getText());
+ }
}
-
- @Override
- public void set(Configuration config) {
- load(config);
- this.config = config;
- }
-
- @Override
- public void reset() {
- set(config);
- }
+
+ /**
+ * Update the GUI from changes in the underlying configuration.
+ * The changes from the configuration are distinguishable by their
+ * property name.
+ */
+ public class DataSourceChangeListener implements PropertyChangeListener {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Object value = evt.getNewValue();
+ if (DATA_SOURCE_TYPE_PROPERTY.equals(evt.getPropertyName())) {
+ dataSourceTypeComboBox.setSelectedItem(value.toString());
+ } else if (DATA_SOURCE_PATH_PROPERTY.equals(evt.getPropertyName())) {
+ dataSourcePathField.setText((String) value);
+ }
+ }
+ }
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -8,8 +8,10 @@
import javax.swing.SwingUtilities;
/**
+ * <p>
* An error handling class which is able to do any of the following,
* depending on what the caller wants to do with the error.
+ * </p>
* <ul>
* <li>Print a message</li>
* <li>Print the stack trace</li>
@@ -18,47 +20,83 @@
* <li>Raise an exception</li>
* <li>Exit the application</li>
* </ul>
+ * </p>
* It mostly uses the "builder" pattern so that the various handling methods
- * can be easily chained, where appropriate.
+ * can be easily chained, where appropriate. Some methods are not available
+ * for chaining when it doesn't make sense, e.g. popping up a dialog should
+ * happen last so this is not chainable.
+ * </p>
*/
-public class ErrorHandler {
+class ErrorHandler {
Logger logger;
Component component;
Throwable error;
String message;
+ /**
+ * Constructor.
+ * @param component The GUI component to which this object is assigned.
+ * @param logger The logger to which messages will be written.
+ */
ErrorHandler(Component component, Logger logger) {
this.logger = logger;
this.component = component;
}
+ /**
+ * Set the error that occurred. This should always be called
+ * first in a method chain.
+ * @param error The error which is a <code>Throwable</code>.
+ * @return This object.
+ */
ErrorHandler setError(Throwable error) {
this.error = error;
this.message = error.getMessage();
return this;
}
+ /**
+ * Set the error message if it differs from the exception's message.
+ * @param message The erro message.
+ * @return This object.
+ */
ErrorHandler setMessage(String message) {
this.message = message;
return this;
}
+ /**
+ * Print the full stack trace of the error to System.err.
+ * @return This object.
+ */
ErrorHandler printStackTrace() {
error.printStackTrace();
return this;
}
+ /**
+ * Print the error message to System.err.
+ * @return This object.
+ */
ErrorHandler printMessage() {
System.err.println(message);
return this;
}
+ /**
+ * Log the error message to the <code>Logger</code>.
+ * @return This object.
+ */
ErrorHandler log() {
logger.log(Level.SEVERE, message);
return this;
}
+ /**
+ * Show an error dialog with the message.
+ * @return This object.
+ */
ErrorHandler showErrorDialog() {
final Runnable runnable = new Runnable() {
public void run() {
@@ -73,10 +111,18 @@
return this;
}
- void raiseException() {
+ /**
+ * Rethrow the error as a <code>RuntimeException</code>.
+ * Additional methods cannot be chained to this
+ * as they would not be executed.
+ */
+ void raiseException() {
throw new RuntimeException(message, error);
}
+ /**
+ * Exit the application. This is not chainable for obvious reasons.
+ */
void exit() {
System.err.println("Fatal error. Application will exit.");
System.exit(1);
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -32,7 +32,7 @@
c.insets = new Insets(0, 0, 0, 10);
connectButton = new JButton("Connect");
connectButton.setEnabled(true);
- connectButton.setActionCommand(MonitoringCommands.CONNECT);
+ connectButton.setActionCommand(Commands.CONNECT);
add(connectButton, c);
c = new GridBagConstraints();
@@ -40,7 +40,7 @@
c.gridy = 0;
c.insets = new Insets(0, 0, 0, 10);
pauseButton = new JButton("Pause");
- pauseButton.setActionCommand(MonitoringCommands.PAUSE);
+ pauseButton.setActionCommand(Commands.PAUSE);
pauseButton.setEnabled(false);
add(pauseButton, c);
@@ -49,33 +49,21 @@
c.gridy = 0;
nextEventsButton = new JButton("Next Event");
nextEventsButton.setEnabled(false);
- nextEventsButton.setActionCommand(MonitoringCommands.NEXT);
+ nextEventsButton.setActionCommand(Commands.NEXT);
add(nextEventsButton, c);
}
/**
- * Toggle the connect button from its current state. If it is in "Connect" state
- * then it will be toggled to "Disconnect" and vice versa.
+ * Set the application connection state.
+ * @param connected True if application is connected or false if disconnected.
*/
- /*
- void toggleConnectButton() {
- if (connectButton.getText().equals("Connect")) {
- connectButton.setText("Disconnect");
- connectButton.setActionCommand(MonitoringCommands.DISCONNECT);
- } else {
- connectButton.setText("Connect");
- connectButton.setActionCommand(MonitoringCommands.CONNECT);
- }
- }
- */
-
void setConnected(boolean connected) {
if (connected) {
connectButton.setText("Disconnect");
- connectButton.setActionCommand(MonitoringCommands.DISCONNECT);
+ connectButton.setActionCommand(Commands.DISCONNECT);
} else {
connectButton.setText("Connect");
- connectButton.setActionCommand(MonitoringCommands.CONNECT);
+ connectButton.setActionCommand(Commands.CONNECT);
}
}
@@ -113,10 +101,10 @@
this.nextEventsButton.setEnabled(enable);
if (enable) {
pauseButton.setText("Resume");
- pauseButton.setActionCommand(MonitoringCommands.RESUME);
+ pauseButton.setActionCommand(Commands.RESUME);
} else {
pauseButton.setText("Pause");
- pauseButton.setActionCommand(MonitoringCommands.PAUSE);
+ pauseButton.setActionCommand(Commands.PAUSE);
}
}
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/HasErrorHandler.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/HasErrorHandler.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,9 +0,0 @@
-package org.hps.monitoring.gui;
-
-
-public interface HasErrorHandler {
-
- void setErrorHandler(ErrorHandler errorHandler);
-
- ErrorHandler getErrorHandler();
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,22 +1,7 @@
package org.hps.monitoring.gui;
-import static org.hps.monitoring.gui.MonitoringCommands.AIDA_AUTO_SAVE_CHANGED;
-import static org.hps.monitoring.gui.MonitoringCommands.DISCONNECT_ON_ERROR_CHANGED;
-import static org.hps.monitoring.gui.MonitoringCommands.LOG_LEVEL_CHANGED;
-import static org.hps.monitoring.gui.MonitoringCommands.LOG_TO_FILE_CHANGED;
-import static org.hps.monitoring.gui.MonitoringCommands.STEERING_RESOURCE_CHANGED;
-import static org.hps.monitoring.gui.MonitoringCommands.STEERING_TYPE_CHANGED;
-import static org.hps.monitoring.gui.model.ConfigurationModel.AIDA_AUTO_SAVE_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.AIDA_FILE_NAME_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.DETECTOR_NAME_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.DISCONNECT_ON_ERROR_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.EVENT_BUILDER_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.LOG_FILE_NAME_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.LOG_LEVEL_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.LOG_TO_FILE_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.STEERING_FILE_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.STEERING_RESOURCE_PROPERTY;
-import static org.hps.monitoring.gui.model.ConfigurationModel.STEERING_TYPE_PROPERTY;
+import static org.hps.monitoring.gui.Commands.*;
+import static org.hps.monitoring.gui.model.ConfigurationModel.*;
import java.awt.GridBagLayout;
import java.awt.Insets;
@@ -44,7 +29,6 @@
import org.hps.monitoring.enums.SteeringType;
import org.hps.monitoring.gui.model.ConfigurationModel;
-import org.hps.monitoring.gui.model.HasConfigurationModel;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -56,10 +40,10 @@
*/
// TODO: Add validity checks for event builder, lcsim steering files, etc. when edited and revert to old
// values if invalid.
+// http://docs.oracle.com/javase/7/docs/api/javax/swing/JFormattedTextField.html
// TODO: Remove default values in components. These should all come from the default configuration.
// TODO: Double check that all settings to and from the configuration are working properly.
-// TODO: Add HasErrorHandler implementation and use it for error handling of exceptions.
-class JobSettingsPanel extends AbstractFieldsPanel implements ActionListener, PropertyChangeListener, HasConfigurationModel {
+class JobSettingsPanel extends AbstractFieldsPanel {
private JTextField aidaSaveFileNameField;
private JCheckBox aidaAutoSaveCheckbox;
@@ -69,7 +53,6 @@
private JTextField logFileNameField;
private JComboBox<?> logLevelComboBox;
private JCheckBox logToFileCheckbox;
- private JCheckBox pauseModeCheckBox;
private JTextField steeringFileField;
private JComboBox<?> steeringResourcesComboBox;
private JComboBox<?> steeringTypeComboBox;
@@ -103,23 +86,17 @@
super(new Insets(4, 2, 2, 4), true);
setLayout(new GridBagLayout());
-
- // FIXME: This shouldn't really be part of this GUI.
- pauseModeCheckBox = addCheckBox("Pause mode", false, true);
- pauseModeCheckBox.addPropertyChangeListener(this);
disconnectOnErrorCheckBox = addCheckBox("Disconnect on error", false, true);
- disconnectOnErrorCheckBox.addPropertyChangeListener(this);
disconnectOnErrorCheckBox.setActionCommand(DISCONNECT_ON_ERROR_CHANGED);
disconnectOnErrorCheckBox.addActionListener(this);
logLevelComboBox = addComboBox("Log Level", LOG_LEVELS);
- logLevelComboBox.setActionCommand(MonitoringCommands.LOG_LEVEL_CHANGED);
+ logLevelComboBox.setActionCommand(Commands.LOG_LEVEL_CHANGED);
logLevelComboBox.addActionListener(this);
steeringTypeComboBox = addComboBox("Steering Type",
- new String[] {SteeringType.RESOURCE.name(), SteeringType.FILE.name()});
- steeringTypeComboBox.addPropertyChangeListener(this);
+ new String[] {SteeringType.RESOURCE.name(), SteeringType.FILE.name()});
steeringTypeComboBox.setActionCommand(STEERING_TYPE_CHANGED);
steeringTypeComboBox.addActionListener(this);
@@ -127,9 +104,8 @@
steeringFileField.addPropertyChangeListener("value", this);
JButton steeringFileButton = addButton("Select Steering File");
- steeringFileButton.setActionCommand(MonitoringCommands.CHOOSE_STEERING_FILE);
+ steeringFileButton.setActionCommand(Commands.CHOOSE_STEERING_FILE);
steeringFileButton.addActionListener(this);
- steeringFileButton.addPropertyChangeListener("value", this);
steeringResourcesComboBox = addComboBoxMultiline("Steering File Resource",
getAvailableSteeringFileResources(STEERING_PACKAGE));
@@ -140,7 +116,7 @@
detectorNameField.addPropertyChangeListener("value", this);
eventBuilderField = addField("Event Builder Class", 30);
- eventBuilderField.setActionCommand(MonitoringCommands.SET_EVENT_BUILDER);
+ eventBuilderField.setActionCommand(Commands.SET_EVENT_BUILDER);
eventBuilderField.addPropertyChangeListener("value", this);
logToFileCheckbox = addCheckBox("Log to File", false, false);
@@ -184,7 +160,6 @@
void enableJobPanel(boolean enable) {
detectorNameField.setEnabled(enable);
eventBuilderField.setEnabled(enable);
- pauseModeCheckBox.setEnabled(enable);
steeringTypeComboBox.setEnabled(enable);
steeringFileField.setEnabled(enable);
steeringResourcesComboBox.setEnabled(enable);
@@ -234,11 +209,17 @@
checkSteeringFile(file);
configurationModel.setSteeringFile(file.getCanonicalPath());
} catch (IOException | JDOMException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException("Error parsing the selected steering file.", e);
}
}
}
+ /**
+ * Parse the lcsim steering file to see if it appears to be valid.
+ * @param file The input steering file.
+ * @throws IOException if there is a basic IO problem.
+ * @throws JDOMException if the XML is not valid.
+ */
private void checkSteeringFile(File file) throws IOException, JDOMException {
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(file);
@@ -295,31 +276,8 @@
});
}
*/
-
+
/**
- * Check if pause mode is selected.
- * @return True if pause mode is enabled; false if not.
- */
- // FIXME: Should not be here.
- boolean pauseMode() {
- return this.pauseModeCheckBox.isSelected();
- }
-
- /**
- * Set the pause mode.
- * @param p The pause mode; true for on; false for off.
- */
- // FIXME: Should not be here. This has nothing to do with the GUI.
- void enablePauseMode(final boolean p) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- pauseModeCheckBox.setSelected(p);
- }
- });
- }
-
-
- /**
* Get the files with extension "lcsim" from all loaded jar files.
* @return A list of embedded steering file resources.
*/
@@ -355,7 +313,7 @@
@Override
public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equals(MonitoringCommands.CHOOSE_STEERING_FILE)) {
+ if (e.getActionCommand().equals(Commands.CHOOSE_STEERING_FILE)) {
this.chooseSteeringFile();
} else if (DISCONNECT_ON_ERROR_CHANGED.equals(e.getActionCommand())) {
configurationModel.setDisconnectOnError(disconnectOnErrorCheckBox.isSelected());
@@ -378,15 +336,10 @@
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
-
+
+ // FIXME: Anyway to make sure this is not needed?
if (evt.getPropertyName().equals("ancestor"))
return;
-
- //System.out.println("JobSettingsPanel.propertyChange");
- //System.out.println(" source: " + evt.getSource().getClass().getCanonicalName());
- //System.out.println(" propertyName: " + evt.getPropertyName());
- //System.out.println(" newValue: " + evt.getNewValue());
- //System.out.println(" oldValue: " + evt.getOldValue());
Object source = evt.getSource();
@@ -416,13 +369,7 @@
if (evt.getPropertyName().equals("ancestor"))
return;
-
- //System.out.println("JobSettingsChangeListener.propertyChange");
- //System.out.println(" source: " + evt.getSource().getClass().getCanonicalName());
- //System.out.println(" propertyName: " + evt.getPropertyName());
- //System.out.println(" newValue: " + evt.getNewValue());
- //System.out.println(" oldValue: " + evt.getOldValue());
-
+
Object value = evt.getNewValue();
if (evt.getPropertyName().equals(DETECTOR_NAME_PROPERTY)) {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,6 +1,23 @@
package org.hps.monitoring.gui;
-import static org.hps.monitoring.gui.MonitoringCommands.*;
+import static org.hps.monitoring.gui.Commands.AIDA_AUTO_SAVE;
+import static org.hps.monitoring.gui.Commands.CHOOSE_LOG_FILE;
+import static org.hps.monitoring.gui.Commands.CLEAR_LOG_TABLE;
+import static org.hps.monitoring.gui.Commands.CONNECT;
+import static org.hps.monitoring.gui.Commands.DISCONNECT;
+import static org.hps.monitoring.gui.Commands.EXIT;
+import static org.hps.monitoring.gui.Commands.LOAD_DEFAULT_CONFIG_FILE;
+import static org.hps.monitoring.gui.Commands.LOG_LEVEL_CHANGED;
+import static org.hps.monitoring.gui.Commands.LOG_TO_TERMINAL;
+import static org.hps.monitoring.gui.Commands.NEXT;
+import static org.hps.monitoring.gui.Commands.PAUSE;
+import static org.hps.monitoring.gui.Commands.RESUME;
+import static org.hps.monitoring.gui.Commands.SAVE_CONFIG_FILE;
+import static org.hps.monitoring.gui.Commands.SAVE_LOG_TABLE;
+import static org.hps.monitoring.gui.Commands.SAVE_PLOTS;
+import static org.hps.monitoring.gui.Commands.SCREENSHOT;
+import static org.hps.monitoring.gui.Commands.SELECT_CONFIG_FILE;
+import static org.hps.monitoring.gui.Commands.SHOW_SETTINGS;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
@@ -49,12 +66,12 @@
import javax.swing.table.DefaultTableModel;
import org.hps.evio.LCSimEventBuilder;
-import org.hps.monitoring.config.Configurable;
-import org.hps.monitoring.config.Configuration;
import org.hps.monitoring.enums.ConnectionStatus;
import org.hps.monitoring.enums.DataSourceType;
import org.hps.monitoring.enums.SteeringType;
+import org.hps.monitoring.gui.model.Configuration;
import org.hps.monitoring.gui.model.ConfigurationModel;
+import org.hps.monitoring.gui.model.HasConfigurationModel;
import org.hps.monitoring.plotting.MonitoringAnalysisFactory;
import org.hps.monitoring.plotting.MonitoringPlotFactory;
import org.hps.monitoring.record.EventProcessingChain;
@@ -62,7 +79,9 @@
import org.hps.monitoring.record.etevent.EtConnection;
import org.hps.monitoring.record.etevent.EtEventSource;
import org.hps.monitoring.record.evio.EvioFileSource;
+import org.hps.monitoring.subsys.StatusCode;
import org.hps.monitoring.subsys.SystemStatus;
+import org.hps.monitoring.subsys.SystemStatusListener;
import org.hps.monitoring.subsys.SystemStatusRegistry;
import org.hps.monitoring.subsys.et.EtSystemMonitor;
import org.hps.monitoring.subsys.et.EtSystemStripCharts;
@@ -73,8 +92,7 @@
/**
* This class is the implementation of the GUI for the Monitoring Application.
*/
-// FIXME: The log to file or terminal is probably broken with changes to JobSettingsPanel.
-public class MonitoringApplication extends JFrame implements ActionListener, Configurable {
+public final class MonitoringApplication extends JFrame implements ActionListener, SystemStatusListener {
// Top-level Swing components.
private JPanel mainPanel;
@@ -96,7 +114,7 @@
private final PrintStream sysErr = System.err;
// Error handling class for the application.
- ErrorHandler errorHandler;
+ private ErrorHandler errorHandler;
// ET connection parameters and state.
private EtConnection connection;
@@ -113,7 +131,7 @@
private static Logger logger;
private Handler logHandler;
private DefaultTableModel logTableModel;
- static final String[] logTableColumns = { "Message", "Date", "Level" };
+ static final String[] logTableColumns = { "Date", "Message", "Level" };
private JTable logTable;
private static Level DEFAULT_LOG_LEVEL = Level.INFO;
@@ -133,14 +151,14 @@
private static final int MAIN_FRAME_WIDTH = 650;
// Default config which can be overridden by command line argument.
- static final String DEFAULT_CONFIG_RESOURCE = "/org/hps/monitoring/config/default_config.prop";
+ private static final String DEFAULT_CONFIG_RESOURCE = "/org/hps/monitoring/config/default_config.prop";
- Configuration config = new Configuration(DEFAULT_CONFIG_RESOURCE);
- ConfigurationModel configModel;
+ // The application global Configuration object which is the default configuration unless overridden.
+ private Configuration configuration = new Configuration(DEFAULT_CONFIG_RESOURCE);
- // List of GUI objects to which configuration should be pushed.
- List<Configurable> configurables = new ArrayList<Configurable>();
-
+ // The ConfigurationModel for updating GUI components from the global configuration.
+ private ConfigurationModel configurationModel = new ConfigurationModel();
+
/**
* Constructor for the monitoring application.
*/
@@ -159,7 +177,7 @@
setupErrorHandler();
// Setup an uncaught exception handler.
- setupExceptionHandler();
+ setupUncaughtExceptionHandler();
// Setup the application menus.
createApplicationMenu();
@@ -185,12 +203,11 @@
// Create settings dialog window.
createSettingsDialog();
- // Add configurable objects to list.
- addConfigurables();
-
- // Load configuration from a properties file.
- set(config);
- load(config);
+ // Register the ConfigurationModel with sub-components.
+ setupConfigurationModel();
+
+ // Load the current configuration, either the default or from command line arg.
+ loadConfiguration();
// Log that the application started successfully.
log(Level.CONFIG, "Application initialized successfully.");
@@ -200,7 +217,7 @@
errorHandler = new ErrorHandler(this, logger);
}
- private void setupExceptionHandler() {
+ private void setupUncaughtExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable exception) {
MonitoringApplication.this.errorHandler.setError(exception)
@@ -233,6 +250,7 @@
}
public void setVisible(boolean visible) {
+
super.setVisible(true);
this.systemStatusFrame.setVisible(true);
@@ -326,7 +344,7 @@
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(KeyEvent.VK_X);
- exitItem.setActionCommand(MonitoringCommands.EXIT);
+ exitItem.setActionCommand(EXIT);
exitItem.addActionListener(this);
exitItem.setToolTipText("Exit from the application.");
applicationMenu.add(exitItem);
@@ -404,12 +422,16 @@
/**
* Puts log messages into the log table.
*/
- public void publish(LogRecord record) {
- Object[] row = new Object[] { /* record.getLoggerName(), */ // source
- record.getMessage(), // message
- dateFormat.format(new Date(record.getMillis())), // date
- record.getLevel() }; // level
+ public void publish(LogRecord record) {
+ // Add the row to the log table.
+ Object[] row = new Object[] {
+ dateFormat.format(new Date(record.getMillis())),
+ record.getLevel(),
+ record.getMessage() };
logTableModel.insertRow(logTable.getRowCount(), row);
+
+ // Print all messages to System.out so they show up in the terminal or log file output.
+ System.out.println(row[0] + " :: " + row[1] + " :: " + row[2]);
}
public void close() throws SecurityException {
@@ -429,6 +451,7 @@
logTableModel = new DefaultTableModel(data, logTableColumns);
logTable = new JTable(logTableModel);
logTable.setEnabled(false);
+ logTable.setAutoCreateRowSorter(true);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
@@ -457,8 +480,6 @@
* The action handler method for the entire application.
* @param e The event to handle.
*/
- // FIXME: Review all these commands to see which need to have menu items added back,
- // which should be removed, those that are duplicated, etc.
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (CONNECT.equals(cmd)) {
@@ -479,9 +500,9 @@
savePlots();
} else if (CHOOSE_LOG_FILE.equals(cmd)) {
chooseLogFile();
- } /*else if (LOG_TO_TERMINAL.equals(cmd)) {
+ } else if (LOG_TO_TERMINAL.equals(cmd)) {
logToTerminal();
- }*/ else if (SCREENSHOT.equals(cmd)) {
+ } else if (SCREENSHOT.equals(cmd)) {
chooseScreenshot();
} else if (EXIT.equals(cmd)) {
exit();
@@ -489,9 +510,7 @@
saveLogTableToFile();
} else if (CLEAR_LOG_TABLE.equals(cmd)) {
clearLogTable();
- } /*else if (SET_EVENT_BUILDER.equals(cmd)) {
- getJobSettingsPanel().editEventBuilder();
- }*/ else if (PAUSE.equals(cmd)) {
+ } else if (PAUSE.equals(cmd)) {
pauseEventProcessing();
} else if (NEXT.equals(cmd)) {
nextEvent();
@@ -501,20 +520,15 @@
setLogLevel();
} else if (AIDA_AUTO_SAVE.equals(cmd)) {
getJobSettingsPanel().chooseAidaAutoSaveFile();
- } /*else if (SET_STEERING_RESOURCE.equals(cmd)) {
- steeringResourceSelected();
- }*/ else if (SHOW_SETTINGS.equals(cmd)) {
+ } else if (SHOW_SETTINGS.equals(cmd)) {
showSettingsWindow();
} else if (SELECT_CONFIG_FILE.equals(cmd)) {
- chooseConfigFile();
+ chooseConfigurationFile();
} else if (SAVE_CONFIG_FILE.equals(cmd)) {
- saveConfigFile();
+ saveConfigurationFile();
} else if (LOAD_DEFAULT_CONFIG_FILE.equals(cmd)) {
loadDefaultConfigFile();
- } else if (LOG_TO_FILE_CHANGED.equals(cmd)) {
- if (!configModel.getLogToFile())
- logToTerminal();
- }
+ }
}
/**
@@ -529,10 +543,10 @@
* a new log level will NOT be set.
*/
private void setLogLevel() {
- Level newLevel = configModel.getLogLevel();
+ Level newLevel = configurationModel.getLogLevel();
if (logger.getLevel() != newLevel) {
logger.setLevel(newLevel);
- log(Level.INFO, "Log Level was changed to <" + configModel.getLogLevel().toString() + ">");
+ log(Level.INFO, "Log Level was changed to <" + configurationModel.getLogLevel().toString() + ">");
}
}
@@ -564,7 +578,7 @@
}
/**
- * Immediately save all plots to a selected output file using a file chooser.
+ * Save all the plots to a file using a <code>JFileChooser</code>.
*/
private void savePlots() {
JFileChooser fc = new JFileChooser();
@@ -633,17 +647,16 @@
/**
* Redirect <code>System.out</code> and <code>System.err</code> back to the terminal, e.g. if
- * they were previously sent to a file. This is independent of messages that are sent to the
- * application's log table.
+ * they were previously sent to a file.
*/
private void logToTerminal() {
System.setOut(sysOut);
System.setErr(sysErr);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- configModel.setLogToFile(false);
+ configurationModel.setLogToFile(false);
- // These should be toggled via a PropertyChangeListener or ActionEvent.
+ // FIXME: These should be toggled via a PropertyChangeListener or ActionEvent.
terminalItem.setEnabled(false);
logItem.setEnabled(true);
}
@@ -652,17 +665,18 @@
}
/**
- * Redirect std out and err to a file.
+ * Redirect <code>System.out</code> and <code>System.err</code> to a file.
*/
private void logToFile(File file) {
redirectStdOutAndErrToFile(file);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
+ // FIXME: These should be toggled via PropertyChangeListener on the ConfigurationModel.
terminalItem.setEnabled(true);
logItem.setEnabled(false);
}
});
- log("Redirected std out and err to file <" + file.getPath() + ">");
+ log("Redirected System.out and err to file <" + file.getPath() + ">");
}
/**
@@ -679,7 +693,7 @@
terminalItem.setEnabled(true);
// Re-enable the ConnectionPanel.
- getConnectionPanel().enableConnectionPanel(true);
+ getConnectionSettingsPanel().enableConnectionPanel(true);
// Re-enable the getJobPanel().
getJobSettingsPanel().enableJobPanel(true);
@@ -702,7 +716,7 @@
public void run() {
// Disable connection panel.
- getConnectionPanel().enableConnectionPanel(false);
+ getConnectionSettingsPanel().enableConnectionPanel(false);
// Disable getJobPanel().
getJobSettingsPanel().enableJobPanel(false);
@@ -714,7 +728,6 @@
// Enable relevant event panel buttons.
buttonsPanel.enablePauseButton(true);
- buttonsPanel.setPauseModeState(getJobSettingsPanel().pauseMode());
// Toggle connection button to proper settings.
buttonsPanel.setConnected(true);
@@ -867,7 +880,7 @@
}
}
- private ConnectionSettingsPanel getConnectionPanel() {
+ private ConnectionSettingsPanel getConnectionSettingsPanel() {
return settingsDialog.getSettingsPanel().getConnectionPanel();
}
@@ -875,10 +888,6 @@
return settingsDialog.getSettingsPanel().getJobSettingsPanel();
}
- private DataSourcePanel getDataSourcePanel() {
- return settingsDialog.getSettingsPanel().getDataSourcePanel();
- }
-
private void disconnect() {
disconnect(ConnectionStatus.DISCONNECTING);
}
@@ -928,17 +937,17 @@
// Get steering resource or file as a String parameter.
String steering = null;
- SteeringType steeringType = configModel.getSteeringType();
+ SteeringType steeringType = configurationModel.getSteeringType();
if (steeringType.equals(SteeringType.FILE))
try {
- steering = configModel.getSteeringFile().getCanonicalPath();
+ steering = configurationModel.getSteeringFile().getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
else
- steering = configModel.getSteeringResource();
+ steering = configurationModel.getSteeringResource();
- log(Level.CONFIG, "Set LCSim steering to <" + steering + "> with type <" + (steeringType == SteeringType.RESOURCE ? "RESOURCE" : "FILE") + ">");
+ log(Level.CONFIG, "Set steering to <" + steering + "> with type <" + (steeringType == SteeringType.RESOURCE ? "RESOURCE" : "FILE") + ">");
try {
// Create job manager and configure.
@@ -958,7 +967,7 @@
} catch (Throwable t) {
// Catch all errors and rethrow them as RuntimeExceptions.
errorHandler.setError(t)
- .setMessage("Failed to setup LCSim.")
+ .setMessage("Error setting up LCSim.")
.printStackTrace()
.raiseException();
}
@@ -984,7 +993,7 @@
private void createEventBuilder() {
// Get the class for the event builder.
- String eventBuilderClassName = configModel.getEventBuilderClassName();
+ String eventBuilderClassName = configurationModel.getEventBuilderClassName();
log(Level.FINE, "Initializing event builder <" + eventBuilderClassName + ">");
@@ -996,7 +1005,7 @@
}
// Set the detector name on the event builder so it can find conditions data.
- eventBuilder.setDetectorName(configModel.getDetectorName());
+ eventBuilder.setDetectorName(configurationModel.getDetectorName());
log(Level.CONFIG, "Successfully initialized event builder <" + eventBuilderClassName + ">");
}
@@ -1008,7 +1017,7 @@
private void createEtConnection() {
// Setup connection to ET system.
- connection = EtConnection.fromConfiguration(config);
+ connection = EtConnection.fromConfigurationModel(configurationModel);
if (connection != null) {
@@ -1018,7 +1027,7 @@
log(Level.INFO, "Successfully connected to ET system.");
} else {
- // Some error occurred and the connection is not valid.
+ // Some error occurred and the connection was not created.
setConnectionStatus(ConnectionStatus.ERROR);
errorHandler.setError(new RuntimeException("Failed to create ET connection."))
@@ -1029,7 +1038,7 @@
}
/**
- * Save the log table to a tab-delimited text file selected by a file chooser.
+ * Save the log table to a tab-delimited text file selected by a <code>JFileChooser</code>.
*/
private void saveLogTableToFile() {
JFileChooser fc = new JFileChooser();
@@ -1069,21 +1078,15 @@
logTableModel.setRowCount(0);
log(Level.INFO, "Log table was cleared.");
}
-
+
/**
- * True if connected to ET system.
- * @return True if connected to ET system.
- */
- private boolean connected() {
- return connectionStatus == ConnectionStatus.CONNECTED;
- }
-
- /**
* Notify event processor to get next set of events, if in pause mode.
*/
private void nextEvent() {
+ this.setConnectionStatus(ConnectionStatus.CONNECTED);
eventProcessing.next();
log(Level.FINEST, "Getting next event.");
+ this.setConnectionStatus(ConnectionStatus.PAUSED);
}
/**
@@ -1096,10 +1099,9 @@
// Set state of event buttons.
buttonsPanel.setPauseModeState(false);
- // Toggle job panel setting.
- getJobSettingsPanel().enablePauseMode(false);
-
log(Level.FINEST, "Resuming event processing after pause.");
+
+ this.setConnectionStatus(ConnectionStatus.CONNECTED);
}
/**
@@ -1112,10 +1114,9 @@
// Set GUI state.
buttonsPanel.setPauseModeState(true);
- // FIXME: Remove this.
- getJobSettingsPanel().enablePauseMode(false);
-
log(Level.FINEST, "Event processing was paused.");
+
+ this.setConnectionStatus(ConnectionStatus.PAUSED);
}
/**
@@ -1160,7 +1161,7 @@
eventProcessing.setEventBuilder(eventBuilder);
// Set the detector name for LCSim conditions system.
- eventProcessing.setDetectorName(configModel.getDetectorName());
+ eventProcessing.setDetectorName(configurationModel.getDetectorName());
// Get a list of Drivers to execute from the JobManager which was
// already configured.
@@ -1171,7 +1172,7 @@
// ET or EVIO source can be used for updating the RunPanel.
eventProcessing.add(runPanel.new EvioUpdater());
- // Basic ET system monitor.
+ // Basic ET system monitor.
if (usingEtServer())
eventProcessing.add(new EtSystemMonitor());
@@ -1196,29 +1197,27 @@
}
private boolean usingEtServer() {
- // FIXME: Should check the configuration instead.
- return this.getDataSourcePanel().getDataSourceType().equals(DataSourceType.ET_SERVER);
+ return configurationModel.getDataSourceType().equals(DataSourceType.ET_SERVER);
}
private boolean usingEvioFile() {
- // FIXME: Should check the configuration instead.
- return this.getDataSourcePanel().getDataSourceType().equals(DataSourceType.EVIO_FILE);
+ return configurationModel.getDataSourceType().equals(DataSourceType.EVIO_FILE);
}
private void configDataSource() {
- DataSourceType dataSourceType = getDataSourcePanel().getDataSourceType();
- String filePath = getDataSourcePanel().getFilePath();
- log(Level.INFO, "Data source type <" + dataSourceType + ">");
+ DataSourceType dataSourceType = configurationModel.getDataSourceType();
+ String filePath = configurationModel.getDataSourcePath();
+ log(Level.CONFIG, "Data source type <" + dataSourceType + ">");
if (dataSourceType.equals(DataSourceType.ET_SERVER)) {
eventProcessing.setRecordSource(new EtEventSource(connection));
- log(Level.FINE, "ET event source");
+ log(Level.CONFIG, "ET event source");
} else if (dataSourceType.equals(DataSourceType.EVIO_FILE)){
eventProcessing.setRecordSource(new EvioFileSource(new File(filePath)));
- log(Level.FINE, "EVIO file <" + filePath + " >");
+ log(Level.CONFIG, "EVIO file <" + filePath + " >");
} else if (dataSourceType.equals(DataSourceType.LCIO_FILE)) {
try {
eventProcessing.setRecordSource(new LCIOEventSource(new File(filePath)));
- log(Level.FINE, "LCIO file <" + filePath + ">");
+ log(Level.CONFIG, "LCIO file <" + filePath + ">");
} catch (IOException e) {
errorHandler.setError(e)
.log()
@@ -1229,11 +1228,19 @@
}
private void setupSystemStatusMonitor() {
+ // Clear the system status monitor table.
systemStatusFrame.getTableModel().clear();
+
+ // Get the global registry of SystemStatus objects.
SystemStatusRegistry registry = SystemStatusRegistry.getSystemStatusRegistery();
+
+ // Process the SystemStatus objects.
for (SystemStatus systemStatus : registry.getSystemStatuses()) {
- // Add a row to the table for every registered SystemStatus object.
+ // Add a row to the table for every SystemStatus.
systemStatusFrame.getTableModel().addSystemStatus(systemStatus);
+
+ // Add this class as a listener so all status changes can be logged.
+ systemStatus.addListener(this);
}
}
@@ -1249,22 +1256,20 @@
if (!plotFrame.isVisible())
// Turn on plot frame if it is off.
plotFrame.setVisible(true);
- //else
// Reset plots.
- plotFrame.reset(); // I think this should always happen here???
+ plotFrame.reset();
}
/**
* Save the plots to an AIDA output file at the end of the job.
*/
private void saveAidaFile() {
-
// Save final AIDA file if option is selected.
- if (configModel.getAidaAutoSave()) {
- log(Level.INFO, "Saving AIDA file <" + configModel.getAidaFileName() + ">");
+ if (configurationModel.getAidaAutoSave()) {
+ log(Level.INFO, "Saving AIDA file <" + configurationModel.getAidaFileName() + ">");
try {
- AIDA.defaultInstance().saveAs(configModel.getAidaFileName());
+ AIDA.defaultInstance().saveAs(configurationModel.getAidaFileName());
} catch (IOException e) {
errorHandler.setError(e)
.setMessage("Error saving AIDA file.")
@@ -1276,11 +1281,11 @@
}
/**
- * Stop the session by stopping the event processing thread, ending the job, and disconnecting
+ * Stop the session by killing the event processing thread, ending the job, and disconnecting
* from the ET system.
*/
private void stopSession() {
- // Show a modal message window.
+ // Show a modal message window while this method executes.
JDialog dialog = showStatusDialog("Info", "Disconnecting from session ...", true);
try {
@@ -1352,13 +1357,12 @@
* In this case, event processing will exit later when the ET system goes down.
*/
private void stopEventProcessing() {
-
- // Is the event processing thread actually alive?
+
if (eventProcessingThread != null) {
+ // Is the event processing thread actually still alive?
if (eventProcessingThread.isAlive()) {
- // Interrupt and kill the session thread if necessary.
- // FIXME: Not sure this should happen here!
+ // Interrupt and kill the event processing watchdog thread if necessary.
killSessionWatchdogThread();
// Request the event processing to stop.
@@ -1393,9 +1397,10 @@
private void killSessionWatchdogThread() {
if (sessionWatchdogThread != null) {
if (sessionWatchdogThread.isAlive()) {
+ // Interrupt the thread which should cause it to stop.
sessionWatchdogThread.interrupt();
try {
- // This should always work.
+ // This should always work once the thread is interupted.
sessionWatchdogThread.join();
} catch (InterruptedException e) {
}
@@ -1407,7 +1412,7 @@
/**
* Thread to automatically trigger a disconnect when the event processing chain finishes or
* throws a fatal error. This thread joins to the event processing thread and automatically
- * requests a disconnect using an action event after it finishes.
+ * requests a disconnect using an ActionEvent when the event processing thread stops.
*/
private class SessionWatchdogThread extends Thread {
@@ -1419,7 +1424,7 @@
// Activate a disconnect using the ActionEvent which is used by the disconnect button.
// FIXME: When this happens the event processing object and its thread don't get set to null!
- actionPerformed(new ActionEvent(Thread.currentThread(), 0, MonitoringCommands.DISCONNECT));
+ actionPerformed(new ActionEvent(Thread.currentThread(), 0, DISCONNECT));
} catch (InterruptedException e) {
// This probably just means that the disconnect button was pushed, and this thread should
@@ -1428,6 +1433,9 @@
}
}
+ /**
+ * Choose an output log file using a <code>JFileChooser</code>.
+ */
private void chooseLogFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Create Log File");
@@ -1438,14 +1446,9 @@
if (file.exists()) {
throw new RuntimeException("Log file already exists.");
} else {
- // This should trigger an action event that performs the actual config
- // of the log file.
- //System.out.println("setting log file to " + file.getAbsolutePath());
- //getJobSettingsPanel().setLogToFile(true);
- //getJobSettingsPanel().setLogFile(file);
- configModel.setLogToFile(true);
+ configurationModel.setLogToFile(true);
try {
- configModel.setLogFileName(file.getCanonicalPath());
+ configurationModel.setLogFileName(file.getCanonicalPath());
} catch (IOException e) {
errorHandler.setError(e).log().printStackTrace().showErrorDialog();
}
@@ -1455,7 +1458,10 @@
}
- private void chooseConfigFile() {
+ /**
+ * Choose an input configuration file using a <code>JFileChooser</code>.
+ */
+ private void chooseConfigurationFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Load Settings");
fc.setCurrentDirectory(new File("."));
@@ -1464,12 +1470,14 @@
File f = fc.getSelectedFile();
log(Level.CONFIG, "Loading settings from file <" + f.getPath() + ">");
Configuration newConfig = new Configuration(f);
- this.set(newConfig);
- this.load(config);
+ setConfiguration(newConfig);
}
}
- private void saveConfigFile() {
+ /**
+ * Save a configuration file using a <code>JFileChooser</code>.
+ */
+ private void saveConfigurationFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Save Configuration");
fc.setCurrentDirectory(new File("."));
@@ -1477,66 +1485,70 @@
if (r == JFileChooser.APPROVE_OPTION) {
File f = fc.getSelectedFile();
log(Level.CONFIG, "Saving configuration to file <" + f.getPath() + ">");
- config.writeToFile(f);
+ configuration.writeToFile(f);
}
}
+
+ /**
+ * Setup the <code>ConfigurationModel</code> by registering it with sub-components.
+ */
+ private void setupConfigurationModel() {
+ getJobSettingsPanel().setConfigurationModel(configurationModel);
+ getConnectionSettingsPanel().setConfigurationModel(configurationModel);
+ settingsDialog.getSettingsPanel().getDataSourcePanel().setConfigurationModel(configurationModel);
+ }
- @Override
- public void load(Configuration config) {
-
- for (Configurable configurable : configurables) {
- configurable.set(config);
- }
-
- configModel.fireAllChanged();
+ /**
+ * Set the Configuration but don't update the ConfigurationModel.
+ * @param configuration
+ */
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * Load the current Configuration by updating the ConfigurationModel.
+ */
+ private void loadConfiguration() {
- if (config.getFile() != null)
- log(Level.CONFIG, "Loaded config from file <" + config.getFile().getPath() + ">");
+ // Set the Configuration on the ConfigurationModel which will trigger all the PropertyChangelListeners.
+ configurationModel.setConfiguration(configuration);
+
+ // Log that a new configuration was loaded.
+ if (configuration.getFile() != null)
+ log(Level.CONFIG, "Loaded configuration from file <" + configuration.getFile().getPath() + ">");
else
- log(Level.CONFIG, "Loaded config resource <" + config.getResourcePath() + ">");
+ log(Level.CONFIG, "Loaded configuration from resource <" + configuration.getResourcePath() + ">");
+
}
-
- private void addConfigurables() {
- configurables.add(this.getConnectionPanel());
- configurables.add(this.getDataSourcePanel());
+
+ /**
+ * Load the default configuration file.
+ */
+ private void loadDefaultConfigFile() {
+ setConfiguration(new Configuration(DEFAULT_CONFIG_RESOURCE));
+ loadConfiguration();
}
+ /**
+ * Log all status changes.
+ */
@Override
- public void save(Configuration config) {
- for (Configurable configurable : configurables) {
- configurable.save(config);
- }
- }
-
- @Override
- public Configuration getConfiguration() {
- return config;
- }
-
- @Override
- public void save() {
- save(config);
- }
-
- @Override
- public void set(Configuration config) {
- this.config = config;
- if (configModel == null) {
- configModel = new ConfigurationModel(config);
- getJobSettingsPanel().setConfigurationModel(configModel);
- } else {
- configModel.setConfiguration(config);
+ public void statusChanged(SystemStatus status) {
+
+ // Choose the appropriate log level.
+ Level level = Level.INFO;
+ if (status.getStatusCode().equals(Level.WARNING)) {
+ level = Level.WARNING;
+ } else if (status.getStatusCode().ordinal() >= StatusCode.ERROR.ordinal()) {
+ level = Level.SEVERE;
}
+
+ // Log all status changes.
+ log(level, "STATUS CHANGED, "
+ + "subsystem: " + status.getSubsystem() + ", "
+ + "code: " + status.getStatusCode().name() + ", "
+ + "description: " + status.getDescription() + ", "
+ + "message: " + status.getMessage());
}
-
- @Override
- public void reset() {
- load(config);
- }
-
- public void loadDefaultConfigFile() {
- log(Level.CONFIG, "Loading default config file from resource <" + DEFAULT_CONFIG_RESOURCE + ">");
- set(new Configuration(DEFAULT_CONFIG_RESOURCE));
- load(config);
- }
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringCommands.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringCommands.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,39 +0,0 @@
-package org.hps.monitoring.gui;
-
-/**
- * These strings are used to identify ActionEvents in the MonitoringApplication.
- * A few commands handled only by sub-components are not listed here.
- */
-final class MonitoringCommands {
-
- static final String DISCONNECT_ON_ERROR_CHANGED = "disconnectOnErrorChanged";
- static final String STEERING_TYPE_CHANGED = "steeringTypeChanged";
- static final String STEERING_RESOURCE_CHANGED = "steeringResourceChanged";
- static final String LOG_TO_FILE_CHANGED = "logToFileChanged";
- static final String AIDA_AUTO_SAVE_CHANGED = "aidaAutoSaveChanged";
- static final String LOG_LEVEL_CHANGED = "logLevelChanged";
-
- static final String AIDA_AUTO_SAVE = "aidaAutoSave";
- static final String CLEAR_LOG_TABLE = "clearLogTable";
- static final String CHOOSE_LOG_FILE = "chooseLogFile";
- static final String CHOOSE_STEERING_FILE = "chooseSteeringFile";
- static final String CONNECT = "connect";
- static final String DISCONNECT = "disconnect";
- static final String EXIT = "exit";
- static final String LOAD_DEFAULT_CONFIG_FILE = "loadDefaultConfigFile";
- static final String LOG_TO_FILE = "logToFile";
- static final String LOG_TO_TERMINAL = "logToTerminal";
- static final String NEXT = "next";
- static final String PAUSE = "pause";
- static final String RESUME = "resume";
- static final String SAVE_LOG_TABLE = "saveLogTable";
- static final String SAVE_PLOTS = "savePlots";
- static final String SCREENSHOT = "screenshot";
- static final String SAVE_CONFIG_FILE = "saveConfigFile";
- static final String SET_EVENT_BUILDER = "setEventBuilder";
-
- static final String SET_STEERING_RESOURCE = "setSteeringResource";
- static final String SELECT_CONFIG_FILE = "selectConfigFile";
- static final String SELECT_LOG_FILE = "logToFile";
- static final String SHOW_SETTINGS = "showSettings";
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotFrame.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotFrame.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -6,7 +6,7 @@
/**
* A <code>JFrame</code> where monitoring plots will show in tabs.
*/
-public class PlotFrame extends JFrame {
+class PlotFrame extends JFrame {
private JTabbedPane plotPane;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -20,6 +20,7 @@
* Dashboard for displaying information about the current run.
* @author Jeremy McCormick <[log in to unmask]>
*/
+// FIXME: This component should be updated via a Model rather than direct calls to this class.
public class RunPanel extends JPanel {
FieldPanel runNumberField = new FieldPanel("Run Number", "", 10, false);
@@ -55,7 +56,7 @@
startDateField.setValue("");
endDateField.setValue("");
lengthField.setValue("");
- totalEventsField.setValue("0");
+ totalEventsField.setValue("");
elapsedTimeField.setValue("");
eventsReceivedField.setValue("0");
dataReceivedField.setValue("0");
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -9,7 +9,6 @@
/**
* Miscellaneous utility methods for getting information about the graphics environment.
- * @author Jeremy McCormick <[log in to unmask]>
*/
class ScreenUtil {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -9,7 +9,7 @@
* The modal dialog for entering settings. It contains a <code>JPanel</code>
* with the different settings sub-tabs.
*/
-public class SettingsDialog extends JDialog {
+class SettingsDialog extends JDialog {
final SettingsPanel settingsPanel = new SettingsPanel(this);
@@ -24,7 +24,6 @@
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
- settingsPanel.reset();
setVisible(false);
}
});
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -4,19 +4,16 @@
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.IOException;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import javax.swing.SwingUtilities;
/**
- * The container component with the tabs which have job and connection settings.
+ * The container component with the tabs that have job and connection settings.
*/
class SettingsPanel extends JPanel implements ActionListener {
@@ -25,12 +22,10 @@
ConnectionSettingsPanel connectionPanel = new ConnectionSettingsPanel();
DataSourcePanel dataSourcePanel = new DataSourcePanel();
static final String OKAY_COMMAND = "settingsOkay";
- static final String CANCEL_COMMAND = "settingsCancel";
JButton defaultsButton;
JDialog parent;
- ErrorHandler errorHandler;
SettingsPanel(JDialog parent) {
@@ -47,19 +42,14 @@
JButton okayButton = new JButton("Okay");
okayButton.setActionCommand(OKAY_COMMAND);
okayButton.addActionListener(this);
-
- JButton cancelButton = new JButton("Cancel");
- cancelButton.setActionCommand(CANCEL_COMMAND);
- cancelButton.addActionListener(this);
defaultsButton = new JButton("Defaults");
- defaultsButton.setActionCommand(MonitoringCommands.LOAD_DEFAULT_CONFIG_FILE);
+ defaultsButton.setActionCommand(Commands.LOAD_DEFAULT_CONFIG_FILE);
defaultsButton.addActionListener(this);
add(Box.createRigidArea(new Dimension(1,5)));
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(okayButton);
- buttonsPanel.add(cancelButton);
buttonsPanel.add(defaultsButton);
buttonsPanel.setLayout(new FlowLayout());
add(buttonsPanel);
@@ -77,56 +67,11 @@
DataSourcePanel getDataSourcePanel() {
return dataSourcePanel;
}
-
- /**
- * Pushes the GUI settings into the current configuration object.
- */
- void save() {
- connectionPanel.save();
- //jobPanel.save();
- dataSourcePanel.save();
- }
-
- /**
- * Resets the settings to the last saved configuration.
- */
- void reset() {
- connectionPanel.reset();
- //jobPanel.reset();
- dataSourcePanel.reset();
- }
-
- // FIXME: This isn't the right way to do this!
- String getError() {
- try {
- this.dataSourcePanel.checkFile();
- return null;
- } catch (IOException e) {
- return e.getMessage();
- }
- }
-
+
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(OKAY_COMMAND)) {
- final String errorMessage = getError();
- if (errorMessage != null) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- SettingsPanel.this,
- errorMessage,
- "Settings Error",
- JOptionPane.ERROR_MESSAGE);
- }
- });
- } else {
- save();
- parent.setVisible(false);
- }
- } else if (e.getActionCommand().equals(CANCEL_COMMAND)) {
- reset();
- parent.setVisible(false);
+ parent.setVisible(false);
}
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusFrame.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusFrame.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -23,16 +23,18 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
-import org.hps.monitoring.enums.StatusCode;
import org.hps.monitoring.gui.model.SystemStatusTableModel;
+import org.hps.monitoring.subsys.StatusCode;
/**
- * A GUI window for showing changes to {@link org.hps.monitoring.subsys.SystemStatus} objects.
+ * A GUI window for showing changes to {@link org.hps.monitoring.subsys.SystemStatus} objects
+ * using a <code>JTable</code>.
*/
-public class SystemStatusFrame extends JFrame implements HasErrorHandler {
+// TODO: It might be a good idea if there was a second table which logged all status changes as separate
+// rows so they could be seen in order.
+class SystemStatusFrame extends JFrame {
JTable table;
- ErrorHandler errorHandler;
int WIDTH = 650;
int HEIGHT = ScreenUtil.getScreenHeight() / 2;
@@ -103,6 +105,8 @@
table.getColumnModel().getColumn(STATUS_COL).setPreferredWidth(10);
table.getColumnModel().getColumn(SYSTEM_COL).setPreferredWidth(10);
// TODO: Add widths for every column.
+
+ table.setAutoCreateRowSorter(true);
// Scroll pane.
JScrollPane scrollPane = new JScrollPane(table);
@@ -117,16 +121,6 @@
pack();
}
- @Override
- public void setErrorHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- @Override
- public ErrorHandler getErrorHandler() {
- return errorHandler;
- }
-
public SystemStatusTableModel getTableModel() {
return (SystemStatusTableModel) table.getModel();
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -7,7 +7,7 @@
import java.lang.reflect.Method;
/**
- * Abstract class that updates listeners of property changes in backing model.
+ * Abstract class that updates listeners from property changes in a backing model object.
* @author Jeremy McCormick <[log in to unmask]>
*/
public abstract class AbstractModel {
@@ -36,13 +36,8 @@
abstract public String[] getProperties();
+ // FIXME: This method is kind of a hack. Any other good way to do this?
public void fireAllChanged() {
- //System.out.println("AbstractModel.fireAllChanged");
- //System.out.println(" listeners: ");
- //for (PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
- // System.out.print(listener.getClass().getCanonicalName() + " ");
- //}
- System.out.println();
for (String property : getProperties()) {
Method getMethod = null;
for (Method method : getClass().getMethods()) {
@@ -52,20 +47,13 @@
}
}
try {
- //System.out.println("firePropertyChange");
- //System.out.println(" property: " + property);
- //System.out.println(" getMethod: " + getMethod.getName());
Object value = getMethod.invoke(this, null);
- //System.out.println(" value: " + value);
if (value != null) {
firePropertyChange(property, value, value);
for (PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
- //System.out.println(" propertyChange: " + listener.getClass().getCanonicalName());
+ // FIXME: For some reason calling the propertyChangeSupport methods directly here doesn't work!!!
listener.propertyChange(new PropertyChangeEvent(this, property, value, value));
}
- //firePropertyChange(new PropertyChangeEvent(this, property, value, value));
- } else {
- System.err.println("WARNING: AbstractModel.fireAllChanged - missing property " + property);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -3,19 +3,23 @@
import java.io.File;
import java.util.logging.Level;
-import org.hps.monitoring.config.Configuration;
+import org.hps.monitoring.enums.DataSourceType;
import org.hps.monitoring.enums.SteeringType;
+import org.jlab.coda.et.enums.Mode;
/**
* A model of the global configuration parameters that can be
- * used to automatically update the GUI or push changes in GUI
- * component values into the configuration.
- * @author Jeremy McCormick <[log in to unmask]>
+ * used to automatically update the GUI from a configuration
+ * or push changes from GUI components into the current configuration.
*/
+// TODO: Should set methods check if new value is equal to old and then ignore if so?
+// FIXME: When the set methods are called, e.g. from GUI updates, this triggers
+// a property change event that pushes the values back to the GUI again.
public final class ConfigurationModel extends AbstractModel {
Configuration config;
+ // Job settings
public static final String AIDA_AUTO_SAVE_PROPERTY = "AidaAutoSave";
public static final String AIDA_FILE_NAME_PROPERTY = "AidaFileName";
public static final String DETECTOR_NAME_PROPERTY = "DetectorName";
@@ -26,9 +30,29 @@
public static final String LOG_TO_FILE_PROPERTY = "LogToFile";
public static final String STEERING_TYPE_PROPERTY = "SteeringType";
public static final String STEERING_FILE_PROPERTY = "SteeringFile";
- public static final String STEERING_RESOURCE_PROPERTY = "SteeringResource";
-
+ public static final String STEERING_RESOURCE_PROPERTY = "SteeringResource";
+
+ // Data source
+ public static final String DATA_SOURCE_TYPE_PROPERTY = "DataSourceType";
+ public static final String DATA_SOURCE_PATH_PROPERTY = "DataSourcePath";
+
+ // ET connection parameters
+ public static final String ET_NAME_PROPERTY = "EtName";
+ public static final String HOST_PROPERTY = "Host";
+ public static final String PORT_PROPERTY = "Port";
+ public static final String BLOCKING_PROPERTY = "Blocking";
+ public static final String VERBOSE_PROPERTY = "Verbose";
+ public static final String STATION_NAME_PROPERTY = "StationName";
+ public static final String CHUNK_SIZE_PROPERTY = "ChunkSize";
+ public static final String QUEUE_SIZE_PROPERTY = "QueueSize";
+ public static final String STATION_POSITION_PROPERTY = "StationPosition";
+ public static final String WAIT_MODE_PROPERTY = "WaitMode";
+ public static final String WAIT_TIME_PROPERTY = "WaitTime";
+ public static final String PRESCALE_PROPERTY = "Prescale";
+
static final String[] CONFIG_PROPERTIES = new String[] {
+
+ // Job settings
AIDA_AUTO_SAVE_PROPERTY,
AIDA_FILE_NAME_PROPERTY,
DETECTOR_NAME_PROPERTY,
@@ -40,9 +64,31 @@
STEERING_FILE_PROPERTY,
STEERING_RESOURCE_PROPERTY,
STEERING_TYPE_PROPERTY,
+
+ // Data source
+ DATA_SOURCE_TYPE_PROPERTY,
+ DATA_SOURCE_PATH_PROPERTY,
+
+ // ET parameters
+ ET_NAME_PROPERTY,
+ HOST_PROPERTY,
+ PORT_PROPERTY,
+ BLOCKING_PROPERTY,
+ VERBOSE_PROPERTY,
+ STATION_NAME_PROPERTY,
+ CHUNK_SIZE_PROPERTY,
+ QUEUE_SIZE_PROPERTY,
+ STATION_POSITION_PROPERTY,
+ WAIT_MODE_PROPERTY,
+ WAIT_TIME_PROPERTY,
+ PRESCALE_PROPERTY
};
String detectorName;
+
+ public ConfigurationModel() {
+ this.config = new Configuration();
+ }
public ConfigurationModel(Configuration config) {
this.config = config;
@@ -50,6 +96,7 @@
public void setConfiguration(Configuration config) {
this.config = config;
+ fireAllChanged();
}
public Level getLogLevel() {
@@ -164,7 +211,147 @@
config.set(DISCONNECT_ON_ERROR_PROPERTY, disconnectOnError);
firePropertyChange(DISCONNECT_ON_ERROR_PROPERTY, oldValue, getDisconnectOnError());
}
+
+ public DataSourceType getDataSourceType() {
+ return DataSourceType.valueOf(config.get(DATA_SOURCE_TYPE_PROPERTY));
+ }
+ public void setDataSourceType(DataSourceType dataSourceType) {
+ DataSourceType oldValue = getDataSourceType();
+ config.set(DATA_SOURCE_TYPE_PROPERTY, dataSourceType);
+ firePropertyChange(DATA_SOURCE_TYPE_PROPERTY, oldValue, getDataSourceType());
+ }
+
+ public String getDataSourcePath() {
+ return config.get(DATA_SOURCE_PATH_PROPERTY);
+ }
+
+ public void setDataSourcePath(String dataSourcePath) {
+ String oldValue = getDataSourcePath();
+ config.set(DATA_SOURCE_PATH_PROPERTY, dataSourcePath);
+ firePropertyChange(DATA_SOURCE_PATH_PROPERTY, oldValue, getDataSourcePath());
+ }
+
+ public String getEtName() {
+ return config.get(ET_NAME_PROPERTY);
+ }
+
+ public void setEtName(String etName) {
+ String oldValue = getEtName();
+ config.set(ET_NAME_PROPERTY, etName);
+ firePropertyChange(ET_NAME_PROPERTY, oldValue, getEtName());
+ }
+
+ public String getHost() {
+ return config.get(HOST_PROPERTY);
+ }
+
+ public void setHost(String host) {
+ String oldValue = getHost();
+ config.set(HOST_PROPERTY, host);
+ firePropertyChange(HOST_PROPERTY, oldValue, getHost());
+ }
+
+ public int getPort() {
+ return config.getInteger(PORT_PROPERTY);
+ }
+
+ public void setPort(int port) {
+ int oldValue = getPort();
+ config.set(PORT_PROPERTY, port);
+ firePropertyChange(PORT_PROPERTY, oldValue, getPort());
+ }
+
+ public boolean getBlocking() {
+ return config.getBoolean(BLOCKING_PROPERTY);
+ }
+
+ public void setBlocking(boolean blocking) {
+ boolean oldValue = getBlocking();
+ config.set(BLOCKING_PROPERTY, blocking);
+ firePropertyChange(BLOCKING_PROPERTY, oldValue, getBlocking());
+ }
+
+ public boolean getVerbose() {
+ return config.getBoolean(VERBOSE_PROPERTY);
+ }
+
+ public void setVerbose(boolean verbose) {
+ boolean oldValue = getVerbose();
+ config.set(VERBOSE_PROPERTY, verbose);
+ firePropertyChange(VERBOSE_PROPERTY, oldValue, getVerbose());
+ }
+
+ public String getStationName() {
+ return config.get(STATION_NAME_PROPERTY);
+ }
+
+ public void setStationName(String stationName) {
+ String oldValue = getStationName();
+ config.set(STATION_NAME_PROPERTY, stationName);
+ firePropertyChange(STATION_NAME_PROPERTY, oldValue, getStationName());
+ }
+
+ public int getChunkSize() {
+ return config.getInteger(CHUNK_SIZE_PROPERTY);
+ }
+
+ public void setChunkSize(int chunkSize) {
+ int oldValue = getChunkSize();
+ config.set(CHUNK_SIZE_PROPERTY, chunkSize);
+ firePropertyChange(CHUNK_SIZE_PROPERTY, oldValue, getChunkSize());
+ }
+
+ public int getQueueSize() {
+ return config.getInteger(QUEUE_SIZE_PROPERTY);
+ }
+
+ public void setQueueSize(int queueSize) {
+ int oldValue = getQueueSize();
+ config.set(QUEUE_SIZE_PROPERTY, queueSize);
+ firePropertyChange(QUEUE_SIZE_PROPERTY, oldValue, getQueueSize());
+ }
+
+ public int getStationPosition() {
+ return config.getInteger(STATION_POSITION_PROPERTY);
+ }
+
+ public void setStationPosition(int stationPosition) {
+ int oldValue = getStationPosition();
+ config.set(STATION_POSITION_PROPERTY, stationPosition);
+ firePropertyChange(STATION_POSITION_PROPERTY, oldValue, getStationPosition());
+ }
+
+ public Mode getWaitMode() {
+ return Mode.valueOf(config.get(WAIT_MODE_PROPERTY));
+ }
+
+ public void setWaitMode(Mode waitMode) {
+ Mode oldValue = getWaitMode();
+ config.set(WAIT_MODE_PROPERTY, waitMode.name());
+ firePropertyChange(WAIT_MODE_PROPERTY, oldValue, getWaitMode());
+ }
+
+ public int getWaitTime() {
+ return config.getInteger(WAIT_TIME_PROPERTY);
+ }
+
+ public void setWaitTime(int waitTime) {
+ int oldValue = getWaitTime();
+ config.set(WAIT_TIME_PROPERTY, waitTime);
+ firePropertyChange(WAIT_TIME_PROPERTY, oldValue, getWaitTime());
+ }
+
+ public int getPrescale() {
+ return config.getInteger(PRESCALE_PROPERTY);
+ }
+
+ public void setPrescale(int prescale) {
+ int oldValue = getPrescale();
+ config.set(PRESCALE_PROPERTY, prescale);
+ firePropertyChange(PRESCALE_PROPERTY, oldValue, getPrescale());
+ }
+
@Override
public String[] getProperties() {
return CONFIG_PROPERTIES;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,9 +1,18 @@
package org.hps.monitoring.gui.model;
-
-public interface HasConfigurationModel {
-
+/**
+ * Mixin interface for classes that have an associated {@link ConfigurationModel}.
+ */
+public interface HasConfigurationModel {
+ /**
+ * Set the ConfigurationModel of the object.
+ * @param configurationModel The ConfigurationModel.
+ */
void setConfigurationModel(ConfigurationModel configurationModel);
+ /**
+ * Get the current ConfigurationModel of the object.
+ * @return The ConfigurationModel.
+ */
ConfigurationModel getConfigurationModel();
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -10,24 +10,23 @@
import javax.swing.JButton;
import javax.swing.table.AbstractTableModel;
-import org.hps.monitoring.enums.StatusCode;
+import org.hps.monitoring.subsys.StatusCode;
import org.hps.monitoring.subsys.SystemStatus;
import org.hps.monitoring.subsys.SystemStatusListener;
/**
- * A <code>JTableModel</code> that has a backing list of
- * {@link org.hps.monitoring.subsys.SystemStatus} objects.
+ * A <code>JTableModel</code> that has a list of {@link org.hps.monitoring.subsys.SystemStatus} objects.
*/
-public class SystemStatusTableModel extends AbstractTableModel implements SystemStatusListener {
+public final class SystemStatusTableModel extends AbstractTableModel implements SystemStatusListener {
- static final int RESET_COL = 0;
- static final int ACTIVE_COL = 1;
- static final int STATUS_COL = 2;
- static final int SYSTEM_COL = 3;
- static final int DESCRIPTION_COL = 4;
- static final int MESSAGE_COL = 5;
- static final int LAST_CHANGED_COL = 6;
- static final int CLEARABLE_COL = 7;
+ public static final int RESET_COL = 0;
+ public static final int ACTIVE_COL = 1;
+ public static final int STATUS_COL = 2;
+ public static final int SYSTEM_COL = 3;
+ public static final int DESCRIPTION_COL = 4;
+ public static final int MESSAGE_COL = 5;
+ public static final int LAST_CHANGED_COL = 6;
+ public static final int CLEARABLE_COL = 7;
static final String[] columnNames = {
"Reset",
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -21,7 +21,6 @@
* The top level component is set externally by the MonitoringApplication before any calls
* to AIDA are made from Drivers.
*/
-// FIXME: Move to plotting package.
public class MonitoringPlotFactory extends PlotterFactory {
// The name of the factory which will be used in naming tabs in the monitoring app.
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -11,6 +11,9 @@
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
+/**
+ * Utility methods for building strip charts using JFreeChart backend.
+ */
public final class StripChartBuilder {
private StripChartBuilder() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -5,9 +5,9 @@
import org.jfree.data.time.TimeSeriesCollection;
-public class StripChartUtil {
+public final class StripChartUtil {
- private StripChartUtil() {
+ private StripChartUtil() {
}
public static TimeSeries getTimeSeries(JFreeChart chart) {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -3,7 +3,7 @@
/**
* Thread for running the event processing chain.
*/
-public class EventProcessingThread extends Thread {
+public final class EventProcessingThread extends Thread {
EventProcessingChain processing;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecord.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecord.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -8,7 +8,7 @@
* This class is used to group together corresponding ET, EVIO and LCIO events
* for use by the {@link CompositeRecordLoop}.
*/
-public class CompositeRecord {
+public final class CompositeRecord {
EtEvent etEvent;
EvioEvent evioEvent;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoop.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoop.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -8,7 +8,7 @@
* Implementation of a composite record loop for processing
* ET, EVIO and LCIO events using a single record source.
*/
-public class CompositeRecordLoop extends DefaultRecordLoop {
+public final class CompositeRecordLoop extends DefaultRecordLoop {
CompositeRecordSource recordSource = new CompositeRecordSource();
CompositeRecordLoopAdapter adapter = new CompositeRecordLoopAdapter();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoopAdapter.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoopAdapter.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -11,7 +11,7 @@
/**
* Adapter for listening on the {@link CompositeRecordLoop} for records and loop events.
*/
-public class CompositeRecordLoopAdapter extends AbstractLoopListener implements RecordListener {
+public final class CompositeRecordLoopAdapter extends AbstractLoopListener implements RecordListener {
List<CompositeRecordProcessor> processors = new ArrayList<CompositeRecordProcessor>();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordProcessor.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordProcessor.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -6,7 +6,7 @@
* An <code>EventProcessor</code> implementation for processing <code>CompositeRecord</code>
* records.
*/
-public class CompositeRecordProcessor implements EventProcessor<CompositeRecord> {
+public abstract class CompositeRecordProcessor implements EventProcessor<CompositeRecord> {
@Override
public void startJob() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordSource.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordSource.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -8,7 +8,7 @@
/**
* A record source providing <code>CompositeRecord</code> objects.
*/
-public class CompositeRecordSource extends AbstractRecordSource {
+public final class CompositeRecordSource extends AbstractRecordSource {
CompositeRecord currentRecord;
int sequenceNumber = 0;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -2,7 +2,7 @@
import java.io.IOException;
-import org.hps.monitoring.config.Configuration;
+import org.hps.monitoring.gui.model.ConfigurationModel;
import org.jlab.coda.et.EtAttachment;
import org.jlab.coda.et.EtConstants;
import org.jlab.coda.et.EtEvent;
@@ -23,7 +23,7 @@
/**
* Create an EtSystem and EtAttachment from ConnectionParameters.
*/
-public class EtConnection {
+public final class EtConnection {
EtSystem sys;
EtAttachment att;
@@ -112,14 +112,14 @@
}
}
- public static EtConnection fromConfiguration(Configuration config) {
+ public static EtConnection fromConfigurationModel(ConfigurationModel configurationModel) {
try {
// make a direct connection to ET system's tcp server
EtSystemOpenConfig etConfig = new EtSystemOpenConfig(
- config.get("bufferName"),
- config.get("host"),
- config.getInteger("port"));
+ configurationModel.getEtName(),
+ configurationModel.getHost(),
+ configurationModel.getPort());
// create ET system object with verbose debugging output
EtSystem sys = new EtSystem(etConfig, EtConstants.debugInfo);
@@ -130,27 +130,27 @@
//statConfig.setFlowMode(cn.flowMode);
// FIXME: Flow mode hard-coded.
statConfig.setFlowMode(EtConstants.stationSerial);
- boolean blocking = config.getBoolean("blocking");
+ boolean blocking = configurationModel.getBlocking();
if (!blocking) {
statConfig.setBlockMode(EtConstants.stationNonBlocking);
- int qSize = config.getInteger("qSize");
+ int qSize = configurationModel.getQueueSize();
if (qSize > 0) {
statConfig.setCue(qSize);
}
}
// Set prescale.
- int prescale = config.getInteger("prescale");
+ int prescale = configurationModel.getPrescale();
if (prescale > 0) {
//System.out.println("setting prescale to " + cn.prescale);
statConfig.setPrescale(prescale);
}
// Create the station.
- System.out.println("position="+config.getInteger("position"));
+ //System.out.println("position="+config.getInteger("position"));
EtStation stat = sys.createStation(
statConfig,
- config.get("statName"),
- config.getInteger("position"));
+ configurationModel.getStationName(),
+ configurationModel.getStationPosition());
// attach to new station
EtAttachment att = sys.attach(stat);
@@ -160,9 +160,9 @@
sys,
att,
stat,
- Mode.valueOf(config.get("waitMode")),
- config.getInteger("waitTime"),
- config.getInteger("chunk")
+ configurationModel.getWaitMode(),
+ configurationModel.getWaitTime(),
+ configurationModel.getChunkSize()
);
return connection;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnectionParameters.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnectionParameters.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -9,7 +9,7 @@
/**
* Connection parameters for ET system consumer.
*/
-public class EtConnectionParameters {
+public final class EtConnectionParameters {
/**
* Parameters that are externally settable from within the package.
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventAdapter.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventAdapter.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -12,7 +12,7 @@
/**
* Adapter for processing <tt>EtEvent</tt> objects using a loop.
*/
-public class EtEventAdapter extends AbstractLoopListener implements RecordListener {
+public final class EtEventAdapter extends AbstractLoopListener implements RecordListener {
List<EtEventProcessor> processors = new ArrayList<EtEventProcessor>();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventLoop.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventLoop.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -7,7 +7,7 @@
/**
* Record loop implementation for processing <tt>EtEvent</tt> objects.
*/
-public class EtEventLoop extends DefaultRecordLoop {
+public final class EtEventLoop extends DefaultRecordLoop {
EtEventAdapter adapter = new EtEventAdapter();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventQueue.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventQueue.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -8,7 +8,7 @@
* This would most likely be run on a separate thread than the
* loop to avoid undesired blocking behavior.
*/
-public class EtEventQueue extends AbstractRecordQueue<EtEvent> {
+public final class EtEventQueue extends AbstractRecordQueue<EtEvent> {
@Override
public Class<EtEvent> getRecordClass() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -13,23 +13,14 @@
* Implement a loop record source supplying <tt>EtEvent</tt> objects
* from an ET ring server connection.
*/
-public class EtEventSource extends AbstractRecordSource {
+public final class EtEventSource extends AbstractRecordSource {
EtConnection connection;
EtEvent currentRecord;
Queue<EtEvent> eventQueue = new LinkedBlockingQueue<EtEvent>();
-
- /*
- public EtEventSource() {
- // Default connection parameters.
- this.connection = EtConnection.createEtConnection(new EtConnectionParameters());
- }
- */
-
+
public EtEventSource(EtConnection connection) {
this.connection = connection;
- System.out.println("EtEventSource using ET system parameters ...");
- System.out.println(this.connection.toString());
}
@Override
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioAdapter.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioAdapter.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -13,7 +13,7 @@
/**
* Adapter to process <tt>EvioEvent</tt> objects using a record loop.
*/
-public class EvioAdapter extends AbstractLoopListener implements RecordListener {
+public final class EvioAdapter extends AbstractLoopListener implements RecordListener {
List<EvioEventProcessor> processors = new ArrayList<EvioEventProcessor>();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventLoop.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventLoop.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -9,7 +9,7 @@
/**
* Implementation of record loop for processing <tt>EvioEvent</tt> objects.
*/
-public class EvioEventLoop extends DefaultRecordLoop {
+public final class EvioEventLoop extends DefaultRecordLoop {
EvioAdapter adapter = new EvioAdapter();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventQueue.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventQueue.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -6,7 +6,7 @@
/**
* A dynamic queue providing <tt>EvioEvent</tt> objects to a loop.
*/
-public class EvioEventQueue extends AbstractRecordQueue<EvioEvent> {
+public final class EvioEventQueue extends AbstractRecordQueue<EvioEvent> {
@Override
public Class<EvioEvent> getRecordClass() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileProducer.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileProducer.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -23,7 +23,7 @@
* This is copied and modified from the EvioProducer class in the ET 12.0 CODA module.
*/
// TODO: Add option to set number of events in the put array.
-public class EvioFileProducer {
+public final class EvioFileProducer {
private List<File> evioFiles = new ArrayList<File>();
private EvioReader reader;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileSource.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileSource.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -16,7 +16,7 @@
* objects to a loop from EVIO files. Unlike the LCIO record source, it has no rewind or
* indexing capabilities (for now at least).
*/
-public class EvioFileSource extends AbstractRecordSource {
+public final class EvioFileSource extends AbstractRecordSource {
EvioEvent currentEvent;
EvioReader reader;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioEventQueue.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioEventQueue.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -6,7 +6,7 @@
/**
* A dynamic queue providing <tt>EvioEvent</tt> objects to a loop.
*/
-public class LcioEventQueue extends AbstractRecordQueue<EventHeader> {
+public final class LcioEventQueue extends AbstractRecordQueue<EventHeader> {
@Override
public Class<EventHeader> getRecordClass() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioLoop.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioLoop.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -6,7 +6,7 @@
* This class overrides the error handling of <code>LCSimLoop</code>
* so it does not exit the application when errors occur.
*/
-public class LcioLoop extends LCSimLoop {
+public final class LcioLoop extends LCSimLoop {
protected void handleClientError(Throwable x) {
if (x != null) {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -12,6 +12,8 @@
/**
* Implementation of {@link SystemStatistics}.
*/
+// FIXME: Rolling averages need to happen over a greater time period like 30 seconds
+// instead of 1 second, because otherwise the statistics don't look right.
public class SystemStatisticsImpl implements SystemStatistics {
long tickLengthMillis = 1000; // default is one second tick
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -1,7 +1,5 @@
package org.hps.monitoring.subsys;
-import org.hps.monitoring.enums.StatusCode;
-import org.hps.monitoring.enums.Subsystem;
/**
* The <tt>SystemStatus</tt> describes the state of a system, e.g. whether it is okay
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -3,9 +3,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.monitoring.enums.StatusCode;
-import org.hps.monitoring.enums.Subsystem;
-
/**
* The implementation of {@link SystemStatus}.
*/
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -7,11 +7,14 @@
/**
* Global registry of all {@link SystemStatus} objects.
*/
-public class SystemStatusRegistry {
+public final class SystemStatusRegistry {
static SystemStatusRegistry instance = new SystemStatusRegistry();
List<SystemStatus> systemStatuses = new ArrayList<SystemStatus>();
+ private SystemStatusRegistry() {
+ }
+
public static SystemStatusRegistry getSystemStatusRegistery() {
return instance;
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -14,7 +14,7 @@
import org.lcsim.util.aida.AIDA;
/**
- * Proof of principle Driver for plotting a sub-system's data using a strip chart.
+ * Example Driver for plotting a sub-system's data using a strip chart.
*/
public class EcalStripChartTestDriver extends Driver {
@@ -49,10 +49,6 @@
series.add(new Millisecond(new Date()), averageHits);
hits = 0;
events = 0;
- }
-
- //long millis = (long) ((double) event.getTimeStamp() / 1e6);
- //series.addOrUpdate(new Second(new Date(timestamp)), size);
- //series.addOrUpdate(new Millisecond(new Date(millis)), size);
+ }
}
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -3,17 +3,17 @@
import java.util.Timer;
import java.util.TimerTask;
-import org.hps.monitoring.enums.StatusCode;
-import org.hps.monitoring.enums.Subsystem;
import org.hps.monitoring.record.etevent.EtEventProcessor;
+import org.hps.monitoring.subsys.StatusCode;
+import org.hps.monitoring.subsys.Subsystem;
import org.hps.monitoring.subsys.SystemStatus;
import org.hps.monitoring.subsys.SystemStatusImpl;
import org.jlab.coda.et.EtEvent;
/**
- * This is a test class for monitoring the ET system.
+ * This is a class for monitoring the ET system.
*/
-public class EtSystemMonitor extends EtEventProcessor {
+public final class EtSystemMonitor extends EtEventProcessor {
SystemStatus systemStatus;
int events = 0;
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -9,7 +9,7 @@
/**
* A basic set of strip charts for monitoring the ET system.
*/
-public class EtSystemStripCharts extends EtEventProcessor {
+public final class EtSystemStripCharts extends EtEventProcessor {
SystemStatisticsImpl stats = new SystemStatisticsImpl();
MonitoringPlotFactory plotFactory = (MonitoringPlotFactory)
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java 2014-08-01 22:25:18 UTC (rev 833)
@@ -3,8 +3,8 @@
import java.util.Timer;
import java.util.TimerTask;
-import org.hps.monitoring.enums.StatusCode;
-import org.hps.monitoring.enums.Subsystem;
+import org.hps.monitoring.subsys.StatusCode;
+import org.hps.monitoring.subsys.Subsystem;
import org.hps.monitoring.subsys.SystemStatus;
import org.hps.monitoring.subsys.SystemStatusImpl;
import org.lcsim.event.EventHeader;
java/trunk/monitoring-app/src/main/resources/org/hps/monitoring/config
--- java/trunk/monitoring-app/src/main/resources/org/hps/monitoring/config/default_config.prop 2014-07-30 19:56:08 UTC (rev 832)
+++ java/trunk/monitoring-app/src/main/resources/org/hps/monitoring/config/default_config.prop 2014-08-01 22:25:18 UTC (rev 833)
@@ -11,28 +11,28 @@
LogLevel=ALL
LogToFile=false
#SteeringFile=
-SteeringResource=/org/hps/steering/monitoring/TestRunMonitoring.lcsim
+SteeringResource=org/hps/steering/monitoring/DummyMonitoring.lcsim
SteeringType=RESOURCE
# event source
-dataSourceType=ET_SERVER
-dataSourcePath=
+DataSourceType=ET_SERVER
+DataSourcePath=
# ET connection settings
-blocking=false
-bufferName=ETBuffer
-chunk=1
-host=localhost
-port=11111
-position=1
-# prescale was 1
-prescale=0
-qSize=0
-statName=MY_STATION
-verbose=false
-# flow mode needs GUI binding!
-#flowMode=0
-waitMode=TIMED
-waitTime=10000000
+Blocking=false
+EtName=ETBuffer
+ChunkSize=1
+Host=localhost
+Port=11111
+StationPosition=1
+# Prescale was 1
+Prescale=0
+QueueSize=0
+StationName=MY_STATION
+Verbose=false
+# Does flow mode need GUI binding?!
+#FlowMode=0
+WaitMode=TIMED
+WaitTime=10000000
SVNspam 0.1