Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ConfigurationListener.java

00001 /*
00002  * ConfigurationListener.java
00003  *
00004  * 
00005  */
00006 
00007 package DisplayGUI;
00008 
00009 import Sct.IS.SctNames;
00010 import is.*;
00011 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
00012 //import CS.DAQApplicationInfo; // ditto as above, except the relevant file is DAQApplicationInfo.java
00013 
00014 
00015 public class ConfigurationListener implements InfoListener {
00016     
00017     gui guiControl;
00018     String rc_status="NONE";
00019 
00020     public ConfigurationListener(gui parent) {
00021         guiControl=parent;
00022         subscribe();
00023     }
00024 
00025     private void subscribe() {     
00026 
00027 
00028  //       try {
00029  //          is.subscribe("ConfigurationServer","ModuleConfChangeCount",false,this);
00030  //          is.subscribe("ConfigurationServer","ModuleMappingChangeCount",false,this);
00031  //          is.subscribe("ConfigurationServer","SystemStructureChangeCount",false,this);
00032  //       } catch (RuntimeException e2) {
00033  //           System.err.println("SctGUI::ConfigurationListener::Couldn't subscribe to ConfigurationServer: " + e2.toString());
00034  //       }
00035         try {
00036           GuiComponents.System.ISInterface.getInstance().subscribe("RunCtrl","RootController",false,this);
00037         } catch (RuntimeException e3) {
00038             System.err.println("SctGUI::ConfigurationListener::Couldn't subscribe to RunCtrl.RootController: " + e3.toString());
00039         }
00040     }
00041     
00042     void close() {
00043 
00044 
00045         try {
00046 //            is.unsubscribe("ConfigurationServer","ModuleConfChangeCount");
00047 //            is.unsubscribe("ConfigurationServer","ModuleMappingChangeCount");
00048 //            is.unsubscribe("ConfigurationServer","SystemStructureChangeCount");
00049             GuiComponents.System.ISInterface.getInstance().unsubscribe("RunCtrl","RootController");
00050         } catch (RuntimeException e2) {
00051             System.err.println("Couldn't unsubscribe from ConfigurationServer: " + e2.getMessage());
00052         }
00053     }
00054 
00055     abstract class StringRunnable implements Runnable {
00056         protected String name;
00057         StringRunnable(String name) {
00058             this.name = name;
00059         }
00060     }
00061 
00062     public void infoCreated(is.InfoEvent infoEvent) {
00063 //       javax.swing.SwingUtilities.invokeLater(new StringRunnable(infoEvent.getName()) {
00064 //          public void run() {
00065 //                  if(!name.equals("RunCtrl.RootCtrl")) resetDisplayConfiguration();
00066 //             }
00067 //        });
00068         infoUpdated(infoEvent);
00069     }
00070 
00071     public void infoDeleted(is.InfoEvent infoEvent) {
00072       infoUpdated(infoEvent);
00073     }
00074 
00075     public void infoUpdated(is.InfoEvent infoEvent) {
00076     // run states:
00077     // NONE <-> INITIAL <-> LOADED <-> CONFIGURED <-> READY <-> RUNNING <-> READY <-> PAUSED
00078 //       System.out.println("*** got "+infoEvent.getName());
00079        javax.swing.SwingUtilities.invokeLater(new StringRunnable(infoEvent.getName()) {
00080           public void run() {
00081                 if(GuiComponents.System.ISInterface.getInstance().getRepository().contains(name)) {
00082                   RCStateInfo rc = new RCStateInfo();
00083                   GuiComponents.System.ISInterface.getInstance().getRepository().getValue(name, rc);
00084 //                System.out.println("new run state = "+rc.state);
00085                   if(rc.state.matches("CONFIGURED") && rc_status.matches("LOADED")) resetDisplayConfiguration();
00086                   if(rc.state.matches("INITIAL") && rc_status.matches("NONE")) resetCCPanel();
00087                   if(rc.state.matches("NONE") && rc_status.matches("INITIAL")) {resetCCPanel();resetDisplayConfiguration();}
00088                   rc_status=rc.state;
00089                   }
00090                 else rc_status="NONE";
00091         //        System.out.println("RC moved to state "+rc_status);
00092 
00093              }
00094         });
00095     }
00096 
00097 
00098     private void resetCCPanel() {
00099        GuiComponents.System.SystemInterface.getInstance().refresh();
00100        GuiComponents.System.ISInterface.getInstance().refresh();
00101        guiControl.calibrationControllerPanel.subscribeToServers(); // fix for loss of contact
00102        guiControl.guiMenus.rebuildTestMenus(); // rebuild all tests menu - requires CC to be present
00103        }
00104        
00105     private void resetDisplayConfiguration() {
00106        GuiComponents.System.SystemInterface.getInstance().refresh();
00107        GuiComponents.System.ISInterface.getInstance().refresh();
00108        ConfigurationInterface.getInstance().Refresh();
00109        guiControl.displayStatus.setConfigurationMode();
00110        int nmods = ConfigurationInterface.getInstance().getTotalNumberOfModules();
00111        System.out.println("Configuration updated with "+nmods+" modules.");
00112        int cacheSize = nmods<200 ? 200 : nmods;
00113        cacheSize*=2;
00114        guiControl.isInterface.setCacheSize(cacheSize);
00115 
00116          guiControl.displayPane.refreshDisplay();
00117        }
00118 
00119 
00120  
00121 }
00122 
00123 

Generated on Thu Dec 15 21:22:35 2005 for SCT DAQ/DCS Software - Java by doxygen 1.3.5