9 added + 5 removed + 49 modified, total 63 files
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplicationMain.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplicationMain.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -11,10 +11,12 @@
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;
/**
- * Front-end for running the monitoring app via a {@link #main(String[])} method.
+ * 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 {
@@ -28,8 +30,7 @@
// Set up command line parsing.
Options options = new Options();
options.addOption(new Option("h", false, "Print help."));
- options.addOption(new Option("c", true, "Load properties file with connection settings."));
- options.addOption(new Option("j", true, "Load properties file with job settings."));
+ options.addOption(new Option("c", true, "Load a properties file with configuration parameters."));
CommandLineParser parser = new PosixParser();
// Parse command line arguments.
@@ -47,6 +48,7 @@
System.exit(1);
}
+ // Run the application on the Swing EDT.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -55,14 +57,10 @@
// Load the connection settings.
if (cl.hasOption("c")) {
- app.loadConnectionSettings(new File(cl.getOptionValue("c")));
+ app.load(new Configuration(new File(cl.getOptionValue("c"))));
}
-
- // Load the job settings.
- if (cl.hasOption("j")) {
- app.loadJobSettings(new File(cl.getOptionValue("j")));
- }
+ // 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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configurable.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,44 @@
+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]>
+ */
+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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/config/Configuration.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,146 @@
+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.
+ * It can be used to configure objects such as GUI panels.
+ * @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/DataSourceType.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/DataSourceType.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/StatusCode.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,15 @@
+package org.hps.monitoring.enums;
+
+/**
+ * Code that represents a sub-system status.
+ */
+public enum StatusCode {
+ OKAY,
+ UNKNOWN,
+ CLEARED,
+ OFFLINE,
+ 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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/Subsystem.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,11 @@
+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/ConnectionPanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,279 +0,0 @@
-package org.hps.monitoring.gui;
-
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.JTextField;
-
-import org.hps.monitoring.record.etevent.EtConnectionParameters;
-import org.jlab.coda.et.enums.Mode;
-
-/**
- * Connection settings panel.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-class ConnectionPanel extends FieldsPanel {
-
- 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 JTextField ppositionField;
- private JComboBox<?> waitComboBox;
- private JTextField waitTimeField;
- private JTextField prescaleField;
- private EtConnectionParameters connectionParameters;
- static final String[] waitModes = {
- Mode.SLEEP.toString(),
- Mode.TIMED.toString(),
- Mode.ASYNC.toString()
- };
-
- /**
- * Class constructor.
- */
- ConnectionPanel() {
-
- super(new Insets(5, 5, 5, 5), true);
-
- setLayout(new GridBagLayout());
-
- // Define fields.
- etNameField = addField("ET Name", "", 20);
- hostField = addField("Host", 20);
- portField = addField("Port", 5);
- 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);
- ppositionField = addField("Station Parallel Position", 3);
- waitComboBox = addComboBox("Wait Mode", waitModes);
- waitTimeField = addField("Wait Time [microseconds]", 8);
- prescaleField = addField("Prescale", 8);
-
- // Set default connection parameters which are pushed to GUI.
- setConnectionParameters(new EtConnectionParameters());
- }
-
- /**
- * Cache the connection parameters from the GUI into a new
- * <tt>EtConnectionParameters</tt> object.
- * @return The connection parameters.
- */
- void cache() {
- connectionParameters = new EtConnectionParameters();
- connectionParameters.setBufferName(etNameField.getText());
- connectionParameters.setHost(hostField.getText());
- connectionParameters.setPort(Integer.parseInt(portField.getText()));
- connectionParameters.setBlocking(blockingCheckBox.isSelected());
- connectionParameters.setVerbose(verboseCheckBox.isSelected());
- connectionParameters.setStationName(statNameField.getText());
- connectionParameters.setChunkSize(Integer.parseInt(chunkField.getText()));
- connectionParameters.setQueueSize(Integer.parseInt(qSizeField.getText()));
- connectionParameters.setStationPosition(Integer.parseInt(positionField.getText()));
- connectionParameters.setStationsParallelPosition(Integer.parseInt(ppositionField.getText()));
- connectionParameters.setWaitMode(getWaitMode());
- connectionParameters.setWaitTime(Integer.parseInt(waitTimeField.getText()));
- connectionParameters.setPreScale(Integer.parseInt(prescaleField.getText()));
- }
-
- /**
- * This will reset the GUI parameters from the current connection parameters,
- * discarding any possible changes the user made recently.
- */
- void revert() {
- setConnectionParameters(connectionParameters);
- }
-
- /**
- * Get the current connection parameters.
- * @return The current connection parameters.
- */
- EtConnectionParameters getConnectionParameters() {
- return connectionParameters;
- }
-
- /**
- * Get the current wait mode from the GUI selection.
- * @return The wait mode.
- */
- private Mode getWaitMode() {
- Mode mode = null;
- String sel = (String) waitComboBox.getSelectedItem();
- if (Mode.TIMED.toString().equalsIgnoreCase(sel)) {
- mode = Mode.TIMED;
- } else if (Mode.ASYNC.toString().equalsIgnoreCase(sel)) {
- mode = Mode.ASYNC;
- } else if (Mode.SLEEP.toString().equalsIgnoreCase(sel)) {
- mode = Mode.SLEEP;
- }
- return mode;
- }
-
- /**
- * Set the wait mode and push to the GUI.
- * @param waitMode The wait mode.
- */
- private void setWaitMode(Mode waitMode) {
- if (waitMode == Mode.SLEEP) {
- waitComboBox.setSelectedIndex(0);
- } else if (waitMode == Mode.TIMED) {
- waitComboBox.setSelectedIndex(1);
- } else if (waitMode == Mode.ASYNC) {
- waitComboBox.setSelectedIndex(2);
- }
- }
-
- /**
- * Set the connection parameters and push them into the GUI.
- * @param cn The connection parameters.
- */
- private void setConnectionParameters(EtConnectionParameters connectionParameters) {
- this.connectionParameters = connectionParameters;
- etNameField.setText(connectionParameters.getBufferName());
- hostField.setText(connectionParameters.getHost());
- portField.setText(Integer.toString(connectionParameters.getPort()));
- blockingCheckBox.setSelected(connectionParameters.getBlocking());
- verboseCheckBox.setSelected(connectionParameters.getVerbose());
- statNameField.setText(connectionParameters.getStationName());
- chunkField.setText(Integer.toString(connectionParameters.getChunkSize()));
- qSizeField.setText(Integer.toString(connectionParameters.getQueueSize()));
- positionField.setText(Integer.toString(connectionParameters.getStationPosition()));
- ppositionField.setText(Integer.toString(connectionParameters.getStationParallelPosition()));
- setWaitMode(connectionParameters.getWaitMode());
- waitTimeField.setText(Integer.toString(connectionParameters.getWaitTime()));
- prescaleField.setText(Integer.toString(connectionParameters.getPrescale()));
- }
-
- /**
- * Enable or disable the connection panel GUI elements.
- * @param e Set to true for enabled; false to disable.
- */
- void enableConnectionPanel(boolean e) {
- etNameField.setEnabled(e);
- hostField.setEnabled(e);
- portField.setEnabled(e);
- blockingCheckBox.setEnabled(e);
- verboseCheckBox.setEnabled(e);
- statNameField.setEnabled(e);
- chunkField.setEnabled(e);
- qSizeField.setEnabled(e);
- positionField.setEnabled(e);
- ppositionField.setEnabled(e);
- waitComboBox.setEnabled(e);
- waitTimeField.setEnabled(e);
- prescaleField.setEnabled(e);
- }
-
- /**
- * Load connection parameters from a properties file using a file chooser.
- */
- void load() {
- JFileChooser fc = new JFileChooser();
- int r = fc.showOpenDialog(ConnectionPanel.this);
- if (r == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- loadPropertiesFile(file);
- }
- }
-
- /**
- * Reset the connection parameters to their defaults.
- */
- void reset() {
- setConnectionParameters(new EtConnectionParameters());
- }
-
- /**
- * Write the connection parameters to a properties file.
- * @param file The output properties file.
- */
- void writePropertiesFile(File file) {
- Properties prop = new Properties();
- prop.setProperty("etName", etNameField.getText());
- prop.setProperty("host", hostField.getText());
- prop.setProperty("port", portField.getText());
- prop.setProperty("blocking", Boolean.toString(blockingCheckBox.isSelected()));
- prop.setProperty("verbose", Boolean.toString(verboseCheckBox.isSelected()));
- prop.setProperty("statName", statNameField.getText());
- prop.setProperty("chunk", chunkField.getText());
- prop.setProperty("qSize", qSizeField.getText());
- prop.setProperty("position", positionField.getText());
- prop.setProperty("pposition", ppositionField.getText());
- prop.setProperty("waitMode", (String) waitComboBox.getSelectedItem());
- prop.setProperty("waitTime", waitTimeField.getText());
- prop.setProperty("prescale", prescaleField.getText());
- try {
- prop.store(new FileOutputStream(file), null);
- } catch (Exception e) {
- showErrorDialog(e.getLocalizedMessage());
- }
- }
-
- /**
- * Show an error dialog.
- * @param mesg The dialog message.
- */
- private void showErrorDialog(String mesg) {
- JOptionPane.showMessageDialog(this, mesg);
- }
-
- /**
- * Set the wait mode.
- * @param waitMode The wait mode.
- */
- private void setWaitMode(String waitMode) {
- if (Mode.SLEEP.toString().equalsIgnoreCase(waitMode)) {
- waitComboBox.setSelectedIndex(0);
- } else if (Mode.TIMED.toString().equalsIgnoreCase(waitMode)) {
- waitComboBox.setSelectedIndex(1);
- } else if (Mode.ASYNC.toString().equalsIgnoreCase(waitMode)) {
- waitComboBox.setSelectedIndex(2);
- }
- }
-
- /**
- * Load connection parameters from properties file.
- * @param file The properties file.
- */
- void loadPropertiesFile(File file) {
- Properties prop = new Properties();
- try {
- prop.load(new FileInputStream(file));
- etNameField.setText(prop.getProperty("etName"));
- hostField.setText(prop.getProperty("host"));
- portField.setText(prop.getProperty("port"));
- blockingCheckBox.setSelected(Boolean.parseBoolean(prop.getProperty("blocking")));
- verboseCheckBox.setSelected(Boolean.parseBoolean(prop.getProperty("verbose")));
- statNameField.setText(prop.getProperty("statName"));
- chunkField.setText(prop.getProperty("chunk"));
- qSizeField.setText(prop.getProperty("qSize"));
- positionField.setText(prop.getProperty("position"));
- ppositionField.setText(prop.getProperty("pposition"));
- setWaitMode(prop.getProperty("waitMode"));
- waitTimeField.setText(prop.getProperty("waitTime"));
- prescaleField.setText(prop.getProperty("prescale"));
- } catch (Exception e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.getLocalizedMessage());
- }
- cache();
- }
-}
\ 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/ConnectionStatus.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatus.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,51 +0,0 @@
-package org.hps.monitoring.gui;
-
-/**
- * Status of the connection to the ET server from the monitoring client.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: ConnectionStatus.java,v 1.3 2013/11/05 17:15:04 jeremy Exp $
- */
-// TODO: Make this class an enum.
-final class ConnectionStatus
-{
- /**
- * The status codes.
- */
- static final int DISCONNECTED = 0;
- static final int CONNECTED = 1;
- static final int CONNECTING = 2;
- static final int TIMED_OUT = 3;
- static final int SLEEPING = 4;
- static final int DISCONNECTING = 5;
- static final int ERROR = 6;
- static final int CONNECTION_REQUESTED = 7;
- static final int DISCONNECT_REQUESTED = 8;
-
- /**
- * The string descriptions for connection statuses.
- */
- private static final String[] statuses = {
- "DISCONNECTED",
- "CONNECTED",
- "CONNECTING",
- "TIMED OUT",
- "SLEEPING",
- "DISCONNECTING",
- "ERROR",
- "CONNECTION REQUESTED",
- "DISCONNECT REQUESTED" };
-
- /**
- * Total number of statuses.
- */
- static final int NUMBER_STATUSES = statuses.length;
-
- /**
- * Convert status setting to string.
- * @param status The status setting.
- * @return The status string.
- */
- static String toString(int status) {
- return statuses[status].toUpperCase();
- }
-}
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -16,10 +16,10 @@
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
+import org.hps.monitoring.enums.ConnectionStatus;
+
/**
* This is the panel for showing the current connection status (connected, disconnected, etc.).
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: ConnectionStatusPanel.java,v 1.11 2013/11/05 17:15:04 jeremy Exp $
*/
class ConnectionStatusPanel extends JPanel {
@@ -107,21 +107,32 @@
c.gridwidth = GridBagConstraints.REMAINDER;
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.NUMBER_STATUSES - 1)) {
+ 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.toString(status));
+ statusField.setText(ConnectionStatus.values()[status].name());
dateField.setText(dateFormat.format(new Date()));
}
});
}
+ */
+
+ void setConnectionStatus(final ConnectionStatus status) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ statusField.setText(status.name());
+ dateField.setText(dateFormat.format(new Date()));
+ }
+ });
+ }
}
\ 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/DataSourcePanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -11,6 +11,9 @@
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;
@@ -18,63 +21,22 @@
/**
* A sub-panel of the settings window for selecting a data source,
* e.g. an ET server, an LCIO file, or an EVIO file.
- * @author Jeremy McCormick <[log in to unmask]>
*/
-public class DataSourcePanel extends FieldsPanel implements ActionListener {
-
- enum DataSourceType {
- ET_SERVER("ET Server"),
- EVIO_FILE("EVIO File"),
- LCIO_FILE("LCIO File");
-
- String name;
- DataSourceType(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- static DataSourceType fromString(String dataSourceString) {
- if (dataSourceString == ET_SERVER.toString()) {
- return ET_SERVER;
- } else if (dataSourceString == EVIO_FILE.toString()) {
- return EVIO_FILE;
- } else if (dataSourceString == LCIO_FILE.toString()) {
- return LCIO_FILE;
- } else {
- throw new IllegalArgumentException("Unknown data source type: " + dataSourceString);
- }
- }
-
- static DataSourceType fromIndex(int index) {
- if (index == ET_SERVER.ordinal()) {
- return ET_SERVER;
- } else if (index == EVIO_FILE.ordinal()) {
- return EVIO_FILE;
- } else if (index == LCIO_FILE.ordinal()) {
- return LCIO_FILE;
- } else {
- throw new IllegalArgumentException("Invalid data source index: " + index);
- }
- }
-
- boolean isFile() {
- return this.ordinal() > ET_SERVER.ordinal();
- }
- }
-
+public class DataSourcePanel extends AbstractFieldsPanel implements ActionListener, Configurable {
+
static String[] dataSourceTypes = {
- DataSourceType.ET_SERVER.toString(),
- DataSourceType.EVIO_FILE.toString(),
- DataSourceType.LCIO_FILE.toString()};
+ DataSourceType.ET_SERVER.description(),
+ DataSourceType.EVIO_FILE.description(),
+ DataSourceType.LCIO_FILE.description()
+ };
JComboBox dataSourceCombo;
- JTextField fileField;
+ JTextField fileField;
String DATA_SOURCE_COMMAND = "dataSourceChanged";
ErrorHandler errorHandler;
+ Configuration config;
+
DataSourcePanel() {
setLayout(new GridBagLayout());
dataSourceCombo = addComboBox("Data Source", dataSourceTypes);
@@ -82,26 +44,25 @@
dataSourceCombo.setActionCommand(DATA_SOURCE_COMMAND);
dataSourceCombo.addActionListener(this);
fileField = addField("File Path", 40);
- fileField.setEnabled(false);
+ fileField.setEditable(false);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(DATA_SOURCE_COMMAND)) {
int selectedIndex = dataSourceCombo.getSelectedIndex();
- DataSourceType dataSourceType = DataSourceType.fromIndex(selectedIndex);
- if (dataSourceType.isFile()) {
- fileField.setEnabled(true);
- chooseFile();
+ DataSourceType dataSourceType = DataSourceType.values()[selectedIndex];
+ if (dataSourceType.isFile()) {
+ chooseFile();
} else {
- fileField.setEnabled(false);
+ setFilePath("");
}
}
}
private void chooseFile() {
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
- fc.setDialogTitle("Choose Data Source");
- int r = fc.showDialog(this, "SELECT ...");
+ fc.setDialogTitle("Select Data Source");
+ int r = fc.showDialog(this, "Select ...");
File file = null;
if (r == JFileChooser.APPROVE_OPTION) {
file = fc.getSelectedFile();
@@ -115,7 +76,7 @@
}
void checkFile() throws IOException {
- DataSourceType dataSourceType = DataSourceType.fromIndex(this.dataSourceCombo.getSelectedIndex());
+ DataSourceType dataSourceType = DataSourceType.values()[this.dataSourceCombo.getSelectedIndex()];
if (!dataSourceType.isFile())
return;
File file = new File(fileField.getText());
@@ -143,6 +104,49 @@
}
DataSourceType getDataSourceType() {
- return DataSourceType.fromIndex(this.dataSourceCombo.getSelectedIndex());
+ 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"));
+ }
+
+ @Override
+ public void save(Configuration config) {
+ config.set("dataSourceType", getDataSourceType().name());
+ config.set("dataSourcePath", getFilePath());
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return config;
+ }
+
+ @Override
+ public void save() {
+ save(config);
+ }
+
+ @Override
+ public void set(Configuration config) {
+ load(config);
+ this.config = config;
+ }
+
+ @Override
+ public void reset() {
+ set(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/DatePanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DatePanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,7 +6,6 @@
/**
* A small JPanel with a date field and a label on its border.
- * @author Jeremy McCormick <[log in to unmask]>
*/
class DatePanel extends FieldPanel {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -8,8 +8,18 @@
import javax.swing.SwingUtilities;
/**
- * An error handling class.
- * @author Jeremy McCormick <[log in to unmask]>
+ * An error handling class which is able to do any of the following,
+ * depending on what the caller wants to do with the error.
+ * <ul>
+ * <li>Print a message</li>
+ * <li>Print the stack trace</li>
+ * <li>Log to a Logger</li>
+ * <li>Show an error dialog</li>
+ * <li>Raise an exception</li>
+ * <li>Exit the application</li>
+ * </ul>
+ * It mostly uses the "builder" pattern so that the various handling methods
+ * can be easily chained, where appropriate.
*/
public class ErrorHandler {
@@ -70,9 +80,5 @@
void exit() {
System.err.println("Fatal error. Application will exit.");
System.exit(1);
- }
-
- /*
- void handleError(final String message, boolean showDialog, boolean throwException)
- */
+ }
}
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -57,6 +57,7 @@
* Toggle the connect button from its current state. If it is in "Connect" state
* then it will be toggled to "Disconnect" and vice versa.
*/
+ /*
void toggleConnectButton() {
if (connectButton.getText().equals("Connect")) {
connectButton.setText("Disconnect");
@@ -66,6 +67,17 @@
connectButton.setActionCommand(MonitoringCommands.CONNECT);
}
}
+ */
+
+ void setConnected(boolean connected) {
+ if (connected) {
+ connectButton.setText("Disconnect");
+ connectButton.setActionCommand(MonitoringCommands.DISCONNECT);
+ } else {
+ connectButton.setText("Connect");
+ connectButton.setActionCommand(MonitoringCommands.CONNECT);
+ }
+ }
/**
* Add an ActionListener to this component.
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -9,7 +9,6 @@
/**
* A panel with a label and a text field.
- * @author Jeremy McCormick <[log in to unmask]>
*/
class FieldPanel extends JPanel {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldsPanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldsPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,237 +0,0 @@
-package org.hps.monitoring.gui;
-
-import java.awt.Color;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
-import java.awt.event.ActionListener;
-
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-/**
- * 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.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: FieldsPanel.java,v 1.3 2013/11/05 17:15:04 jeremy Exp $
- */
-class FieldsPanel extends JPanel {
-
- private int currY = 0;
- private Insets insets;
- private boolean editable = false;
-
- /**
- * Class constructor.
- * @param insets The insets for the panel.
- * @param editable Editable setting.
- */
- FieldsPanel(Insets insets, boolean editable) {
- this.insets = insets;
- this.editable = editable;
- }
-
- /**
- * Class constructor.
- */
- FieldsPanel() {
- this.insets = new Insets(1, 1, 1, 1);
- }
-
- /**
- * Add a field.
- * @param name The name of the field.
- * @param size The size of the field.
- * @return The JTextField component.
- */
- protected final JTextField addField(String name, int size) {
- return addField(name, "", size, this.editable);
- }
-
- /**
- * Add a field.
- * @param name The name of the field.
- * @param value The default value of the field.
- * @param size The size of the field.
- * @return The JTextField component.
- */
- protected final JTextField addField(String name, String value, int size) {
- return addField(name, value, size, this.editable);
- }
-
- /**
- * Add a field.
- * @param name The name of the field.
- * @param value The default value of the field.
- * @param tooltip The tooltip text.
- * @param size The size of the field.
- * @param editable The editable setting.
- * @return The JTextField component.
- */
- protected final JTextField addField(String name, String value, String tooltip, int size, boolean editable) {
- JTextField f = addField(name, value, size, editable);
- f.setToolTipText(tooltip);
- return f;
- }
-
- /**
- * Add a field.
- * @param name The name of the field.
- * @param value The default value of the field.
- * @param size The size of the field.
- * @param editable The editable setting.
- * @return The JTextField component.
- */
- protected final JTextField addField(String name, String value, int size, boolean editable) {
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.WEST;
- JLabel label = new JLabel(name + ":");
- add(label, c);
-
- c = new GridBagConstraints();
- c.gridx = 1;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.EAST;
- JTextField field = new JTextField(value, size);
- field.setHorizontalAlignment(JTextField.RIGHT);
- field.setEditable(editable);
- field.setBackground(Color.WHITE);
- add(field, c);
-
- ++currY;
-
- return field;
- }
-
- /**
- * Add a combo box.
- * @param name The name of the combo box.
- * @param values The set of values for the combo box.
- * @return The JComboBox component.
- */
- protected final JComboBox addComboBox(String name, String[] values) {
-
- //System.out.println("addComboBox = " + name);
-
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.WEST;
- JLabel waitModeLabel = new JLabel(name + ":");
- waitModeLabel.setHorizontalAlignment(JLabel.LEFT);
- add(waitModeLabel, c);
-
- c = new GridBagConstraints();
- c.gridx = 1;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.EAST;
- JComboBox combo = new JComboBox(values);
- //System.out.println("combo width = " + combo.getWidth());
- //System.out.println("combo width = " + combo.getSize().getWidth());
- combo.setEditable(editable);
- add(combo, c);
-
- ++currY;
-
- return combo;
- }
-
- /**
- * Add a multiline combo box.
- * @param name The name of the combo box.
- * @param values The values for the combo box.
- * @return The JComboBox component.
- */
- protected final JComboBox addComboBoxMultiline(String name, String[] values) {
-
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.WEST;
- JLabel waitModeLabel = new JLabel(name + ":");
- waitModeLabel.setHorizontalAlignment(JLabel.LEFT);
- add(waitModeLabel, c);
- ++currY;
-
- c = new GridBagConstraints();
- c.gridx = 0;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.WEST;
- JComboBox combo = new JComboBox(values);
- //System.out.println("combo width = " + combo.getWidth());
- //System.out.println("combo width = " + combo.getSize().getWidth());
- combo.setEditable(editable);
- add(combo, c);
-
- ++currY;
-
- return combo;
- }
-
- /**
- * Add a check box.
- * @param name The name of the check box.
- * @param tooltip The tooltip text.
- * @param selected Whether the box is selected or not.
- * @param enabled Whether it is enabled or not.
- * @return The JCheckBox component.
- */
- protected final JCheckBox addCheckBox(String name, String tooltip, boolean selected, boolean enabled) {
- JCheckBox c = addCheckBox(name, selected, enabled);
- c.setToolTipText(tooltip);
- return c;
- }
-
- /**
- * Add a check box.
- * @param name The name of the check box.
- * @param selected Whether the check box is selected or not.
- * @param enabled Whether it is enabled or not.
- * @return The JCheckBox component.
- */
- protected final JCheckBox addCheckBox(String name, boolean selected, boolean enabled) {
-
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.WEST;
- JLabel label = new JLabel(name + ":");
- add(label, c);
-
- c = new GridBagConstraints();
- c.gridx = 1;
- c.gridy = currY;
- c.insets = insets;
- c.anchor = GridBagConstraints.EAST;
- JCheckBox checkbox = new JCheckBox();
- checkbox.setSelected(selected);
- checkbox.setEnabled(enabled);
- add(checkbox, c);
-
- ++currY;
-
- return checkbox;
- }
-
- /**
- * Add an ActionListener to this component. By default this does nothing, but
- * individual sub-components should attach this to individual components.
- * @param listener The AcitonListener to add.
- */
- void addActionListener(ActionListener listener) {
- }
-}
\ 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/JobPanel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,573 +0,0 @@
-package org.hps.monitoring.gui;
-
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.logging.Level;
-
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-
-/**
- * The panel for setting job parameters.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: JobPanel.java,v 1.17 2013/11/05 17:15:04 jeremy Exp $
- */
-class JobPanel extends FieldsPanel {
-
- private JTextField detectorNameField;
- //private JCheckBox disconnectOnErrorCheckBox;
- private JTextField eventBuilderField;
- private JComboBox<?> steeringTypeComboBox;
- private JTextField steeringFileField;
- private JComboBox<?> steeringResourcesComboBox;
- private JCheckBox logCheckBox;
- private JTextField logFileField;
- private JCheckBox pauseModeCheckBox;
- private JComboBox<?> logLevelComboBox;
- private JTextField aidaSaveField;
- private JCheckBox aidaSaveCheckBox;
-
- private String steeringPackage = "org/hps/steering/monitoring/";
-
- private String defaultEventBuilderClassName = (new JobSettings()).eventBuilderClassName;
-
- private final static String[] steeringTypes = {"RESOURCE", "FILE"};
- final static int RESOURCE = 0;
- final static int FILE = 1;
-
- JobSettings settings;
-
- /**
- * The available LogLevel settings.
- */
- String[] logLevels = new String[] {
- Level.ALL.toString(),
- Level.FINEST.toString(),
- Level.FINER.toString(),
- Level.FINE.toString(),
- Level.CONFIG.toString(),
- Level.INFO.toString(),
- Level.WARNING.toString(),
- Level.SEVERE.toString(),
- Level.OFF.toString()};
-
- /**
- * Class constructor.
- */
- JobPanel() {
-
- super(new Insets(4, 2, 2, 4), true);
- setLayout(new GridBagLayout());
-
- pauseModeCheckBox = addCheckBox("Pause mode", false, true);
- //disconnectOnErrorCheckBox = addCheckBox("Disconnect on error", false, true);
- logLevelComboBox = addComboBox("Log Level", this.logLevels);
- logLevelComboBox.setActionCommand(MonitoringCommands.SET_LOG_LEVEL);
- steeringTypeComboBox = addComboBox("Steering Type", steeringTypes);
- steeringFileField = addField("Steering File", 35);
- steeringResourcesComboBox = addComboBoxMultiline("Steering File Resource",
- getAvailableSteeringFileResources(steeringPackage));
- steeringResourcesComboBox.setActionCommand(MonitoringCommands.SET_STEERING_RESOURCE);
- detectorNameField = addField("Detector Name", 20);
- eventBuilderField = addField("Event Builder Class", 30);
- eventBuilderField.setActionCommand(MonitoringCommands.SET_EVENT_BUILDER);
- logCheckBox = addCheckBox("Log to File", false, false);
- logFileField = addField("Log File", "", "Full path to log file.", 30, false);
- aidaSaveCheckBox = addCheckBox("Save AIDA at End of Job", false, false);
- aidaSaveField = addField("AIDA Auto Save File Name", "", 30, false);
-
- // Set default job settings.
- setJobSettings(new JobSettings());
- }
-
- /**
- * Enable this component.
- * @param enable Whether to enable or not.
- */
- void enableJobPanel(boolean enable) {
- detectorNameField.setEnabled(enable);
- eventBuilderField.setEnabled(enable);
- pauseModeCheckBox.setEnabled(enable);
- steeringTypeComboBox.setEnabled(enable);
- steeringFileField.setEnabled(enable);
- steeringResourcesComboBox.setEnabled(enable);
- }
-
- /**
- * Attaches the ActionListener from the main app to GUI components in this class.
- */
- void addActionListener(ActionListener listener) {
- steeringResourcesComboBox.addActionListener(listener);
- logLevelComboBox.addActionListener(listener);
- eventBuilderField.addActionListener(listener);
- }
-
- /**
- * Choose a file name for the automatic AIDA save file.
- */
- void chooseAidaAutoSaveFile() {
- JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Choose AIDA Auto Save File");
- int r = fc.showSaveDialog(this);
- if (r == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- String fileName = file.getPath();
- int extIndex = fileName.lastIndexOf(".");
- if ((extIndex == -1) || !(fileName.substring(extIndex + 1, fileName.length())).toLowerCase().equals("aida")) {
- fileName = fileName + ".aida";
- }
- final String fileName2 = fileName;
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- aidaSaveCheckBox.setSelected(true);
- aidaSaveField.setText(fileName2);
- }
- });
- }
- }
-
- /**
- * Check that the steering file or resource is valid.
- * @return True if steering is valid; false if not.
- */
- void checkSteering() throws IOException {
- String steering = steeringFileField.getText();
- int steeringType = steeringTypeComboBox.getSelectedIndex();
- if (RESOURCE == steeringType) {
- // Check that steering resource exists.
- InputStream is = getClass().getResourceAsStream(steering);
- if (is == null) {
- throw new IOException("Steering resource does not exist or is not accessible.");
- }
- } else if (FILE == steeringType) {
- // Check that steering file exists.
- File f = new File(steering);
- if (!f.exists()) {
- throw new IOException("Steering file does not exist or is not readable.");
- }
- } else {
- // Can this actually ever happen???
- throw new IOException("The steering type is invalid.");
- }
- }
-
- /**
- * Setup the event builder from the field setting.
- * @return True if builder is setup successfully; false if not.
- */
- void editEventBuilder() {
- String eventBuilderClassName = eventBuilderField.getText();
- boolean okay = true;
- try {
- // Test that the event builder can be created without throwing any exceptions.
- Class<?> eventBuilderClass = Class.forName(eventBuilderClassName);
- eventBuilderClass.newInstance();
- }
- catch (ClassNotFoundException e) {
- JOptionPane.showMessageDialog(this, "The event builder class does not exist.");
- okay = false;
- }
- catch (InstantiationException e) {
- JOptionPane.showMessageDialog(this, "Failed to instantiate instance of event builder class.");
- okay = false;
- }
- catch (IllegalAccessException e) {
- JOptionPane.showMessageDialog(this, "Couldn't access event builder class.");
- okay = false;
- }
-
- if (!okay)
- resetEventBuilder();
- }
-
- /**
- * Reset the event builder to the default.
- */
- private void resetEventBuilder() {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- eventBuilderField.setText(defaultEventBuilderClassName);
- }
- });
- }
-
- /**
- * Get the event builder class name.
- * @return The event builder class name.
- */
- String getEventBuilderClassName() {
- return eventBuilderField.getText();
- }
-
- /**
- * Set the steering file field.
- * @param steeringFile The path to the file.
- */
- void setSteeringFile(final String steeringFile) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- steeringFileField.setText(steeringFile);
- }
- });
- }
-
- /**
- * Set the steering file resource.
- * @param s The resource path.
- */
- void setSteeringResource(final String s) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- steeringResourcesComboBox.setSelectedItem(s);
- }
- });
- }
-
- /**
- * Set the name of the detector.
- * @param detectorName The name of the detector.
- */
- void setDetectorName(final String detectorName) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- detectorNameField.setText(detectorName);
- }
- });
- }
-
- /**
- * Get the steering file or resource path from the field setting.
- * @return The steering file or resource path.
- */
- String getSteering() {
- if (getSteeringType() == FILE) {
- return steeringFileField.getText();
- }
- else if (getSteeringType() == RESOURCE) {
- return (String) steeringResourcesComboBox.getSelectedItem();
- }
- else {
- return null;
- }
- }
-
- /**
- * Get the type of steering, file or resource.
- * @return The type of steering.
- */
- int getSteeringType() {
- return steeringTypeComboBox.getSelectedIndex();
- }
-
- /**
- * Get the name of the detector.
- * @return The name of the detector.
- */
- String getDetectorName() {
- return detectorNameField.getText();
- }
-
- /**
- *
- * @param defaultEventBuilderClassName
- */
- void setDefaultEventBuilder(final String defaultEventBuilderClassName) {
- this.defaultEventBuilderClassName = defaultEventBuilderClassName;
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- eventBuilderField.setText(defaultEventBuilderClassName);
- }
- });
- }
-
- /**
- * Check if pause mode is selected.
- * @return True if pause mode is enabled; false if not.
- */
- boolean pauseMode() {
- return this.pauseModeCheckBox.isSelected();
- }
-
- /**
- * Set the pause mode.
- * @param p The pause mode; true for on; false for off.
- */
- void enablePauseMode(final boolean p) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- pauseModeCheckBox.setSelected(p);
- }
- });
- }
-
- /**
- * Get the log level from the combo box.
- * @return The log level.
- */
- Level getLogLevel() {
- return Level.parse((String) logLevelComboBox.getSelectedItem());
- }
-
- /**
- * Get the disconnect on error setting from the check box.
- * @return The disconnect on error setting.
- */
- //boolean disconnectOnError() {
- // return disconnectOnErrorCheckBox.isSelected();
- //}
-
- /**
- * Get the log to file setting.
- * @return The log to file setting.
- */
- boolean logToFile() {
- return logCheckBox.isSelected();
- }
-
- /**
- * Get the log file name.
- * @return The log file name.
- */
- String getLogFileName() {
- return logFileField.getText();
- }
-
- /**
- * Get whether AIDA autosave is enabled.
- * @return True if AIDA autosave is enabled; false if not.
- */
- boolean isAidaAutoSaveEnabled() {
- return aidaSaveCheckBox.isSelected();
- }
-
- /**
- * Get the AIDA autosave file name.
- * @return The AIDA autosave file name.
- */
- String getAidaAutoSaveFileName() {
- return aidaSaveField.getText();
- }
-
- /**
- * Set whether to disconnect if errors occur.
- * @param b The disconnect on error setting.
- */
- //private void setDisconnectOnError(final boolean b) {
- // SwingUtilities.invokeLater(new Runnable() {
- // public void run() {
- // disconnectOnErrorCheckBox.setSelected(b);
- // }
- // });
- //}
-
- /**
- * Set the steering type.
- * @param t The steering type.
- */
- void setSteeringType(final int t) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- steeringTypeComboBox.setSelectedIndex(t);
- }
- });
- }
-
- /**
- * Set the log level.
- * @param level The log level.
- */
- private void setLogLevel(final Level level) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- logLevelComboBox.setSelectedItem(level.toString());
- }
- });
- }
-
- /**
- * Set the fully qualified class name of the event builder.
- * @param c The class name of the event builder.
- */
- private void setEventBuilder(final String c) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- eventBuilderField.setText(c);
- }
- });
- }
-
- /**
- * Set whether to log to a file.
- * @param b The log to file setting.
- */
- void setLogToFile(final boolean b) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- logCheckBox.setSelected(b);
- }
- });
- }
-
- /**
- * Set the log file name.
- * @param s The log file name.
- */
- void setLogFile(final String s) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- logFileField.setText(s);
- }
- });
- }
-
- /**
- * Set AIDA autosave.
- * @param b The AIDA autosave setting.
- */
- private void enableAidaAutoSave(final boolean b) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- aidaSaveCheckBox.setSelected(b);
- }
- });
- }
-
- /**
- * Set the AIDA autosave file name.
- * @param s The AIDA autosave file name.
- */
- private void setAidaAutoSaveFileName(final String s) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- aidaSaveField.setText(s);
- }
- });
- }
-
- /**
- * Get the resource path for the steering file.
- * @return The resource path for the steering file.
- */
- private String getSelectedSteeringResource() {
- return (String) steeringResourcesComboBox.getSelectedItem();
- }
-
- /**
- * Get the path to the steering file path.
- * @return The steering file path.
- */
- private String getSteeringFile() {
- return steeringFileField.getText();
- }
-
- /**
- * Gather {@link JobSettings} parameters from GUI and return a JobSettings object.
- * @return The JobSettings from the JobPanel.
- */
- JobSettings getJobSettings() {
- return settings;
- }
-
- /**
- * Cache the settings from the GUI into the <tt>JobSettings</tt> object.
- */
- void cache() {
- settings = new JobSettings();
- settings.pauseMode = pauseMode();
- //settings.disconnectOnError = disconnectOnError();
- settings.logLevel = getLogLevel();
- settings.steeringType = getSteeringType();
- settings.steeringFile = getSteeringFile();
- settings.steeringResource = getSelectedSteeringResource();
- settings.detectorName = getDetectorName();
- settings.eventBuilderClassName = getEventBuilderClassName();
- settings.logToFile = logToFile();
- settings.logFileName = getLogFileName();
- settings.autoSaveAida = isAidaAutoSaveEnabled();
- settings.autoSaveAidaFileName = getAidaAutoSaveFileName();
- }
-
- /**
- * Revert job settings in GUI based on current <tt>JobSettings</tt> object.
- */
- void revert() {
- setJobSettings(settings);
- }
-
- /**
- * Set the JobPanel parameters from a JobSettings object.
- * @param settings The JobSettings to load.
- */
- void setJobSettings(JobSettings settings) {
- this.settings = settings;
- enablePauseMode(settings.pauseMode);
- //setDisconnectOnError(settings.disconnectOnError);
- setLogLevel(settings.logLevel);
- setSteeringType(settings.steeringType);
- setSteeringFile(settings.steeringFile);
- setSteeringResource(settings.steeringResource);
- setDetectorName(settings.detectorName);
- setEventBuilder(settings.eventBuilderClassName);
- setLogToFile(settings.logToFile);
- setLogFile(settings.logFileName);
- enableAidaAutoSave(settings.autoSaveAida);
- setAidaAutoSaveFileName(settings.autoSaveAidaFileName);
- }
-
- /**
- * Reset the JobPanel to its defaults.
- */
- void resetJobSettings() {
- setJobSettings(new JobSettings());
- }
-
- /**
- * Get the files that end in .lcsim from all loaded jar files.
- * @return A list of embedded steering file resources.
- */
- public static String[] getAvailableSteeringFileResources(String packageName) {
- List<String> resources = new ArrayList<String>();
- URL url = JobPanel.class.getResource("MonitoringApplication.class");
- String scheme = url.getProtocol();
- if (!"jar".equals(scheme)) {
- throw new IllegalArgumentException("Unsupported scheme: " + scheme);
- }
- try {
- JarURLConnection con = (JarURLConnection) url.openConnection();
- JarFile archive = con.getJarFile();
- Enumeration<JarEntry> entries = archive.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- if (entry.getName().endsWith(".lcsim") && entry.getName().contains(packageName)) {
- resources.add(entry.getName());
- }
- }
- archive.close();
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- java.util.Collections.sort(resources);
- String[] arr = new String[resources.size()];
- for (int i=0; i<arr.length; i++) {
- arr[i] = resources.get(i);
- }
- return arr;
- }
-
-}
\ 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/JobSettings.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettings.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,77 +0,0 @@
-package org.hps.monitoring.gui;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.logging.Level;
-
-/**
- * The job settings panel.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: JobSettings.java,v 1.6 2013/10/30 17:05:17 jeremy Exp $
- */
-final class JobSettings {
-
- // Default job settings.
- boolean pauseMode = false;
- boolean disconnectOnError = false;
- Level logLevel = Level.ALL;
- int steeringType = 0; // resource = 0; file = 1
- String steeringResource = "org/hps/steering/monitoring/TestRunMonitoring.lcsim";
- String steeringFile = "";
- String detectorName = "HPS-TestRun-v5";
- String eventBuilderClassName = "org.hps.evio.LCSimTestRunEventBuilder";
- boolean logToFile = false;
- String logFileName = "";
- boolean autoSaveAida = false;
- String autoSaveAidaFileName = "";
- boolean enableRemoteAida = false;
- String remoteAidaName = "hps";
-
- JobSettings() {
- }
-
- JobSettings(File f) throws IOException {
- load(f);
- }
-
- void save(File file) throws IOException {
- Properties prop = new Properties();
- prop.setProperty("pauseMode", Boolean.toString(pauseMode));
- prop.setProperty("disconnectOnError", Boolean.toString(disconnectOnError));
- prop.setProperty("logLevel", logLevel.toString());
- prop.setProperty("steeringType", Integer.toString(steeringType));
- prop.setProperty("steeringFile", steeringFile);
- prop.setProperty("steeringResource", steeringResource);
- prop.setProperty("detectorName", detectorName);
- prop.setProperty("eventBuilderClassName", eventBuilderClassName);
- prop.setProperty("logToFile", Boolean.toString(logToFile));
- prop.setProperty("logFileName", logFileName);
- prop.setProperty("autoSaveAida", Boolean.toString(autoSaveAida));
- prop.setProperty("autoSaveAidaFileName", autoSaveAidaFileName);
- prop.setProperty("enableRemoteAida", Boolean.toString(enableRemoteAida));
- prop.setProperty("remoteAidaName", remoteAidaName);
- prop.store(new FileOutputStream(file), null);
- }
-
- void load(File file) throws IOException {
- Properties prop = new Properties();
- prop.load(new FileInputStream(file));
- pauseMode = Boolean.parseBoolean(prop.getProperty("pauseMode"));
- disconnectOnError = Boolean.parseBoolean(prop.getProperty("disconnectOnError"));
- logLevel = Level.parse(prop.getProperty("logLevel"));
- steeringType = Integer.parseInt(prop.getProperty("steeringType"));
- steeringFile = prop.getProperty("steeringFile");
- steeringResource = prop.getProperty("steeringResource");
- detectorName = prop.getProperty("detectorName");
- eventBuilderClassName = prop.getProperty("eventBuilderClassName");
- logToFile = Boolean.parseBoolean(prop.getProperty("logToFile"));
- logFileName = prop.getProperty("logFileName");
- autoSaveAida = Boolean.parseBoolean(prop.getProperty("autoSaveAida"));
- autoSaveAidaFileName = prop.getProperty("autoSaveAidaFileName");
- enableRemoteAida = Boolean.parseBoolean(prop.getProperty("enableRemoteAida"));
- remoteAidaName = prop.getProperty("remoteAidaName");
- }
-}
\ 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/MonitoringApplication.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,29 +1,6 @@
package org.hps.monitoring.gui;
-import static org.hps.monitoring.gui.MonitoringCommands.AIDA_AUTO_SAVE;
-import static org.hps.monitoring.gui.MonitoringCommands.CLEAR_LOG_TABLE;
-import static org.hps.monitoring.gui.MonitoringCommands.CONNECT;
-import static org.hps.monitoring.gui.MonitoringCommands.DISCONNECT;
-import static org.hps.monitoring.gui.MonitoringCommands.EXIT;
-import static org.hps.monitoring.gui.MonitoringCommands.LOAD_CONNECTION;
-import static org.hps.monitoring.gui.MonitoringCommands.LOAD_JOB_SETTINGS;
-import static org.hps.monitoring.gui.MonitoringCommands.LOG_TO_FILE;
-import static org.hps.monitoring.gui.MonitoringCommands.LOG_TO_TERMINAL;
-import static org.hps.monitoring.gui.MonitoringCommands.NEXT;
-import static org.hps.monitoring.gui.MonitoringCommands.PAUSE;
-import static org.hps.monitoring.gui.MonitoringCommands.RESET_CONNECTION_SETTINGS;
-import static org.hps.monitoring.gui.MonitoringCommands.RESET_JOB_SETTINGS;
-import static org.hps.monitoring.gui.MonitoringCommands.RESUME;
-import static org.hps.monitoring.gui.MonitoringCommands.SAVE_CONNECTION;
-import static org.hps.monitoring.gui.MonitoringCommands.SAVE_JOB_SETTINGS;
-import static org.hps.monitoring.gui.MonitoringCommands.SAVE_LOG_TABLE;
-import static org.hps.monitoring.gui.MonitoringCommands.SAVE_PLOTS;
-import static org.hps.monitoring.gui.MonitoringCommands.SCREENSHOT;
-import static org.hps.monitoring.gui.MonitoringCommands.SET_EVENT_BUILDER;
-import static org.hps.monitoring.gui.MonitoringCommands.SET_LOG_LEVEL;
-import static org.hps.monitoring.gui.MonitoringCommands.SET_STEERING_FILE;
-import static org.hps.monitoring.gui.MonitoringCommands.SET_STEERING_RESOURCE;
-import static org.hps.monitoring.gui.MonitoringCommands.SHOW_SETTINGS;
+import static org.hps.monitoring.gui.MonitoringCommands.*;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
@@ -48,7 +25,9 @@
import java.io.PrintStream;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Vector;
import java.util.logging.Handler;
import java.util.logging.Level;
@@ -70,13 +49,16 @@
import javax.swing.table.DefaultTableModel;
import org.hps.evio.LCSimEventBuilder;
-import org.hps.monitoring.gui.DataSourcePanel.DataSourceType;
+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.plotting.MonitoringAnalysisFactory;
import org.hps.monitoring.plotting.MonitoringPlotFactory;
import org.hps.monitoring.record.EventProcessingChain;
import org.hps.monitoring.record.EventProcessingThread;
import org.hps.monitoring.record.etevent.EtConnection;
-import org.hps.monitoring.record.etevent.EtConnectionParameters;
import org.hps.monitoring.record.etevent.EtEventSource;
import org.hps.monitoring.record.evio.EvioFileSource;
import org.hps.monitoring.subsys.SystemStatus;
@@ -90,15 +72,8 @@
/**
* Monitoring application for HPS, which can run LCSim steering files on data converted
* from the ET server.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringApplication.java,v 1.61 2013/12/10 07:36:40 jeremy Exp $
*/
-// TODO: Test all application error handling!
-// TODO: Review GUI size settings.
-// TODO: Add back option to continue if event processing errors occur.
-// Fatal errors like the ET system being down should still cause an automatic disconnect.
-// FIXME: Review use of the watchdog thread for automatic disconnect. It may be overcomplicated.
-public class MonitoringApplication extends JFrame implements ActionListener {
+public class MonitoringApplication extends JFrame implements ActionListener, Configurable {
// Top-level Swing components.
private JPanel mainPanel;
@@ -111,17 +86,9 @@
private SystemStatusFrame systemStatusFrame;
// References to menu items that will be toggled depending on application state.
- private JMenuItem connectItem;
- private JMenuItem disconnectItem;
- private JMenuItem resetConnectionItem;
- private JMenuItem connectionLoadItem;
private JMenuItem savePlotsItem;
private JMenuItem logItem;
private JMenuItem terminalItem;
- private JMenuItem steeringItem;
- private JMenuItem aidaAutoSaveItem;
- private JMenuItem loadJobSettingsItem;
- private JMenuItem resetJobSettingsItem;
// Saved references to System.out and System.err in case need to reset.
private final PrintStream sysOut = System.out;
@@ -131,9 +98,9 @@
ErrorHandler errorHandler;
// ET connection parameters and state.
- private EtConnectionParameters connectionParameters;
+ //private EtConnectionParameters connectionParameters;
private EtConnection connection;
- private int connectionStatus = ConnectionStatus.DISCONNECTED;
+ private ConnectionStatus connectionStatus = ConnectionStatus.DISCONNECTED;
// Event processing objects.
private JobControlManager jobManager;
@@ -164,12 +131,27 @@
private final static int LOG_TABLE_HEIGHT = 270;
private static final int MAIN_FRAME_HEIGHT = ScreenUtil.getScreenHeight() / 2;
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";
+
+ Configuration config = new Configuration(DEFAULT_CONFIG_RESOURCE);
+
+ // List of GUI objects to which configuration should be pushed.
+ List<Configurable> configurables = new ArrayList<Configurable>();
/**
* Constructor for the monitoring application.
*/
- public MonitoringApplication() {
+ public MonitoringApplication() {
+ initialize();
+ }
+ /**
+ * Perform all intialization on start up.
+ */
+ private void initialize() {
+
// Create and configure the logger.
setupLogger();
@@ -191,6 +173,7 @@
// Configuration of window for showing plots.
createPlotFrame();
+ // Create the system status window.
createSystemStatusFrame();
// Setup AIDA.
@@ -199,13 +182,19 @@
// Configure the application's primary JFrame.
configApplicationFrame();
- // Create settings window.
+ // Create settings dialog window.
createSettingsDialog();
+
+ // Add configurable objects to list.
+ addConfigurables();
+
+ // Load configuration from properties file.
+ load(config);
// Log that the application started successfully.
- log("Application initialized successfully.");
+ log(Level.CONFIG, "Application initialized successfully.");
}
-
+
private void setupErrorHandler() {
errorHandler = new ErrorHandler(this, logger);
}
@@ -220,7 +209,8 @@
private void createSettingsDialog() {
settingsDialog = new SettingsDialog();
- getJobPanel().addActionListener(this);
+ settingsDialog.getSettingsPanel().addActionListener(this);
+ getJobSettingsPanel().addActionListener(this);
}
private void createPlotFrame() {
@@ -244,7 +234,7 @@
this.systemStatusFrame.setVisible(true);
// FIXME: If this is done earlier before app is visible, the GUI will fail to show!
- this.connectionStatusPanel.setStatus(ConnectionStatus.DISCONNECTED);
+ this.connectionStatusPanel.setConnectionStatus(ConnectionStatus.DISCONNECTED);
}
/**
@@ -307,123 +297,102 @@
JMenu applicationMenu = new JMenu("Application");
applicationMenu.setMnemonic(KeyEvent.VK_A);
- menuBar.add(applicationMenu);
- addMenuItem("Settings...", KeyEvent.VK_S, SHOW_SETTINGS, true, "Monitoring Application settings", applicationMenu);
- addMenuItem("Exit", KeyEvent.VK_X, EXIT, true, "Exit from the application.", applicationMenu);
-
- JMenu connectionMenu = new JMenu("Connection");
- connectionMenu.setMnemonic(KeyEvent.VK_C);
- menuBar.add(connectionMenu);
-
- connectItem = addMenuItem("Connect", KeyEvent.VK_C, CONNECT, true, "Connect to ET system using parameters from connection panel.", connectionMenu);
- disconnectItem = addMenuItem("Disconnect", KeyEvent.VK_D, DISCONNECT, false, "Disconnect from the current ET session.", connectionMenu);
- resetConnectionItem = addMenuItem("Reset Connection Settings", KeyEvent.VK_R, RESET_CONNECTION_SETTINGS, true, "Reset connection settings to defaults.", connectionMenu);
- connectionLoadItem = addMenuItem("Load Connection...", KeyEvent.VK_L, LOAD_CONNECTION, true, "Load connection settings from a saved properties file.", connectionMenu);
- addMenuItem("Save Connection...", KeyEvent.VK_S, SAVE_CONNECTION, true, "Save connection settings to a properties file.", connectionMenu);
-
- JMenu jobMenu = new JMenu("Job");
- jobMenu.setMnemonic(KeyEvent.VK_J);
- menuBar.add(jobMenu);
-
- addMenuItem("Save Job Settings...", KeyEvent.VK_J, SAVE_JOB_SETTINGS, true, "Save Job Settings configuration to a properties file.", jobMenu);
-
- // FIXME: Rest of these should be converted to use the addMenuItem() helper method ...
-
- loadJobSettingsItem = new JMenuItem("Load Job Settings...");
- loadJobSettingsItem.setMnemonic(KeyEvent.VK_L);
- loadJobSettingsItem.setActionCommand(LOAD_JOB_SETTINGS);
- loadJobSettingsItem.addActionListener(this);
- loadJobSettingsItem.setToolTipText("Load Job Settings from a properties file.");
- jobMenu.add(loadJobSettingsItem);
-
- resetJobSettingsItem = new JMenuItem("Reset Job Settings");
- resetJobSettingsItem.setMnemonic(KeyEvent.VK_R);
- resetJobSettingsItem.setActionCommand(RESET_JOB_SETTINGS);
- resetJobSettingsItem.addActionListener(this);
- resetJobSettingsItem.setToolTipText("Reset Job Settings to the defaults.");
- jobMenu.add(resetJobSettingsItem);
-
- steeringItem = new JMenuItem("Set Steering File...");
- steeringItem.setMnemonic(KeyEvent.VK_S);
- steeringItem.setActionCommand(SET_STEERING_FILE);
- steeringItem.addActionListener(this);
- steeringItem.setToolTipText("Set the job's LCSim steering file.");
- jobMenu.add(steeringItem);
-
- aidaAutoSaveItem = new JMenuItem("AIDA Auto Save File...");
+ menuBar.add(applicationMenu);
+
+ JMenuItem loadConfigItem = new JMenuItem("Load Settings ...");
+ loadConfigItem.addActionListener(this);
+ loadConfigItem.setMnemonic(KeyEvent.VK_C);
+ loadConfigItem.setActionCommand(SELECT_CONFIG_FILE);
+ loadConfigItem.setToolTipText("Load application settings from a properties file.");
+ applicationMenu.add(loadConfigItem);
+
+ JMenuItem saveConfigItem = new JMenuItem("Save Settings ...");
+ saveConfigItem.addActionListener(this);
+ saveConfigItem.setMnemonic(KeyEvent.VK_S);
+ saveConfigItem.setActionCommand(SAVE_CONFIG_FILE);
+ saveConfigItem.setToolTipText("Save settings to a properties file.");
+ applicationMenu.add(saveConfigItem);
+
+ JMenuItem settingsItem = new JMenuItem("Show Settings ...");
+ settingsItem.setMnemonic(KeyEvent.VK_P);
+ settingsItem.setActionCommand(SHOW_SETTINGS);
+ settingsItem.addActionListener(this);
+ settingsItem.setToolTipText("Show application settings menu.");
+ applicationMenu.add(settingsItem);
+
+ JMenuItem exitItem = new JMenuItem("Exit");
+ exitItem.setMnemonic(KeyEvent.VK_X);
+ exitItem.setActionCommand(MonitoringCommands.EXIT);
+ exitItem.addActionListener(this);
+ exitItem.setToolTipText("Exit from the application.");
+ applicationMenu.add(exitItem);
+
+ JMenu plotsMenu = new JMenu("Plots");
+ plotsMenu.setMnemonic(KeyEvent.VK_O);
+ menuBar.add(plotsMenu);
+
+ JMenuItem aidaAutoSaveItem = new JMenuItem("Set AIDA Auto Save File ...");
aidaAutoSaveItem.setMnemonic(KeyEvent.VK_A);
aidaAutoSaveItem.setActionCommand(AIDA_AUTO_SAVE);
aidaAutoSaveItem.addActionListener(this);
aidaAutoSaveItem.setToolTipText("Select name of file to auto save AIDA plots at end of job.");
- jobMenu.add(aidaAutoSaveItem);
-
+ plotsMenu.add(aidaAutoSaveItem);
+
savePlotsItem = new JMenuItem("Save Plots to AIDA File...");
savePlotsItem.setMnemonic(KeyEvent.VK_P);
savePlotsItem.setActionCommand(SAVE_PLOTS);
savePlotsItem.addActionListener(this);
savePlotsItem.setEnabled(false);
savePlotsItem.setToolTipText("Save plots from default AIDA tree to an output file.");
- jobMenu.add(savePlotsItem);
+ plotsMenu.add(savePlotsItem);
+
+ JMenu logMenu = new JMenu("Log");
+ logMenu.setMnemonic(KeyEvent.VK_L);
+ menuBar.add(logMenu);
- logItem = new JMenuItem("Redirect to File...");
+ logItem = new JMenuItem("Redirect to File ...");
logItem.setMnemonic(KeyEvent.VK_F);
- logItem.setActionCommand(LOG_TO_FILE);
+ logItem.setActionCommand(CHOOSE_LOG_FILE);
logItem.addActionListener(this);
logItem.setEnabled(true);
- logItem.setToolTipText("Redirect job's standard out and err to a file.");
- jobMenu.add(logItem);
+ logItem.setToolTipText("Redirect std out and err to a file.");
+ logMenu.add(logItem);
terminalItem = new JMenuItem("Redirect to Terminal");
terminalItem.setMnemonic(KeyEvent.VK_T);
terminalItem.setActionCommand(LOG_TO_TERMINAL);
terminalItem.addActionListener(this);
terminalItem.setEnabled(false);
- terminalItem.setToolTipText("Redirect job's standard out and err back to the terminal.");
- jobMenu.add(terminalItem);
-
- JMenuItem screenshotItem = new JMenuItem("Take a screenshot...");
- screenshotItem.setMnemonic(KeyEvent.VK_N);
- screenshotItem.setActionCommand(SCREENSHOT);
- screenshotItem.addActionListener(this);
- screenshotItem.setToolTipText("Save a full screenshot to a " + screenshotFormat + " file.");
- jobMenu.add(screenshotItem);
-
- JMenu logMenu = new JMenu("Log");
- jobMenu.setMnemonic(KeyEvent.VK_L);
- menuBar.add(logMenu);
-
- JMenuItem saveLogItem = new JMenuItem("Save log to file...");
+ terminalItem.setToolTipText("Redirect std out and err back to the terminal.");
+ logMenu.add(terminalItem);
+
+ JMenuItem saveLogItem = new JMenuItem("Save Log Table to File ...");
saveLogItem.setMnemonic(KeyEvent.VK_S);
saveLogItem.setActionCommand(SAVE_LOG_TABLE);
saveLogItem.addActionListener(this);
saveLogItem.setToolTipText("Save the log records to a tab delimited text file.");
logMenu.add(saveLogItem);
+
+ JMenuItem clearLogItem = new JMenuItem("Clear Log Table");
+ clearLogItem.addActionListener(this);
+ clearLogItem.setMnemonic(KeyEvent.VK_C);
+ clearLogItem.setActionCommand(CLEAR_LOG_TABLE);
+ clearLogItem.setToolTipText("Clear the log table of all messages.");
+ logMenu.add(clearLogItem);
+
+ JMenu utilMenu = new JMenu("Util");
+ plotsMenu.setMnemonic(KeyEvent.VK_U);
+ menuBar.add(utilMenu);
- addMenuItem("Clear log", KeyEvent.VK_C, CLEAR_LOG_TABLE, true, "Clear the log table of all messages.", logMenu);
+ JMenuItem screenshotItem = new JMenuItem("Take a Screenshot ...");
+ screenshotItem.setMnemonic(KeyEvent.VK_N);
+ screenshotItem.setActionCommand(SCREENSHOT);
+ screenshotItem.addActionListener(this);
+ screenshotItem.setToolTipText("Save a full screenshot to a " + screenshotFormat + " file.");
+ utilMenu.add(screenshotItem);
}
-
+
/**
- * Add a menu item.
- * @param label The label.
- * @param mnemonic The single letter shortcut.
- * @param cmd The command.
- * @param enabled Whether it is enabled.
- * @param tooltip The tooltip text.
- * @param menu The parent menu to which it should be added.
- * @return The created menu item.
- */
- private JMenuItem addMenuItem(String label, int mnemonic, String cmd, boolean enabled, String tooltip, JMenu menu) {
- JMenuItem item = new JMenuItem(label);
- item.setMnemonic(mnemonic);
- item.setActionCommand(cmd);
- item.setEnabled(enabled);
- item.setToolTipText(tooltip);
- item.addActionListener(this);
- menu.add(item);
- return item;
- }
-
- /**
* Log handler for inserting messages into the log table.
*/
private class MonitoringApplicationLogHandler extends Handler {
@@ -479,35 +448,13 @@
logger.addHandler(logHandler);
logger.setLevel(Level.ALL);
}
-
+
/**
- * Load connection settings from a file.
- * @param file The properties file.
- */
- public void loadConnectionSettings(File file) {
- getConnectionPanel().loadPropertiesFile(file);
- }
-
- /**
- * Load job settings from a file.
- * @param file The properties file.
- */
- public void loadJobSettings(File file) {
- try {
- getJobPanel().setJobSettings(new JobSettings(file));
- // Need to check here if System.out and err have been redirected.
- if (getJobPanel().logToFile()) {
- redirectStdOutAndErrToFile(new File(getJobPanel().getLogFileName()));
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
* 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, etc.
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (CONNECT.equals(cmd)) {
@@ -526,26 +473,20 @@
}.start();
} else if (SAVE_PLOTS.equals(cmd)) {
savePlots();
- } else if (LOG_TO_FILE.equals(cmd)) {
- logToFile();
+ } else if (CHOOSE_LOG_FILE.equals(cmd)) {
+ chooseLogFile();
} else if (LOG_TO_TERMINAL.equals(cmd)) {
logToTerminal();
} else if (SCREENSHOT.equals(cmd)) {
chooseScreenshot();
} else if (EXIT.equals(cmd)) {
exit();
- } else if (SAVE_CONNECTION.equals(cmd)) {
- saveConnection();
- } else if (LOAD_CONNECTION.equals(cmd)) {
- getConnectionPanel().load();
- } else if (RESET_CONNECTION_SETTINGS.equals(cmd)) {
- getConnectionPanel().reset();
} else if (SAVE_LOG_TABLE.equals(cmd)) {
- saveLogToFile();
+ saveLogTableToFile();
} else if (CLEAR_LOG_TABLE.equals(cmd)) {
- clearLog();
+ clearLogTable();
} else if (SET_EVENT_BUILDER.equals(cmd)) {
- getJobPanel().editEventBuilder();
+ getJobSettingsPanel().editEventBuilder();
} else if (PAUSE.equals(cmd)) {
pauseEventProcessing();
} else if (NEXT.equals(cmd)) {
@@ -555,19 +496,17 @@
} else if (SET_LOG_LEVEL.equals(cmd)) {
setLogLevel();
} else if (AIDA_AUTO_SAVE.equals(cmd)) {
- getJobPanel().chooseAidaAutoSaveFile();
- } else if (SAVE_JOB_SETTINGS.equals(cmd)) {
- saveJobSettings();
- } else if (LOAD_JOB_SETTINGS.equals(cmd)) {
- loadJobSettings();
- } else if (RESET_JOB_SETTINGS.equals(cmd)) {
- resetJobSettings();
+ getJobSettingsPanel().chooseAidaAutoSaveFile();
} else if (SET_STEERING_RESOURCE.equals(cmd)) {
steeringResourceSelected();
- } else if (SET_STEERING_FILE.equals(cmd)) {
- selectSteeringFile();
} else if (SHOW_SETTINGS.equals(cmd)) {
showSettingsWindow();
+ } else if (SELECT_CONFIG_FILE.equals(cmd)) {
+ chooseConfigFile();
+ } else if (SAVE_CONFIG_FILE.equals(cmd)) {
+ saveConfigFile();
+ } else if (LOAD_DEFAULT_CONFIG_FILE.equals(cmd)) {
+ loadDefaultConfigFile();
}
}
@@ -583,94 +522,29 @@
* are changed to use a resource type.
*/
private void steeringResourceSelected() {
- getJobPanel().setSteeringType(JobPanel.RESOURCE);
+ getJobSettingsPanel().setSteeringType(SteeringType.RESOURCE);
}
-
+
/**
- * Save the job settings to a selected file.
+ * Set a new log level for the application. If the new log level is the same as the old one,
+ * a new log level will NOT be set.
*/
- private void saveJobSettings() {
- JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Save Job Settings");
- fc.setCurrentDirectory(new File("."));
- int r = fc.showSaveDialog(mainPanel);
- if (r == JFileChooser.APPROVE_OPTION) {
- File f = fc.getSelectedFile();
- JobSettings settings = getJobPanel().getJobSettings();
- try {
- settings.save(f);
- log(Level.INFO, "Saved Job Settings to properties file < " + f.getPath() + " >");
- } catch (IOException e) {
- errorHandler.setError(e)
- .printStackTrace()
- .log()
- .showErrorDialog();
- }
+ private void setLogLevel() {
+ Level newLevel = getJobSettingsPanel().getLogLevel();
+ if (logger.getLevel() != newLevel) {
+ logger.setLevel(newLevel);
+ log(Level.INFO, "Log Level was changed to < " + getJobSettingsPanel().getLogLevel().toString() + " >");
}
}
/**
- * Load job settings from a selected file.
- */
- private void loadJobSettings() {
- JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Load Job Settings");
- fc.setCurrentDirectory(new File("."));
- int r = fc.showOpenDialog(mainPanel);
- if (r == JFileChooser.APPROVE_OPTION) {
- File f = fc.getSelectedFile();
- try {
- getJobPanel().setJobSettings(new JobSettings(f));
- log(Level.INFO, "Loaded Job Settings from file < " + f.getPath() + " >");
- } catch (IOException e) {
- errorHandler.setError(e)
- .printStackTrace()
- .log()
- .showErrorDialog();
- }
- }
- }
-
- /**
- * Save the connection settings to a properties file using a file chooser.
- */
- void saveConnection() {
- JFileChooser fc = new JFileChooser();
- fc.setCurrentDirectory(new File("."));
- int r = fc.showSaveDialog(this);
- if (r == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- getConnectionPanel().writePropertiesFile(file);
- log(Level.INFO, "Saved connection properties to file < " + file.getPath() + " >");
- }
- }
-
- /**
- * Reset the job settings to the defaults.
- */
- private void resetJobSettings() {
- getJobPanel().resetJobSettings();
- // Redirect System.out and err back to the terminal.
- logToTerminal();
- }
-
- /**
- * Set a new log level for the application and also forward to the event processor.
- */
- private void setLogLevel() {
- Level newLevel = getJobPanel().getLogLevel();
- logger.setLevel(newLevel);
- log(Level.INFO, "Log Level was changed to < " + getJobPanel().getLogLevel().toString() + " >");
- }
-
- /**
* Set the connection status.
* @param status The connection status.
*/
- private void setConnectionStatus(int status) {
+ private void setConnectionStatus(ConnectionStatus status) {
connectionStatus = status;
- connectionStatusPanel.setStatus(status);
- log(Level.FINE, "Connection status changed to < " + ConnectionStatus.toString(status) + " >");
+ connectionStatusPanel.setConnectionStatus(status);
+ log(Level.FINE, "Connection status changed to < " + status.name() + " >");
logHandler.flush();
}
@@ -710,31 +584,8 @@
}
}
}
-
+
/**
- * Select an LCSim steering file using a file chooser.
- */
- private void selectSteeringFile() {
- JFileChooser fc = new JFileChooser();
- int r = fc.showOpenDialog(mainPanel);
- if (r == JFileChooser.APPROVE_OPTION) {
- File fileName = fc.getSelectedFile();
- try {
- (new JobControlManager()).setup(fileName);
- getJobPanel().setSteeringFile(fileName.getPath());
- getJobPanel().setSteeringType(JobPanel.FILE);
- log("Steering file set to < " + fileName.getPath() + " >");
- } catch (Exception e) {
- errorHandler.setError(e)
- .setMessage("Error reading steering file.")
- .printStackTrace()
- .log()
- .showErrorDialog();
- }
- }
- }
-
- /**
* Get the full title of the application.
* @return The application title.
*/
@@ -767,55 +618,18 @@
}
/**
- * Redirect System.out and System.err to a file. This can be used to capture lengthy
- * debug output from event processing into a file. Messages sent to the <code>Logger</code>
- * are unaffected and will still appear in the log table.
- */
- private void logToFile() {
- JFileChooser fc = new JFileChooser();
- fc.setDialogTitle("Log File");
- fc.setCurrentDirectory(new File("."));
- int fcs = fc.showSaveDialog(mainPanel);
- if (fcs == JFileChooser.APPROVE_OPTION) {
- final File logFile = fc.getSelectedFile();
- if (logFile.exists()) {
- JOptionPane.showMessageDialog(this, "Log file already exists.");
- } else {
- try {
- if (!logFile.createNewFile()) {
- throw new IOException();
- }
- redirectStdOutAndErrToFile(logFile);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- getJobPanel().setLogToFile(true);
- getJobPanel().setLogFile(logFile.getPath());
- terminalItem.setEnabled(true);
- logItem.setEnabled(false);
- }
- });
-
- log("Redirected System output to file < " + logFile.getPath() + " >");
- } catch (IOException e) {
- errorHandler.setError(e)
- .setMessage("Error redirecting System.out to file.")
- .log()
- .printStackTrace()
- .showErrorDialog();
- }
- }
- }
- }
-
- /**
* Redirect <code>System.out</code> and <code>System.err</code> to a file.
* @param file The output log file.
* @throws FileNotFoundException if the file does not exist.
*/
- private void redirectStdOutAndErrToFile(File file) throws FileNotFoundException {
- PrintStream ps = new PrintStream(new FileOutputStream(file.getPath()));
- System.setOut(ps);
- System.setErr(ps);
+ private void redirectStdOutAndErrToFile(File file) {
+ try {
+ PrintStream ps = new PrintStream(new FileOutputStream(file.getPath()));
+ System.setOut(ps);
+ System.setErr(ps);
+ } catch (Exception e) {
+ errorHandler.setError(e).log().printStackTrace().raiseException();
+ }
}
/**
@@ -828,14 +642,27 @@
System.setErr(sysErr);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- getJobPanel().setLogFile("");
- getJobPanel().setLogToFile(false);
+ getJobSettingsPanel().setLogToFile(false);
terminalItem.setEnabled(false);
logItem.setEnabled(true);
}
});
- log(Level.INFO, "Redirected print output to terminal.");
+ log(Level.INFO, "Redirected std out and err back to terminal.");
}
+
+ /**
+ * Redirect std out and err to a file.
+ */
+ private void logToFile(File file) {
+ redirectStdOutAndErrToFile(file);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ terminalItem.setEnabled(true);
+ logItem.setEnabled(false);
+ }
+ });
+ log("Redirected std out and err to file < " + file.getPath() + " >");
+ }
/**
* Set the GUI state to disconnected, which will enable/disable applicable GUI components and
@@ -846,27 +673,23 @@
public void run() {
// Enable or disable appropriate menu items.
- connectItem.setEnabled(true);
- disconnectItem.setEnabled(false);
- resetConnectionItem.setEnabled(true);
- connectionLoadItem.setEnabled(true);
savePlotsItem.setEnabled(false);
logItem.setEnabled(true);
terminalItem.setEnabled(true);
- steeringItem.setEnabled(true);
// Re-enable the ConnectionPanel.
getConnectionPanel().enableConnectionPanel(true);
// Re-enable the getJobPanel().
- getJobPanel().enableJobPanel(true);
+ getJobSettingsPanel().enableJobPanel(true);
// Set relevant event panel buttons to disabled.
buttonsPanel.enablePauseButton(false);
buttonsPanel.enableNextEventsButton(false);
// Toggle connection button to proper setting.
- buttonsPanel.toggleConnectButton();
+ //buttonsPanel.toggleConnectButton();
+ buttonsPanel.setConnected(false);
}
});
}
@@ -882,24 +705,20 @@
getConnectionPanel().enableConnectionPanel(false);
// Disable getJobPanel().
- getJobPanel().enableJobPanel(false);
+ getJobSettingsPanel().enableJobPanel(false);
// Enable or disable appropriate menu items.
- connectItem.setEnabled(false);
- disconnectItem.setEnabled(true);
- resetConnectionItem.setEnabled(false);
- connectionLoadItem.setEnabled(false);
savePlotsItem.setEnabled(true);
logItem.setEnabled(false);
terminalItem.setEnabled(false);
- steeringItem.setEnabled(false);
// Enable relevant event panel buttons.
buttonsPanel.enablePauseButton(true);
- buttonsPanel.setPauseModeState(getJobPanel().pauseMode());
+ buttonsPanel.setPauseModeState(getJobSettingsPanel().pauseMode());
// Toggle connection button to proper settings.
- buttonsPanel.toggleConnectButton();
+ //buttonsPanel.toggleConnectButton();
+ buttonsPanel.setConnected(true);
}
});
}
@@ -962,20 +781,21 @@
* @return The class name of the event builder.
*/
private String getEventBuilderClassName() {
- return getJobPanel().getEventBuilderClassName();
+ return getJobSettingsPanel().getEventBuilderClassName();
}
/**
* Get the type of steering file being used.
* @return The type of the steering file.
*/
- private int getSteeringType() {
- return getJobPanel().getSteeringType();
+ private SteeringType getSteeringType() {
+ return getJobSettingsPanel().getSteeringType();
}
/**
- * Start a new monitoring session. This is executed in a separate thread from the EDT
- * in order to not block the GUI from updating.
+ * Start a new monitoring session. This method is executed in a separate thread from the EDT
+ * within {@link #actionPerformed(ActionEvent)} so GUI updates are not blocked while the session
+ * is being setup.
*/
private void startSession() {
@@ -989,21 +809,16 @@
// Reset the plot panel and global AIDA state.
resetPlots();
- // The system status registry should be cleared here before any processors
- // which might have a SystemStatus are added to the event processing chain
+ // The system status registry is cleared here before any event processors
+ // which might create a SystemStatus are added to the event processing chain
// e.g. an LCSim Driver, etc.
SystemStatusRegistry.getSystemStatusRegistery().clear();
// Setup the LCSim JobControlManager and event builder.
setupLCSim();
- // Using an ET server for this session?
- if (usingEtServer())
- // Connect to the ET system, which will create a valid EtConnection object.
- connect();
- else
- // Using a file source so just set correct GUI state.
- this.setConnectedGuiState();
+ // Connect to the ET system.
+ connect();
// Setup the EventProcessingChain object using the EtConnection.
setupEventProcessingChain();
@@ -1011,29 +826,27 @@
// Setup the system status monitor table.
setupSystemStatusMonitor();
- // Start thread which will trigger a disconnect if the event processing thread
- // finishes.
+ // Start thread which will trigger a disconnect if the event processing finishes.
startSessionWatchdogThread();
log(Level.INFO, "Successfully started the monitoring session.");
- // Close modal window.
- dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
-
} catch (Exception e) {
- // Close modal window.
- dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
+ log(Level.SEVERE, "An error occurred while setting up the session.");
- // Handle the error that occurred.
+ // Log the error that occurred.
errorHandler.setError(e)
- .printStackTrace()
.log();
// Disconnect from the session.
- // FIXME: Is this okay when ET is not being used e.g. for direct file streaming?
+ //if (this.connected())
disconnect(ConnectionStatus.ERROR);
- }
+
+ } finally {
+ // Close modal window.
+ dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
+ }
}
/**
@@ -1049,20 +862,24 @@
*/
private void connect() throws IOException {
- log(Level.FINE, "Connecting to ET system.");
-
- setConnectionStatus(ConnectionStatus.CONNECTION_REQUESTED);
-
// Make sure applicable menu items are enabled or disabled.
+ // This applies whether or not using an ET server or file source.
setConnectedGuiState();
+
+ // Setup the network connection if using an ET server.
+ if (usingEtServer()) {
+
+ setConnectionStatus(ConnectionStatus.CONNECTION_REQUESTED);
- // Create a connection to the ET server.
- try {
- createEtConnection();
- log(Level.INFO, "Successfully connected to ET system.");
- } catch (Exception e) {
- //log(e.getMessage());
- throw new IOException(e);
+ // Create a connection to the ET server.
+ try {
+ createEtConnection();
+ log(Level.INFO, "Successfully connected to ET system.");
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ } else {
+ this.setConnectionStatus(ConnectionStatus.CONNECTED);
}
}
@@ -1071,7 +888,7 @@
* @return The steering parameter.
*/
private String getSteering() {
- return getJobPanel().getSteering();
+ return getJobSettingsPanel().getSteering();
}
/**
@@ -1079,23 +896,15 @@
* @return The name of the detector.
*/
private String getDetectorName() {
- return getJobPanel().getDetectorName();
+ return getJobSettingsPanel().getDetectorName();
}
-
- /**
- * Get the connection parameter settings from the connection panel.
- * @return The connection parameters.
- */
- private EtConnectionParameters getConnectionParameters() {
- return getConnectionPanel().getConnectionParameters();
- }
-
- private ConnectionPanel getConnectionPanel() {
+
+ private ConnectionSettingsPanel getConnectionPanel() {
return settingsDialog.getSettingsPanel().getConnectionPanel();
}
- private JobPanel getJobPanel() {
- return settingsDialog.getSettingsPanel().getJobPanel();
+ private JobSettingsPanel getJobSettingsPanel() {
+ return settingsDialog.getSettingsPanel().getJobSettingsPanel();
}
private DataSourcePanel getDataSourcePanel() {
@@ -1118,13 +927,13 @@
* Disconnect from the current ET session with a particular status.
* @param status The connection status.
*/
- private void disconnect(int status) {
+ private void disconnect(ConnectionStatus status) {
log(Level.FINE, "Disconnecting from the ET server.");
// Cleanup the ET connection.
cleanupEtConnection();
-
+
// Update state of GUI to disconnected.
setDisconnectedGuiState();
@@ -1142,9 +951,10 @@
* Cleanup the ET connection.
*/
private void cleanupEtConnection() {
-
- if (connection != null) {
- connection.cleanup();
+ if (connection != null) {
+ if (connection.getEtSystem().alive()) {
+ connection.cleanup();
+ }
connection = null;
}
}
@@ -1158,48 +968,45 @@
// Get steering resource or file as a String parameter.
String steering = getSteering();
- int steeringType = getJobPanel().getSteeringType();
- log(Level.CONFIG, "Set LCSim steering to < " + steering + " > with type < " + (steeringType == JobPanel.RESOURCE ? "RESOURCE" : "FILE") + " >");
+ SteeringType steeringType = getJobSettingsPanel().getSteeringType();
+ log(Level.CONFIG, "Set LCSim steering to < " + steering + " > with type < " + (steeringType == SteeringType.RESOURCE ? "RESOURCE" : "FILE") + " >");
- // Check if the LCSim steering file looks valid.
try {
- getJobPanel().checkSteering();
- } catch (IOException e) {
- errorHandler.setError(e)
- .log()
- .printStackTrace()
- .raiseException();
- }
-
- try {
// Create job manager and configure.
jobManager = new JobControlManager();
jobManager.setPerformDryRun(true);
- if (steeringType == JobPanel.RESOURCE) {
- log(Level.CONFIG, "Setting up steering resource < " + steering + " >");
- InputStream is = this.getClass().getClassLoader().getResourceAsStream(steering);
- jobManager.setup(is);
- is.close();
- } else if (getSteeringType() == JobPanel.FILE) {
- log(Level.CONFIG, "Setting up steering file < " + steering + " >");
- jobManager.setup(new File(steering));
[truncated at 1000 lines; 447 more skipped]
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringCommands.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -3,34 +3,29 @@
/**
* These strings are used to identify ActionEvents in the MonitoringApplication.
* A few commands handled only by sub-components are not listed here.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
final class MonitoringCommands {
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 EDIT_EVENT_REFRESH = "editEventRefresh";
- static final String EXIT = "exit";
- static final String LOAD_CONNECTION = "loadConnection";
- static final String LOAD_JOB_SETTINGS = "loadJobSettings";
+ 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 LOG_TO_TERMINAL = "logToTerminal";
static final String NEXT = "next";
static final String PAUSE = "pause";
static final String RESUME = "resume";
- static final String RESET_CONNECTION_SETTINGS = "resetConnectionSettings";
- static final String RESET_JOB_SETTINGS = "resetJobSettings";
- static final String SAVE_CONNECTION = "saveConnection";
- static final String SAVE_JOB_SETTINGS = "saveJobSettings";
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_EVENT_REFRESH = "setEventRefresh";
static final String SET_LOG_LEVEL = "setLogLevel";
- static final String SET_STEERING_FILE = "setSteeringFile";
- static final String SET_STEERING_RESOURCE = "setSteeringResource";
+ 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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotFrame.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -4,8 +4,7 @@
import javax.swing.JTabbedPane;
/**
- * A <code>JFrame</code> where monitoring plots will show.
- * @author Jeremy McCormick <[log in to unmask]>
+ * A <code>JFrame</code> where monitoring plots will show in tabs.
*/
public class PlotFrame extends JFrame {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -8,7 +8,6 @@
/**
* The modal dialog for entering settings. It contains a <code>JPanel</code>
* with the different settings sub-tabs.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class SettingsDialog extends JDialog {
@@ -25,7 +24,7 @@
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
- settingsPanel.revert();
+ 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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -17,21 +17,23 @@
/**
* The container component with the tabs which have job and connection settings.
- * @author Jeremy McCormick <[log in to unmask]>
*/
class SettingsPanel extends JPanel implements ActionListener {
JTabbedPane tabs;
- JobPanel jobPanel = new JobPanel();
- ConnectionPanel connectionPanel = new ConnectionPanel();
+ JobSettingsPanel jobPanel = new JobSettingsPanel();
+ ConnectionSettingsPanel connectionPanel = new ConnectionSettingsPanel();
DataSourcePanel dataSourcePanel = new DataSourcePanel();
- static final String okayCommand = "settingsOkay";
- static final String cancelCommand = "settingsCancel";
+ static final String OKAY_COMMAND = "settingsOkay";
+ static final String CANCEL_COMMAND = "settingsCancel";
+
+ JButton defaultsButton;
+
JDialog parent;
ErrorHandler errorHandler;
-
+
SettingsPanel(JDialog parent) {
-
+
this.parent = parent;
this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
@@ -43,27 +45,32 @@
add(tabs);
JButton okayButton = new JButton("Okay");
- okayButton.setActionCommand(okayCommand);
+ okayButton.setActionCommand(OKAY_COMMAND);
okayButton.addActionListener(this);
JButton cancelButton = new JButton("Cancel");
- cancelButton.setActionCommand(cancelCommand);
+ cancelButton.setActionCommand(CANCEL_COMMAND);
cancelButton.addActionListener(this);
+
+ defaultsButton = new JButton("Defaults");
+ defaultsButton.setActionCommand(MonitoringCommands.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);
add(Box.createRigidArea(new Dimension(1,5)));
}
-
- ConnectionPanel getConnectionPanel() {
+
+ ConnectionSettingsPanel getConnectionPanel() {
return connectionPanel;
}
- JobPanel getJobPanel() {
+ JobSettingsPanel getJobSettingsPanel() {
return jobPanel;
}
@@ -72,24 +79,27 @@
}
/**
- * Caches the object for the settings based on current GUI values.
+ * Pushes the GUI settings into the current configuration object.
*/
- void cache() {
- connectionPanel.cache();
- jobPanel.cache();
+ void save() {
+ connectionPanel.save();
+ jobPanel.save();
+ dataSourcePanel.save();
}
/**
- * Revert the settings to their unedited values.
+ * Resets the settings to the last saved configuration.
*/
- void revert() {
- connectionPanel.revert();
- jobPanel.revert();
+ void reset() {
+ connectionPanel.reset();
+ jobPanel.reset();
+ dataSourcePanel.reset();
}
+ // FIXME: This isn't the right way to do this!
String getError() {
try {
- this.dataSourcePanel.checkFile();
+ this.dataSourcePanel.checkFile();
return null;
} catch (IOException e) {
return e.getMessage();
@@ -98,7 +108,7 @@
@Override
public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equals(okayCommand)) {
+ if (e.getActionCommand().equals(OKAY_COMMAND)) {
final String errorMessage = getError();
if (errorMessage != null) {
SwingUtilities.invokeLater(new Runnable() {
@@ -111,12 +121,22 @@
}
});
} else {
- cache();
+ save();
parent.setVisible(false);
}
- } else if (e.getActionCommand().equals(cancelCommand)) {
- revert();
+ } else if (e.getActionCommand().equals(CANCEL_COMMAND)) {
+ reset();
parent.setVisible(false);
}
+ }
+
+ /**
+ * This method is used to register a listener so that the Monitoring Application
+ * can reset to the default configuration when the "Defaults" button is pushed from
+ * the settings panel.
+ * @param listener
+ */
+ void addActionListener(ActionListener listener) {
+ defaultsButton.addActionListener(listener);
}
}
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusFrame.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -4,10 +4,6 @@
import static org.hps.monitoring.gui.SystemStatusTableModel.LAST_CHANGED_COL;
import static org.hps.monitoring.gui.SystemStatusTableModel.STATUS_COL;
import static org.hps.monitoring.gui.SystemStatusTableModel.SYSTEM_COL;
-import static org.hps.monitoring.subsys.SystemStatus.StatusCode.OFFLINE;
-import static org.hps.monitoring.subsys.SystemStatus.StatusCode.OKAY;
-import static org.hps.monitoring.subsys.SystemStatus.StatusCode.UNKNOWN;
-import static org.hps.monitoring.subsys.SystemStatus.StatusCode.WARNING;
import java.awt.Color;
import java.awt.Component;
@@ -21,12 +17,10 @@
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
-import org.hps.monitoring.subsys.SystemStatus;
-import org.hps.monitoring.subsys.SystemStatus.StatusCode;
+import org.hps.monitoring.enums.StatusCode;
/**
* A GUI window for showing changes to {@link org.hps.monitoring.subsys.SystemStatus} objects.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class SystemStatusFrame extends JFrame implements HasErrorHandler {
@@ -47,20 +41,20 @@
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
// Color code the cell by its status.
- SystemStatus.StatusCode statusCode = SystemStatus.StatusCode.valueOf((String) value);
+ StatusCode statusCode = StatusCode.valueOf((String) value);
if (statusCode.ordinal() >= StatusCode.ERROR.ordinal()) {
// Any type of error is red.
label.setBackground(Color.RED);
- } else if (statusCode.ordinal() == WARNING.ordinal()) {
+ } else if (statusCode.ordinal() == StatusCode.WARNING.ordinal()) {
// Warnings are yellow.
label.setBackground(Color.YELLOW);
- } else if (statusCode.ordinal() == OKAY.ordinal()) {
+ } else if (statusCode.ordinal() == StatusCode.OKAY.ordinal()) {
// Okay is green.
label.setBackground(Color.GREEN);
- } else if (statusCode.ordinal() == OFFLINE.ordinal()) {
+ } else if (statusCode.ordinal() == StatusCode.OFFLINE.ordinal()) {
// Offline is orange.
label.setBackground(Color.ORANGE);
- } else if (statusCode.ordinal() == UNKNOWN.ordinal()) {
+ } else if (statusCode.ordinal() == StatusCode.UNKNOWN.ordinal()) {
// Unknown is gray.
label.setBackground(Color.GRAY);
} else {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusTableModel.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusTableModel.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -13,7 +13,6 @@
/**
* A <code>JTableModel</code> that has a backing list of
* {@link org.hps.monitoring.subsys.SystemStatus} objects.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class SystemStatusTableModel extends AbstractTableModel implements SystemStatusListener {
@@ -41,13 +40,7 @@
status.addListener(this);
fireTableDataChanged();
}
-
- /*
- public SystemStatus getSystemStatus(int row) {
- return statuses.get(row);
- }
- */
-
+
@Override
public int getRowCount() {
return statuses.size();
@@ -72,7 +65,7 @@
case STATUS_COL:
return status.getStatusCode().name();
case SYSTEM_COL:
- return status.getSystemName().name();
+ return status.getSubsystem().name();
case DESCRIPTION_COL:
return status.getDescription();
case MESSAGE_COL:
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/package-info.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/package-info.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,25 @@
+/**
+ * <p>
+ * The Monitoring Application is a flexible framework for monitoring the
+ * event processing chain of the HPS experiment. It implements the conversion
+ * of ET byte buffers to EVIO and then the building of LCIO events from the
+ * raw EVIO data.
+ * <p>
+ * <p>
+ * It provides three primary GUI components:
+ * </p>
+ * <ul>
+ * <li>run dashboard showing basic information about data received</li>
+ * <li>system status monitor that can monitor the status of specific subsystems</li>
+ * <li>plotting window that displays any plots generated through the AIDA API</li>
+ * </ul>
+ * <p>
+ * The FreeHep framework is used extensively for the record processing. Every part
+ * of the event processing chain uses the
+ * <a href="http://java.freehep.org/freehep-record/">freehep-record</a>
+ * module to manage the flow of records and activate any processors that are listening
+ * on the record loops.
+ * </p>
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+package org.hps.monitoring;
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -13,9 +13,6 @@
* its regions are shown. This class overrides {@link #createPlotterFactory()} and
* {@link #createPlotterFactory(String)} to return a custom <code>IPlotterFactory</code> object
* that implements this behavior.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringAnalysisFactory.java,v 1.4 2013/12/10 07:36:40 jeremy Exp $
*/
public class MonitoringAnalysisFactory extends AnalysisFactory {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -20,8 +20,6 @@
* for each plotter. The root pane is static and shared across all plotter factories.
* The top level component is set externally by the MonitoringApplication before any calls
* to AIDA are made from Drivers.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringPlotFactory.java,v 1.6 2013/12/10 07:36:40 jeremy Exp $
*/
// FIXME: Move to plotting package.
public class MonitoringPlotFactory extends PlotterFactory {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -8,7 +8,6 @@
/**
* An abstract <tt>TimerTask</tt> to update a strip chart at a regular interval.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public abstract class StripChartUpdater extends TimerTask {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/AbstractRecordQueue.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/AbstractRecordQueue.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -11,8 +11,6 @@
/**
* Implementation of <tt>AbstractRecordSource</tt> using a dynamic queue that
* can receive events "on the fly" e.g. from an ET ring.
- *
- * @author Jeremy McCormick
*/
public abstract class AbstractRecordQueue<RecordType> extends AbstractRecordSource {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -32,8 +32,6 @@
* EVIO file source, or LCIO file source. Any number of event processors
* can be registered with the three different loops for processing the different
* record types, in order to plot, update a GUI component, or analyze the events.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EventProcessingChain extends AbstractLoopListener {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -2,7 +2,6 @@
/**
* Thread for running the event processing chain.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EventProcessingThread extends Thread {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessor.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessor.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -2,7 +2,6 @@
/**
* This is a generic interface for event processing.
- * @author Jeremy McCormick <[log in to unmask]>
*
* @param <EventType> The concrete type of the event record.
*/
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/LcioProcessingStep.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/LcioProcessingStep.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -16,7 +16,6 @@
/**
* Processing step for building LCIO events from EVIO
* or reading them directly from an input event file.
- * @author Jeremy McCormick <[log in to unmask]>
*/
class LcioProcessingStep extends 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/CompositeRecord.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecord.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -7,7 +7,6 @@
/**
* This class is used to group together corresponding ET, EVIO and LCIO events
* for use by the {@link CompositeRecordLoop}.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class CompositeRecord {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoop.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,7 +6,6 @@
/**
* Implementation of a composite record loop for processing
* ET, EVIO and LCIO events using a single record source.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class CompositeRecordLoop extends DefaultRecordLoop {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordLoopAdapter.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -10,7 +10,6 @@
/**
* Adapter for listening on the {@link CompositeRecordLoop} for records and loop events.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class CompositeRecordLoopAdapter extends AbstractLoopListener implements RecordListener {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordProcessor.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -5,7 +5,6 @@
/**
* An <code>EventProcessor</code> implementation for processing <code>CompositeRecord</code>
* records.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class CompositeRecordProcessor implements EventProcessor<CompositeRecord> {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/composite/CompositeRecordSource.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -7,7 +7,6 @@
/**
* A record source providing <code>CompositeRecord</code> objects.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class CompositeRecordSource extends AbstractRecordSource {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -2,6 +2,7 @@
import java.io.IOException;
+import org.hps.monitoring.config.Configuration;
import org.jlab.coda.et.EtAttachment;
import org.jlab.coda.et.EtConstants;
import org.jlab.coda.et.EtEvent;
@@ -9,6 +10,7 @@
import org.jlab.coda.et.EtStationConfig;
import org.jlab.coda.et.EtSystem;
import org.jlab.coda.et.EtSystemOpenConfig;
+import org.jlab.coda.et.enums.Mode;
import org.jlab.coda.et.enums.Modify;
import org.jlab.coda.et.exception.EtBusyException;
import org.jlab.coda.et.exception.EtClosedException;
@@ -20,14 +22,16 @@
/**
* Create an EtSystem and EtAttachment from ConnectionParameters.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EtConnection {
- EtConnectionParameters param;
EtSystem sys;
EtAttachment att;
EtStation stat;
+
+ Mode waitMode;
+ int waitTime;
+ int chunkSize;
/**
* Class constructor.
@@ -36,18 +40,21 @@
* @param att The ET attachment.
* @param stat The ET station.
*/
- private EtConnection(EtConnectionParameters param, EtSystem sys, EtAttachment att, EtStation stat) {
- this.param = param;
+ private EtConnection(EtSystem sys, EtAttachment att, EtStation stat,
+ Mode waitMode, int waitTime, int chunkSize) {
this.sys = sys;
this.att = att;
this.stat = stat;
+ this.waitMode = waitMode;
+ this.waitTime = waitTime;
+ this.chunkSize = chunkSize;
}
/**
* Get the ET system.
* @return The ET system.
*/
- EtSystem getEtSystem() {
+ public EtSystem getEtSystem() {
return sys;
}
@@ -55,7 +62,7 @@
* Get the ET attachment.
* @return The ET attachment.
*/
- EtAttachment getEtAttachment() {
+ public EtAttachment getEtAttachment() {
return att;
}
@@ -66,16 +73,8 @@
public EtStation getEtStation() {
return stat;
}
-
+
/**
- * Get the connection parameters.
- * @return The connection parameters.
- */
- public EtConnectionParameters getConnectionParameters() {
- return param;
- }
-
- /**
* Cleanup the ET connection.
*/
public void cleanup() {
@@ -112,51 +111,67 @@
e.printStackTrace();
}
}
-
- /**
- * Create an ET connection from connection parameters.
- * @param cn The connection parameters.
- * @return The ET connection.
- */
- public static EtConnection createEtConnection(EtConnectionParameters cn) {
+
+ public static EtConnection fromConfiguration(Configuration config) {
try {
+
+ // make a direct connection to ET system's tcp server
+ EtSystemOpenConfig etConfig = new EtSystemOpenConfig(
+ config.get("bufferName"),
+ config.get("host"),
+ config.getInteger("port"));
- // make a direct connection to ET system's tcp server
- EtSystemOpenConfig config = new EtSystemOpenConfig(cn.bufferName, cn.host, cn.port);
-
// create ET system object with verbose debugging output
- EtSystem sys = new EtSystem(config, EtConstants.debugInfo);
+ EtSystem sys = new EtSystem(etConfig, EtConstants.debugInfo);
sys.open();
// configuration of a new station
EtStationConfig statConfig = new EtStationConfig();
- statConfig.setFlowMode(cn.flowMode);
- if (!cn.blocking) {
+ //statConfig.setFlowMode(cn.flowMode);
+ // FIXME: Flow mode hard-coded.
+ statConfig.setFlowMode(EtConstants.stationSerial);
+ boolean blocking = config.getBoolean("blocking");
+ if (!blocking) {
statConfig.setBlockMode(EtConstants.stationNonBlocking);
- if (cn.qSize > 0) {
- statConfig.setCue(cn.qSize);
+ int qSize = config.getInteger("qSize");
+ if (qSize > 0) {
+ statConfig.setCue(qSize);
}
}
// Set prescale.
- if (cn.prescale > 0) {
+ int prescale = config.getInteger("prescale");
+ if (prescale > 0) {
//System.out.println("setting prescale to " + cn.prescale);
- statConfig.setPrescale(cn.prescale);
+ statConfig.setPrescale(prescale);
}
// Create the station.
- EtStation stat = sys.createStation(statConfig, cn.statName, cn.position, cn.pposition);
+ System.out.println("position="+config.getInteger("position"));
+ EtStation stat = sys.createStation(
+ statConfig,
+ config.get("statName"),
+ config.getInteger("position"));
// attach to new station
EtAttachment att = sys.attach(stat);
// Return new connection.
- return new EtConnection(cn, sys, att, stat);
+ EtConnection connection = new EtConnection(
+ sys,
+ att,
+ stat,
+ Mode.valueOf(config.get("waitMode")),
+ config.getInteger("waitTime"),
+ config.getInteger("chunk")
+ );
+
+ return connection;
} catch (Exception e) {
e.printStackTrace();
return null;
}
- }
+ }
/**
* Read EtEvent objects from the ET ring.
@@ -178,17 +193,10 @@
EtWakeUpException, EtClosedException {
return getEtSystem().getEvents(
getEtAttachment(),
- getConnectionParameters().getWaitMode(),
+ waitMode,
Modify.NOTHING,
- getConnectionParameters().getWaitTime(),
- getConnectionParameters().getChunkSize());
+ waitTime,
+ chunkSize);
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(this.param.toString());
- buffer.append("attachment: " + this.att.getStation().getName());
- return buffer.toString();
- }
+ }
}
\ No newline at end of file
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventAdapter.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -11,7 +11,6 @@
/**
* Adapter for processing <tt>EtEvent</tt> objects using a loop.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EtEventAdapter extends AbstractLoopListener implements RecordListener {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventLoop.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,8 +6,6 @@
/**
* Record loop implementation for processing <tt>EtEvent</tt> objects.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EtEventLoop extends DefaultRecordLoop {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventProcessor.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventProcessor.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,8 +6,6 @@
/**
* This is the basic abstract class that processors of
* <tt>EtEvent</tt> objects should implement.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public abstract class EtEventProcessor implements EventProcessor<EtEvent> {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventQueue.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -7,8 +7,6 @@
* A dynamic queue for supplying <tt>EtEvent</tt> objects to a loop.
* This would most likely be run on a separate thread than the
* loop to avoid undesired blocking behavior.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EtEventQueue extends AbstractRecordQueue<EtEvent> {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -12,8 +12,6 @@
/**
* Implement a loop record source supplying <tt>EtEvent</tt> objects
* from an ET ring server connection.
- *
- * @author Jeremy McCormick
*/
public class EtEventSource extends AbstractRecordSource {
@@ -21,10 +19,12 @@
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;
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioAdapter.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -12,7 +12,6 @@
/**
* Adapter to process <tt>EvioEvent</tt> objects using a record loop.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EvioAdapter extends AbstractLoopListener implements RecordListener {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventLoop.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -8,8 +8,6 @@
/**
* Implementation of record loop for processing <tt>EvioEvent</tt> objects.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EvioEventLoop extends DefaultRecordLoop {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventProcessor.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventProcessor.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,9 +6,7 @@
/**
* This is the basic abstract class that processors of
* <tt>EvioEvent</tt> objects should implement.
- * @author Jeremy McCormick <[log in to unmask]>
*/
-// TODO: Add handling for all event types (see EtEventListener).
public abstract class EvioEventProcessor implements EventProcessor<EvioEvent> {
@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/EvioEventQueue.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventQueue.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -5,7 +5,6 @@
/**
* A dynamic queue providing <tt>EvioEvent</tt> objects to a loop.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EvioEventQueue extends AbstractRecordQueue<EvioEvent> {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileProducer.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -21,8 +21,6 @@
/**
*
* This is copied and modified from the EvioProducer class in the ET 12.0 CODA module.
- * @author Jeremy McCormick <[log in to unmask]>
- *
*/
// TODO: Add option to set number of events in the put array.
public class EvioFileProducer {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioFileSource.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -15,8 +15,6 @@
* A very basic implementation of <tt>AbstractRecordSource</tt> for supplying <tt>EvioEvent</tt>
* objects to a loop from EVIO files. Unlike the LCIO record source, it has no rewind or
* indexing capabilities (for now at least).
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EvioFileSource extends AbstractRecordSource {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioEventQueue.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -5,7 +5,6 @@
/**
* A dynamic queue providing <tt>EvioEvent</tt> objects to a loop.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class LcioEventQueue extends AbstractRecordQueue<EventHeader> {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioLoop.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -5,8 +5,6 @@
/**
* This class overrides the error handling of <code>LCSimLoop</code>
* so it does not exit the application when errors occur.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class LcioLoop extends LCSimLoop {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -6,8 +6,6 @@
/**
* This is an interface for a set of basic statistics
* about an online event processing system.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public interface SystemStatistics {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -11,8 +11,6 @@
/**
* Implementation of {@link SystemStatistics}.
- *
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class SystemStatisticsImpl implements SystemStatistics {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,5 +1,8 @@
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
* or some level of error has occurred. Listeners can be registered on these objects,
@@ -10,39 +13,17 @@
* on a sub-system. New objects are not created when the status changes. Instead,
* the <tt>StatusCode</tt> is changed with a custom message describing the new state.
* Listeners are updated whenever the status is changed. It is up to the notified
- * object to determine what to do when the state changes.
- *
- * @author Jeremy McCormick <[log in to unmask]>
+ * object to determine what to do when the state changes.
*/
public interface SystemStatus {
-
+
/**
- * Code that represents the status of the monitoring quantity.
+ * Get the sub-system e.g. "SVT".
+ * @return The assigned sub-system.
*/
- enum StatusCode {
- OKAY,
- UNKNOWN,
- OFFLINE,
- WARNING,
- ERROR,
- ALARM,
- HALT;
- }
+ Subsystem getSubsystem();
- /** Names of valid subsystems that can be monitored. */
- enum SystemName {
- ET,
- ECAL,
- SVT,
- TRIGGER;
- }
-
/**
- * Get the name of the sub-system e.g. "SVT".
- */
- SystemName getSystemName();
-
- /**
* Get the current status code.
* @return The current status code.
*/
@@ -63,11 +44,11 @@
String getMessage();
/**
- * Set the current status code, which will cause the last changed
- * time to be set and the listeners to be notified.
+ * Set the current status code and message, which will cause the last changed
+ * time to be set and the listeners to be notified of the status change.
* @param code The new status code.
*/
- void setStatusCode(StatusCode code, String message);
+ void setStatus(StatusCode code, String message);
/**
* Get the time when the system status last changed.
@@ -76,8 +57,7 @@
long getLastChangedMillis();
/**
- * Add a listener to receive notification when the system
- * status changes.
+ * Add a listener to receive notification when the status changes.
* @param listener The listener object.
*/
void addListener(SystemStatusListener listener);
@@ -85,7 +65,7 @@
/**
* Set whether this status is active. Inactive statuses will not be
* updated in the GUI. This can be changed "on the fly" in the system status panel.
- * Listeners will not be notified of state changes when active is <code>False</code>.
+ * Listeners will NOT be notified of state changes when active is <code>False</code>.
*/
void setActive(boolean active);
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -3,21 +3,23 @@
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}.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public final class SystemStatusImpl implements SystemStatus {
- StatusCode code = SystemStatus.StatusCode.UNKNOWN;
+ StatusCode code = StatusCode.UNKNOWN;
long lastChangedMillis;
String message;
List<SystemStatusListener> listeners = new ArrayList<SystemStatusListener>();
- final SystemName systemName;
+ final Subsystem systemName;
final String description;
boolean active = true;
- public SystemStatusImpl(SystemName systemName, String description) {
+ public SystemStatusImpl(Subsystem systemName, String description) {
this.systemName = systemName;
this.description = description;
setLastChangedTime();
@@ -25,7 +27,7 @@
}
@Override
- public SystemName getSystemName() {
+ public Subsystem getSubsystem() {
return systemName;
}
@@ -45,7 +47,7 @@
}
@Override
- public void setStatusCode(StatusCode code, String message) {
+ public void setStatus(StatusCode code, String message) {
this.code = code;
this.message = message;
setLastChangedTime();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java 2014-07-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -2,9 +2,7 @@
/**
* Interface for receiving changes to {@link SystemStatus} objects,
- * e.g. when a new code is set.
- *
- * @author Jeremy McCormick <[log in to unmask]>
+ * e.g. when a new status is set.
*/
public interface SystemStatusListener {
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -4,6 +4,9 @@
import java.util.Collections;
import java.util.List;
+/**
+ * Global registry of all {@link SystemStatus} objects.
+ */
public class SystemStatusRegistry {
static SystemStatusRegistry instance = new SystemStatusRegistry();
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -1,20 +1,17 @@
package org.hps.monitoring.subsys.et;
-import static org.hps.monitoring.subsys.SystemStatus.SystemName.ET;
-
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.SystemStatus;
-import org.hps.monitoring.subsys.SystemStatus.StatusCode;
import org.hps.monitoring.subsys.SystemStatusImpl;
import org.jlab.coda.et.EtEvent;
/**
- * This is just a test class for a monitor of the ET system.
- * It should actually do something useful eventually!
- * @author Jeremy McCormick <[log in to unmask]>
+ * This is a test class for monitoring the ET system.
*/
public class EtSystemMonitor extends EtEventProcessor {
@@ -25,8 +22,8 @@
Timer timer = new Timer("ET Event Monitor");
public EtSystemMonitor() {
- systemStatus = new SystemStatusImpl(ET, "Example ET Monitor");
- systemStatus.setStatusCode(StatusCode.UNKNOWN, "System is not active yet.");
+ systemStatus = new SystemStatusImpl(Subsystem.ET, "Example ET Monitor");
+ systemStatus.setStatus(StatusCode.UNKNOWN, "System is not active yet.");
}
public void setWarningIntervalMillis(long warningIntervalMillis) {
@@ -34,7 +31,7 @@
}
public void startJob() {
- systemStatus.setStatusCode(StatusCode.OKAY, "ET job started.");
+ systemStatus.setStatus(StatusCode.OKAY, "ET job started.");
TimerTask task = new TimerTask() {
long startedMillis = 0;
public void run() {
@@ -46,9 +43,9 @@
else
elapsedMillis = System.currentTimeMillis() - eventReceivedMillis;
if (elapsedMillis > warningIntervalMillis)
- systemStatus.setStatusCode(StatusCode.WARNING, "No ET events received for " + elapsedMillis + " millis.");
+ systemStatus.setStatus(StatusCode.WARNING, "No ET events received for " + elapsedMillis + " millis.");
else
- systemStatus.setStatusCode(StatusCode.OKAY, "ET events received.");
+ systemStatus.setStatus(StatusCode.OKAY, "ET events received.");
}
};
@@ -62,6 +59,6 @@
public void endJob() {
timer.cancel();
timer.purge();
- systemStatus.setStatusCode(StatusCode.OFFLINE, "ET job ended.");
+ systemStatus.setStatus(StatusCode.OFFLINE, "ET job ended.");
}
}
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-29 19:07:15 UTC (rev 828)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -8,7 +8,6 @@
/**
* A basic set of strip charts for monitoring the ET system.
- * @author Jeremy McCormick <[log in to unmask]>
*/
public class EtSystemStripCharts extends EtEventProcessor {
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 (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,73 @@
+package org.hps.monitoring.subsys.svt;
+
+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.SystemStatus;
+import org.hps.monitoring.subsys.SystemStatusImpl;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.util.Driver;
+
+/**
+ * This is a basic example of monitoring hits using an updateable <code>SystemStatus</code>.
+ * It checks from a <code>TimerTask</code> once per second whether <code>RawTrackerHit</code>
+ * objects are being received by the {@link #process(EventHeader)} method.
+ */
+public class BasicHitMonitoringDriver extends Driver {
+
+ SystemStatus status;
+ long hitsReceivedMillis;
+ long warningIntervalMillis = 1000;
+ Timer timer;
+ static final String hitsCollectionName = "SVTRawTrackerHits";
+
+ public BasicHitMonitoringDriver() {
+ status = new SystemStatusImpl(Subsystem.SVT, "Checks that SVT hits are received.");
+ status.setStatus(StatusCode.UNKNOWN, "Status is unknown.");
+ }
+
+ public void setWarningIntervalMillis(long warningIntervalMillis) {
+ this.warningIntervalMillis = warningIntervalMillis;
+ }
+
+ public void startOfData() {
+ if (hitsCollectionName == null)
+ throw new RuntimeException("The hitsCollectionName was never set.");
+ status.setStatus(StatusCode.OKAY, "SVT hit monitor started.");
+ timer = new Timer("SVT Hit Monitor");
+ TimerTask task = new TimerTask() {
+ long startedMillis = 0;
+ public void run() {
+ if (startedMillis == 0)
+ startedMillis = System.currentTimeMillis();
+ long elapsedMillis = 0;
+ if (hitsReceivedMillis == 0)
+ elapsedMillis = System.currentTimeMillis() - startedMillis;
+ else
+ elapsedMillis = System.currentTimeMillis() - hitsReceivedMillis;
+ if (elapsedMillis > warningIntervalMillis)
+ status.setStatus(StatusCode.WARNING, "No SVT hits received for " + elapsedMillis + " millis.");
+ else
+ status.setStatus(StatusCode.OKAY, "SVT hits received.");
+ }
+ };
+ // Task will run once per second.
+ timer.schedule(task, 0, 1000);
+ }
+
+ public void process(EventHeader event) {
+ if (event.hasCollection(RawTrackerHit.class, hitsCollectionName))
+ if (event.get(RawTrackerHit.class, hitsCollectionName).size() > 0)
+ hitsReceivedMillis = System.currentTimeMillis();
+ }
+
+ public void endOfData() {
+ timer.cancel();
+ timer.purge();
+ status.setStatus(StatusCode.OFFLINE, "SVT hit monitor went offline.");
+ status.setActive(false);
+ }
+}
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 (rev 0)
+++ java/trunk/monitoring-app/src/main/resources/org/hps/monitoring/config/default_config.prop 2014-07-29 19:59:29 UTC (rev 829)
@@ -0,0 +1,38 @@
+# Wed Jul 16 13:48:13 PDT 2014
+# Monitoring Application configuration
+
+# job settings
+autoSaveAida=true
+autoSaveAidaFileName=monitoringPlots.aida
+detectorName=HPS-TestRun-v5
+disconnectOnError=true
+eventBuilderClassName=org.hps.evio.LCSimTestRunEventBuilder
+logFileName=
+logLevel=ALL
+logToFile=false
+#steeringFile=
+steeringResource=/org/hps/steering/monitoring/TestRunMonitoring.lcsim
+steeringType=RESOURCE
+
+# event source
+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
+
+
SVNspam 0.1