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 rc.RCStateInfo;
00012 
00013 
00014 public class ConfigurationListener implements InfoListener {
00015     
00016     gui guiControl;
00017     int runCtrl_presence=-1;
00018 
00019     public ConfigurationListener(gui parent) {
00020         guiControl=parent;
00021         is = GuiComponents.System.ISInterface.getInstance();
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.getMessage());
00034         }
00035         try {
00036           is.subscribe("RunCtrl","RootCtrl",false,this);
00037         } catch (RuntimeException e3) {
00038             System.err.println("SctGUI::ConfigurationListener::Couldn't subscribe to RunCtrl: " + e3.getMessage());
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             is.unsubscribe("RunCtrl","RootCtrl");
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     }
00069     
00070     public void infoDeleted(is.InfoEvent infoEvent) {
00071     }
00072     
00073     public void infoUpdated(is.InfoEvent infoEvent) {
00074        javax.swing.SwingUtilities.invokeLater(new StringRunnable(infoEvent.getName()) {
00075           public void run() {
00076              if(!name.equals("RunCtrl.RootCtrl")) resetDisplayConfiguration();
00077              else {
00078                 RCStateInfo rc = new RCStateInfo();
00079                 GuiComponents.System.ISInterface.getInstance().getRepository().getValue(name, rc); 
00080 // if runCtrl is alive, and before it was absent or dead, then refresh and reconfigure
00081                 if(rc.presence==0 && runCtrl_presence!=rc.presence) {
00082                        GuiComponents.System.SystemInterface.getInstance().refresh();  
00083                        resetDisplayConfiguration();
00084                        }      
00085 // if runCtrl is absent or dead, then refresh               
00086                 if(rc.presence!=0) {
00087                        GuiComponents.System.SystemInterface.getInstance().refresh();   
00088                        }
00089                 runCtrl_presence=rc.presence;               
00090                 }             
00091              }
00092         });
00093     }
00094 
00095 
00096     private void resetDisplayConfiguration() {
00097        ConfigurationInterface.getInstance().Refresh();
00098        guiControl.displayStatus.setConfigurationMode(); 
00099        int nmods = ConfigurationInterface.getInstance().getTotalNumberOfModules();
00100        System.out.println("Configuration updated with "+nmods+" modules.");
00101        int cacheSize = nmods<200 ? 200 : nmods;
00102        guiControl.isInterface.setCacheSize(cacheSize);
00103        }
00104     
00105 
00106      private GuiComponents.System.ISInterface is;
00107 
00108 
00109  
00110 }
00111 
00112 

Generated on Thu Jul 15 09:55:41 2004 for SCT DAQ/DCS Software - Java by doxygen 1.3.5