Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/monitoring on MAIN
MonitoringApplication.java+242-2171.36 -> 1.37
a first shot at useful command-line options for use in the shifter-friendly startup script

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplication.java 1.36 -> 1.37
diff -u -r1.36 -r1.37
--- MonitoringApplication.java	3 May 2012 16:59:28 -0000	1.36
+++ MonitoringApplication.java	4 May 2012 19:42:36 -0000	1.37
@@ -67,6 +67,8 @@
 import javax.swing.Timer;
 import javax.swing.table.DefaultTableModel;
 
+import org.apache.commons.cli.*;
+
 import org.lcsim.hps.evio.LCSimEventBuilder;
 import org.lcsim.hps.evio.LCSimTestRunEventBuilder;
 import org.lcsim.job.JobControlManager;
@@ -74,25 +76,25 @@
 import org.lcsim.util.aida.AIDA;
 
 /**
- * Monitoring application for HPS Test Run, which can run LCSim steering files 
- * on data converted from the ET ring.  This class is accessible to users by 
+ * Monitoring application for HPS Test Run, which can run LCSim steering files
+ * on data converted from the ET ring. This class is accessible to users by
  * calling its main() method.
- * 
+ *
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringApplication.java,v 1.36 2012/05/03 16:59:28 jeremy Exp $
+ * @version $Id: MonitoringApplication.java,v 1.36 2012/05/03 16:59:28 jeremy
+ * Exp $
  */
 public class MonitoringApplication {
 
     // Top-level Swing components.
     private JPanel mainPanel;
-    private JTabbedPane tabs;	
+    private JTabbedPane tabs;
     private ConnectionPanel connectionPanel;
     private ConnectionStatusPanel connectionStatusPanel;
     private EventPanel eventPanel;
-    private JobPanel jobPanel;			
-    private JMenuBar menuBar;	
+    private JobPanel jobPanel;
+    private JMenuBar menuBar;
     private EventButtonsPanel buttonsPanel;
-
     // References to menu items that will be enabled/disabled depending on application state.
     private JMenuItem connectItem;
     private JMenuItem disconnectItem;
@@ -104,55 +106,44 @@
     private JMenuItem logItem;
     private JMenuItem terminalItem;
     private JMenuItem steeringItem;
-
     // Saved references to System.out and System.err in case need to reset.
     private final PrintStream sysOut = System.out;
     private final PrintStream sysErr = System.err;
-
     // ET connection parameters and state.
     private ConnectionParameters connectionParameters;
     private EtConnection connection;
-    private int connectionStatus = ConnectionStatus.DISCONNECTED;	
-
+    private int connectionStatus = ConnectionStatus.DISCONNECTED;
     // Event processing objects.
     private JobControlManager jobManager;
     private LCSimEventBuilder eventBuilder;
     private EtEventProcessor eventProcessor;
     private Thread eventProcessingThread;
-
     // Job timing.
     private Timer timer;
     private long jobStartTime;
-
     // ActionListener for GUI event dispatching.
     private ActionListener actionListener;
-
     // Logging objects.
     private static Logger logger;
     private Handler logHandler;
     private DefaultTableModel logTableModel;
     private JTable logTable;
-
     // Some default GUI size parameters.
     private final int maxWidth = 800;
     private final int logHeight = 300;
-
     // Format for screenshots.  Hard-coded to PNG.
     private static final String screenshotFormat = "png";
-
     // The AIDA remote server.
     private AIDAServer server;
-
     // Listener for processing EtEvents.
     private EtEventListener etListener = new MonitoringApplicationEtListener();
-
     // Maximum time to wait for ET system to disconnect before zombifying the station, in milliseconds.
     // TODO: Make this an option in JobPanel.
     private int maxCleanupTime = 5000;
 
     /**
-     * Constructor for monitoring application.  Users should not
-     * need to use this; call main() method instead.
+     * Constructor for monitoring application. Users should not need to use
+     * this; call main() method instead.
      */
     private MonitoringApplication() {
 
@@ -178,8 +169,7 @@
     /**
      * Creates all the JPanels for the application.
      */
-    private void createPanels()
-    {
+    private void createPanels() {
         // Main panel for the application.
         mainPanel = new JPanel();
         mainPanel.setLayout(new GridBagLayout());
@@ -223,7 +213,7 @@
         // Add tabs to main panel.
         c = new GridBagConstraints();
         c.gridx = 0;
-        c.gridy = 2;        
+        c.gridy = 2;
         c.fill = GridBagConstraints.BOTH;
         c.weightx = c.weighty = 1.0;
         mainPanel.add(tabsPanel, c);
@@ -235,7 +225,7 @@
 
         JMenu connectionMenu = new JMenu("Connection");
         connectionMenu.setMnemonic(KeyEvent.VK_C);
-        menuBar.add(connectionMenu);        
+        menuBar.add(connectionMenu);
 
         connectItem = new JMenuItem("Connect");
         connectItem.setMnemonic(KeyEvent.VK_C);
@@ -289,14 +279,14 @@
         resetEventsItem.setActionCommand(resetEventsCmd);
         resetEventsItem.addActionListener(actionListener);
         resetEventsItem.setToolTipText("Reset timer and counters in the event monitor tab.");
-        eventMenu.add(resetEventsItem);     
+        eventMenu.add(resetEventsItem);
 
         JMenuItem eventRefreshItem = new JMenuItem("Set Event Refresh...");
         eventRefreshItem.setMnemonic(KeyEvent.VK_V);
         eventRefreshItem.setActionCommand(eventRefreshCmd);
         eventRefreshItem.addActionListener(actionListener);
         eventRefreshItem.setToolTipText("Set the number of events between GUI updates.");
-        eventMenu.add(eventRefreshItem);        
+        eventMenu.add(eventRefreshItem);
 
         JMenuItem maxEventsItem = new JMenuItem("Set Max Events...");
         maxEventsItem.setMnemonic(KeyEvent.VK_M);
@@ -322,7 +312,7 @@
         savePlotsItem.addActionListener(actionListener);
         savePlotsItem.setEnabled(false);
         savePlotsItem.setToolTipText("Save plots from default AIDA tree to an output file.");
-        jobMenu.add(savePlotsItem);     
+        jobMenu.add(savePlotsItem);
 
         resetDriversItem = new JMenuItem("Reset LCSim Drivers");
         resetDriversItem.setMnemonic(KeyEvent.VK_D);
@@ -386,24 +376,24 @@
          * Puts log messages into the application's log table GUI component.
          */
         public void publish(LogRecord record) {
-            Object[] row = new Object[] {
-                    record.getLoggerName(), // source
-                    record.getMessage(), // message
-                    dateFormat.format(new Date(record.getMillis())), // date
-                    record.getLevel()}; // level
+            Object[] row = new Object[]{
+                record.getLoggerName(), // source
+                record.getMessage(), // message
+                dateFormat.format(new Date(record.getMillis())), // date
+                record.getLevel()}; // level
             logTableModel.insertRow(logTable.getRowCount(), row);
         }
 
-        public void close() throws SecurityException
-        {}
+        public void close() throws SecurityException {
+        }
 
-        public void flush()
-        {}        
+        public void flush() {
+        }
     }
 
     /**
-     * Creates the application's log table GUI component, which is a JTable containing
-     * messages from the logger.
+     * Creates the application's log table GUI component, which is a JTable
+     * containing messages from the logger.
      */
     private void createLogTable() {
         final String[] logTableColumns = {"Source", "Message", "Date", "Level"};
@@ -423,7 +413,8 @@
     }
 
     /**
-     * Setup the application's Logger object for writing messages to the log table.
+     * Setup the application's Logger object for writing messages to the log
+     * table.
      */
     private void setupLogger() {
         logger = Logger.getLogger(this.getClass().getSimpleName());
@@ -435,11 +426,13 @@
 
     /**
      * Create the monitoring application frame and run it on a separate thread.
+     *
      * @return Reference to the created application.
      */
     private static final MonitoringApplication createMonitoringApplication() {
         final MonitoringApplication app = new MonitoringApplication();
         SwingUtilities.invokeLater(new Runnable() {
+
             public void run() {
                 app.createApplicationFrame();
             }
@@ -449,35 +442,70 @@
 
     /**
      * Run the monitoring application from the command line.
+     *
      * @param args The command line arguments.
      */
     // TODO: Command line arguments should be: [etFile] [steeringFile] (according to Matthew Graham!)
-    public static void main(String[] args)
-    {   
+    public static void main(String[] args) {
         final String defaultDetectorName;
         final String defaultSteering;
         final String defaultEventBuilder;
 
-        if (args.length == 0) {
-            defaultDetectorName = "HPS-Test-JLAB-v4pt0"; 
+        // Set up command line parsing.
+        Options options = new Options();
+
+        options.addOption(new Option("h", false, "Print this help."));
+//        options.addOption(new Option("e", true, "ET file buffer to use."));
+        options.addOption(new Option("c", true, "Load properties file."));
+        options.addOption(new Option("r", true, "Load specified steering file resource."));
+//        options.addOption(new Option("x", true, "Load specified steering file path."));
+        options.addOption(new Option("d", true, "Detector to use."));
+        options.addOption(new Option("b", true, "Event builder to use."));
+        CommandLineParser parser = new PosixParser();
+
+        // Parse command line arguments.
+        CommandLine cl = null;
+        try {
+            cl = parser.parse(options, args);
+        } catch (ParseException e) {
+            throw new RuntimeException("Problem parsing command line options.", e);
+        }
+
+        if (cl.hasOption("h")) {
+            System.out.println("MonitoringApplication [options]");
+            HelpFormatter help = new HelpFormatter();
+            help.printHelp(" ", options);
+            System.exit(1);
+        }
+
+        if (cl.hasOption("r")) {
+            defaultSteering = cl.getOptionValue("r");
+        } else {
             defaultSteering = "/org/lcsim/hps/steering/TestRunMonitoring.lcsim";
-            defaultEventBuilder = LCSimTestRunEventBuilder.class.getCanonicalName();
         }
-        else {
-            if (args.length != 3) {
-                System.out.println("Usage: MonitoringApplication [detectorName] [steeringFile] [eventBuilderClass]");
-                System.exit(1);
-            }
-            defaultDetectorName = args[0];
-            defaultSteering = args[1];
-            defaultEventBuilder = args[2];
+
+        if (cl.hasOption("d")) {
+            defaultDetectorName = cl.getOptionValue("d");
+        } else {
+            defaultDetectorName = "HPS-Test-JLAB-v4pt0";
+        }
+
+        if (cl.hasOption("b")) {
+            defaultEventBuilder = cl.getOptionValue("b");
+        } else {
+            defaultEventBuilder = LCSimTestRunEventBuilder.class.getCanonicalName();
         }
 
         // Create the main app class.
         MonitoringApplication app = MonitoringApplication.createMonitoringApplication();
 
+        if (cl.hasOption("p")) {
+            File propertiesFile = new File(cl.getOptionValue("p"));
+            app.connectionPanel.loadPropertiesFile(propertiesFile);
+        }
+
         // Set job parameters.
-        app.setJobParameters(new JobParameters(new String[] {defaultDetectorName, defaultSteering, defaultEventBuilder}));
+        app.setJobParameters(new JobParameters(new String[]{defaultDetectorName, defaultSteering, defaultEventBuilder}));
 
         // Run the app.
         app.run();
@@ -493,15 +521,15 @@
     }
 
     /**
-     * Application parameters:
-     * params[0] = detectorName
-     * params[1] = steeringResourceString
-     * params[2] = eventBuilderClassName
+     * Application parameters: params[0] = detectorName params[1] =
+     * steeringResourceString params[2] = eventBuilderClassName
      */
     private static final class JobParameters {
+
         private String detectorName;
         private String steeringResource;
         private String eventBuilderClassName;
+
         JobParameters(String[] params) {
             if (params.length != 3) {
                 new IllegalArgumentException("Parameter array is wrong length.");
@@ -519,84 +547,63 @@
 
         public void actionPerformed(ActionEvent e) {
             String cmd = e.getActionCommand();
-            if (cmd != MonitoringCommands.updateTimeCmd)
+            if (cmd != MonitoringCommands.updateTimeCmd) {
                 logger.log(Level.FINEST, "Action performed <" + cmd + ">.");
+            }
             if (connectCmd.equals(cmd)) {
                 startSessionThread();
-            } 
-            else if (disconnectCmd.equals(cmd)) {
+            } else if (disconnectCmd.equals(cmd)) {
                 startDisconnectThread();
-            } 
-            else if (eventRefreshCmd.equals(cmd)) {
+            } else if (eventRefreshCmd.equals(cmd)) {
                 setEventRefresh();
-            }
-            else if (savePlotsCmd.equals(cmd)) {
+            } else if (savePlotsCmd.equals(cmd)) {
                 savePlots();
-            } 
-            else if (resetDriversCmd.equals(cmd)) {
+            } else if (resetDriversCmd.equals(cmd)) {
                 resetDrivers();
-            } 
-            else if (logCmd.equals(cmd)) {
+            } else if (logCmd.equals(cmd)) {
                 logToFile();
-            } 
-            else if (terminalCmd.equals(cmd)) {
+            } else if (terminalCmd.equals(cmd)) {
                 logToTerminal();
-            }
-            else if (screenshotCmd.equals(cmd)) {
+            } else if (screenshotCmd.equals(cmd)) {
                 screenshot();
-            }
-            else if (exitCmd.equals(cmd)) {
+            } else if (exitCmd.equals(cmd)) {
                 exit();
-            }
-            else if (updateTimeCmd.equals(cmd)) {
+            } else if (updateTimeCmd.equals(cmd)) {
                 updateTime();
-            }
-            else if (resetEventsCmd.equals(cmd)) {
+            } else if (resetEventsCmd.equals(cmd)) {
                 resetJob();
-            } 
-            else if (saveConnectionCmd.equals(cmd)) {
+            } else if (saveConnectionCmd.equals(cmd)) {
                 connectionPanel.save();
-            } 
-            else if (loadConnectionCmd.equals(cmd)) {
+            } else if (loadConnectionCmd.equals(cmd)) {
                 connectionPanel.load();
-            } 
-            else if (resetConnectionSettingsCmd.equals(cmd)) {
+            } else if (resetConnectionSettingsCmd.equals(cmd)) {
                 connectionPanel.reset();
-            }
-            else if (setSteeringFileCmd.equals(cmd)) {
+            } else if (setSteeringFileCmd.equals(cmd)) {
                 selectSteeringFile();
-            } 
-            else if (setMaxEventsCmd.equals(cmd)) {
+            } else if (setMaxEventsCmd.equals(cmd)) {
                 setMaxEvents();
-            }
-            else if (saveLogCmd.equals(cmd)) {
+            } else if (saveLogCmd.equals(cmd)) {
                 saveLogToFile();
-            }
-            else if (clearLogCmd.equals(cmd)) {
+            } else if (clearLogCmd.equals(cmd)) {
                 clearLog();
-            }
-            else if (steeringCmd.equals(cmd)) {
+            } else if (steeringCmd.equals(cmd)) {
                 jobPanel.editSteering();
-            } 
-            else if (eventBuilderCmd.equals(cmd)) {
+            } else if (eventBuilderCmd.equals(cmd)) {
                 jobPanel.editEventBuilder();
-            }
-            else if (pauseCmd.equals(cmd)) {
+            } else if (pauseCmd.equals(cmd)) {
                 pause();
-            }
-            else if (nextCmd.equals(cmd)) {
+            } else if (nextCmd.equals(cmd)) {
                 next();
-            }
-            else if (resumeCmd.equals(cmd)) {
+            } else if (resumeCmd.equals(cmd)) {
                 resume();
-            }
-            else if (logLevelCmd.equals(cmd)) {
+            } else if (logLevelCmd.equals(cmd)) {
                 setLogLevel();
             }
         }
 
         private void startDisconnectThread() {
             Runnable r = new Runnable() {
+
                 public void run() {
                     disconnect();
                 }
@@ -605,31 +612,32 @@
             t.start();
         }
     }
-    
+
     /**
-     * This is the primary entry point for starting a monitoring session.
-     * The session is started on a new thread so it doesn't block.
+     * This is the primary entry point for starting a monitoring session. The
+     * session is started on a new thread so it doesn't block.
      */
     private void startSessionThread() {
         if (getConnectionStatus() != ConnectionStatus.CONNECTED) {
             Runnable r = new Runnable() {
+
                 public void run() {
                     session();
                 }
             };
             Thread t = new Thread(r, "Session Thread");
             t.start();
-        }
-        else {
+        } else {
             logger.log(Level.SEVERE, "Ignoring connection request.  Already connected!");
         }
     }
 
     /**
-     * Set a new log level for the application and also forward to the event processor.
+     * Set a new log level for the application and also forward to the event
+     * processor.
      */
     private void setLogLevel() {
-        Level newLevel = jobPanel.getLogLevel(); 
+        Level newLevel = jobPanel.getLogLevel();
         logger.setLevel(newLevel);
         if (eventProcessor != null) {
             eventProcessor.setLogLevel(newLevel);
@@ -670,10 +678,10 @@
             try {
                 // Call cleanup methods of Drivers.
                 try {
-                    if (jobManager != null)
+                    if (jobManager != null) {
                         jobManager.finish();
-                }
-                catch (Exception e) {
+                    }
+                } catch (Exception e) {
                     e.printStackTrace();
                     logger.log(Level.WARNING, "Error calling jobManager.finish() in job cleanup.");
                 }
@@ -692,15 +700,14 @@
                     server = null;
                     logger.log(Level.CONFIG, "Remote AIDA server was closed.");
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
                 logger.log(Level.WARNING, "Error in finish() method <" + e.getMessage() + ">.");
             }
         }
 
         public void prestart(int seconds, int runNumber) {
-            final long millis = ((long)seconds) * 1000;
+            final long millis = ((long) seconds) * 1000;
             eventPanel.setRunNumber(runNumber);
             eventPanel.setRunStartTime(millis);
             logger.log(Level.INFO, "Set run number <" + runNumber + "> from Pre Start.");
@@ -708,7 +715,7 @@
         }
 
         public void endRun(int seconds, int events) {
-            final long millis = ((long)seconds) * 1000;
+            final long millis = ((long) seconds) * 1000;
             eventPanel.setRunEndTime(millis);
             eventPanel.setRunEventCount(events);
             logger.log(Level.INFO, "Set number of events in run to <" + events + ">.");
@@ -718,9 +725,10 @@
 
     /**
      * Set the job parameters.
+     *
      * @param p The job parameters.
      */
-    private void setJobParameters(JobParameters p) {		
+    private void setJobParameters(JobParameters p) {
         jobPanel.setDetectorName(p.detectorName);
         jobPanel.setSteeringResource(p.steeringResource);
         jobPanel.setDefaultEventBuilder(p.eventBuilderClassName);
@@ -728,6 +736,7 @@
 
     /**
      * Set the connection status.
+     *
      * @param status The connection status.
      */
     private void setConnectionStatus(int status) {
@@ -739,6 +748,7 @@
 
     /**
      * Get the current connection status.
+     *
      * @return The connection status.
      */
     private int getConnectionStatus() {
@@ -747,14 +757,16 @@
 
     /**
      * Get whether there is currently a connection request.
+     *
      * @return True if connection is currently requested; false if no.
      */
     private boolean connectionRequested() {
         return connectionStatus == ConnectionStatus.CONNECTION_REQUESTED;
-    }            
+    }
 
     /**
      * Pop-up a modal dialog.
+     *
      * @param m The message to display in the dialog box.
      */
     private void showDialog(String m) {
@@ -762,8 +774,8 @@
     }
 
     /**
-     * Setup the frame to run the application.  
-     * This should be called using Runnable.run() (see MonitoringExample).
+     * Setup the frame to run the application. This should be called using
+     * Runnable.run() (see MonitoringExample).
      */
     private void createApplicationFrame() {
         mainPanel.setOpaque(true);
@@ -771,7 +783,7 @@
         frame.setContentPane(mainPanel);
         frame.setJMenuBar(menuBar);
         frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
-        frame.setMinimumSize(new Dimension(800,400));
+        frame.setMinimumSize(new Dimension(800, 400));
         frame.setResizable(false);
         frame.pack();
         frame.setVisible(true);
@@ -806,45 +818,45 @@
                 (new JobControlManager()).setup(fileName);
                 jobPanel.setSteeringFile(fileName.getPath());
                 logger.log(Level.INFO, "Steering file set to <" + fileName.getPath() + ">.");
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
                 logger.log(Level.SEVERE, "Failed to read steering file <" + fileName.getPath() + ">.");
                 showDialog("Failed to read the LCSim XML file.");
-            }	       
+            }
         }
     }
 
     /**
      * Get the full title of the application.
+     *
      * @return The application title.
      */
     private static String getApplicationTitle() {
-        return "HPS Monitoring - " + getUserName() + "@"+ getHostname();
+        return "HPS Monitoring - " + getUserName() + "@" + getHostname();
     }
 
     /**
      * Get the hostname, which is used in the application title.
+     *
      * @return The hostname.
      */
     private static String getHostname() {
         try {
             return InetAddress.getLocalHost().getHostName();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return "UNKNOWN_HOST";
         }
     }
 
     /**
      * Get the user name, which is used in the application title.
+     *
      * @return The user name.
      */
     private static String getUserName() {
         if (System.getProperty("user.name") == null) {
             return "UNKNOWN_USER";
-        } 
-        else {
+        } else {
             return System.getProperty("user.name");
         }
     }
@@ -862,14 +874,14 @@
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
-                } 
+                }
             }
         }
         logger.log(Level.INFO, "LCSim drivers were reset.");
     }
 
     /**
-     * Redirect System.out and System.err to a file.  This is independent of 
+     * Redirect System.out and System.err to a file. This is independent of
      * messages that are sent to the application's log table and is primarily
      * used to capture lengthy debug output from event processing.
      */
@@ -881,14 +893,17 @@
             final File logFile = fc.getSelectedFile();
             if (logFile.exists()) {
                 JOptionPane.showMessageDialog(this.mainPanel, "Log file already exists.");
-            } else {			
+            } else {
                 try {
-                    if (!logFile.createNewFile()) throw new IOException();
+                    if (!logFile.createNewFile()) {
+                        throw new IOException();
+                    }
                     PrintStream ps = new PrintStream(new FileOutputStream(logFile.getPath()));
                     System.setOut(ps);
-                    System.setErr(ps);				
+                    System.setErr(ps);
 
                     SwingUtilities.invokeLater(new Runnable() {
+
                         public void run() {
                             jobPanel.logFileField.setText(logFile.getPath());
                             jobPanel.logCheckBox.setSelected(true);
@@ -907,13 +922,15 @@
     }
 
     /**
-     * Redirect System.out and System.err back to the terminal, e.g. if they were previously sent to a file.
-     * This is independent of messages that are sent to the application's log table.
+     * Redirect System.out and System.err back to the terminal, e.g. if they
+     * were previously sent to a file. This is independent of messages that are
+     * sent to the application's log table.
      */
     private void logToTerminal() {
         System.setOut(sysOut);
-        System.setErr(sysErr);		
+        System.setErr(sysErr);
         SwingUtilities.invokeLater(new Runnable() {
+
             public void run() {
                 jobPanel.logFileField.setText("");
                 jobPanel.logCheckBox.setSelected(false);
@@ -936,15 +953,15 @@
             }
             eventPanel.setEventRefresh(newEventRefresh);
             logger.log(Level.INFO, "Event refresh set to <" + newEventRefresh + ">.");
-        } 
-        catch (Exception e) {
+        } catch (Exception e) {
             logger.log(Level.WARNING, "Ignored invalid event refresh setting.");
             showDialog("The value " + inputValue + " is not valid for Event Refresh Rate.");
         }
     }
 
     /**
-     * Using a modal input dialog, set the maximum number of events to process before automatic disconnect.
+     * Using a modal input dialog, set the maximum number of events to process
+     * before automatic disconnect.
      */
     private void setMaxEvents() {
         String inputValue = JOptionPane.showInputDialog("Max Events:", eventPanel.getMaxEvents());
@@ -959,24 +976,23 @@
             // Set max events in event processor.
             eventProcessor.setMaxEvents(newMaxEvents);
             logger.log(Level.INFO, "Max events set to <" + newMaxEvents + ">.");
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             logger.log(Level.WARNING, "Ignored invalid max events setting <" + inputValue + ">.");
             showDialog("The value " + inputValue + " is not valid for Max Events.");
         }
     }
 
     /**
-     * Set the GUI state to disconnected, which will enable/disable applicable GUI
-     * components and menu items.
+     * Set the GUI state to disconnected, which will enable/disable applicable
+     * GUI components and menu items.
      */
-    private void setDisconnectedGuiState() {		
+    private void setDisconnectedGuiState() {
 
         // Enable or disable appropriate menu items.
         connectItem.setEnabled(true);
         disconnectItem.setEnabled(false);
         resetConnectionItem.setEnabled(true);
-        connectionLoadItem.setEnabled(true);		
+        connectionLoadItem.setEnabled(true);
         savePlotsItem.setEnabled(false);
         resetDriversItem.setEnabled(false);
         logItem.setEnabled(true);
@@ -998,7 +1014,8 @@
     }
 
     /**
-     * Set the GUI to connected state, which will enable/disable appropriate components and menu items.
+     * Set the GUI to connected state, which will enable/disable appropriate
+     * components and menu items.
      */
     private void setConnectedGuiState() {
 
@@ -1047,9 +1064,9 @@
         if (r == JFileChooser.APPROVE_OPTION) {
             String fileName = fc.getSelectedFile().getPath();
             int extIndex = fileName.lastIndexOf(".");
-            if ((extIndex == -1) || !(fileName.substring(extIndex+1, fileName.length())).toLowerCase().equals(screenshotFormat)) {
+            if ((extIndex == -1) || !(fileName.substring(extIndex + 1, fileName.length())).toLowerCase().equals(screenshotFormat)) {
                 fileName = fileName + "." + screenshotFormat;
-            } 
+            }
             takeScreenshot(fileName);
             logger.log(Level.INFO, "Screenshot saved to <" + fileName + ">.");
         }
@@ -1057,13 +1074,14 @@
 
     /**
      * Save a screenshot to output file.
+     *
      * @param fileName The name of the output file.
      */
     private void takeScreenshot(String fileName) {
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
         Rectangle screenRectangle = new Rectangle(screenSize);
         try {
-            Robot robot = new Robot();			
+            Robot robot = new Robot();
             BufferedImage image = robot.createScreenCapture(screenRectangle);
             ImageIO.write(image, screenshotFormat, new File(fileName));
         } catch (AWTException e) {
@@ -1074,8 +1092,9 @@
     }
 
     /**
-     * Get the fully qualified class name of the current event builder
-     * for converting from EVIO to LCIO.
+     * Get the fully qualified class name of the current event builder for
+     * converting from EVIO to LCIO.
+     *
      * @return The class name of the event builder.
      */
     private String getEventBuilderClassName() {
@@ -1084,6 +1103,7 @@
 
     /**
      * Get the type of steering file being used.
+     *
      * @return The type of the steering file.
      */
     private int getSteeringType() {
@@ -1092,6 +1112,7 @@
 
     /**
      * Get the current max events setting.
+     *
      * @return The maximum number of events to process before disconnect.
      */
     private int getMaxEvents() {
@@ -1104,9 +1125,9 @@
     private void session() {
 
         logger.log(Level.INFO, "Starting a new monitoring session.");
-        
+
         int endStatus = ConnectionStatus.DISCONNECTING;
-        
+
         try {
 
             // Setup LCSim.
@@ -1126,25 +1147,24 @@
             logger.log(Level.FINEST, "Started event processing thread.");
 
             logHandler.flush();
-            
+
             // Wait for the event processing thread to finish.
             try {
-                 eventProcessingThread.join();
+                eventProcessingThread.join();
+            } catch (InterruptedException e) {
             }
-            catch (InterruptedException e) {}
             logger.log(Level.INFO, "Event processor finished with status <" + ConnectionStatus.toString(eventProcessor.getStatus()) + ">.");
             endStatus = eventProcessor.getStatus();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             logger.log(Level.SEVERE, "Fatal error in monitoring session.");
             endStatus = ConnectionStatus.ERROR;
-        }
-        finally {
+        } finally {
             logHandler.flush();
             // Disconnect if needed.
-            if (getConnectionStatus() != ConnectionStatus.DISCONNECTED)
+            if (getConnectionStatus() != ConnectionStatus.DISCONNECTED) {
                 disconnect(endStatus);
+            }
         }
     }
 
@@ -1158,8 +1178,7 @@
             boolean ok = this.server.start();
             if (ok) {
                 logger.log(Level.INFO, "Remote AIDA server started with name <" + jobPanel.getRemoteAIDAName() + ">.");
-            }
-            else {
+            } else {
                 this.server = null;
                 logger.log(Level.SEVERE, "Failed to start remote AIDA server.");
             }
@@ -1168,39 +1187,41 @@
 
     /**
      * Create the Thread for processing EtEvents.
+     *
      * @return The Thread for event processing.
      */
-    private Thread createEventProcessingThread()
-    {
+    private Thread createEventProcessingThread() {
         // Create a new event processor.
         eventProcessor = new DefaultEtEventProcessor(
-                this.connection, 
-                this.eventBuilder, 
-                this.jobManager, 
-                getMaxEvents(), 
+                this.connection,
+                this.eventBuilder,
+                this.jobManager,
+                getMaxEvents(),
                 disconnectOnError(),
                 this.logHandler);
         // Add the application's listener for callback to GUI.
         eventProcessor.addListener(this.etListener);
         // Set initial pause mode from job panel after which it can be toggled via event buttons.
-        eventProcessor.pauseMode(this.jobPanel.pauseMode()); 
+        eventProcessor.pauseMode(this.jobPanel.pauseMode());
         Runnable run = new Runnable() {
+
             public void run() {
                 eventProcessor.process();
-             }
+            }
         };
         return new Thread(run, "EtEvent Processing Thread");
     }
 
     /**
-     * Connect to the ET system specified in the GUI's connection panel settings.
+     * Connect to the ET system specified in the GUI's connection panel
+     * settings.
      */
     private void connect() {
 
         logger.log(Level.INFO, "Connecting to ET system.");
-        
+
         setConnectionStatus(ConnectionStatus.CONNECTION_REQUESTED);
-        
+
         // Make sure applicable menu items are enabled or disabled.
         setConnectedGuiState();
 
@@ -1212,6 +1233,7 @@
 
     /**
      * Get whether the current steering file or resource looks valid.
+     *
      * @return True if steering is valid; false if no.
      */
     private boolean validSteering() {
@@ -1219,7 +1241,9 @@
     }
 
     /**
-     * Get the steering parameter, which is either a file path or resource string.
+     * Get the steering parameter, which is either a file path or resource
+     * string.
+     *
      * @return The steering parameter.
      */
     private String getSteering() {
@@ -1228,6 +1252,7 @@
 
     /**
      * Get the name of the detector for conditions data.
+     *
      * @return The name of the detector.
      */
     private String getDetectorName() {
@@ -1236,6 +1261,7 @@
 
     /**
      * Get the connection parameter settings from the connection panel.
+     *
      * @return The connection parameters.
      */
     private ConnectionParameters getConnectionParameters() {
@@ -1244,6 +1270,7 @@
 
     /**
      * Get whether a warning dialog will open before disconnect.
+     *
      * @return True if warning will occur before disconnect; false if no.
      */
     private boolean warnOnDisconnect() {
@@ -1252,6 +1279,7 @@
 
     /**
      * Get whether errors in event processing will cause automatic disconnect.
+     *
      * @return True if disconnect on event processing error; false if no.
      */
     private boolean disconnectOnError() {
@@ -1264,6 +1292,7 @@
 
     /**
      * Disconnect from the ET session with a particular status.
+     *
      * @param status The connection status.
      */
     synchronized private void disconnect(int status) {
@@ -1281,7 +1310,7 @@
             logger.log(Level.WARNING, "ET system is already disconnecting.");
             return;
         }
-        
+
         // Show a warning dialog box before disconnecting, if this option is selected.
         if (warnOnDisconnect()) {
             logger.log(Level.FINEST, "Waiting for user to verify disconnect request.");
@@ -1296,10 +1325,10 @@
             // when the ET connection goes down.
             eventProcessor.stop();
         }
-        
+
         // Set the application status from the caller.
-        setConnectionStatus(status);        
-       
+        setConnectionStatus(status);
+
         // Cleanup the ET session.
         cleanupConnection();
 
@@ -1349,13 +1378,12 @@
             cleanupThread.start();
[truncated at 1000 lines; 178 more skipped]
CVSspam 0.2.12


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