Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/monitoring on MAIN
ConnectionPanel.java+35-241.6 -> 1.7
ConnectionParameters.java+13-61.5 -> 1.6
MonitoringApplication.java+14-61.2 -> 1.3
MonitoringExample.java+14-21.2 -> 1.3
SensorOccupancyPlotsDriver.java+14-111.6 -> 1.7
+90-49
5 modified files
more updates to monitoring

hps-java/src/main/java/org/lcsim/hps/monitoring
ConnectionPanel.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConnectionPanel.java	27 Mar 2012 04:13:37 -0000	1.6
+++ ConnectionPanel.java	27 Mar 2012 05:02:37 -0000	1.7
@@ -20,6 +20,7 @@
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+import org.jlab.coda.et.enums.Mode;
 import org.lcsim.hps.monitoring.ConnectionParameters.WaitMode;
 
 // TODO Add status field of (connected|disconnected|connecting|timed out)
@@ -42,6 +43,8 @@
         
     private boolean connectRequested = false;    
     private boolean disconnectRequested = false;
+    
+    static final String[] waitStrings = { "SLEEP", "TIMED", "ASYNC" };
 
     ConnectionPanel() {
             	
@@ -225,7 +228,6 @@
         c.gridx = 1;
         c.gridy = 10;
         c.anchor = GridBagConstraints.EAST;
-        String[] waitStrings = { "SLEEP", "WAIT" };
         waitComboBox = new JComboBox(waitStrings);
         add(waitComboBox, c);
         
@@ -267,15 +269,25 @@
         return connectionParameters;
     }
     
-    private WaitMode getWaitMode() {
-    	WaitMode mode = WaitMode.SLEEP;
+    private Mode getWaitMode() {
+    	Mode mode = Mode.SLEEP;
     	String sel = (String)waitComboBox.getSelectedItem();
     	if ("wait".equals(sel.toLowerCase())) {
-    		mode = WaitMode.WAIT;
+    		mode = Mode.TIMED;
     	}
     	return mode;
     }
     
+    private void setWaitMode(Mode waitMode) {
+    	if (waitMode == Mode.SLEEP) {
+        	waitComboBox.setSelectedIndex(0);
+        } else if (waitMode == Mode.TIMED) {
+        	waitComboBox.setSelectedIndex(1);
+        } else if (waitMode == Mode.ASYNC) {
+        	waitComboBox.setSelectedIndex(2);
+        }
+    }
+    
     private void setConnectionParameters(ConnectionParameters cn) {
     	etNameField.setText(cn.etName);
     	hostField.setText(cn.host);
@@ -287,35 +299,18 @@
         qSizeField.setText(Integer.toString(cn.qSize));
         positionField.setText(Integer.toString(cn.position));
         ppositionField.setText(Integer.toString(cn.pposition));
-        if (cn.waitMode == WaitMode.SLEEP) {
-        	waitComboBox.setSelectedIndex(0);
-        } else if (cn.waitMode == WaitMode.WAIT) {
-        	waitComboBox.setSelectedIndex(1);
-        }
+        setWaitMode(cn.waitMode);
         waitTimeField.setText(Integer.toString(cn.waitTime));
     	this.connectionParameters = cn;
     }
-         
-    public void actionPerformed(ActionEvent e) {
-    	if ("connect".equals(e.getActionCommand())) {
-    		setConnectRequested();
-    	} else if ("disconnect".equals(e.getActionCommand())) {
-    		setDisconnectRequested();    		
-    	} else if ("saveConnection".equals(e.getActionCommand())) {
-    		save();
-    	} else if ("loadConnection".equals(e.getActionCommand())) {
-    		load();
-    	} else if ("resetConnectionSettings".equals(e.getActionCommand())) {
-    		reset();
-    	}
-    }
-    
+                
     private void setConnectRequested() {
     	connectRequested = true;
     	disconnectRequested = false;
     	enableConnectionPanel(false);
     }
     
+	// FIXME Somehow this needs to interrupt if events are being fetched in Mode.SLEEP or we will never wake-up.
     private void setDisconnectRequested() {
     	disconnectRequested = true;
     	connectRequested = false;
@@ -344,6 +339,22 @@
     	return this.disconnectRequested;
     }
     
+    // FIXME These strings should be changed to constants.  If there are duplications
+    // with MonitorinApplication then move to common class like MonitoringCommands.
+    public void actionPerformed(ActionEvent e) {
+    	if ("connect".equals(e.getActionCommand())) {
+    		setConnectRequested();
+    	} else if ("disconnect".equals(e.getActionCommand())) {
+    		setDisconnectRequested();    		
+    	} else if ("saveConnection".equals(e.getActionCommand())) {
+    		save();
+    	} else if ("loadConnection".equals(e.getActionCommand())) {
+    		load();
+    	} else if ("resetConnectionSettings".equals(e.getActionCommand())) {
+    		reset();
+    	}
+    }
+    
     private void save() {
     	JFileChooser fc = new JFileChooser();
         int r = fc.showSaveDialog(ConnectionPanel.this);

hps-java/src/main/java/org/lcsim/hps/monitoring
ConnectionParameters.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- ConnectionParameters.java	27 Mar 2012 03:18:21 -0000	1.5
+++ ConnectionParameters.java	27 Mar 2012 05:02:37 -0000	1.6
@@ -5,6 +5,7 @@
 import java.net.UnknownHostException;
 
 import org.jlab.coda.et.EtConstants;
+import org.jlab.coda.et.enums.Mode;
 
 /**
  * Connection parameters for ET system consumer.
@@ -22,7 +23,7 @@
     public int position = 1;
     public int pposition = 0;
     public int flowMode = EtConstants.stationSerial;
-    public WaitMode waitMode = WaitMode.SLEEP;
+    public Mode waitMode = Mode.SLEEP; // sleep, timed or async
     public int waitTime = 20000000; // wait time in microseconds
     
     public enum WaitMode {
@@ -55,10 +56,11 @@
                 "       -q     queue size if creating nonblocking station\n" +
                 "       -pos   position of created station in station list (1,2,...)\n" +
                 "       -ppos  position of created station within a group of parallel stations (-1=end, -2=head)\n" +
-                "       -w     wait for events for specified time period in microseconds rather than sleeping" +
+                "       -a     run in async mode which needs immediate connection (no wait)\n" +
                 "       -t     time to wait for events before timing out\n\n" +
                 "        This consumer works by making a direct connection\n" +
                 "        to the ET system's tcp server port.\n");
+//      "       -w     wait for events for specified time period in microseconds rather than sleeping" +
     }
     
     public void loadPropertiesFile(File propFile) {    	
@@ -136,15 +138,20 @@
                     throw new ConnectionParametersException("Did not specify a proper parallel position number.");
                 }                
             } else if (args[i].equalsIgnoreCase("-w")) {
-            	waitMode = WaitMode.WAIT;
+            	waitMode = Mode.TIMED;
+            } else if (args[i].equalsIgnoreCase("-a")) {
+            	waitMode = Mode.ASYNC;
+            	if (waitTime != 0) {
+            		throw new ConnectionParametersException("Can't specify wait time and async mode at the same time.");
+            	}
+            		
             } else if (args[i].equalsIgnoreCase("-t")) {
+            	waitMode = Mode.TIMED;
             	waitTime = Integer.parseInt(args[++i]);
             	if (waitTime < 0) {
             		throw new ConnectionParametersException("Invalid wait time specified.");
             	}
-            } 
-            
-            else {
+            } else {
                 throw new ConnectionParametersException("Arguments included invalid command line parameter:" + args[i]);
             }
         }

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplication.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MonitoringApplication.java	27 Mar 2012 04:13:37 -0000	1.2
+++ MonitoringApplication.java	27 Mar 2012 05:02:37 -0000	1.3
@@ -65,6 +65,7 @@
 		JMenu connectionMenu = new JMenu("Connection");
 		menuBar.add(connectionMenu);
 		
+		
 		connectItem = new JMenuItem("Connect");
 		connectItem.setMnemonic(KeyEvent.VK_C);
 		connectItem.setActionCommand(connectCmd);
@@ -75,6 +76,7 @@
 		disconnectItem.setMnemonic(KeyEvent.VK_D);
 		disconnectItem.setActionCommand(disconnectCmd);
 		disconnectItem.addActionListener(this);
+		disconnectItem.setEnabled(false);
 		connectionMenu.add(disconnectItem);
 		
 		resetConnectionItem = new JMenuItem("Reset Connection Settings");
@@ -117,12 +119,14 @@
 		savePlotsItem.setMnemonic(KeyEvent.VK_P);
 		savePlotsItem.setActionCommand("savePlots");
 		savePlotsItem.addActionListener(this);
+		savePlotsItem.setEnabled(false);
 		jobMenu.add(savePlotsItem);		
 		
 		resetDriversItem = new JMenuItem("Reset LCSim Drivers");
 		resetDriversItem.setMnemonic(KeyEvent.VK_D);
 		resetDriversItem.setActionCommand("resetDrivers");
 		resetDriversItem.addActionListener(this);
+		resetDriversItem.setEnabled(false);
 		jobMenu.add(resetDriversItem);
 		
 		//
@@ -195,28 +199,32 @@
 		System.exit(0);
 	}
 	
-	void disconnect() {		
+	synchronized void disconnect() {		
+		
 		// Enable or disable appropriate menu items.
 		connectItem.setEnabled(true);
 		disconnectItem.setEnabled(false);
 		resetConnectionItem.setEnabled(true);
 		connectionLoadItem.setEnabled(true);		
 		savePlotsItem.setEnabled(false);
+		resetDriversItem.setEnabled(false);
 		
-		// Reset the LCSim Drivers, which should destroy Plotters.
-		resetDrivers();
-		
-		// Reenable the ConnectionPanel.
+		// Re-enable the ConnectionPanel.
 		connectionPanel.enableConnectionPanel(true);
+		
+		// Reset the LCSim Drivers, which should destroy Plotters.
+		resetDrivers();		
 	}
 	
-	void connect() {		
+	synchronized void connect() {
+		
 		// Enable or disable appropriate menu items.
 		connectItem.setEnabled(false);
 		disconnectItem.setEnabled(true);
 		resetConnectionItem.setEnabled(false);
 		connectionLoadItem.setEnabled(false);
 		savePlotsItem.setEnabled(true);
+		resetDriversItem.setEnabled(true);
 	}
 			
 	ConnectionPanel getConnectionPanel() {

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringExample.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MonitoringExample.java	27 Mar 2012 04:13:37 -0000	1.2
+++ MonitoringExample.java	27 Mar 2012 05:02:37 -0000	1.3
@@ -104,16 +104,28 @@
 
     			// array of events
     			EtEvent[] mevs = null;
+    			
+    			Mode waitMode = cn.waitMode;
+    			int waitTime = cn.waitTime;
+    			int chunk = cn.chunk;
 
     			// EtEvent loop.
     			while (true) { 
     				try {           
     					// Choose wait or sleep mode depending on connection settings.
-    					if (cn.waitMode == WaitMode.WAIT) {
+    					/*
+    					if (cn.waitMode == Mode.TIMED) {
     						mevs = sys.getEvents(att, Mode.TIMED, Modify.NOTHING, cn.waitTime, cn.chunk);
-    					} else {
+    					} else if (cn.waitMode == Mode.SLEEP) {
     						mevs = sys.getEvents(att, Mode.SLEEP, Modify.NOTHING, 0, cn.chunk);
+    					} else if (cn.waitMode == Mode.ASYNC) {
+    						mevs = sys.getEvents(att, Mode.ASYNC, Modify.NOTHING, 0, cn.chunk);
     					}
+    					*/
+    					
+    					// Get EtEvents.
+    					// TODO Allow interrupt of sleep mode using EtWakeUpException.  (not sure how though!)
+    					mevs = sys.getEvents(att, waitMode, Modify.NOTHING, waitTime, chunk);
 
     					// Loop over retrieved EtEvents.
     					for (EtEvent mev : mevs) {

hps-java/src/main/java/org/lcsim/hps/monitoring
SensorOccupancyPlotsDriver.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- SensorOccupancyPlotsDriver.java	27 Mar 2012 04:13:37 -0000	1.6
+++ SensorOccupancyPlotsDriver.java	27 Mar 2012 05:02:37 -0000	1.7
@@ -68,9 +68,10 @@
         
     protected void detectorChanged(Detector detector) {
         
-        // If called > 1 then destroy plots that might be currently up.
+        // If called multiple times then destroy plots that might be currently up.
         if (occuPlotter != null) {
             occuPlotter.hide();
+            occuPlotter.destroyRegions();
         }
        
         // Setup the plotter.  Should only need to be done once per job.
@@ -81,15 +82,20 @@
             pstyle.dataStyle().fillStyle().setColor("green");
             pstyle.dataStyle().markerStyle().setColor("green");
             pstyle.dataStyle().errorBarStyle().setVisible(false);
-            pstyle.statisticsBoxStyle().setVisible(false);
-            occuPlotter.createRegions(5, 4); // FIXME Hard-coded to 20 sensors.
+            pstyle.statisticsBoxStyle().setVisible(false);            
         }            
         
+        // Create regions.
+        occuPlotter.createRegions(5, 4); // FIXME Hard-coded to 20 sensors.
+        
         // Cache Detector object.
         this.detector = detector;
         
         // Make a list of SiSensors in the SVT.
-        sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);        
+        sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
+        
+        // Reset the data structure that keeps track of strip occupancies.
+        resetOccupancyMap();
        
         // For now throw an error if there are "too many" sensors.
         if (sensors.size() > 20) {
@@ -97,27 +103,24 @@
         }
 
         // Map a map of sensors to their region numbers in the plotter.
-        IIdentifierHelper helper = sensors.get(0).getIdentifierHelper();
         sensorRegionMap = new HashMap<SiSensor,Integer>();
         for (SiSensor sensor : sensors) {                      
             int region = computePlotterRegion(sensor);
             sensorRegionMap.put(sensor,region);
         }
-               
-        // Reset the data structure that keeps track of strip occupancies.
-        resetOccupancyMap();
 
         // Setup the occupancy plots.
         aida.tree().cd("/");
         for (SiSensor sensor : sensors) {
             IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName(), 640, 0, 639);
+            occupancyPlot.reset();
             occuPlotter.region(sensorRegionMap.get(sensor)).plot(occupancyPlot);
         }
-        occuPlotter.show();
+        occuPlotter.show();                
     }
             
     public void process(EventHeader event) {
-        
+            	    
         // Increment event counter.
         ++eventCount;
 
@@ -154,8 +157,8 @@
     }
     
     public void reset() {
-    	occuPlotter.hide();
         eventCount = 0;
         resetOccupancyMap();
+        //detectorChanged(detector);        
     }
 }
\ No newline at end of file
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