Commit in java/trunk/monitoring-app/src/main/java/org/hps/monitoring on MAIN
record/EventProcessingChain.java+36-24717 -> 718
      /EventProcessingStep.java+2717 -> 718
      /EventProcessingThread.java+1717 -> 718
record/etevent/EtConnection.java+25-10717 -> 718
              /EtEventSource.java+2717 -> 718
subsys/SystemStatisticsImpl.java+2-1717 -> 718
+68-35
6 modified files
minor updates to non GUI parts of monitoring packages

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
EventProcessingChain.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingChain.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -45,11 +45,12 @@
  * 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, update a GUI component, or analyze the events.
+ * can be registered with the different loops for processing the different 
+ * record types, in order to plot, update a GUI component, or analyze the events.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
  */
+// FIXME: Make sure that end run EVIO events cause the processing to end.
 public class EventProcessingChain extends AbstractLoopListener {
       
     /**
@@ -244,39 +245,43 @@
     }
     
     public void suspend(LoopEvent loopEvent) {
-        System.out.println(this.getClass().getSimpleName() + ".suspend");
-        System.out.println("Error occurred ...");
-        if (loopEvent.getException() != null)
+        if (loopEvent.getException() != null) {
             loopEvent.getException().printStackTrace();
-        this.isDone = true;
+            lastException = (Exception) loopEvent.getException();
+        }
     }
     
-    // TODO: EventProcessingChain should be registered as an AbstractLoopListener on the composite loop.
-    // This way it can catch processing errors and set the done state.
     public void loop() {
         while (!isDone) {
-            System.out.println("not done...");
             if (!paused) {
-                //System.out.println("doing compositeLoop.execute ...");
-                compositeLoop.execute(Command.GO, false);
-                //System.out.println("done with compositeLoop.execute");
-                //System.out.println("Errors ...");
-                //if (compositeLoop.getProgress().getException() != null) {
-                //    System.out.println(compositeLoop.getProgress().getException().getMessage());                    
-                //} else {
-                //    System.out.println("none");
-                //}
+                // TODO: Add check here for correct loop state.
+                compositeLoop.execute(Command.GO, true);
+                
+                // When an exception occurs, which can sometimes just be control flow,
+                // the event processing should stop.
+                if (lastException != null) {
+                    lastException.printStackTrace();
+                    if (!isDone)
+                        // Call finish manually here as the loop was suspended.
+                        finish(); 
+                } 
             }
         }
     }
     
     public void pause() {
+        // TODO: Add check here for correct loop state.
         compositeLoop.execute(Command.PAUSE);
         paused = true;
     }
         
     public void finish() {
-        compositeLoop.execute(Command.STOP);
+        // TODO: Add check here for correct loop state.
+        try {
+            compositeLoop.execute(Command.STOP);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         isDone = true;
     }    
         
@@ -307,10 +312,11 @@
          */
         public void execute() throws IOException, NoSuchRecordException {
             
-            // Load the next EtEvent.
+            // Load the next EtEvent, which calls getEvents() on the ET connection
+            // and feeds records to any loop listeners like status monitors.
             etLoop.execute(NEXT);
             
-            // Get an EtEvent from the loop.
+            // Get the current EtEvent from the loop, which should have been cached.
             EtEvent nextEtEvent = (EtEvent) etLoop.getRecordSource().getCurrentRecord();
             
             // Failed to read an EtEvent from the ET server.
@@ -318,6 +324,7 @@
                 //throw new NoSuchRecordException("No current EtEvent is available.");
                 throw new IOException("No current EtEvent is available.");
             
+            // Update the CompositeRecord with reference to the current EtEvent.
             getCompositeRecord().setEtEvent(nextEtEvent);
         }
     }
@@ -334,6 +341,7 @@
          */
         public void execute() throws IOException, NoSuchRecordException {
             
+            // Handle case of reading from ET system.
             if (sourceType == SourceType.ET_EVENT) {
                 EvioEvent evioEvent = null;
                 try {
@@ -362,6 +370,7 @@
             // Encountered an end of run record.
             if (EventConstants.isEndEvent(nextEvioEvent))
                 // If stop on end run is enabled, then trigger an exception to end processing.
+                // FIXME: Does this suspend/stop the event loop properly???
                 if (stopOnEndRun)
                     throw new EndRunException("EVIO end event received, and stop on end run is enabled.");
         }
@@ -429,7 +438,7 @@
                     // Add LCIO event to the queue.
                     lcioQueue.addRecord(lcioEvent);
                 } else {
-                    // The LCIO processing ignores non-physics events.
+                    // The LCIO processing ignores non-physics events coming from EVIO.
                     return;
                 }
             }
@@ -440,15 +449,18 @@
                     throw new NoSuchRecordException("No next LCIO event.");
             }
             
-            // Process the next LCIO event.
+            // Load the next LCIO event.
             lcsimLoop.execute(NEXT);
                                    
-            // The last call to the loop did not create a current record for some reason.
+            // The last call to the loop did not create a current record.
             if (lcsimLoop.getRecordSource().getCurrentRecord() == null) {
                 throw new NoSuchRecordException("No current LCIO event.");
             }
             
+            // Get the current LCIO event.
             EventHeader lcioEvent = (EventHeader) lcsimLoop.getRecordSource().getCurrentRecord();
+            
+            // Update the CompositeRecord with referece to the LCIO event.
             getCompositeRecord().setLcioEvent(lcioEvent);
         }
     }

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
EventProcessingStep.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingStep.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingStep.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -7,6 +7,8 @@
 /**
  * Interface for a single processing step which handles one type of record.
  */
+// FIXME: This could be done by registering record listener's on CompositeLoop
+// which receive and alter the current CompositeRecord.
 public interface EventProcessingStep {    
     void execute() throws IOException, NoSuchRecordException;    
 }
\ No newline at end of file

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record
EventProcessingThread.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/EventProcessingThread.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -20,6 +20,7 @@
     @Override
     public void run() {
         processing.loop();
+
         /*
         while (!processing.isDone()) {
             try {

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
EtConnection.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -79,19 +79,34 @@
      * Cleanup the ET connection.
      */
     public void cleanup() {
-        boolean debug = false;
+        boolean debug = true;
         try {
-            if (debug)
-                System.out.println("ET cleanup - sys.detach ...");
+            if (!sys.alive()) {
+                throw new RuntimeException("EtSystem is not alive!");
+            }               
+            if (debug) {
+                System.out.println("EtConnection cleanup ...");
+                System.out.println("sys.detach ...");
+            }
+            //if (!att.isUsable()) {
+            //    throw new RuntimeException("EtAttachment is not usable!");
+            //}
+            // FIXME: This can hang forever when in getEvents() call!!!
             sys.detach(att);
-            if (debug)
-                System.out.println("ET cleanup - sys.removeStation ...");
+            if (debug) {
+                System.out.println("sys.detach okay");
+                System.out.println("sys.removeStation ...");
+            }
             sys.removeStation(stat);
-            if (debug)
-                System.out.println("ET cleanup - sys.close ...");
+            if (debug) {
+                System.out.println("sys.removeStation okay");
+                System.out.println("sys.close ...");
+            }
             sys.close();
-            if (debug)
-                System.out.println("ET cleanup - successful");
+            if (debug) {
+                System.out.println("sys.close okay");
+                System.out.println("EtConnection cleanup successful!");
+            }
         }
         catch (Exception e) {
             e.printStackTrace();
@@ -146,7 +161,7 @@
     /**
      * Read EtEvent objects from the ET ring.  
      * Preserve all specific Exception types in throws clause so caller
-     * can implement their own specific error and state handling.
+     * can implement their own error and state handling.
      * @return
      * @throws IOException
      * @throws EtException

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
EtEventSource.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtEventSource.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -100,7 +100,9 @@
     
     void readEtEvents() throws IOException {
         try {
+            System.out.println("reading EtEvents ...");
             EtEvent[] mevs = connection.readEtEvents();
+            System.out.println("done reading EtEvents");
             eventQueue.addAll(Arrays.asList(mevs));
         } catch (Exception e) {
             throw new IOException(e);

java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
SystemStatisticsImpl.java 717 -> 718
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java	2014-06-17 20:36:21 UTC (rev 717)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java	2014-06-17 20:42:29 UTC (rev 718)
@@ -149,7 +149,8 @@
     }
 
     @Override
-    public void stop() {        
+    public void stop() { 
+        System.out.println("SystemStatistics.stop");
         // Kill the Timer.
         if (timer != null)
             timer.cancel();
SVNspam 0.1