5 added + 4 removed + 18 modified, total 27 files
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/ConnectionPanel.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/ConnectionPanel.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -15,11 +15,11 @@
import javax.swing.JOptionPane;
import javax.swing.JTextField;
+import org.hps.monitoring.record.etevent.EtConnectionParameters;
import org.jlab.coda.et.enums.Mode;
/**
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: ConnectionPanel.java,v 1.24 2013/11/05 17:15:04 jeremy Exp $
*/
class ConnectionPanel extends FieldsPanel {
@@ -33,10 +33,10 @@
private JTextField qSizeField;
private JTextField positionField;
private JTextField ppositionField;
- private JComboBox waitComboBox;
+ private JComboBox<?> waitComboBox;
private JTextField waitTimeField;
private JTextField prescaleField;
- private ConnectionParameters connectionParameters;
+ private EtConnectionParameters connectionParameters;
static final String[] waitModes = {
Mode.SLEEP.toString(),
Mode.TIMED.toString(),
@@ -69,28 +69,28 @@
prescaleField = addField("Prescale", 8);
// Set default connection parameters which are pushed to GUI.
- setConnectionParameters(new ConnectionParameters());
+ setConnectionParameters(new EtConnectionParameters());
}
/**
* Get the connection parameters.
* @return The connection parameters.
*/
- ConnectionParameters getConnectionParameters() {
- connectionParameters = new ConnectionParameters();
- connectionParameters.etName = etNameField.getText();
- connectionParameters.host = hostField.getText();
- connectionParameters.port = Integer.parseInt(portField.getText());
- connectionParameters.blocking = blockingCheckBox.isSelected();
- connectionParameters.verbose = verboseCheckBox.isSelected();
- connectionParameters.statName = statNameField.getText();
- connectionParameters.chunk = Integer.parseInt(chunkField.getText());
- connectionParameters.qSize = Integer.parseInt(qSizeField.getText());
- connectionParameters.position = Integer.parseInt(positionField.getText());
- connectionParameters.pposition = Integer.parseInt(ppositionField.getText());
- connectionParameters.waitMode = getWaitMode();
- connectionParameters.waitTime = Integer.parseInt(waitTimeField.getText());
- connectionParameters.prescale = Integer.parseInt(prescaleField.getText());
+ EtConnectionParameters getConnectionParameters() {
+ 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()));
return connectionParameters;
}
@@ -129,21 +129,21 @@
* Set the connection parameters and push into the GUI.
* @param cn The connection parameters.
*/
- private void setConnectionParameters(ConnectionParameters cn) {
- etNameField.setText(cn.etName);
- hostField.setText(cn.host);
- portField.setText(Integer.toString(cn.port));
- blockingCheckBox.setSelected(cn.blocking);
- verboseCheckBox.setSelected(cn.verbose);
- statNameField.setText(cn.statName);
- chunkField.setText(Integer.toString(cn.chunk));
- qSizeField.setText(Integer.toString(cn.qSize));
- positionField.setText(Integer.toString(cn.position));
- ppositionField.setText(Integer.toString(cn.pposition));
- setWaitMode(cn.waitMode);
- waitTimeField.setText(Integer.toString(cn.waitTime));
- prescaleField.setText(Integer.toString(cn.prescale));
- this.connectionParameters = cn;
+ private void setConnectionParameters(EtConnectionParameters 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()));
+ this.connectionParameters = connectionParameters;
}
/**
@@ -194,7 +194,7 @@
* Reset the connection parameters.
*/
void reset() {
- setConnectionParameters(new ConnectionParameters());
+ setConnectionParameters(new EtConnectionParameters());
}
/**
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/ConnectionParameters.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/ConnectionParameters.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -1,75 +0,0 @@
-package org.hps.monitoring;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.jlab.coda.et.EtConstants;
-import org.jlab.coda.et.enums.Mode;
-
-/**
- * Connection parameters for ET system consumer.
- */
-class ConnectionParameters {
-
- /**
- * Parameters that are externally settable from within the package.
- */
- String etName = "ETBuffer";
- String host = null;
- int port = EtConstants.serverPort;
- boolean blocking = false;
- boolean verbose = false;
- String statName = "MY_STATION";
- int chunk = 1;
- int qSize = 0;
- int position = 1;
- int pposition = 0;
- int flowMode = EtConstants.stationSerial;
- Mode waitMode = Mode.TIMED;
- int waitTime = 10000000; // wait time in microseconds
- int prescale = 1;
-
- /**
- * Class constructor.
- */
- public ConnectionParameters() {
- // Set the default host to this machine.
- try {
- InetAddress addr = InetAddress.getLocalHost();
- host = addr.getHostName();
- } catch (UnknownHostException e) {
- throw new ConnectionParametersException("Unable to assign default host.");
- }
- }
-
- /**
- * This is thrown from the constructor if there a problem setting up the default host.
- */
- public class ConnectionParametersException extends RuntimeException {
- ConnectionParametersException(String msg) {
- super(msg);
- }
- }
-
- /**
- * Convert this class to a readable string (properties format).
- */
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("etName: " + etName + '\n');
- buf.append("host: " + host + '\n');
- buf.append("port: " + port + '\n');
- buf.append("blocking: " + blocking + '\n');
- buf.append("verbose: " + verbose + '\n');
- buf.append("statName: " + statName + '\n');
- buf.append("chunk: " + chunk + '\n');
- buf.append("qSize: " + qSize + '\n');
- buf.append("position: " + position + '\n');
- buf.append("pposition: " + pposition + '\n');
- buf.append("flowMode: " + flowMode + '\n');
- buf.append("waitMode: " + waitMode + '\n');
- buf.append("waitTime: " + waitTime + '\n');
- buf.append("prescale: " + prescale + '\n');
- return buf.toString();
- }
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/DefaultEtEventProcessor.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/DefaultEtEventProcessor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -11,8 +11,9 @@
import org.hps.evio.EventConstants;
import org.hps.evio.LCSimEventBuilder;
+import org.hps.monitoring.record.etevent.EtConnection;
+import org.hps.monitoring.record.etevent.EtEventListener;
import org.jlab.coda.et.EtEvent;
-import org.jlab.coda.et.enums.Modify;
import org.jlab.coda.et.exception.EtTimeoutException;
import org.jlab.coda.jevio.EvioEvent;
import org.jlab.coda.jevio.EvioException;
@@ -29,7 +30,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: DefaultEtEventProcessor.java,v 1.13 2013/10/25 23:13:53 jeremy Exp $
*/
-public class DefaultEtEventProcessor implements EtEventProcessor {
+public class DefaultEtEventProcessor implements OldEtEventProcessor {
private int maxEvents;
private int eventsProcessed;
@@ -217,7 +218,8 @@
* WARNING: This can potentially block forever until it receives events.
*/
blocked = true;
- EtEvent[] mevs = et.sys.getEvents(et.att, et.param.waitMode, Modify.NOTHING, et.param.waitTime, et.param.chunk);
+ //EtEvent[] mevs = et.sys.getEvents(et.att, et.param.waitMode, Modify.NOTHING, et.param.waitTime, et.param.chunk);
+ EtEvent[] mevs = et.readEtEvents();
blocked = false;
// Loop over retrieved EtEvents.
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtConnection.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtConnection.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -1,134 +0,0 @@
-package org.hps.monitoring;
-
-import org.jlab.coda.et.EtAttachment;
-import org.jlab.coda.et.EtConstants;
-import org.jlab.coda.et.EtStation;
-import org.jlab.coda.et.EtStationConfig;
-import org.jlab.coda.et.EtSystem;
-import org.jlab.coda.et.EtSystemOpenConfig;
-
-/**
- * Create an EtSystem and EtAttachment from ConnectionParameters.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-class EtConnection {
-
- ConnectionParameters param;
- EtSystem sys;
- EtAttachment att;
- EtStation stat;
-
- /**
- * Class constructor.
- * @param param The connection parameters.
- * @param sys The ET system.
- * @param att The ET attachment.
- * @param stat The ET station.
- */
- private EtConnection(ConnectionParameters param, EtSystem sys, EtAttachment att, EtStation stat) {
- this.param = param;
- this.sys = sys;
- this.att = att;
- this.stat = stat;
- }
-
- /**
- * Get the ET system.
- * @return The ET system.
- */
- EtSystem getEtSystem() {
- return sys;
- }
-
- /**
- * Get the ET attachment.
- * @return The ET attachment.
- */
- EtAttachment getEtAttachment() {
- return att;
- }
-
- /**
- * Get the ET station.
- * @return The ET station.
- */
- EtStation getEtStation() {
- return stat;
- }
-
- /**
- * Get the connection parameters.
- * @return The connection parameters.
- */
- ConnectionParameters getConnectionParameters() {
- return param;
- }
-
- /**
- * Cleanup the ET connection.
- */
- void cleanup() {
- boolean debug = false;
- try {
- if (debug)
- System.out.println("ET cleanup - sys.detach ...");
- sys.detach(att);
- if (debug)
- System.out.println("ET cleanup - sys.removeStation ...");
- sys.removeStation(stat);
- if (debug)
- System.out.println("ET cleanup - sys.close ...");
- sys.close();
- if (debug)
- System.out.println("ET cleanup - successful");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Create an ET connection from connection parameters.
- * @param cn The connection parameters.
- * @return The ET connection.
- */
- static EtConnection createEtConnection(ConnectionParameters cn) {
- try {
-
- // make a direct connection to ET system's tcp server
- EtSystemOpenConfig config = new EtSystemOpenConfig(cn.etName, cn.host, cn.port);
-
- // create ET system object with verbose debugging output
- EtSystem sys = new EtSystem(config, EtConstants.debugInfo);
- sys.open();
-
- // configuration of a new station
- EtStationConfig statConfig = new EtStationConfig();
- statConfig.setFlowMode(cn.flowMode);
- if (!cn.blocking) {
- statConfig.setBlockMode(EtConstants.stationNonBlocking);
- if (cn.qSize > 0) {
- statConfig.setCue(cn.qSize);
- }
- }
- // Set prescale.
- if (cn.prescale > 0) {
- System.out.println("setting prescale to " + cn.prescale);
- statConfig.setPrescale(cn.prescale);
- }
-
- // Create the station.
- EtStation stat = sys.createStation(statConfig, cn.statName, cn.position, cn.pposition);
-
- // attach to new station
- EtAttachment att = sys.attach(stat);
-
- // Return new connection.
- return new EtConnection(cn, sys, att, stat);
-
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtEventListener.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtEventListener.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -1,51 +0,0 @@
-package org.hps.monitoring;
-
-/**
- * Interface for notifying listeners of ET ring events.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: EtEventListener.java,v 1.1 2012/05/03 16:59:28 jeremy Exp $
- */
-// FIXME: Should all the callback methods get an EtEvent or event number?
-interface EtEventListener {
-
- /**
- * Called at beginning of event processing session.
- */
- void begin();
-
- /**
- * Called at start of single EtEvent.
- */
- void startOfEvent();
-
- /**
- * Called at end of processing single EtEvent.
- */
- void endOfEvent();
-
- /**
- * Called when an error occurs processing current EtEvent.
- */
- void errorOnEvent();
-
- /**
- * Called when event processing session finishes.
- */
- void finish();
-
- /**
- * Called when a Pre Start event is received from the ET ring,
- * indicating start of run.
- * @param seconds Unix time in seconds.
- * @param runNumber The run number.
- */
- void prestart(int seconds, int runNumber);
-
- /**
- * Called when an End Event is received from the ET ring,
- * indicating end of run.
- * @param seconds Unix time in seconds.
- * @param nevents Number of events in run.
- */
- void endRun(int seconds, int nevents);
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtEventProcessor.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EtEventProcessor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -1,151 +0,0 @@
-package org.hps.monitoring;
-
-import java.util.logging.Level;
-
-import org.jlab.coda.et.EtEvent;
-import org.jlab.coda.et.exception.EtTimeoutException;
-
-/**
- * This is an interface for processing EtEvent objects and receiving callbacks
- * via an {@link EtEventListener}.
- * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: EtEventProcessor.java,v 1.4 2013/11/05 17:15:04 jeremy Exp $
- */
-interface EtEventProcessor
-{
- /**
- * Process a single EtEvent.
- * @param event The ET event.
- * @throws EventProcessingException if there was an error processing the event.
- * @throws MaxEventsException if the maximum number of events was reached or exceeded.
- */
- void processEtEvent(EtEvent event) throws EventProcessingException, MaxEventsException;
-
- /**
- * Process the next array of EtEvents. This method may block for a long time or forever.
- * The default implementation calls processEtEvent() on each event, but this is not required.
- * @throws EtTimeoutException if the connection times out.
- * @throws MaxEventsException if the maximum number of events was reached or exceeded.
- * @throws EventProcessingException if there was an error processing events.
- * @throws Exception if some other exception occurs.
- */
- void processEtEvents() throws EtTimeoutException, MaxEventsException, EventProcessingException, Exception;
-
- /**
- * Process all incoming EtEvents until ET system goes down or stop is requested.
- */
- void process();
-
- /**
- * Get the current status as a {@link ConnectionStatus} code.
- */
- int getStatus();
-
- /**
- * Get the total number of events processing thusfar, including those with errors.
- * @return The number of events processed.
- */
- int getNumberOfEventsProcessed();
-
- /**
- * Get the maximum number of event to process before automatically disconnecting.
- * @return The maximum number of events to process.
- */
- int getMaxEvents();
-
- /**
- * Reset the number of events processed to zero.
- */
- void resetNumberOfEventsProcessed();
-
- /**
- * Add a listener that will receive notifications during event processing.
- * @param callme The ET event listener.
- */
- void addListener(EtEventListener callme);
-
- /**
- * Request that the processor stop processing events.
- */
- void stop();
-
- /**
- * Set the maximum number of events to process before disconnecting.
- * @param maxEvents The maximum number of events to process.
- */
- void setMaxEvents(int maxEvents);
-
- /**
- * Turn pause mode on or off.
- * @param p The pause mode setting; true for on; false for off.
- */
- void pauseMode(boolean p);
-
- /**
- * If using pause mode, this will get the next set of events and then pause again.
- */
- void nextEvents();
-
- /**
- * Set the log level of this object.
- * @param level The log level.
- */
- void setLogLevel(Level level);
-
- /**
- * Check if the processor is done.
- * @return True if processer is done processing events; false if not.
- */
- boolean done();
-
- /**
- * Check if the processor is in the blocked state, e.g. if it is waiting
- * for events from the ET ring.
- * @return True if blocked; false if not.
- */
- boolean blocked();
-
- /**
- * Exception that is thrown when an error occurs during event processing.
- */
- static class EventProcessingException extends Exception {
-
- /**
- * Class constructor.
- * @param e Another Exception object.
- */
- EventProcessingException(Exception e) {
- super(e);
- }
-
- /**
- * Class constructor.
- * @param m The error message.
- * @param e Another Exception object.
- */
- EventProcessingException(String m, Exception e) {
- super(m, e);
- }
-
- /**
- * Class constructor.
- * @param m The error message.
- */
- EventProcessingException(String m) {
- super(m);
- }
- }
-
- /**
- * Exception that is throw when the {@link EtEventProcessor#getMaxEvents()} is exceeded.
- */
- static final class MaxEventsException extends Exception {
-
- /**
- * Class constructor
- */
- MaxEventsException() {
- super("Maximum number of events was reached.");
- }
- }
-}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EventButtonsPanel.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EventButtonsPanel.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -32,7 +32,7 @@
c.insets = new Insets(0, 0, 0, 10);
connectButton = new JButton("Connect");
connectButton.setEnabled(true);
- connectButton.setActionCommand(MonitoringCommands.connectCmd);
+ connectButton.setActionCommand(MonitoringCommands.CONNECT);
add(connectButton, c);
c = new GridBagConstraints();
@@ -40,7 +40,7 @@
c.gridy = 0;
c.insets = new Insets(0, 0, 0, 10);
pauseButton = new JButton("Pause");
- pauseButton.setActionCommand(MonitoringCommands.pauseCmd);
+ pauseButton.setActionCommand(MonitoringCommands.PAUSE);
pauseButton.setEnabled(false);
add(pauseButton, c);
@@ -49,7 +49,7 @@
c.gridy = 0;
nextEventsButton = new JButton("Next Event");
nextEventsButton.setEnabled(false);
- nextEventsButton.setActionCommand(MonitoringCommands.nextCmd);
+ nextEventsButton.setActionCommand(MonitoringCommands.NEXT);
add(nextEventsButton, c);
}
@@ -60,10 +60,10 @@
void toggleConnectButton() {
if (connectButton.getText().equals("Connect")) {
connectButton.setText("Disconnect");
- connectButton.setActionCommand(MonitoringCommands.disconnectCmd);
+ connectButton.setActionCommand(MonitoringCommands.DISCONNECT);
} else {
connectButton.setText("Connect");
- connectButton.setActionCommand(MonitoringCommands.connectCmd);
+ connectButton.setActionCommand(MonitoringCommands.CONNECT);
}
}
@@ -101,10 +101,10 @@
this.nextEventsButton.setEnabled(enable);
if (enable) {
pauseButton.setText("Resume");
- pauseButton.setActionCommand(MonitoringCommands.resumeCmd);
+ pauseButton.setActionCommand(MonitoringCommands.RESUME);
} else {
pauseButton.setText("Pause");
- pauseButton.setActionCommand(MonitoringCommands.pauseCmd);
+ pauseButton.setActionCommand(MonitoringCommands.PAUSE);
}
}
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EventPanel.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EventPanel.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -14,6 +14,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: EventPanel.java,v 1.16 2013/11/05 17:15:04 jeremy Exp $
*/
+// FIXME: Clock seems to be running after disconnect!!!
class EventPanel extends FieldsPanel {
private JTextField eventCounterField; // number of events in this job
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EvioFileProducer.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/EvioFileProducer.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -25,6 +25,7 @@
*
*/
// TODO: Add option to set number of events in put array.
+// TODO: Move to sub-package.
public class EvioFileProducer {
private List<File> evioFiles = new ArrayList<File>();
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/JobPanel.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/JobPanel.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -25,13 +25,13 @@
private JCheckBox disconnectWarningCheckBox;
private JCheckBox disconnectOnErrorCheckBox;
private JTextField eventBuilderField;
- private JComboBox steeringTypeComboBox;
+ private JComboBox<?> steeringTypeComboBox;
private JTextField steeringFileField;
- private JComboBox steeringResourcesComboBox;
+ private JComboBox<?> steeringResourcesComboBox;
private JCheckBox logCheckBox;
private JTextField logFileField;
private JCheckBox pauseModeCheckBox;
- private JComboBox logLevelComboBox;
+ private JComboBox<?> logLevelComboBox;
private JTextField aidaSaveField;
private JCheckBox aidaSaveCheckBox;
@@ -69,16 +69,15 @@
disconnectOnErrorCheckBox = addCheckBox("Disconnect on error", false, true);
disconnectWarningCheckBox = addCheckBox("Warn before disconnect", true, true);
logLevelComboBox = addComboBox("Log Level", this.logLevels);
- logLevelComboBox.setActionCommand(MonitoringCommands.logLevelCmd);
+ logLevelComboBox.setActionCommand(MonitoringCommands.SET_LOG_LEVEL);
steeringTypeComboBox = addComboBox("Steering Type", steeringTypes);
steeringFileField = addField("Steering File", 35);
steeringResourcesComboBox = addComboBoxMultiline("Steering File Resource",
SteeringFileUtil.getAvailableSteeringFileResources(steeringPackage));
- //steeringResourcesComboBox = addComboBox("Steering File Resource", new String[]{});
- steeringResourcesComboBox.setActionCommand(MonitoringCommands.steeringResourceCmd);
+ steeringResourcesComboBox.setActionCommand(MonitoringCommands.SET_STEERING_RESOURCE);
detectorNameField = addField("Detector Name", 20);
eventBuilderField = addField("Event Builder Class", 30);
- eventBuilderField.setActionCommand(MonitoringCommands.eventBuilderCmd);
+ 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);
@@ -171,7 +170,7 @@
boolean okay = true;
try {
// Test that the event builder can be created without throwing any exceptions.
- Class eventBuilderClass = Class.forName(eventBuilderClassName);
+ Class<?> eventBuilderClass = Class.forName(eventBuilderClassName);
eventBuilderClass.newInstance();
}
catch (ClassNotFoundException e) {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringAnalysisFactory.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringAnalysisFactory.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -17,11 +17,8 @@
* @version $Id: MonitoringAnalysisFactory.java,v 1.4 2013/12/10 07:36:40 jeremy Exp $
*/
public class MonitoringAnalysisFactory extends AnalysisFactory {
-
- //Map<String,IPlotterFactory> plotterFactories = new HashMap<String,IPlotterFactory>();
public MonitoringAnalysisFactory() {
- System.out.println("MonitoringAnalysisFactory - ctor");
}
/**
@@ -41,30 +38,13 @@
* Create a named plotter factory for the monitoring application.
*/
public IPlotterFactory createPlotterFactory(String name) {
- System.out.println("createPlotterFactory - " + name);
- //if (!plotterFactories.containsKey(name)) {
- // plotterFactories.put(name, new MonitoringPlotFactory(name));
- //}
return new MonitoringPlotFactory(name);
- //return plotterFactories.get(name);
}
/**
* Create an unnamed plotter factory for the monitoring application.
*/
public IPlotterFactory createPlotterFactory() {
- //System.out.println("createPlotterFactory - w/o name");
return new MonitoringPlotFactory(null);
}
-
- /*
- public void clearPlotterFactories() {
- if (plotterFactories.size() > 0) {
- System.out.println("clearPlotterFactories - clearing " + plotterFactories.size() + " plotterFactories");
- plotterFactories.clear();
- } else {
- System.out.println("clearPlotterFactories - plotterFactories is empty");
- }
- }
- */
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplication.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplication.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -1,33 +1,33 @@
package org.hps.monitoring;
-import static org.hps.monitoring.MonitoringCommands.aidaAutoSaveCmd;
-import static org.hps.monitoring.MonitoringCommands.clearLogTableCmd;
-import static org.hps.monitoring.MonitoringCommands.connectCmd;
-import static org.hps.monitoring.MonitoringCommands.disconnectCmd;
-import static org.hps.monitoring.MonitoringCommands.eventBuilderCmd;
-import static org.hps.monitoring.MonitoringCommands.eventRefreshCmd;
-import static org.hps.monitoring.MonitoringCommands.exitCmd;
-import static org.hps.monitoring.MonitoringCommands.loadConnectionCmd;
-import static org.hps.monitoring.MonitoringCommands.loadJobSettingsCmd;
-import static org.hps.monitoring.MonitoringCommands.logLevelCmd;
-import static org.hps.monitoring.MonitoringCommands.logToFileCmd;
-import static org.hps.monitoring.MonitoringCommands.logToTerminalCmd;
-import static org.hps.monitoring.MonitoringCommands.nextCmd;
-import static org.hps.monitoring.MonitoringCommands.pauseCmd;
-import static org.hps.monitoring.MonitoringCommands.resetConnectionSettingsCmd;
-import static org.hps.monitoring.MonitoringCommands.resetDriversCmd;
-import static org.hps.monitoring.MonitoringCommands.resetEventsCmd;
-import static org.hps.monitoring.MonitoringCommands.resetJobSettingsCmd;
-import static org.hps.monitoring.MonitoringCommands.resumeCmd;
-import static org.hps.monitoring.MonitoringCommands.saveConnectionCmd;
-import static org.hps.monitoring.MonitoringCommands.saveJobSettingsCmd;
-import static org.hps.monitoring.MonitoringCommands.saveLogTableCmd;
-import static org.hps.monitoring.MonitoringCommands.savePlotsCmd;
-import static org.hps.monitoring.MonitoringCommands.screenshotCmd;
-import static org.hps.monitoring.MonitoringCommands.setMaxEventsCmd;
-import static org.hps.monitoring.MonitoringCommands.steeringFileCmd;
-import static org.hps.monitoring.MonitoringCommands.steeringResourceCmd;
-import static org.hps.monitoring.MonitoringCommands.updateTimeCmd;
+import static org.hps.monitoring.MonitoringCommands.AIDA_AUTO_SAVE;
+import static org.hps.monitoring.MonitoringCommands.CLEAR_LOG_TABLE;
+import static org.hps.monitoring.MonitoringCommands.CONNECT;
+import static org.hps.monitoring.MonitoringCommands.DISCONNECT;
+import static org.hps.monitoring.MonitoringCommands.EDIT_EVENT_REFRESH;
+import static org.hps.monitoring.MonitoringCommands.EXIT;
+import static org.hps.monitoring.MonitoringCommands.LOAD_CONNECTION;
+import static org.hps.monitoring.MonitoringCommands.LOAD_JOB_SETTINGS;
+import static org.hps.monitoring.MonitoringCommands.LOG_TO_FILE;
+import static org.hps.monitoring.MonitoringCommands.LOG_TO_TERMINAL;
+import static org.hps.monitoring.MonitoringCommands.NEXT;
+import static org.hps.monitoring.MonitoringCommands.PAUSE;
+import static org.hps.monitoring.MonitoringCommands.RESET_CONNECTION_SETTINGS;
+import static org.hps.monitoring.MonitoringCommands.RESET_DRIVERS;
+import static org.hps.monitoring.MonitoringCommands.RESET_EVENTS;
+import static org.hps.monitoring.MonitoringCommands.RESET_JOB_SETTINGS;
+import static org.hps.monitoring.MonitoringCommands.RESUME;
+import static org.hps.monitoring.MonitoringCommands.SAVE_CONNECTION;
+import static org.hps.monitoring.MonitoringCommands.SAVE_JOB_SETTINGS;
+import static org.hps.monitoring.MonitoringCommands.SAVE_LOG_TABLE;
+import static org.hps.monitoring.MonitoringCommands.SAVE_PLOTS;
+import static org.hps.monitoring.MonitoringCommands.SCREENSHOT;
+import static org.hps.monitoring.MonitoringCommands.SET_EVENT_BUILDER;
+import static org.hps.monitoring.MonitoringCommands.SET_LOG_LEVEL;
+import static org.hps.monitoring.MonitoringCommands.SET_MAX_EVENTS;
+import static org.hps.monitoring.MonitoringCommands.SET_STEERING_FILE;
+import static org.hps.monitoring.MonitoringCommands.SET_STEERING_RESOURCE;
+import static org.hps.monitoring.MonitoringCommands.UPDATE_TIME;
import java.awt.AWTException;
import java.awt.BorderLayout;
@@ -82,6 +82,9 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.hps.evio.LCSimEventBuilder;
+import org.hps.monitoring.record.etevent.EtConnection;
+import org.hps.monitoring.record.etevent.EtConnectionParameters;
+import org.hps.monitoring.record.etevent.EtEventListener;
import org.hps.util.Resettable;
import org.lcsim.job.JobControlManager;
import org.lcsim.util.Driver;
@@ -103,6 +106,7 @@
// standard Driver API used instead. Resettable can maybe be replaced by startOfData().
// Not sure about Redrawable; maybe it isn't needed at all.
// FIXME: Tracebacks from errors should be caught and written into the log table.
+// TODO: Replace DefaultEtEventProcessor with EventProcessingChain class.
public class MonitoringApplication {
// Top-level Swing components.
@@ -140,14 +144,14 @@
private final PrintStream sysErr = System.err;
// ET connection parameters and state.
- private ConnectionParameters connectionParameters;
+ private EtConnectionParameters connectionParameters;
private EtConnection connection;
private int connectionStatus = ConnectionStatus.DISCONNECTED;
// Event processing objects.
private JobControlManager jobManager;
private LCSimEventBuilder eventBuilder;
- private EtEventProcessor eventProcessor;
+ private OldEtEventProcessor eventProcessor;
private Thread eventProcessingThread;
// Job timing.
@@ -350,18 +354,18 @@
connectionMenu.setMnemonic(KeyEvent.VK_C);
menuBar.add(connectionMenu);
- connectItem = addMenuItem("Connect", KeyEvent.VK_C, connectCmd, true, "Connect to ET system using parameters from connection panel.", connectionMenu);
- disconnectItem = addMenuItem("Disconnect", KeyEvent.VK_D, disconnectCmd, false, "Disconnect from the current ET session.", connectionMenu);
- resetConnectionItem = addMenuItem("Reset Connection Settings", KeyEvent.VK_R, resetConnectionSettingsCmd, true, "Reset connection settings to defaults.", connectionMenu);
- connectionLoadItem = addMenuItem("Load Connection...", KeyEvent.VK_L, loadConnectionCmd, true, "Load connection settings from a saved properties file.", connectionMenu);
- addMenuItem("Save Connection...", KeyEvent.VK_S, saveConnectionCmd, true, "Save connection settings to a properties file.", connectionMenu);
- addMenuItem("Exit", KeyEvent.VK_X, exitCmd, true, "Exit from the application.", 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);
+ addMenuItem("Exit", KeyEvent.VK_X, EXIT, true, "Exit from the application.", connectionMenu);
JMenu eventMenu = new JMenu("Event");
eventMenu.setMnemonic(KeyEvent.VK_E);
menuBar.add(eventMenu);
- addMenuItem("Reset Event Monitor", KeyEvent.VK_E, resetEventsCmd, true, "Reset timer and counters in the event monitor tab.", eventMenu);
+ addMenuItem("Reset Event Monitor", KeyEvent.VK_E, RESET_EVENTS, true, "Reset timer and counters in the event monitor tab.", eventMenu);
/**
* FIXME: Rest of these should be converted to use the addMenuItem() helper
@@ -370,14 +374,14 @@
JMenuItem eventRefreshItem = new JMenuItem("Set Event Refresh...");
eventRefreshItem.setMnemonic(KeyEvent.VK_V);
- eventRefreshItem.setActionCommand(eventRefreshCmd);
+ eventRefreshItem.setActionCommand(EDIT_EVENT_REFRESH);
eventRefreshItem.addActionListener(actionListener);
eventRefreshItem.setToolTipText("Set the number of events between GUI updates.");
eventMenu.add(eventRefreshItem);
JMenuItem maxEventsItem = new JMenuItem("Set Max Events...");
maxEventsItem.setMnemonic(KeyEvent.VK_M);
- maxEventsItem.setActionCommand(setMaxEventsCmd);
+ maxEventsItem.setActionCommand(SET_MAX_EVENTS);
maxEventsItem.addActionListener(actionListener);
maxEventsItem.setToolTipText("Set the maximum number of events to process in one session.");
eventMenu.add(maxEventsItem);
@@ -388,42 +392,42 @@
saveJobSettingsItem = new JMenuItem("Save Job Settings...");
saveJobSettingsItem.setMnemonic(KeyEvent.VK_J);
- saveJobSettingsItem.setActionCommand(saveJobSettingsCmd);
+ saveJobSettingsItem.setActionCommand(SAVE_JOB_SETTINGS);
saveJobSettingsItem.addActionListener(actionListener);
saveJobSettingsItem.setToolTipText("Save Job Settings configuration to a properties file.");
jobMenu.add(saveJobSettingsItem);
loadJobSettingsItem = new JMenuItem("Load Job Settings...");
loadJobSettingsItem.setMnemonic(KeyEvent.VK_L);
- loadJobSettingsItem.setActionCommand(loadJobSettingsCmd);
+ loadJobSettingsItem.setActionCommand(LOAD_JOB_SETTINGS);
loadJobSettingsItem.addActionListener(actionListener);
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(resetJobSettingsCmd);
+ resetJobSettingsItem.setActionCommand(RESET_JOB_SETTINGS);
resetJobSettingsItem.addActionListener(actionListener);
resetJobSettingsItem.setToolTipText("Reset Job Settings to the defaults.");
jobMenu.add(resetJobSettingsItem);
steeringItem = new JMenuItem("Set Steering File...");
steeringItem.setMnemonic(KeyEvent.VK_S);
- steeringItem.setActionCommand(steeringFileCmd);
+ steeringItem.setActionCommand(SET_STEERING_FILE);
steeringItem.addActionListener(actionListener);
steeringItem.setToolTipText("Set the job's LCSim steering file.");
jobMenu.add(steeringItem);
aidaAutoSaveItem = new JMenuItem("AIDA Auto Save File...");
aidaAutoSaveItem.setMnemonic(KeyEvent.VK_A);
- aidaAutoSaveItem.setActionCommand(aidaAutoSaveCmd);
+ aidaAutoSaveItem.setActionCommand(AIDA_AUTO_SAVE);
aidaAutoSaveItem.addActionListener(actionListener);
aidaAutoSaveItem.setToolTipText("Select name of file to auto save AIDA plots at end of job.");
jobMenu.add(aidaAutoSaveItem);
savePlotsItem = new JMenuItem("Save Plots to AIDA File...");
savePlotsItem.setMnemonic(KeyEvent.VK_P);
- savePlotsItem.setActionCommand(savePlotsCmd);
+ savePlotsItem.setActionCommand(SAVE_PLOTS);
savePlotsItem.addActionListener(actionListener);
savePlotsItem.setEnabled(false);
savePlotsItem.setToolTipText("Save plots from default AIDA tree to an output file.");
@@ -431,7 +435,7 @@
resetDriversItem = new JMenuItem("Reset LCSim Drivers");
resetDriversItem.setMnemonic(KeyEvent.VK_D);
- resetDriversItem.setActionCommand(resetDriversCmd);
+ resetDriversItem.setActionCommand(RESET_DRIVERS);
resetDriversItem.addActionListener(actionListener);
resetDriversItem.setEnabled(false);
resetDriversItem.setToolTipText("Reset Drivers that implement the Resettable interface.");
@@ -439,7 +443,7 @@
logItem = new JMenuItem("Redirect to File...");
logItem.setMnemonic(KeyEvent.VK_F);
- logItem.setActionCommand(logToFileCmd);
+ logItem.setActionCommand(LOG_TO_FILE);
logItem.addActionListener(actionListener);
logItem.setEnabled(true);
logItem.setToolTipText("Redirect job's standard out and err to a file.");
@@ -447,7 +451,7 @@
terminalItem = new JMenuItem("Redirect to Terminal");
terminalItem.setMnemonic(KeyEvent.VK_T);
- terminalItem.setActionCommand(logToTerminalCmd);
+ terminalItem.setActionCommand(LOG_TO_TERMINAL);
terminalItem.addActionListener(actionListener);
terminalItem.setEnabled(false);
terminalItem.setToolTipText("Redirect job's standard out and err back to the terminal.");
@@ -455,7 +459,7 @@
JMenuItem screenshotItem = new JMenuItem("Take a screenshot...");
screenshotItem.setMnemonic(KeyEvent.VK_N);
- screenshotItem.setActionCommand(screenshotCmd);
+ screenshotItem.setActionCommand(SCREENSHOT);
screenshotItem.addActionListener(actionListener);
screenshotItem.setToolTipText("Save a full screenshot to a " + screenshotFormat + " file.");
jobMenu.add(screenshotItem);
@@ -466,12 +470,12 @@
JMenuItem saveLogItem = new JMenuItem("Save log to file...");
saveLogItem.setMnemonic(KeyEvent.VK_S);
- saveLogItem.setActionCommand(saveLogTableCmd);
+ saveLogItem.setActionCommand(SAVE_LOG_TABLE);
saveLogItem.addActionListener(actionListener);
saveLogItem.setToolTipText("Save the log records to a tab delimited text file.");
logMenu.add(saveLogItem);
- addMenuItem("Clear log", KeyEvent.VK_C, clearLogTableCmd, true, "Clear the log table of all messages.", logMenu);
+ addMenuItem("Clear log", KeyEvent.VK_C, CLEAR_LOG_TABLE, true, "Clear the log table of all messages.", logMenu);
}
/**
@@ -650,7 +654,7 @@
*/
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
- if (cmd != MonitoringCommands.updateTimeCmd) {
+ if (cmd != MonitoringCommands.UPDATE_TIME) {
// Log actions performed. Catch errors in case logging is not initialized
// yet.
try {
@@ -659,61 +663,61 @@
xx.printStackTrace();
}
}
- if (connectCmd.equals(cmd)) {
+ if (CONNECT.equals(cmd)) {
startSessionThread();
- } else if (disconnectCmd.equals(cmd)) {
+ } else if (DISCONNECT.equals(cmd)) {
startDisconnectThread();
- } else if (eventRefreshCmd.equals(cmd)) {
+ } else if (EDIT_EVENT_REFRESH.equals(cmd)) {
setEventRefresh();
- } else if (savePlotsCmd.equals(cmd)) {
+ } else if (SAVE_PLOTS.equals(cmd)) {
savePlots();
- } else if (resetDriversCmd.equals(cmd)) {
+ } else if (RESET_DRIVERS.equals(cmd)) {
resetDrivers();
- } else if (logToFileCmd.equals(cmd)) {
+ } else if (LOG_TO_FILE.equals(cmd)) {
logToFile();
- } else if (logToTerminalCmd.equals(cmd)) {
+ } else if (LOG_TO_TERMINAL.equals(cmd)) {
logToTerminal();
- } else if (screenshotCmd.equals(cmd)) {
+ } else if (SCREENSHOT.equals(cmd)) {
chooseScreenshot();
- } else if (exitCmd.equals(cmd)) {
+ } else if (EXIT.equals(cmd)) {
exit();
- } else if (updateTimeCmd.equals(cmd)) {
+ } else if (UPDATE_TIME.equals(cmd)) {
updateTime();
- } else if (resetEventsCmd.equals(cmd)) {
+ } else if (RESET_EVENTS.equals(cmd)) {
resetJob();
- } else if (saveConnectionCmd.equals(cmd)) {
+ } else if (SAVE_CONNECTION.equals(cmd)) {
connectionPanel.save();
- } else if (loadConnectionCmd.equals(cmd)) {
+ } else if (LOAD_CONNECTION.equals(cmd)) {
connectionPanel.load();
- } else if (resetConnectionSettingsCmd.equals(cmd)) {
+ } else if (RESET_CONNECTION_SETTINGS.equals(cmd)) {
connectionPanel.reset();
- } else if (setMaxEventsCmd.equals(cmd)) {
+ } else if (SET_MAX_EVENTS.equals(cmd)) {
setMaxEvents();
- } else if (saveLogTableCmd.equals(cmd)) {
+ } else if (SAVE_LOG_TABLE.equals(cmd)) {
saveLogToFile();
- } else if (clearLogTableCmd.equals(cmd)) {
+ } else if (CLEAR_LOG_TABLE.equals(cmd)) {
clearLog();
- } else if (eventBuilderCmd.equals(cmd)) {
+ } else if (SET_EVENT_BUILDER.equals(cmd)) {
jobPanel.editEventBuilder();
- } else if (pauseCmd.equals(cmd)) {
+ } else if (PAUSE.equals(cmd)) {
pause();
- } else if (nextCmd.equals(cmd)) {
+ } else if (NEXT.equals(cmd)) {
next();
- } else if (resumeCmd.equals(cmd)) {
+ } else if (RESUME.equals(cmd)) {
resume();
- } else if (logLevelCmd.equals(cmd)) {
+ } else if (SET_LOG_LEVEL.equals(cmd)) {
setLogLevel();
- } else if (aidaAutoSaveCmd.equals(cmd)) {
+ } else if (AIDA_AUTO_SAVE.equals(cmd)) {
jobPanel.chooseAidaAutoSaveFile();
- } else if (saveJobSettingsCmd.equals(cmd)) {
+ } else if (SAVE_JOB_SETTINGS.equals(cmd)) {
saveJobSettings();
- } else if (loadJobSettingsCmd.equals(cmd)) {
+ } else if (LOAD_JOB_SETTINGS.equals(cmd)) {
loadJobSettings();
- } else if (resetJobSettingsCmd.equals(cmd)) {
+ } else if (RESET_JOB_SETTINGS.equals(cmd)) {
resetJobSettings();
- } else if (steeringResourceCmd.equals(cmd)) {
+ } else if (SET_STEERING_RESOURCE.equals(cmd)) {
steeringResourceSelected();
- } else if (steeringFileCmd.equals(cmd)) {
+ } else if (SET_STEERING_FILE.equals(cmd)) {
selectSteeringFile();
}
}
@@ -1430,7 +1434,7 @@
* Get the connection parameter settings from the connection panel.
* @return The connection parameters.
*/
- private ConnectionParameters getConnectionParameters() {
+ private EtConnectionParameters getConnectionParameters() {
return connectionPanel.getConnectionParameters();
}
@@ -1545,7 +1549,7 @@
if (cleanupThread.succeeded()) {
log(Level.FINE, "EtCleanupThread succeeded in disconnecting from ET system.");
} else {
- log(Level.SEVERE, "EtCleanupThread failed to disconnect. Your station <" + this.connection.stat.getName() + "> is zombified.");
+ log(Level.SEVERE, "EtCleanupThread failed to disconnect. Your station <" + this.connection.getEtStation().getName() + "> is zombified.");
// Make the cleanup thread yield.
cleanupThread.stopCleanup();
// Stop the cleanup thread.
@@ -1668,11 +1672,11 @@
// Set status to connected as there is now a live ET connection.
setConnectionStatus(ConnectionStatus.CONNECTED);
- log(Level.CONFIG, "Created ET connection to <" + connectionParameters.etName + ">.");
+ log(Level.CONFIG, "Created ET connection to <" + connectionParameters.getBufferName() + ">.");
} else {
// Some error occurred and the connection is not valid.
setConnectionStatus(ConnectionStatus.ERROR);
- log(Level.SEVERE, "Failed to create ET connection to <" + connectionParameters.etName + ">.");
+ log(Level.SEVERE, "Failed to create ET connection to <" + connectionParameters.getBufferName() + ">.");
throw new RuntimeException("Failed to create ET connection.");
}
}
@@ -1682,7 +1686,7 @@
*/
private void startTimer() {
timer = new Timer(1000, actionListener);
- timer.setActionCommand(updateTimeCmd);
+ timer.setActionCommand(UPDATE_TIME);
jobStartTime = System.currentTimeMillis();
timer.start();
log(Level.FINE, "Job timer started.");
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringCommands.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringCommands.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -9,33 +9,33 @@
private MonitoringCommands() {}
- static final String connectCmd = "connect";
- static final String disconnectCmd = "disconnect";
- static final String saveConnectionCmd = "saveConnection";
- static final String loadConnectionCmd = "loadConnection";
- static final String resetConnectionSettingsCmd = "resetConnectionSettings";
- static final String resetEventsCmd = "resetEvents";
- static final String savePlotsCmd = "savePlots";
- static final String resetDriversCmd = "resetDrivers";
- static final String eventBuilderCmd = "eventBuilder";
- static final String refreshCmd = "eventRefresh";
- static final String exitCmd = "exit";
- static final String logToFileCmd = "logToFile";
- static final String logToTerminalCmd = "logToTerminal";
- static final String screenshotCmd = "screenshot";
- static final String eventRefreshCmd = "eventRefreshEdit";
- static final String updateTimeCmd = "updateTime";
- static final String setMaxEventsCmd = "setMaxEvents";
- static final String saveLogTableCmd = "saveLogTable";
- static final String clearLogTableCmd = "clearLogTable";
- static final String pauseCmd = "pause";
- static final String resumeCmd = "resume";
- static final String nextCmd = "next";
- static final String logLevelCmd = "logLevel";
- static final String aidaAutoSaveCmd = "aidaAutoSave";
- static final String saveJobSettingsCmd = "saveJobSettings";
- static final String loadJobSettingsCmd = "loadJobSettings";
- static final String resetJobSettingsCmd = "resetJobSettings";
- static final String steeringResourceCmd = "steeringResource";
- static final String steeringFileCmd = "steeringFile";
+ static final String CONNECT = "connect";
+ static final String DISCONNECT = "disconnect";
+ static final String SAVE_CONNECTION = "saveConnection";
+ static final String LOAD_CONNECTION = "loadConnection";
+ static final String RESET_CONNECTION_SETTINGS = "resetConnectionSettings";
+ static final String RESET_EVENTS = "resetEvents";
+ static final String SAVE_PLOTS = "savePlots";
+ static final String RESET_DRIVERS = "resetDrivers";
+ static final String SET_EVENT_BUILDER = "setEventBuilder";
+ static final String SET_EVENT_REFRESH = "setEventRefresh";
+ static final String EXIT = "exit";
+ static final String LOG_TO_FILE = "logToFile";
+ static final String LOG_TO_TERMINAL = "logToTerminal";
+ static final String SCREENSHOT = "screenshot";
+ static final String EDIT_EVENT_REFRESH = "editEventRefresh";
+ static final String UPDATE_TIME = "updateTime";
+ static final String SET_MAX_EVENTS = "setMaxEvents";
+ static final String SAVE_LOG_TABLE = "saveLogTable";
+ static final String CLEAR_LOG_TABLE = "clearLogTable";
+ static final String PAUSE = "pause";
+ static final String RESUME = "resume";
+ static final String NEXT = "next";
+ static final String SET_LOG_LEVEL = "setLogLevel";
+ static final String AIDA_AUTO_SAVE = "aidaAutoSave";
+ static final String SAVE_JOB_SETTINGS = "saveJobSettings";
+ static final String LOAD_JOB_SETTINGS = "loadJobSettings";
+ static final String RESET_JOB_SETTINGS = "resetJobSettings";
+ static final String SET_STEERING_RESOURCE = "setSteeringResource";
+ static final String SET_STEERING_FILE = "setSteeringFile";
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringPlotFactory.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringPlotFactory.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -39,12 +39,9 @@
/* Enable embedded mode. */
setEmbedded(true);
-
+
+ /* Setup the root pane by adding a tab for this factory. */
setupRootPane(" ");
-
- /** Setup the root pane by adding a tab for this factory. */
- //rootPane.addTab(" ", tabs);
- //rootPane.setTabComponentAt(rootPane.getTabCount() - 1, new JLabel(" "));
}
/**
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/SteeringFileUtil.java 2014-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/SteeringFileUtil.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -19,7 +19,7 @@
/**
* Get the files that end in .lcsim from all loaded jar files.
- * @return
+ * @return A list of embedded steering file resources.
*/
public static String[] getAvailableSteeringFileResources(String packageName) {
List<String> resources = new ArrayList<String>();
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/AbstractRecordQueue.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -108,6 +108,7 @@
// null if queue is empty.
currentRecord = records.poll();
} catch (InterruptedException e) {
+ e.printStackTrace();
}
if (currentRecord == null) {
throw new NoSuchRecordException("No records in queue.");
@@ -117,11 +118,4 @@
public long size() {
return records.size();
}
-
- /*
- void drain() {
- do {
- } while (records.peek() != null);
- }
- */
}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -0,0 +1,427 @@
+package org.hps.monitoring.record;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.BufferUnderflowException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.freehep.record.source.RecordSource;
+import org.hps.evio.EventConstants;
+import org.hps.evio.LCSimEventBuilder;
+import org.hps.monitoring.record.etevent.EtEventLoop;
+import org.hps.monitoring.record.etevent.EtEventProcessor;
+import org.hps.monitoring.record.etevent.EtEventSource;
+import org.hps.monitoring.record.evio.EvioEventLoop;
+import org.hps.monitoring.record.evio.EvioEventProcessor;
+import org.hps.monitoring.record.evio.EvioEventQueue;
+import org.hps.monitoring.record.evio.EvioFileSource;
+import org.hps.monitoring.record.lcio.LcioEventQueue;
+import org.jlab.coda.et.EtEvent;
+import org.jlab.coda.jevio.BaseStructure;
+import org.jlab.coda.jevio.EvioEvent;
+import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.EvioReader;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.util.loop.LCIOEventSource;
+import org.lcsim.util.loop.LCSimLoop;
+
+/**
+ * This class provides a serial implementation of the
+ * ET to EVIO to LCIO event processing chain.
+ *
+ * This is a flexible class for handling the event processing with
+ * a number of different configurations and scenarios. The processing
+ * chain can be configured to execute the ET, EVIO event building, or
+ * LCIO eventing building stages. The source can be set to an ET ring,
+ * EVIO file source, or LCIO file source. Any number of event processors
+ * can be registered for processing the different record types, in order
+ * to plot or otherwise visualize or analyze the events in that format.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+class EventProcessingChain {
+
+ /**
+ * Type of source for events.
+ */
+ enum SourceType {
+ ET_EVENT,
+ EVIO_FILE,
+ LCIO_FILE
+ }
+
+ /**
+ * Processing stages to execute.
+ */
+ enum ProcessingStage {
+ READ_ET_EVENT,
+ BUILD_EVIO_EVENT,
+ BUILD_LCIO_EVENT
+ }
+
+ SourceType sourceType;
+ ProcessingStage processingStage = ProcessingStage.BUILD_LCIO_EVENT;
+ PrintStream logStream = System.out;
+ List<EventProcessingStep> processingSteps = new ArrayList<EventProcessingStep>();
+ RecordSource recordSource;
+ EtEventLoop etLoop = new EtEventLoop();
+ EvioEventLoop evioLoop = new EvioEventLoop();
+ LCSimLoop lcsimLoop = new LCSimLoop();
+ EvioEventQueue evioQueue = new EvioEventQueue();
+ LcioEventQueue lcioQueue = new LcioEventQueue();
+ LCSimEventBuilder eventBuilder;
+ EtEvent currentEtEvent;
+ EvioEvent currentEvioEvent;
+ int totalEventsProcessed;
+ String detectorName;
+ boolean stopRequested;
+ boolean paused;
+ boolean stopOnEndRun;
+
+ /**
+ * No argument constructor.
+ * The setter methods should be used to setup this class.
+ */
+ public EventProcessingChain() {
+ }
+
+ public void configure() {
+
+ if (recordSource == null)
+ throw new RuntimeException("No record source was set.");
+
+ if (sourceType == SourceType.ET_EVENT) {
+ this.processingSteps.add(new EtProcessingStep());
+ }
+ if (processingStage.ordinal() >= ProcessingStage.BUILD_EVIO_EVENT.ordinal()) {
+ if (sourceType.ordinal() <= SourceType.EVIO_FILE.ordinal()) {
+ this.processingSteps.add(new EvioProcessingStep());
+ }
+ if (sourceType == SourceType.ET_EVENT) {
+ this.evioLoop.setRecordSource(evioQueue);
+ }
+ }
+ if (processingStage.ordinal() >= ProcessingStage.BUILD_LCIO_EVENT.ordinal()) {
+ if (this.eventBuilder != null)
+ this.eventBuilder.setDetectorName(detectorName);
+ this.processingSteps.add(new LcioProcessingStep());
+ if (sourceType.ordinal() != SourceType.LCIO_FILE.ordinal()) {
+ this.lcsimLoop.setRecordSource(lcioQueue);
+ }
+ }
+ }
+
+ void setSourceType(SourceType sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ public void setProcessingStage(ProcessingStage processingStage) {
+ this.processingStage = processingStage;
+ }
+
+ public void setEventBuilder(LCSimEventBuilder eventBuilder) {
+ this.eventBuilder = eventBuilder;
+ }
+
+ public void setRecordSource(EtEventSource recordSource) {
+ this.recordSource = recordSource;
+ this.etLoop.setRecordSource(recordSource);
+ this.sourceType = SourceType.ET_EVENT;
+ }
+
+ public void setRecordSource(EvioFileSource recordSource) {
+ this.recordSource = recordSource;
+ this.evioLoop.setRecordSource(recordSource);
+ setSourceType(SourceType.EVIO_FILE);
+ }
+
+ public void setRecordSource(LCIOEventSource recordSource) {
+ this.recordSource = recordSource;
+ try {
+ this.lcsimLoop.setLCIORecordSource(recordSource);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ setSourceType(SourceType.LCIO_FILE);
+ }
+
+ public void add(Driver driver) {
+ this.lcsimLoop.add(driver);
+ }
+
+ public void add(Collection<Driver> drivers) {
+ for (Driver driver : drivers) {
+ this.lcsimLoop.add(driver);
+ }
+ }
+
+ public void add(EtEventProcessor processor) {
+ this.etLoop.addEtEventProcessor(processor);
+ }
+
+ public void add(EvioEventProcessor processor) {
+ this.evioLoop.addEvioEventProcessor(processor);
+ }
+
+ public void setDetectorName(String detectorName) {
+ this.detectorName = detectorName;
+ }
+
+ public void setPrintStream(PrintStream logStream) {
+ this.logStream = logStream;
+ }
+
+ public void setStopOnEndRun() {
+ this.stopOnEndRun = true;
+ }
+
+ /**
+ * Process one event by executing the processing steps.
+ * @throws IOException If some error occurs while processing events.
+ */
+ void processEvent() throws IOException {
+ for (EventProcessingStep step : this.processingSteps) {
+ step.execute();
+ }
+ ++this.totalEventsProcessed;
+ }
+
+ /**
+ * Stop event processing.
+ */
+ public void stop() {
+ this.stopRequested = true;
+ }
+
+ /**
+ * Pause event processing.
+ */
+ public void pause() {
+ this.paused = true;
+ }
+
+ /**
+ * Resume event processing after pausing.
+ */
+ public void resume() {
+ this.paused = false;
+ }
+
+ /**
+ * This exception occurs when the call to the event loop
+ * results in a null current record.
+ */
+ class EventsExhaustedException extends IOException {
+ EventsExhaustedException(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * This exception occurs when an EVIO end record is encountered
+ * in the event stream.
+ */
+ class EndRunException extends IOException {
+ EndRunException(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Primary method for event processing. This will run events
+ * until a stop or pause is requested, the event source is exhausted,
+ * or (if this behavior is enabled) the end of run record is reached.
+ */
+ public synchronized void run() {
+ this.stopRequested = false;
+ for (;;) {
+ try {
+ processEvent();
+ } catch (EventsExhaustedException e) {
+ this.logStream.println(e.getMessage());
+ break;
+ } catch (EndRunException e) {
+ this.logStream.println(e.getMessage());
+ break;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (stopRequested) {
+ this.logStream.println("Stop was requested. Processing will end!");
+ break;
+ }
+
+ if (this.paused) {
+ synchronized (Thread.currentThread()) {
+ for (;;) {
+ try {
+ // Sleep for 1 second.
+ Thread.currentThread().wait(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // Check if unpaused.
+ if (!this.paused)
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the total number of events processed.
+ * @return The number of events processed.
+ */
+ public int getTotalEventsProcessed() {
+ return this.totalEventsProcessed;
+ }
+
+ /**
+ * Interface for a single processing step which handles one type of record.
+ */
+ interface EventProcessingStep {
+ void execute() throws IOException;
+ }
+
+ /**
+ * ET processing step to load an <tt>EtEvent</tt> from the ET ring.
+ */
+ private class EtProcessingStep implements EventProcessingStep {
+
+ /**
+ * Load the next <tt>EtEvent</tt>.
+ */
+ public void execute() throws IOException {
+ // Load the next EtEvent.
+ etLoop.loop(1);
+
+ // Get an EtEvent from the loop.
+ currentEtEvent = (EtEvent) etLoop.getRecordSource().getCurrentRecord();
+ }
+ }
+
+ /**
+ * EVIO processing step to build an <tt>EvioEvent</tt> from the <tt>EtEvent</tt>
+ * or load the next <tt>EvioEvent</tt> from a file if using an EVIO file source.
+ */
+ private class EvioProcessingStep implements EventProcessingStep {
+
+ /**
+ * Load the next <tt>EvioEvent</tt>, either from a record source
+ * or from the <tt>EtEvent</tt> data.
+ */
+ public void execute() throws IOException {
+
+ if (sourceType == SourceType.ET_EVENT) {
+ EvioEvent evioEvent = null;
+ try {
+ evioEvent = createEvioEvent(currentEtEvent);
+ setEventNumber(evioEvent);
+ } catch (EvioException e) {
+ throw new IOException(e);
+ }
+
+ // Add EvioEvent to the queue for loop.
+ evioQueue.addRecord(evioEvent);
+ }
+
+ // Process one EvioEvent.
+ evioLoop.loop(1);
+ currentEvioEvent = (EvioEvent) evioLoop.getRecordSource().getCurrentRecord();
+
+ // The call to loop did not create a current record.
+ if (currentEvioEvent == null)
+ throw new EventsExhaustedException("No current EVIO event.");
+
+ // Encountered an end of run record.
+ if (EventConstants.isEndEvent(currentEvioEvent))
+ // If stop on end run is enabled then trigger an exception to end processing.
+ if (stopOnEndRun)
+ throw new EndRunException("EVIO end event received, and stop on end run is enabled.");
+ }
+
+ /**
+ * Create an <tt>EvioEvent</tt> from the current <tt>EtEvent</tt>.
+ * @param etEvent
+ * @return
+ * @throws IOException
+ * @throws EvioException
+ * @throws BufferUnderflowException
+ */
+ private EvioEvent createEvioEvent(EtEvent etEvent)
+ throws IOException, EvioException, BufferUnderflowException {
+ return (new EvioReader(etEvent.getDataBuffer())).parseNextEvent();
+ }
+
+ /**
+ * When reading from ET data, the EVIO event number needs to be set manually
+ * from the event ID bank.
+ * @param event The <tt>EvioEvent</tt> on which to set the event number.
+ */
+ private void setEventNumber(EvioEvent event) {
+ int eventNumber = -1;
+ for (BaseStructure bank : event.getChildren()) {
+ if (bank.getHeader().getTag() == EventConstants.EVENTID_BANK_TAG) {
+ eventNumber = bank.getIntData()[0];
+ break;
+ }
+ }
+ if (eventNumber != -1)
+ event.setEventNumber(eventNumber);
+ }
+ }
+
+ /**
+ * Processing step to build an LCIO event from an <tt>EvioEvent</tt>
+ * or load the next event if using a file source.
+ */
+ private class LcioProcessingStep implements EventProcessingStep {
+
+ /**
+ * Create the next LCIO event either from the EVIO record
+ * or from a direct LCIO file source.
+ */
+ public void execute() throws IOException {
+
+ // When the loop does not have a direct event source, the events
+ // need to be built from EVIO.
+ if (sourceType.ordinal() < SourceType.LCIO_FILE.ordinal()) {
+
+ // Set state on LCIO event builder.
+ eventBuilder.readEvioEvent(currentEvioEvent);
+
+ // The LCIO event will be built if processing an EVIO physics event.
+ if (eventBuilder.isPhysicsEvent(currentEvioEvent)) {
+
+ // Use the event builder to create the next LCIO event.
+ EventHeader lcioEvent = eventBuilder.makeLCSimEvent(currentEvioEvent);
+
+ // Add LCIO event to the queue.
+ lcioQueue.addRecord(lcioEvent);
+ } else {
+ // The LCIO processing ignores non-physics events.
+ return;
+ }
+ }
+
+ // Process the next LCIO event.
+ lcsimLoop.loop(1, null);
+
+ // In this case, there are no more records in the file.
+ if (sourceType == SourceType.LCIO_FILE) {
+ if (!lcsimLoop.getRecordSource().hasNext())
+ throw new EventsExhaustedException("No next LCIO event.");
+ }
+
+ // The last call to loop did not create a current record.
+ if (lcsimLoop.getRecordSource().getCurrentRecord() == null) {
+ throw new EventsExhaustedException("No current LCIO event.");
+ }
+ }
+ }
+}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -0,0 +1,32 @@
+package org.hps.monitoring.record;
+
+/**
+ * Thread for handling the event processing chain.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EventProcessingThread extends Thread {
+
+ EventProcessingChain processing;
+
+ EventProcessingThread(EventProcessingChain processing) {
+ super("EventProcessingThread");
+ this.processing = processing;
+ }
+
+ @Override
+ public void run() {
+ processing.run();
+ }
+
+ public void pause() {
+ processing.pause();
+ }
+
+ public void stopProcessing() {
+ processing.stop();
+ }
+
+ public void resumeProcessing() {
+ processing.resume();
+ }
+}
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -6,6 +6,15 @@
*
* @param <EventType> The concrete type of the event record.
*/
-public interface EventProcessor<EventType> {
+public interface EventProcessor<EventType> {
+
+ // void jobStart();
+
+ // void runStart(EventType event);
+
void processEvent(EventType event);
+
+ // void runEnd(EventType event);
+
+ // void jobEnd();
}
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventProcessor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -29,4 +29,14 @@
*/
public void stop() {
}
+
+ // from EtEventListener
+ //
+ // void begin();
+ // void startOfEvent();
+ // void endOfEvent();
+ // void errorOnEvent();
+ // void finish();
+ // void prestart(int seconds, int runNumber);
+ // void endRun(int seconds, int nevents);
}
\ 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/EtEventSource.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -0,0 +1,109 @@
+package org.hps.monitoring.record.etevent;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Queue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.freehep.record.source.AbstractRecordSource;
+import org.freehep.record.source.NoSuchRecordException;
+import org.jlab.coda.et.EtEvent;
+
+/**
+ * Implement a loop record source supplying <tt>EtEvent</tt> objects
+ * from an ET ring server connection.
+ *
+ * @author Jeremy McCormick
+ */
+public class EtEventSource extends AbstractRecordSource {
+
+ EtConnection connection;
+ EtEvent currentRecord;
+ Queue<EtEvent> eventQueue = new LinkedBlockingQueue<EtEvent>();
+
+ public EtEventSource() {
+ // Default connection parameters.
+ this.connection = EtConnection.createEtConnection(new EtConnectionParameters());
+ }
+
+ public EtEventSource(EtConnection connection) {
+ this.connection = connection;
+ }
+
+ @Override
+ public Object getCurrentRecord() throws IOException {
+ return currentRecord;
+ }
+
+ @Override
+ public boolean supportsCurrent() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNext() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsPrevious() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsIndex() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsShift() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRewind() {
+ return false;
+ }
+
+ @Override
+ public boolean hasCurrent() {
+ return currentRecord != null;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public void next() throws IOException, NoSuchRecordException {
+
+ System.out.println("EtEventSource.next");
+
+ // Fill the queue if there are no events cached.
+ if (eventQueue.size() == 0) {
+ readEtEvents();
+ }
+
+ // Poll the queue.
+ currentRecord = eventQueue.poll();
+
+ if (currentRecord == null) {
+ throw new NoSuchRecordException("No records in queue.");
+ }
+ }
+
+ @Override
+ public long size() {
+ return this.eventQueue.size();
+ }
+
+ void readEtEvents() throws IOException {
+ try {
+ EtEvent[] mevs = connection.readEtEvents();
+ eventQueue.addAll(Arrays.asList(mevs));
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+ }
+}
\ No newline at end of file
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/evio/EvioEventProcessor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -8,6 +8,7 @@
* <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/lcio
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioEventQueue.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/lcio/LcioEventQueue.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -0,0 +1,16 @@
+package org.hps.monitoring.record.lcio;
+
+import org.hps.monitoring.record.AbstractRecordQueue;
+import org.lcsim.event.EventHeader;
+
+/**
+ * A dynamic queue providing <tt>EvioEvent</tt> objects to a loop.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class LcioEventQueue extends AbstractRecordQueue<EventHeader> {
+
+ @Override
+ public Class<EventHeader> getRecordClass() {
+ return EventHeader.class;
+ }
+}
\ No newline at end of file
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -45,13 +45,19 @@
* @return The current status code.
*/
StatusCode getStatusCode();
+
+ /**
+ * Get the current message.
+ * @return The current message
+ */
+ String getMessage();
/**
* Set the current status code, which will cause the last changed
* time to be set and the listeners to be notified.
* @param code The new status code.
*/
- void setStatusCode(StatusCode code);
+ void setStatus(StatusCode code, String message);
/**
* Get the time when the system status last changed.
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -11,6 +11,7 @@
StatusCode code = SystemStatus.StatusCode.UNKNOWN;
long lastChangedMillis;
+ String message;
List<SystemStatusListener> listeners = new ArrayList<SystemStatusListener>();
SystemStatusImpl() {
@@ -23,8 +24,9 @@
}
@Override
- public void setStatusCode(StatusCode code) {
+ public void setStatus(StatusCode code, String message) {
this.code = code;
+ this.message = message;
setCurrentTime();
notifyListeners();
}
@@ -39,6 +41,11 @@
return lastChangedMillis;
}
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
void notifyListeners() {
for (SystemStatusListener listener : listeners) {
listener.statusChanged(this);
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-06-09 10:24:16 UTC (rev 690)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -20,7 +20,7 @@
@Override
public void start() {
info.getStatistics().start();
- info.getStatus().setStatusCode(StatusCode.OKAY);
+ info.getStatus().setStatus(StatusCode.OKAY, "EtSystemMonitor set okay.");
}
@Override
@@ -31,7 +31,7 @@
@Override
public void stop() {
info.getStatistics().stop();
- info.getStatus().setStatusCode(StatusCode.OFFLINE);
+ info.getStatus().setStatus(StatusCode.OFFLINE, "EtSystemMonitor set offline.");
}
@Override
java/trunk/monitoring-app/src/test/java/org/hps/monitoring/record
--- java/trunk/monitoring-app/src/test/java/org/hps/monitoring/record/EventProcessingChainTest.java (rev 0)
+++ java/trunk/monitoring-app/src/test/java/org/hps/monitoring/record/EventProcessingChainTest.java 2014-06-09 18:05:54 UTC (rev 691)
@@ -0,0 +1,78 @@
+package org.hps.monitoring.record;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.hps.evio.LCSimTestRunEventBuilder;
+import org.hps.monitoring.record.etevent.EtEventSource;
+import org.hps.monitoring.record.evio.EvioEventProcessor;
+import org.hps.monitoring.record.evio.EvioFileSource;
+import org.jlab.coda.jevio.EvioEvent;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.Driver;
+import org.lcsim.util.loop.LCIOEventSource;
+
+public class EventProcessingChainTest {
+
+ static String evioFilePath = "/work/data/hps/hps_001351.evio.0";
+ static String lcioFilePath = "/work/data/hps/hps_001351.evio.0_recon.slcio";
+ static String detectorName = "HPS-TestRun-v8-5";
+
+ // ET ring with streaming EVIO file must be running for this to work.
+ public void testEtSource() {
+ EventProcessingChain processing = new EventProcessingChain();
+ processing.setRecordSource(new EtEventSource());
+ processing.setEventBuilder(new LCSimTestRunEventBuilder());
+ processing.setDetectorName(detectorName);
+ processing.add(new DummyEvioProcessor());
+ processing.add(new DummyDriver());
+ processing.setStopOnEndRun();
+ processing.configure();
+ processing.run();
+ }
+
+ public void testEvioFile() {
+ EventProcessingChain processing = new EventProcessingChain();
+ processing.setRecordSource(new EvioFileSource(new File(evioFilePath)));
+ processing.setEventBuilder(new LCSimTestRunEventBuilder());
+ processing.setDetectorName(detectorName);
+ processing.add(new DummyEvioProcessor());
+ processing.add(new DummyDriver());
+ processing.setStopOnEndRun();
+ processing.configure();
+ processing.run();
+ }
+
+ public void testLcioFile() {
+ EventProcessingChain processing = new EventProcessingChain();
+ try {
+ processing.setRecordSource(new LCIOEventSource(new File(lcioFilePath)));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ processing.setEventBuilder(new LCSimTestRunEventBuilder());
+ processing.setDetectorName(detectorName);
+ processing.add(new DummyDriver());
+ processing.configure();
+ processing.run();
+ }
+
+ static class DummyDriver extends Driver {
+ public void process(EventHeader event) {
+ System.out.println(this.getClass().getSimpleName() + " got LCIO event #" + event.getEventNumber());
+ for (LCMetaData metaData : event.getMetaData()) {
+ String collectionName = metaData.getName();
+ Class type = metaData.getType();
+ System.out.println (collectionName + " " + event.get(type, collectionName).size());
+ }
+ }
+ }
+
+ static class DummyEvioProcessor extends EvioEventProcessor {
+ public void processEvent(EvioEvent event) {
+ System.out.println(this.getClass().getSimpleName() + " got EVIO event #" + event.getEventNumber());
+ }
+ }
+
+}
SVNspam 0.1