Commit in hps-java/src/main/java/org/lcsim/hps/monitoring on MAIN | |||
AIDAServer.java | +40 | added 1.1 | |
JobPanel.java | +206 | -155 | 1.9 -> 1.10 |
MonitoringApplication.java | +35 | -30 | 1.33 -> 1.34 |
+281 | -185 |
add ability to run remote AIDA server for viewing plots in JAS
diff -N AIDAServer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ AIDAServer.java 30 Apr 2012 22:27:36 -0000 1.1 @@ -0,0 +1,40 @@
+package org.lcsim.hps.monitoring; + +import hep.aida.dev.IDevTree; +import hep.aida.ref.remote.RemoteServer; +import hep.aida.ref.remote.rmi.server.RmiServerImpl; + +import org.lcsim.util.aida.AIDA; + +/** + * Wrapper class for remote AIDA server. + * @author Jeremy McCormick <[log in to unmask]> + * @version $Id: AIDAServer.java,v 1.1 2012/04/30 22:27:36 jeremy Exp $ + */ +class AIDAServer { + + RmiServerImpl server; + String name; + + AIDAServer(String name) { + this.name = name; + } + + boolean start() { + //RmiStoreFactory store = new RmiStoreFactory(); // Is this needed? + final boolean serverDuplex = false; + RemoteServer treeServer = new RemoteServer((IDevTree) AIDA.defaultInstance().tree(), serverDuplex); + try { + server = new RmiServerImpl(treeServer, "/" + name); + return true; + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + void close() { + server.disconnect(); + } +}
\ No newline at end of file
diff -u -r1.9 -r1.10 --- JobPanel.java 30 Apr 2012 04:17:58 -0000 1.9 +++ JobPanel.java 30 Apr 2012 22:27:36 -0000 1.10 @@ -17,30 +17,32 @@
import javax.swing.JTextField; class JobPanel extends JPanel implements ActionListener {
- - private JComboBox steeringComboBox; - private JTextField steeringField; - private JTextField detectorNameField; - private JTextField eventBuilderField; - JCheckBox disconnectWarningCheckBox; - JCheckBox disconnectOnErrorCheckBox; - JCheckBox logCheckBox; - JTextField logFileField; - - private String defaultEventBuilderClassName = ""; - - private final static String[] steeringTypes = { "RESOURCE", "FILE", "NONE" }; - final static int RESOURCE = 0; - final static int FILE = 1; - final static int NONE = 2; - - JobPanel() { - - setLayout(new GridBagLayout()); - - Insets insets = new Insets(1, 1, 1, 1); - - GridBagConstraints c = new GridBagConstraints();
+ + private JComboBox steeringComboBox; + private JTextField steeringField; + private JTextField detectorNameField; + private JTextField eventBuilderField; + JCheckBox disconnectWarningCheckBox; + JCheckBox disconnectOnErrorCheckBox; + JCheckBox logCheckBox; + JTextField logFileField; + JCheckBox remoteAidaCheckBox; + JTextField aidaNameField; + + private String defaultEventBuilderClassName = ""; + + private final static String[] steeringTypes = { "RESOURCE", "FILE", "NONE" }; + final static int RESOURCE = 0; + final static int FILE = 1; + final static int NONE = 2; + + JobPanel() { + + setLayout(new GridBagLayout()); + + Insets insets = new Insets(1, 1, 1, 1); + + GridBagConstraints c = new GridBagConstraints();
c.gridx = 0; c.gridy = 0; c.insets = insets;
@@ -59,8 +61,8 @@
steeringComboBox.setSelectedIndex(NONE); steeringComboBox.setBackground(Color.WHITE); add(steeringComboBox, c);
- - c = new GridBagConstraints();
+ + c = new GridBagConstraints();
c.gridx = 0; c.gridy = 1; c.insets = insets;
@@ -81,7 +83,7 @@
steeringField.setActionCommand(MonitoringCommands.steeringCmd); steeringField.addActionListener(this); add(steeringField, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 2;
@@ -101,7 +103,7 @@
detectorNameField.setHorizontalAlignment(JTextField.RIGHT); detectorNameField.setBackground(Color.WHITE); add(detectorNameField, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3;
@@ -123,7 +125,7 @@
eventBuilderField.addActionListener(this); eventBuilderField.setActionCommand(MonitoringCommands.eventBuilderCmd); add(eventBuilderField, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4;
@@ -141,7 +143,7 @@
logCheckBox = new JCheckBox(); logCheckBox.setEnabled(false); add(logCheckBox, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5;
@@ -162,7 +164,7 @@
logFileField.setEditable(false); logFileField.setBackground(Color.WHITE); add(logFileField, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 6;
@@ -172,7 +174,7 @@
disconnectWarningLabel.setHorizontalAlignment(JLabel.LEFT); disconnectWarningLabel.setToolTipText("Whether or not to warn with a dialog box before disconnect."); add(disconnectWarningLabel, c);
-
+
c = new GridBagConstraints(); c.gridx = 1; c.gridy = 6;
@@ -181,7 +183,7 @@
disconnectWarningCheckBox = new JCheckBox(); disconnectWarningCheckBox.setSelected(false); add(disconnectWarningCheckBox, c);
-
+
c = new GridBagConstraints(); c.gridx = 0; c.gridy = 7;
@@ -191,7 +193,7 @@
disconnectOnErrorLabel.setHorizontalAlignment(JLabel.LEFT); disconnectOnErrorLabel.setToolTipText("Whether or not to disconnect if there is an error in event processing."); add(disconnectOnErrorLabel, c);
-
+
c = new GridBagConstraints(); c.gridx = 1; c.gridy = 7;
@@ -200,125 +202,174 @@
disconnectOnErrorCheckBox = new JCheckBox(); disconnectOnErrorCheckBox.setSelected(true); add(disconnectOnErrorCheckBox, c);
- } - - public void actionPerformed(ActionEvent e) { - if (MonitoringCommands.steeringCmd == e.getActionCommand()) { - editSteering(); - } - else if (MonitoringCommands.eventBuilderCmd == e.getActionCommand()) { - editEventBuilder(); - } - } - - private void editSteering() { - String steering = steeringField.getText(); - int steeringType = steeringComboBox.getSelectedIndex(); - if (RESOURCE == steeringType) { - // Check that steering resource exists. - InputStream is = getClass().getResourceAsStream(steering); - if (is == null) { - JOptionPane.showMessageDialog(this, "The LCSim steering resource does not exist."); - disableSteering(); - } - } - else if (FILE == steeringType) { - // Check that steering file exists. - File f = new File(steering); - if (!f.exists()) { - JOptionPane.showMessageDialog(this, "The LCSim steering file does not exist."); - disableSteering(); - } - } - else if (NONE == steeringType) { - if (!("".equals(steeringField.getText().trim()))) { - JOptionPane.showMessageDialog(this, "Select resource or file type in above combo box to enable LCSim."); - } - } - } - - private void disableSteering() { - JOptionPane.showMessageDialog(this, "No valid steering file was selected, so job will run without LCSim."); - steeringComboBox.setSelectedIndex(NONE); - } - - private void editEventBuilder() { - String eventBuilderClassName = eventBuilderField.getText(); - try { - // Test that the event builder class can be created successfully. - Class eventBuilderClass = Class.forName(eventBuilderClassName); - eventBuilderClass.newInstance(); - } - catch (ClassNotFoundException e) { - JOptionPane.showMessageDialog(this, "Event builder class does not exist."); - resetEventBuilder(); - } - catch (InstantiationException e) { - JOptionPane.showMessageDialog(this, "Failed to instantiate instance of event builder class."); - resetEventBuilder(); - } - catch (IllegalAccessException e) { - JOptionPane.showMessageDialog(this, "Couldn't access event builder class."); - resetEventBuilder(); - } - } - - private void resetEventBuilder() { - eventBuilderField.setText(defaultEventBuilderClassName); - } - - String getEventBuilderClassName() { - if (!"".equals(eventBuilderField.getText().trim())) { - return eventBuilderField.getText(); - } else { - return null; - } - } - - void setSteeringFile(String steeringFile) { - steeringField.setText(steeringFile); - steeringComboBox.setSelectedIndex(FILE); - this.actionPerformed(new ActionEvent(this, 0, MonitoringCommands.steeringCmd)); - } - - void setSteeringResource(String steeringResource) { - steeringField.setText(steeringResource); - steeringComboBox.setSelectedIndex(RESOURCE); - this.actionPerformed(new ActionEvent(this, 0, MonitoringCommands.steeringCmd)); - } - - void setDetectorName(String detectorName) { - detectorNameField.setText(detectorName); - } - - String getSteering() { - if (steeringComboBox.getSelectedIndex() != NONE) - return steeringField.getText(); - else - return null; - } - - int getSteeringType() { - return steeringComboBox.getSelectedIndex(); - } - - String getDetectorName() { - return detectorNameField.getText(); - } - - boolean validSteering() { - return !("".equals(steeringField.getText().trim())) && (this.steeringComboBox.getSelectedIndex() != NONE); - } - - void setDefaultEventBuilder(String defaultEventBuilderClassName) { - this.defaultEventBuilderClassName = defaultEventBuilderClassName; - eventBuilderField.setText(this.defaultEventBuilderClassName); - } - - void enableJobPanel(boolean enable) { - steeringComboBox.setEnabled(enable); - steeringField.setEnabled(enable); - detectorNameField.setEnabled(enable); - eventBuilderField.setEnabled(enable); - }
+ + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 8; + c.insets = insets; + c.anchor = GridBagConstraints.WEST; + JLabel remoteAidaLabel = new JLabel("Enable remote AIDA:"); + remoteAidaLabel.setHorizontalAlignment(JLabel.LEFT); + remoteAidaLabel.setToolTipText("Enable remote AIDA server for viewing plots in realtime using JAS."); + add(remoteAidaLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 8; + c.insets = insets; + c.anchor = GridBagConstraints.EAST; + remoteAidaCheckBox = new JCheckBox(); + remoteAidaCheckBox.setSelected(false); + add(remoteAidaCheckBox, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 9; + c.insets = insets; + c.anchor = GridBagConstraints.WEST; + JLabel aidaNameLabel = new JLabel("Remote AIDA name:"); + aidaNameLabel.setHorizontalAlignment(JLabel.LEFT); + aidaNameLabel.setToolTipText("AIDA session name for connecting in JAS."); + add(aidaNameLabel, c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 9; + c.insets = insets; + c.anchor = GridBagConstraints.EAST; + aidaNameField = new JTextField("", 15); + aidaNameField.setHorizontalAlignment(JLabel.RIGHT); + aidaNameField.setText("hps"); + add(aidaNameField, c); + } + + public void actionPerformed(ActionEvent e) { + if (MonitoringCommands.steeringCmd == e.getActionCommand()) { + editSteering(); + } + else if (MonitoringCommands.eventBuilderCmd == e.getActionCommand()) { + editEventBuilder(); + } + } + + boolean isAIDAServerEnabled() { + return remoteAidaCheckBox.isSelected(); + } + + String getRemoteAIDAName() { + return aidaNameField.getText(); + } + + private void editSteering() { + String steering = steeringField.getText(); + int steeringType = steeringComboBox.getSelectedIndex(); + if (RESOURCE == steeringType) { + // Check that steering resource exists. + InputStream is = getClass().getResourceAsStream(steering); + if (is == null) { + JOptionPane.showMessageDialog(this, "The LCSim steering resource does not exist."); + disableSteering(); + } + } + else if (FILE == steeringType) { + // Check that steering file exists. + File f = new File(steering); + if (!f.exists()) { + JOptionPane.showMessageDialog(this, "The LCSim steering file does not exist."); + disableSteering(); + } + } + else if (NONE == steeringType) { + if (!("".equals(steeringField.getText().trim()))) { + JOptionPane.showMessageDialog(this, "Select resource or file type in above combo box to enable LCSim."); + } + } + } + + private void disableSteering() { + JOptionPane.showMessageDialog(this, "No valid steering file was selected, so job will run without LCSim."); + steeringComboBox.setSelectedIndex(NONE); + } + + private void editEventBuilder() { + String eventBuilderClassName = eventBuilderField.getText(); + try { + // Test that the event builder class can be created successfully. + Class eventBuilderClass = Class.forName(eventBuilderClassName); + eventBuilderClass.newInstance(); + } + catch (ClassNotFoundException e) { + JOptionPane.showMessageDialog(this, "Event builder class does not exist."); + resetEventBuilder(); + } + catch (InstantiationException e) { + JOptionPane.showMessageDialog(this, "Failed to instantiate instance of event builder class."); + resetEventBuilder(); + } + catch (IllegalAccessException e) { + JOptionPane.showMessageDialog(this, "Couldn't access event builder class."); + resetEventBuilder(); + } + } + + private void resetEventBuilder() { + eventBuilderField.setText(defaultEventBuilderClassName); + } + + String getEventBuilderClassName() { + if (!"".equals(eventBuilderField.getText().trim())) { + return eventBuilderField.getText(); + } else { + return null; + } + } + + void setSteeringFile(String steeringFile) { + steeringField.setText(steeringFile); + steeringComboBox.setSelectedIndex(FILE); + this.actionPerformed(new ActionEvent(this, 0, MonitoringCommands.steeringCmd)); + } + + void setSteeringResource(String steeringResource) { + steeringField.setText(steeringResource); + steeringComboBox.setSelectedIndex(RESOURCE); + this.actionPerformed(new ActionEvent(this, 0, MonitoringCommands.steeringCmd)); + } + + void setDetectorName(String detectorName) { + detectorNameField.setText(detectorName); + } + + String getSteering() { + if (steeringComboBox.getSelectedIndex() != NONE) + return steeringField.getText(); + else + return null; + } + + int getSteeringType() { + return steeringComboBox.getSelectedIndex(); + } + + String getDetectorName() { + return detectorNameField.getText(); + } + + boolean validSteering() { + return !("".equals(steeringField.getText().trim())) && (this.steeringComboBox.getSelectedIndex() != NONE); + } + + void setDefaultEventBuilder(String defaultEventBuilderClassName) { + this.defaultEventBuilderClassName = defaultEventBuilderClassName; + eventBuilderField.setText(this.defaultEventBuilderClassName); + } + + void enableJobPanel(boolean enable) { + steeringComboBox.setEnabled(enable); + steeringField.setEnabled(enable); + detectorNameField.setEnabled(enable); + eventBuilderField.setEnabled(enable); + remoteAidaCheckBox.setEnabled(enable); + aidaNameField.setEnabled(enable); + }
}
\ No newline at end of file
diff -u -r1.33 -r1.34 --- MonitoringApplication.java 30 Apr 2012 20:04:39 -0000 1.33 +++ MonitoringApplication.java 30 Apr 2012 22:27:36 -0000 1.34 @@ -18,6 +18,10 @@
import static org.lcsim.hps.monitoring.MonitoringCommands.setSteeringFileCmd; import static org.lcsim.hps.monitoring.MonitoringCommands.terminalCmd; import static org.lcsim.hps.monitoring.MonitoringCommands.updateTimeCmd;
+import hep.aida.dev.IDevTree; +import hep.aida.ref.remote.RemoteServer; +import hep.aida.ref.remote.rmi.client.RmiStoreFactory; +import hep.aida.ref.remote.rmi.server.RmiServerImpl;
import java.awt.AWTException; import java.awt.Dimension;
@@ -73,7 +77,7 @@
* calling its main() method. * * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringApplication.java,v 1.33 2012/04/30 20:04:39 jeremy Exp $
+ * @version $Id: MonitoringApplication.java,v 1.34 2012/04/30 22:27:36 jeremy Exp $
*/ public class MonitoringApplication {
@@ -132,6 +136,9 @@
// Format for screenshots. Hard-coded to PNG. private static final String screenshotFormat = "png";
+ // The AIDA remote server. + private AIDAServer server; +
/** * Constructor for monitoring application. Users should not * need to use this; call main() method instead.
@@ -612,6 +619,14 @@
// Push final event counts to GUI. app.eventPanel.endJob();
+ + // Disconnect from remote AIDA session. + if (app.server != null) { + logger.log(Level.INFO, "Closing remote AIDA server."); + app.server.close(); + app.server = null; + logger.log(Level.INFO, "Remote AIDA server was closed."); + }
} catch (Exception e) { e.printStackTrace();
@@ -1000,17 +1015,16 @@
*/ private void session() {
- logger.log(Level.FINER, "Monitoring session started.");
+ logger.log(Level.FINER, "Waiting for connection request.");
// Wait until connection is requested by the GUI. waitForConnectionRequest(); // Setup LCSim. setupLCSim();
- - // TEST - //this.setupRemoteAida(); - //
+ + // Start a remote AIDA session if selected in GUI. + setupRemoteAida();
// Connect to the ET system. connect();
@@ -1039,6 +1053,21 @@
} /**
+ * Setup a remote AIDA session if user selected this option. + */ + private void setupRemoteAida() { + if (jobPanel.isAIDAServerEnabled()) { + logger.log(Level.INFO, "Starting remote AIDA server."); + this.server = new AIDAServer(jobPanel.getRemoteAIDAName()); + boolean ok = this.server.start(); + if (ok) + logger.log(Level.INFO, "Remote AIDA server was started with name <" + jobPanel.getRemoteAIDAName() + ">."); + else + logger.log(Level.SEVERE, "Failed to start remote AIDA server."); + } + } + + /**
* Create the Thread for processing EtEvents. * @return The Thread for event processing. */
@@ -1332,28 +1361,4 @@
logTableModel.setRowCount(0); logger.log(Level.INFO, "Log was cleared."); }
- - /** - * Start a remote AIDA server. - */ - /* - private void setupRemoteAida() { - final String AIDAName = "hps"; - - RmiStoreFactory store = new RmiStoreFactory(); // FIXME: Is this even needed??? - boolean serverDuplex = true; - RemoteServer treeServer = new RemoteServer((IDevTree) AIDA.defaultInstance().tree(), serverDuplex); - try { - RmiServerImpl impl = new RmiServerImpl(treeServer, "/" + AIDAName); - System.out.println("remote AIDA name: " + impl.getBindName()); - System.out.println("client host: " + impl.getClientHost()); - } - catch (Exception e) { - System.out.println("Error setting up remote AIDA."); - e.printStackTrace(); - } - //logger.log(Level.INFO, "Remote AIDA tree bound: {0}", impl.getBindName()); - - } - */
}
\ No newline at end of file
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1