00001
00002
00003
00004
00005
00006
00007 package GuiComponents.System;
00008
00009 import ipc.*;
00010 import java.util.*;
00011 import java.util.logging.*;
00012 import SctTestApi.*;
00013 import Sct_CalibrationController.*;
00014 import SubscriptionManagerModule.*;
00015 import Sct_SctApi.*;
00016 import AnalysisServiceI.*;
00017 import ArchivingServiceI.*;
00018 import sctConf.*;
00019 import FitterI.*;
00020
00021
00033 public class SystemInterface {
00034
00038 public static SystemInterface getInstance() {
00039 return instance;
00040 }
00041
00045 public void refresh() {
00046 p = null;
00047 testconfig = null;
00048 highlevel = null;
00049 cc = null;
00050 api = null;
00051 config = null;
00052 analysis = null;
00053 archiving = null;
00054 fitter = null;
00055 }
00056
00060 public Partition getPartition() {
00061 if (p == null) {
00062 try {
00063 p = new Partition(partitionName);
00064 } catch (PartitionNotFoundException e) {
00065 logger.info("Failed to get partition: " + partitionName + ": " + e.getMessage());
00066 }
00067 }
00068 return p;
00069 }
00070
00074 public SctTestApi.Configuration getTestConfiguration() {
00075 if (testconfig == null) {
00076 try {
00077 org.omg.CORBA.Object ob = getPartition().lookup(sctConf.Configuration.class, SctTestApi.Configuration.instanceName);
00078 testconfig = SctTestApi.ConfigurationHelper.narrow(ob);
00079 if (testconfig == null) {
00080 logger.info("Failed to lookup SctTest::Configuration using: " + SctTestApi.Configuration.instanceName);
00081 }
00082 } catch (org.omg.CORBA.SystemException se) {
00083 logger.info("Failed to lookup SctTest::Configuration using: " + SctTestApi.Configuration.instanceName + ". Exception: " + se.getMessage());
00084
00085
00086 } catch (NullPointerException npe) {
00087
00088 }
00089 }
00090 return testconfig;
00091 }
00092
00096 public HighLevelApi getTestHighLevelApi() {
00097 if (highlevel == null) {
00098 try {
00099 org.omg.CORBA.Object ob = getPartition().lookup(SctTestApi.HighLevelApi.class, HighLevelApi.instanceName);
00100 highlevel = HighLevelApiHelper.narrow(ob);
00101 if (highlevel == null) {
00102 logger.info("Failed to lookup SctTest::HighLevelApi using: " + HighLevelApi.instanceName);
00103 }
00104 } catch (org.omg.CORBA.SystemException se) {
00105 logger.info("Failed to lookup SctTest::HighLevelApi using: " + HighLevelApi.instanceName + ". Exception: " + se.getMessage());
00106
00107
00108 } catch (NullPointerException npe) {
00109
00110 }
00111 }
00112 return highlevel;
00113 }
00114
00115
00119 public SubscriptionManager getSubscriptionManager() {
00120 subMan=null;
00121 if (subMan == null) {
00122 try {
00123 org.omg.CORBA.Object ob = getPartition().lookup(SubscriptionManagerModule.SubscriptionManager.class, SubscriptionManager.instanceName);
00124 subMan = SubscriptionManagerHelper.narrow(ob);
00125 } catch (org.omg.CORBA.SystemException se) {
00126 logger.info("Failed to lookup SubscriptionManager using: " + SubscriptionManager.instanceName + ". Exception: " + se.getMessage());
00127
00128
00129 } catch (NullPointerException npe) {
00130
00131 }
00132 }
00133 return subMan;
00134 }
00135
00139 public CalibrationController getCalibrationController() {
00140 if (cc == null) {
00141 try {
00142 org.omg.CORBA.Object ob = getPartition().lookup(Sct_CalibrationController.CalibrationController.class, CalibrationController.instanceName);
00143 cc = CalibrationControllerHelper.narrow(ob);
00144 } catch (org.omg.CORBA.SystemException se) {
00145 logger.info("Failed to lookup CalibrationController using: " + CalibrationController.instanceName + ". Exception: " + se.getMessage());
00146
00147
00148 } catch (NullPointerException npe) {
00149
00150 }
00151 }
00152 return cc;
00153 }
00154
00158 public SctApiIPC getSctApi() {
00159 if (api == null) {
00160 try {
00161 org.omg.CORBA.Object ob = getPartition().lookup(Sct_SctApi.SctApiIPC.class, SctApiIPC.instanceName);
00162 api = SctApiIPCHelper.narrow(ob);
00163 } catch (org.omg.CORBA.SystemException se) {
00164 logger.info("Failed to lookup AnalysisService using: " + SctApiIPC.instanceName + " . Exception: " + se.getMessage());
00165
00166
00167 } catch (NullPointerException npe) {
00168
00169 }
00170 }
00171 return api;
00172 }
00173
00177 public sctConf.Configuration getConfigurationService() {
00178 if (config == null) {
00179 try {
00180 org.omg.CORBA.Object ob = getPartition().lookup(sctConf.Configuration.class, sctConf.Configuration.instanceName);
00181 config = sctConf.ConfigurationHelper.narrow(ob);
00182 } catch (org.omg.CORBA.SystemException se) {
00183 logger.info("Failed to lookup Configuration using: " + sctConf.Configuration.instanceName + ". Exception: " + se.getMessage());
00184
00185
00186 } catch (NullPointerException npe) {
00187
00188 }
00189 }
00190 return config;
00191 }
00192
00196 public AnalysisServiceInterface getAnalysisService() {
00197 if (analysis == null) {
00198 try {
00199 org.omg.CORBA.Object ob = getPartition().lookup(AnalysisServiceI.AnalysisServiceInterface.class, AnalysisServiceInterface.instanceName);
00200 analysis = AnalysisServiceInterfaceHelper.narrow(ob);
00201 } catch (org.omg.CORBA.SystemException se) {
00202 logger.info("Failed to lookup AnalysisService using: " + AnalysisServiceInterface.instanceName + ". Exception: " + se.getMessage());
00203
00204
00205 } catch (NullPointerException npe) {
00206
00207 }
00208 }
00209 return analysis;
00210 }
00211
00215 public ArchivingServiceInterface getArchivingService() {
00216 if (archiving == null) {
00217 try {
00218 org.omg.CORBA.Object ob = getPartition().lookup(ArchivingServiceI.ArchivingServiceInterface.class, ArchivingServiceInterface.instanceName);
00219 archiving = ArchivingServiceInterfaceHelper.narrow(ob);
00220 } catch (org.omg.CORBA.SystemException se) {
00221 logger.info("Failed to lookup ArchivingService using: " + ArchivingServiceInterface.instanceName + ". Exception: " + se.getMessage());
00222
00223
00224 } catch (NullPointerException npe) {
00225
00226 }
00227 }
00228 return archiving;
00229 }
00230
00231
00235 public FitterInterface getFittingService() {
00236 if (fitter == null) {
00237 try {
00238 org.omg.CORBA.Object ob = getPartition().lookup(FitterI.FitterInterface.class, FitterInterface.instanceName);
00239 fitter = FitterInterfaceHelper.narrow(ob);
00240 } catch (org.omg.CORBA.SystemException se) {
00241 logger.info("Failed to lookup Fitter using: " + FitterInterface.instanceName + ". Exception: " + se.getMessage());
00242
00243
00244 } catch (NullPointerException npe) {
00245
00246 }
00247 }
00248 return fitter;
00249 }
00250
00252 private SystemInterface() {
00253 logger = Logger.getLogger("GuiComponents.System");
00254 refresh();
00255 }
00256
00257 private static SystemInterface instance = new SystemInterface();
00258 private static final String partitionName = "SCT";
00259 private Partition p;
00260 private Logger logger;
00261 private SctTestApi.Configuration testconfig;
00262 private HighLevelApi highlevel;
00263 private SubscriptionManager subMan;
00264 private CalibrationController cc;
00265 private SctApiIPC api;
00266 private sctConf.Configuration config;
00267 private AnalysisServiceInterface analysis;
00268 private ArchivingServiceInterface archiving;
00269 private FitterInterface fitter;
00270 }