CalibrationControllerPanel2.java

00001 /*
00002  * CalibrationControllerPanel.java
00003  *
00004  * Created on 30 July 2003, 23:01
00005  */
00006 
00007 package DisplayGUI;
00008 
00009 import java.util.logging.*;
00010 import javax.swing.*;
00011 import Sct_CalibrationController.*;
00012 import Sct.IS.SctNames;
00013 import is.*;
00014 import CS.RCStateInfo; // Warning! This file is not always included in the tdaq source release, being gnereated from xml source.  You may need to do something like: cp /afs/cern.ch/atlas/project/tdaq/cmt/tdaq-01-04-00-or-other-version-number/ClipsServer/jsrc/* $TDAQ_INST_PATH/../ClipsServer/jsrc The relevant file for this package is RCStateInfo.java
00015 //import CS.DAQApplicationInfo; // ditto as above, except the relevant file is DAQApplicationInfo.java
00016 import CS.RunParams;
00017 
00022 public class CalibrationControllerPanel2 extends javax.swing.JPanel implements InfoListener, displayParams {
00023     
00024     gui guiControl;
00025     CalibrationControllerStatus status=null;
00026     java.util.regex.Pattern testdatapattern = java.util.regex.Pattern.compile(".*\\.(\\d+\\.\\d+.*)");
00027     java.util.regex.Matcher matcher;
00028     int currentBin=-1;
00029     int maxBin=-1;
00030 
00031     private boolean subscribedToRC=false;
00032     private boolean subscribedToCC=false;
00033 
00034         CalibrationControllerPanelMenu calibrationControllerPanelMenu;
00035 
00036     public CalibrationControllerPanel2(gui parent) {
00037         guiControl=parent;
00038 
00039           logger = Logger.getLogger("DisplayGUI");
00040 
00041           calibrationControllerPanelMenu = new CalibrationControllerPanelMenu(guiControl);
00042 
00043         setBackground(new java.awt.Color(255, 255, 255));
00044         is = GuiComponents.System.ISInterface.getInstance();
00045         initComponents();
00046           subscribeToRC(); // subscribe to RC-related IS objects
00047           readRunType("RunParams.RunParams"); // read the current run type
00048           readRunState("RunCtrl.RootController"); // read the current run state
00049         if(!runstatusField.getText().equals("NONE")) subscribeToServers(); // subscribe to CC-related IS objects
00050         updateStatus();
00051         addMouseListener(new ccMouseAdapter());
00052     }
00053 
00054    private void readRunType(String isname) {
00055         try {
00056                 RunParams rp = new RunParams();
00057                 GuiComponents.System.ISInterface.getInstance().getRepository().getValue(isname, rp);
00058                 String runtype = rp.run_type.equals("") ? "UNKNOWN" : rp.run_type;
00059                 runtypeField.setText(runtype);
00060                 runtypeField.setForeground(runtype.equals("UNKNOWN") ? java.awt.Color.red : java.awt.Color.black);
00061                 }
00062         catch(Exception e) {logger.info("Exception in readRunType: "+e.toString());}
00063         }
00064 
00065    public boolean isCalibrationRun() {
00066         return runtypeField.getText().matches("Calibration");
00067         }
00068 
00069   private void unconfigureGUI() {
00070         guiControl.isInterface.clearSubscriptions();
00071         guiControl.displayStatus.clear();
00072         guiControl.menuActions.enableDisplayMenuItems(false);
00073         subscribedToCC=false;
00074         status=null;
00075         updateStatus();
00076         resetDisplayConfiguration();
00077         }
00078 
00079    private void restartCCPanel() {
00080        GuiComponents.System.SystemInterface.getInstance().refresh();
00081        GuiComponents.System.ISInterface.getInstance().refresh();
00082 
00083          if(!guiControl.isReady) return;
00084        subscribeToServers(); // fix for loss of contact
00085        guiControl.guiMenus.rebuildTestMenus(); // rebuild all tests menu - requires CC to be present
00086        }
00087 
00088     private void resetDisplayConfiguration() {
00089        GuiComponents.System.SystemInterface.getInstance().refresh();
00090        GuiComponents.System.ISInterface.getInstance().refresh();
00091        ConfigurationInterface.getInstance().Refresh();
00092 
00093          if(!guiControl.isReady) return;
00094 
00095        guiControl.displayStatus.setConfigurationMode();
00096        int nmods = ConfigurationInterface.getInstance().getTotalNumberOfModules();
00097        System.out.println("Configuration updated with "+nmods+" modules.");
00098        int cacheSize = nmods<200 ? 200 : nmods;
00099        cacheSize*=2;
00100        guiControl.isInterface.setCacheSize(cacheSize);
00101 
00102          guiControl.displayPane.setDisplayColors();
00103          guiControl.displayPane.refreshDisplay();
00104        }
00105 
00106    private void subscribeToRC() {
00107       is = GuiComponents.System.ISInterface.getInstance();
00108        try {
00109           if(!is.subscribe("RunCtrl.RootController",this).matches(".*successful.*")) logger.info("SctGUI Failed to subscribe to RunCtrl.RootController");
00110             if(!is.subscribe("RunParams.RunParams",this).matches(".*successful.*")) logger.info("SctGUI Failed to subscribe to RunParams.RunParams");
00111             subscribedToRC=true;
00112         } catch (RuntimeException e3) {
00113             System.err.println("SctGUI::ConfigurationListener::Couldn't subscribe to RunCtrl.RootController or RunParams.RunParams: " + e3.toString());
00114         }
00115         }
00116 
00117 
00118     public void subscribeToServers() {
00119         is = GuiComponents.System.ISInterface.getInstance();
00120         try {
00121             status = new CalibrationControllerStatus();
00122             is.getRepository().getValue(SctNames.getControlISServer() + ".Status", status);
00123             updateStatus();
00124         } catch (RuntimeException e) {
00125             status=null;
00126             logger.info("Couldn't get CalibrationController Status: " + e.getMessage());
00127             updateStatus();
00128         }
00129         
00130         //Now subscribe to IS server
00131         try {
00132            if(!is.subscribe(SctNames.getControlISServer()+".Status", this).matches(".*successful.*")) logger.info("SctGUI Failed to subscribe to CC.Status");
00133              if(!is.subscribe("SCTAPIServer.currentBin",this).matches(".*successful.*")) logger.info("SctGUI Failed to subscribe to SCTAPIServer.currentBin");
00134            if(!is.subscribe("SCTAPIServer.maxBin",this).matches(".*successful.*")) logger.info("SctGUI Failed to subscribe to SCTAPIServer.maxBin");
00135              subscribedToCC=true;
00136         } catch (RuntimeException e) {
00137             logger.info("Couldn't subscribe to SctRodDaq IS Server(s): " + e.getMessage());
00138         }
00139 
00140 
00141 
00142 
00143     }
00144 
00145     private void unsubscribeToCC() {
00146         is = GuiComponents.System.ISInterface.getInstance();
00147         //Unsubscribe from IS
00148         try {
00149                 if(subscribedToCC) {
00150                 if(!is.unsubscribe(SctNames.getControlISServer()+".Status").matches(".*successful.*")) logger.info("Failed to unsubscribe from CC.Status");
00151                         if(!is.unsubscribe("SCTAPIServer.currentBin").matches(".*successful.*")) logger.info("Failed to unsubscribe from SCTAPIServer.currentBin");
00152                 if(!is.unsubscribe("SCTAPIServer.maxBin").matches(".*successful.*")) logger.info("Failed to unsubscribe from SCTAPIServer.maxBin");
00153                         }
00154         } catch (RuntimeException e) {
00155             logger.info("Couldn't unsubscribe from ControlData IS Server: " + e.getMessage());
00156         }
00157      }
00158 
00159 
00163     void close() {
00164 
00165           unsubscribeToCC();
00166 
00167         is = GuiComponents.System.ISInterface.getInstance();
00168         //Unsubscribe from IS
00169       try {
00170                 if(subscribedToRC) {
00171                 if(!is.unsubscribe("RunCtrl.RootController").matches(".*successful.*")) logger.info("Failed to unsubscribe from RunCtrl.RootController");
00172                         if(!is.unsubscribe("RunParams.RunParams").matches(".*successful.*")) logger.info("Failed to unsubscribe from RunParams.RunParams");
00173                         }
00174         } catch (RuntimeException e2) {
00175             logger.info("Couldn't unsubscribe from ConfigurationServer: " + e2.getMessage());
00176         }
00177     }
00178     
00179 
00180     private void initComponents() {//GEN-BEGIN:initComponents
00181 
00182         jLabel6 = new javax.swing.JLabel();
00183           runtypeField = new javax.swing.JLabel();
00184           jLabel7 = new javax.swing.JLabel();
00185           runstatusField = new javax.swing.JLabel();
00186         jLabel1 = new javax.swing.JLabel();
00187         statusField = new javax.swing.JLabel();
00188         jLabel2 = new javax.swing.JLabel();
00189         testField = new javax.swing.JLabel();
00190         jLabel3 = new javax.swing.JLabel();
00191         sequenceField = new javax.swing.JLabel();
00192         jLabel4 = new javax.swing.JLabel();
00193         scanIndexField = new javax.swing.JLabel();
00194         jLabel5 = new javax.swing.JLabel();
00195 //        currentBinField = new javax.swing.JLabel();
00196         progressBar = new javax.swing.JProgressBar();
00197 //        progressBar.setIndeterminate(true);
00198         progressBar.setStringPainted(true);
00199         progressBar.setString("");
00200         progressBar.setMaximum(100);
00201         progressBar.setValue(0);
00202 //        progressBar.setString("50 out of 100");
00203         progressBar.setForeground(darkBlueColor);
00204 
00205  //       setLayout(new java.awt.GridLayout(5, 2));
00206         setLayout(new java.awt.GridBagLayout());
00207         setBackground(backgroundColor);
00208           java.awt.GridBagConstraints gridBagConstraints;
00209 
00210         jLabel6.setFont(displayCCBoldFont);
00211         jLabel6.setText("Run Type : ");
00212         jLabel6.setHorizontalAlignment(JLabel.RIGHT);
00213         gridBagConstraints = new java.awt.GridBagConstraints();
00214         gridBagConstraints.gridx = 0;
00215         gridBagConstraints.gridy = 0;
00216         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00217         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00218         add(jLabel6, gridBagConstraints);
00219 
00220         runtypeField.setBackground(backgroundColor);
00221         runtypeField.setFont(displayCCFont);
00222         runtypeField.addMouseListener(new ccMouseAdapter());
00223         gridBagConstraints = new java.awt.GridBagConstraints();
00224         gridBagConstraints.gridx = 1;
00225         gridBagConstraints.gridy = 0;
00226         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00227         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00228         add(runtypeField, gridBagConstraints);
00229           runtypeField.setText("UNKNOWN");
00230           runtypeField.setForeground(java.awt.Color.red);
00231 
00232         jLabel7.setFont(displayCCBoldFont);
00233         jLabel7.setText("Run Status : ");
00234         jLabel7.setHorizontalAlignment(JLabel.RIGHT);
00235         gridBagConstraints = new java.awt.GridBagConstraints();
00236         gridBagConstraints.gridx = 0;
00237         gridBagConstraints.gridy = 1;
00238         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00239         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00240         add(jLabel7, gridBagConstraints);
00241 
00242         runstatusField.setBackground(backgroundColor);
00243         runstatusField.setFont(displayCCFont);
00244         runstatusField.addMouseListener(new ccMouseAdapter());
00245         gridBagConstraints = new java.awt.GridBagConstraints();
00246         gridBagConstraints.gridx = 1;
00247         gridBagConstraints.gridy = 1;
00248         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00249         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00250         add(runstatusField, gridBagConstraints);
00251           runstatusField.setText("UNKNOWN");
00252           runstatusField.setForeground(java.awt.Color.red);
00253 
00254         jLabel1.setFont(displayCCBoldFont);
00255 //        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00256         jLabel1.setText("CC Status : ");
00257         jLabel1.setHorizontalAlignment(JLabel.RIGHT);
00258         gridBagConstraints = new java.awt.GridBagConstraints();
00259         gridBagConstraints.gridx = 0;
00260         gridBagConstraints.gridy = 2;
00261  //       gridBagConstraints.weighty = 0.2;
00262         gridBagConstraints.weightx = 0.3;
00263 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00264         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00265         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00266         add(jLabel1, gridBagConstraints);
00267 
00268 
00269         statusField.setBackground(backgroundColor);
00270         statusField.setFont(displayCCFont);
00271         statusField.addMouseListener(new ccMouseAdapter());
00272         gridBagConstraints = new java.awt.GridBagConstraints();
00273         gridBagConstraints.gridx = 1;
00274         gridBagConstraints.gridy = 2;
00275         gridBagConstraints.weightx = 0.7;
00276 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00277         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00278         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00279         add(statusField, gridBagConstraints);
00280 
00281         jLabel2.setFont(displayCCBoldFont);
00282         jLabel2.setText("Current Test : ");
00283         jLabel2.setHorizontalAlignment(JLabel.RIGHT);
00284         gridBagConstraints = new java.awt.GridBagConstraints();
00285         gridBagConstraints.gridx = 0;
00286         gridBagConstraints.gridy = 3;
00287 //      gridBagConstraints.weighty = 0.2;
00288 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00289         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00290         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00291         add(jLabel2, gridBagConstraints);
00292 
00293         testField.setBackground(backgroundColor);
00294         testField.setMaximumSize(new java.awt.Dimension(5,5));
00295         testField.setFont(displayCCFont);
00296         testField.addMouseListener(new ccMouseAdapter());
00297         gridBagConstraints = new java.awt.GridBagConstraints();
00298         gridBagConstraints.gridx = 1;
00299         gridBagConstraints.gridy = 3;
00300 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00301         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00302         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00303         add(testField, gridBagConstraints);
00304 
00305         jLabel3.setFont(displayCCBoldFont);
00306         jLabel3.setText("Current Sequence : ");
00307         jLabel3.setHorizontalAlignment(JLabel.RIGHT);
00308         gridBagConstraints = new java.awt.GridBagConstraints();
00309         gridBagConstraints.gridx = 0;
00310         gridBagConstraints.gridy = 4;
00311 //      gridBagConstraints.weighty = 0.2;
00312 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00313         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00314         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00315         add(jLabel3, gridBagConstraints);
00316 
00317         sequenceField.setBackground(backgroundColor);
00318         sequenceField.setFont(displayCCFont);
00319         sequenceField.addMouseListener(new ccMouseAdapter());
00320         gridBagConstraints = new java.awt.GridBagConstraints();
00321         gridBagConstraints.gridx = 1;
00322         gridBagConstraints.gridy = 4;
00323 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00324         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00325         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00326         add(sequenceField, gridBagConstraints);
00327 
00328         jLabel4.setFont(displayCCBoldFont);
00329         jLabel4.setText("Current Scan Index : ");
00330         jLabel4.setHorizontalAlignment(JLabel.RIGHT);
00331         gridBagConstraints = new java.awt.GridBagConstraints();
00332         gridBagConstraints.gridx = 0;
00333         gridBagConstraints.gridy = 5;
00334 //      gridBagConstraints.weighty = 0.2;
00335 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00336         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00337         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00338         add(jLabel4, gridBagConstraints);
00339 
00340         scanIndexField.setBackground(backgroundColor);
00341         scanIndexField.setFont(displayCCFont);
00342         scanIndexField.addMouseListener(new ccMouseAdapter());
00343         gridBagConstraints = new java.awt.GridBagConstraints();
00344         gridBagConstraints.gridx = 1;
00345         gridBagConstraints.gridy = 5;
00346 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00347         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00348         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00349         add(scanIndexField, gridBagConstraints);
00350 
00351         jLabel5.setFont(displayCCBoldFont);
00352         jLabel5.setText("Scan Progress : ");
00353         jLabel5.setHorizontalAlignment(JLabel.RIGHT);
00354         gridBagConstraints = new java.awt.GridBagConstraints();
00355         gridBagConstraints.gridx = 0;
00356         gridBagConstraints.gridy = 6;
00357 //      gridBagConstraints.weighty = 0.2;
00358 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00359         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00360         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
00361         add(jLabel5, gridBagConstraints);
00362 
00363         progressBar.setBackground(backgroundColor);
00364         progressBar.setFont(displayCCFont);
00365         progressBar.setBorderPainted(false);
00366         progressBar.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00367         progressBar.addMouseListener(new ccMouseAdapter());
00368         gridBagConstraints = new java.awt.GridBagConstraints();
00369         gridBagConstraints.gridx = 1;
00370         gridBagConstraints.gridy = 6;
00371 //        gridBagConstraints.insets = new java.awt.Insets(10,10,0,10);
00372         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00373         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
00374         add(progressBar, gridBagConstraints);
00375 
00376 
00377 
00378        setBorder(new javax.swing.border.TitledBorder(null, "Scan Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 0, 153)));
00379         
00380     }
00381 
00382     public boolean canProbe() {
00383         //System.out.println("canProbe?");
00384         return statusField.getText().matches("LOADED|INCONTROL");
00385         }
00386     public boolean isInControl() {
00387         return statusField.getText().matches("INCONTROL");
00388         }
00389 
00390     public void updateCCMenus() {
00391                 if(isCalibrationRun()) guiControl.menuActions.enableTaggedMenus(canProbe());
00392 
00393                 if(isInControl() && !isCalibrationRun()) return; // test menus if calibration run only!
00394                 guiControl.guiMenus.enableSubMenuItems(guiControl.guiMenus.getMenu(GuiMenus.PANEL_TESTMENU),isInControl());
00395                 guiControl.guiMenus.enableSubMenuItems(guiControl.guiMenus.getMenu(GuiMenus.MENUBAR_TESTMENU),isInControl());
00396                 }
00397 
00398 //***********************************************************************************    
00399     void updateStatus() {
00400 // run this in the eventDispatching thread, because it changes the gui display
00401        javax.swing.SwingUtilities.invokeLater(new Runnable() {
00402           public void run() {  
00403 
00404         if (status == null) {
00405             statusField.setText("UNAVAILABLE");
00406             statusField.setForeground(java.awt.Color.red);
00407             updateCCMenus();
00408         } else {
00409             switch (status.status) {
00410                 case CalibrationControllerStatus.LOADED:
00411                     statusField.setText("LOADED");
00412                     statusField.setForeground(darkGreenColor); // dark green
00413                     updateCCMenus();
00414                     break;
00415                 case CalibrationControllerStatus.INCONTROL:
00416                     statusField.setText("INCONTROL");
00417                     statusField.setForeground(darkGreenColor);
00418                     updateCCMenus();
00419                     break;
00420                 case CalibrationControllerStatus.BUSY:
00421                     statusField.setText("BUSY");
00422                     statusField.setForeground(java.awt.Color.orange);
00423                     updateCCMenus();
00424                     break;
00425                 case CalibrationControllerStatus.ERROR:
00426                     statusField.setText("ERROR");
00427                     statusField.setForeground(java.awt.Color.orange);
00428                     updateCCMenus();
00429                     break;
00430                 default:
00431                     statusField.setText("UNKNOWN");
00432                     statusField.setForeground(java.awt.Color.red);
00433                     updateCCMenus();
00434             }
00435 
00436             testField.setText(getLabel(status.currentTest));
00437             sequenceField.setText(getLabel(status.currentSequence));
00438             scanIndexField.setText(Integer.toString(status.currentScanIndex));
00439             calibrationControllerPanelMenu.checkCCUpdateMode(); // update status indicators
00440         }
00441           }
00442         });
00443     }
00444 
00445     public String getLabel(String original_string) {
00446             matcher = testdatapattern.matcher(original_string);
00447             String label = matcher.matches() ? original_string.substring(matcher.start(1),matcher.end(1)) : original_string;
00448             if (label.length()>30) label = label.substring(0,30)+"...";
00449             return label;
00450             }
00451 
00452 
00453     void updateProgressBar() {
00454 // run this in the eventDispatching thread, because it changes the gui display
00455        javax.swing.SwingUtilities.invokeLater(new Runnable() {
00456           public void run() {
00457             if(maxBin==-1) progressBar.setMaximum(1000);
00458             else progressBar.setMaximum(maxBin);
00459             if(currentBin==-1) {
00460                progressBar.setValue(0);
00461                progressBar.setString("");
00462                }
00463             else {
00464                progressBar.setValue(currentBin);
00465                if(maxBin==-1) progressBar.setString(Integer.toString(currentBin));
00466                else {
00467                      progressBar.setString(Integer.toString(currentBin)+" out of "+Integer.toString(maxBin)+" bins");
00468                      if(maxBin==currentBin) progressBar.setForeground(darkGreenColor);
00469                      else progressBar.setForeground(darkBlueColor);
00470                     }
00471             }
00472           }
00473         });
00474     }
00475     
00476     abstract class StringRunnable implements Runnable {
00477         protected is.InfoEvent infoEvent;
00478         StringRunnable(is.InfoEvent infoEvent) {
00479             this.infoEvent = infoEvent;
00480         }
00481     }
00482 
00483     
00484     public void infoCreated(is.InfoEvent infoEvent) {
00485        javax.swing.SwingUtilities.invokeLater(new StringRunnable(infoEvent) {
00486           public void run() {
00487             String name = infoEvent.getName();
00488             if(name.equals(SctNames.getControlISServer() + ".Status")) {
00489               try {
00490                  status = new CalibrationControllerStatus();
00491                  infoEvent.getValue(status);
00492               } catch (InfoNotCompatibleException e) {
00493                 status=null;
00494                 System.err.println("Unable to read IS object - not a CalibrationControllerStatus: " + e.getMessage());
00495                 }
00496               updateStatus();
00497            }
00498         else if(name.startsWith("SCTAPIServer")) { // SCTAPIServer
00499           try {
00500             is.AnyInfo theValue = new is.AnyInfo();
00501             infoEvent.getValue(theValue);
00502             if(name.equals("SCTAPIServer.currentBin")) currentBin=((Integer) theValue.getAttribute(0)).intValue();
00503             else if(name.equals("SCTAPIServer.maxBin")) maxBin=((Integer) theValue.getAttribute(0)).intValue();
00504             updateProgressBar();
00505            }catch(Exception e2){ 
00506             System.err.println("Unable to update progressBar - "+e2.toString());
00507             }
00508            
00509            }
00510           else readRunState(name);
00511 
00512 
00513          }
00514         });
00515       
00516 
00517     }
00518 
00519     private void readRunState(String name) {
00520 
00521              // run states:
00522     // NONE <-> INITIAL <-> LOADED <-> CONFIGURED <-> READY <-> RUNNING <-> READY <-> PAUSED
00523                   String rc_status = runstatusField.getText();
00524                 if(GuiComponents.System.ISInterface.getInstance().getRepository().contains(name)) {
00525 
00526                   if(name.startsWith("RunParams")) {
00527                         readRunType(name);
00528                         return;
00529                         }
00530               RCStateInfo rc = new RCStateInfo();
00531               GuiComponents.System.ISInterface.getInstance().getRepository().getValue(name, rc);
00532 //                System.out.println("new run state = "+rc.state);
00533                   if(rc.state.matches("CONFIGURED") && rc_status.matches("LOADED")) resetDisplayConfiguration();
00534                   if(rc.state.matches("INITIAL") && rc_status.matches("NONE")) restartCCPanel();
00535                   if(rc.state.matches("NONE") && rc_status.matches("INITIAL")) unconfigureGUI();
00536                   rc_status = rc.state;
00537                   }
00538               else rc_status = "NONE";
00539 
00540                  runstatusField.setText(rc_status);
00541                  if(rc_status.equals("NONE")) runstatusField.setForeground(java.awt.Color.red);
00542                  else if(rc_status.equals("RUNNING")) runstatusField.setForeground(darkGreenColor);
00543                  else runstatusField.setForeground(java.awt.Color.orange);
00544 
00545 
00546                 // if not a calibration run, enable tagged menus according to daq run state
00547                 if(!isCalibrationRun()) guiControl.menuActions.enableTaggedMenus(!rc_status.matches("RUNNING|READY|PAUSED|NONE"));
00548                 }
00549 
00550     
00551     public void infoDeleted(is.InfoEvent infoEvent) {
00552        javax.swing.SwingUtilities.invokeLater(new StringRunnable(infoEvent) {
00553           public void run() {
00554              if(infoEvent.getName().equals(SctNames.getControlISServer() + ".Status")) {
00555                status=null;
00556                updateStatus();
00557                }
00558              else {
00559               currentBin=-1;
00560               maxBin=-1;
00561               updateProgressBar();
00562               }
00563         }
00564         });
00565     }
00566     
00567     //Pass to infoCreated
00568     public void infoUpdated(is.InfoEvent infoEvent) {
00569         infoCreated(infoEvent);
00570     }
00571     
00572     // Variables declaration - do not modify//GEN-BEGIN:variables
00573 
00574     private javax.swing.JLabel jLabel1;
00575     private javax.swing.JLabel jLabel2;
00576     private javax.swing.JLabel jLabel3;
00577     private javax.swing.JLabel jLabel4;
00578     private javax.swing.JLabel jLabel5, jLabel6, jLabel7;
00579     private javax.swing.JLabel scanIndexField;
00580     private javax.swing.JLabel sequenceField;
00581     private javax.swing.JLabel statusField;
00582     private javax.swing.JLabel testField, runtypeField, runstatusField;
00583 //    private javax.swing.JLabel currentBinField;
00584     private javax.swing.JProgressBar progressBar;
00585     private Logger logger;
00586 
00587      private GuiComponents.System.ISInterface is;
00588 
00589     class ccMouseAdapter extends java.awt.event.MouseAdapter {
00590             public void mouseClicked(java.awt.event.MouseEvent e) {
00591                switch(e.getModifiers()) {
00592                  case java.awt.event.InputEvent.BUTTON2_MASK:
00593                  case java.awt.event.InputEvent.BUTTON3_MASK:             
00594                         JPopupMenu pMenu = calibrationControllerPanelMenu.getPopupMenu();
00595                                         pMenu.show(e.getComponent(),e.getX(),e.getY());
00596 //                                      pMenu.setInvoker(guiControl.guiMenus.getCCPanelMenu());
00597                  break;
00598                  default:
00599                  }
00600             }
00601     }
00602  
00603 }
00604 
00605 

Generated on Mon Feb 6 14:12:08 2006 for SCT DAQ/DCS Software - Java by  doxygen 1.4.6