00001
00002
00003
00004
00005
00006
00007 package DisplayGUI;
00008
00009 import Sct.IS.SctNames;
00010 import is.*;
00011 import CS.RCStateInfo;
00012
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
00029
00030
00031
00032
00033
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
00047
00048
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
00064
00065
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
00077
00078
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
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
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();
00102 guiControl.guiMenus.rebuildTestMenus();
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