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 Sct_SctApi.*;
00015 import AnalysisServiceI.*;
00016 import ArchivingServiceI.*;
00017 import sctConf.*;
00018 import FitterI.*;
00019
00020
00032 public class SystemInterface {
00033
00037 public static SystemInterface getInstance() {
00038 return instance;
00039 }
00040
00044 public void refresh() {
00045 p = null;
00046 testconfig = null;
00047 highlevel = null;
00048 cc = null;
00049 api = null;
00050 config = null;
00051 analysis = null;
00052 archiving = null;
00053 fitter = null;
00054 }
00055
00059 public Partition getPartition() {
00060 if (p == null) {
00061 try {
00062 p = new Partition(partitionName);
00063 } catch (PartitionNotFoundException e) {
00064 logger.info("Failed to get partition: " + partitionName + ": " + e.getMessage());
00065 }
00066 }
00067 return p;
00068 }
00069
00073 public SctTestApi.Configuration getTestConfiguration() {
00074 if (testconfig == null) {
00075 try {
00076 org.omg.CORBA.Object ob = getPartition().lookup(SctTestApi.Configuration.instanceName, SctApi.serverName);
00077 testconfig = SctTestApi.ConfigurationHelper.narrow(ob);
00078 if (testconfig == null) {
00079 logger.info("Failed to lookup SctTest::Configuration using: " + SctTestApi.Configuration.instanceName + " and " + SctApi.serverName);
00080 }
00081 } catch (org.omg.CORBA.SystemException se) {
00082 logger.info("Failed to lookup SctTest::Configuration using: " + SctTestApi.Configuration.instanceName + " and " + SctApi.serverName + ". Exception: " + se.getMessage());
00083 } catch (NullPointerException npe) {
00084
00085 }
00086 }
00087 return testconfig;
00088 }
00089
00093 public HighLevelApi getTestHighLevelApi() {
00094 if (highlevel == null) {
00095 try {
00096 org.omg.CORBA.Object ob = getPartition().lookup(HighLevelApi.instanceName, HighLevelApi.serverName);
00097 highlevel = HighLevelApiHelper.narrow(ob);
00098 if (highlevel == null) {
00099 logger.info("Failed to lookup SctTest::HighLevelApi using: " + HighLevelApi.instanceName + " and " + HighLevelApi.serverName);
00100 }
00101 } catch (org.omg.CORBA.SystemException se) {
00102 logger.info("Failed to lookup SctTest::HighLevelApi using: " + HighLevelApi.instanceName + " and " + HighLevelApi.serverName + ". Exception: " + se.getMessage());
00103 } catch (NullPointerException npe) {
00104
00105 }
00106 }
00107 return highlevel;
00108 }
00109
00110
00114 public CalibrationController getCalibrationController() {
00115 if (cc == null) {
00116 try {
00117 org.omg.CORBA.Object ob = getPartition().lookup(CalibrationController.instanceName, CalibrationController.serverName);
00118 cc = CalibrationControllerHelper.narrow(ob);
00119 } catch (org.omg.CORBA.SystemException se) {
00120 logger.info("Failed to lookup CalibrationController using: " + CalibrationController.instanceName + " and " + CalibrationController.serverName + ". Exception: " + se.getMessage());
00121 } catch (NullPointerException npe) {
00122
00123 }
00124 }
00125 return cc;
00126 }
00127
00131 public SctApi getSctApi() {
00132 if (api == null) {
00133 try {
00134 org.omg.CORBA.Object ob = getPartition().lookup(SctApi.instanceName, SctApi.serverName);
00135 api = SctApiHelper.narrow(ob);
00136 } catch (org.omg.CORBA.SystemException se) {
00137 logger.info("Failed to lookup AnalysisService using: " + SctApi.instanceName + " and " + SctApi.serverName + " . Exception: " + se.getMessage());
00138 } catch (NullPointerException npe) {
00139
00140 }
00141 }
00142 return api;
00143 }
00144
00148 public sctConf.Configuration getConfigurationService() {
00149 if (config == null) {
00150 try {
00151 org.omg.CORBA.Object ob = getPartition().lookup(sctConf.Configuration.instanceName, sctConf.Configuration.serverName);
00152 config = sctConf.ConfigurationHelper.narrow(ob);
00153 } catch (org.omg.CORBA.SystemException se) {
00154 logger.info("Failed to lookup Configuration using: " + sctConf.Configuration.instanceName + " and " + sctConf.Configuration.serverName + ". Exception: " + se.getMessage());
00155 } catch (NullPointerException npe) {
00156
00157 }
00158 }
00159 return config;
00160 }
00161
00165 public AnalysisServiceInterface getAnalysisService() {
00166 if (analysis == null) {
00167 try {
00168 org.omg.CORBA.Object ob = getPartition().lookup(AnalysisServiceInterface.instanceName, AnalysisServiceInterface.serverName);
00169 analysis = AnalysisServiceInterfaceHelper.narrow(ob);
00170 } catch (org.omg.CORBA.SystemException se) {
00171 logger.info("Failed to lookup AnalysisService using: " + AnalysisServiceInterface.instanceName + " and " + AnalysisServiceInterface.serverName + ". Exception: " + se.getMessage());
00172 } catch (NullPointerException npe) {
00173
00174 }
00175 }
00176 return analysis;
00177 }
00178
00182 public ArchivingServiceInterface getArchivingService() {
00183 if (archiving == null) {
00184 try {
00185 org.omg.CORBA.Object ob = getPartition().lookup(ArchivingServiceInterface.instanceName, ArchivingServiceInterface.serverName);
00186 archiving = ArchivingServiceInterfaceHelper.narrow(ob);
00187 } catch (org.omg.CORBA.SystemException se) {
00188 logger.info("Failed to lookup ArchivingService using: " + ArchivingServiceInterface.instanceName + " and " + ArchivingServiceInterface.serverName + ". Exception: " + se.getMessage());
00189 } catch (NullPointerException npe) {
00190
00191 }
00192 }
00193 return archiving;
00194 }
00195
00196
00200 public FitterInterface getFittingService() {
00201 if (fitter == null) {
00202 try {
00203 org.omg.CORBA.Object ob = getPartition().lookup(FitterInterface.instanceName, FitterInterface.serverName);
00204 fitter = FitterInterfaceHelper.narrow(ob);
00205 } catch (org.omg.CORBA.SystemException se) {
00206 logger.info("Failed to lookup Fitter using: " + FitterInterface.instanceName + " and " + FitterInterface.serverName + ". Exception: " + se.getMessage());
00207 } catch (NullPointerException npe) {
00208
00209 }
00210 }
00211 return fitter;
00212 }
00213
00215 private SystemInterface() {
00216 logger = Logger.getLogger("GuiComponents.System");
00217 refresh();
00218 }
00219
00220 private static SystemInterface instance = new SystemInterface();
00221 private static final String partitionName = "SCT";
00222 private Partition p;
00223 private Logger logger;
00224 private SctTestApi.Configuration testconfig;
00225 private HighLevelApi highlevel;
00226 private CalibrationController cc;
00227 private SctApi api;
00228 private sctConf.Configuration config;
00229 private AnalysisServiceInterface analysis;
00230 private ArchivingServiceInterface archiving;
00231 private FitterInterface fitter;
00232 }