00001
00002
00003
00004
00005
00006
00007 package TestGUI;
00008
00009 import javax.swing.*;
00010 import Sct_CalibrationController.*;
00011 import Sct.IS.SctNames;
00012 import is.*;
00013 import GuiComponents.System.*;
00014
00019 public class CalibrationControllerPanel extends javax.swing.JPanel implements InfoListener {
00020
00022 public CalibrationControllerPanel(JTextArea taMessages) {
00023 this.taMessages = taMessages;
00024 si = SystemInterface.getInstance();
00025 initComponents();
00026 myInitComponents();
00027 }
00028
00029 private void myInitComponents() {
00030
00031 try {
00032 CalibrationControllerStatus status = new CalibrationControllerStatus();
00033 SctNames.getISRepository().getValue(SctNames.getControlISServer() + ".Status", status);
00034 updateStatus(status);
00035 } catch (RuntimeException e) {
00036 taMessages.append("Couldn't get CalibrationController Status: " + e.getMessage() + "\n");
00037 updateStatus(null);
00038 }
00039
00040
00041 try {
00042 SctNames.getISRepository().subscribe(SctNames.getControlISServer(), "Status", false, this);
00043 } catch (RuntimeException e) {
00044 taMessages.append("Couldn't subscribe to ControlData IS Server: " + e.getMessage() + "\n");
00045 }
00046 }
00047
00051 void close() {
00052
00053 try {
00054 SctNames.getISRepository().unsubscribe(SctNames.getControlISServer(), "Status", false);
00055 } catch (RuntimeException e) {
00056 taMessages.append("Couldn't unsubscribe from ControlData IS Server: " + e.getMessage() + "\n");
00057 }
00058 }
00059
00065 private void initComponents() {
00066 java.awt.GridBagConstraints gridBagConstraints;
00067
00068 jPanel1 = new javax.swing.JPanel();
00069 bRefresh = new javax.swing.JButton();
00070 tStatus = new javax.swing.JTable();
00071 jLabel1 = new javax.swing.JLabel();
00072 bPing = new javax.swing.JButton();
00073 jPanel2 = new javax.swing.JPanel();
00074 bCharacter = new javax.swing.JButton();
00075 bResponse = new javax.swing.JButton();
00076 bThreshold = new javax.swing.JButton();
00077 jButton1 = new javax.swing.JButton();
00078 bStrobeDelay = new javax.swing.JButton();
00079 bNMask = new javax.swing.JButton();
00080 bThreePt = new javax.swing.JButton();
00081
00082 setLayout(new java.awt.GridBagLayout());
00083
00084 jPanel1.setLayout(new java.awt.GridBagLayout());
00085
00086 jPanel1.setBorder(new javax.swing.border.TitledBorder("Calibration Controller"));
00087 bRefresh.setText("Refresh");
00088 bRefresh.addActionListener(new java.awt.event.ActionListener() {
00089 public void actionPerformed(java.awt.event.ActionEvent evt) {
00090 bRefreshActionPerformed(evt);
00091 }
00092 });
00093
00094 gridBagConstraints = new java.awt.GridBagConstraints();
00095 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
00096 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00097 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00098 jPanel1.add(bRefresh, gridBagConstraints);
00099
00100 tStatus.setBorder(new javax.swing.border.EtchedBorder());
00101 tStatus.setModel(new javax.swing.table.DefaultTableModel(
00102 new Object [][] {
00103 {"Status", "UNAVAILABLE"},
00104 {"Current Sequence", null},
00105 {"Current Test", null},
00106 {"Current Scan Index", null}
00107 },
00108 new String [] {
00109 "Name", "Value"
00110 }
00111 ) {
00112 Class[] types = new Class [] {
00113 java.lang.String.class, java.lang.String.class
00114 };
00115 boolean[] canEdit = new boolean [] {
00116 false, false
00117 };
00118
00119 public Class getColumnClass(int columnIndex) {
00120 return types [columnIndex];
00121 }
00122
00123 public boolean isCellEditable(int rowIndex, int columnIndex) {
00124 return canEdit [columnIndex];
00125 }
00126 });
00127 tStatus.setIntercellSpacing(new java.awt.Dimension(5, 5));
00128 tStatus.setMinimumSize(new java.awt.Dimension(200, 80));
00129 tStatus.setPreferredSize(new java.awt.Dimension(300, 80));
00130 tStatus.setRowHeight(20);
00131 tStatus.setShowHorizontalLines(false);
00132 gridBagConstraints = new java.awt.GridBagConstraints();
00133 gridBagConstraints.gridx = 1;
00134 gridBagConstraints.gridy = 1;
00135 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
00136 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
00137 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00138 gridBagConstraints.weightx = 1.0;
00139 gridBagConstraints.weighty = 1.0;
00140 gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
00141 jPanel1.add(tStatus, gridBagConstraints);
00142
00143 jLabel1.setText("Status");
00144 gridBagConstraints = new java.awt.GridBagConstraints();
00145 gridBagConstraints.gridx = 1;
00146 gridBagConstraints.gridy = 0;
00147 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00148 gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
00149 jPanel1.add(jLabel1, gridBagConstraints);
00150
00151 bPing.setText("Ping");
00152 bPing.addActionListener(new java.awt.event.ActionListener() {
00153 public void actionPerformed(java.awt.event.ActionEvent evt) {
00154 bPingActionPerformed(evt);
00155 }
00156 });
00157
00158 gridBagConstraints = new java.awt.GridBagConstraints();
00159 gridBagConstraints.gridx = 0;
00160 gridBagConstraints.gridy = 1;
00161 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
00162 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00163 gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
00164 jPanel1.add(bPing, gridBagConstraints);
00165
00166 gridBagConstraints = new java.awt.GridBagConstraints();
00167 gridBagConstraints.gridx = 0;
00168 gridBagConstraints.gridy = 0;
00169 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
00170 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00171 gridBagConstraints.weightx = 1.0;
00172 add(jPanel1, gridBagConstraints);
00173
00174 jPanel2.setBorder(new javax.swing.border.TitledBorder("Sequences, Tests and Scans"));
00175 bCharacter.setText("Characterization Sequence");
00176 bCharacter.addActionListener(new java.awt.event.ActionListener() {
00177 public void actionPerformed(java.awt.event.ActionEvent evt) {
00178 bCharacterActionPerformed(evt);
00179 }
00180 });
00181
00182 jPanel2.add(bCharacter);
00183
00184 bResponse.setText("Response Curve");
00185 bResponse.addActionListener(new java.awt.event.ActionListener() {
00186 public void actionPerformed(java.awt.event.ActionEvent evt) {
00187 bResponseActionPerformed(evt);
00188 }
00189 });
00190
00191 jPanel2.add(bResponse);
00192
00193 bThreshold.setText("ExampleTestRequest");
00194 bThreshold.addActionListener(new java.awt.event.ActionListener() {
00195 public void actionPerformed(java.awt.event.ActionEvent evt) {
00196 bThresholdActionPerformed(evt);
00197 }
00198 });
00199
00200 jPanel2.add(bThreshold);
00201
00202 jButton1.setText("ExampleSequenceRequest");
00203 jButton1.addActionListener(new java.awt.event.ActionListener() {
00204 public void actionPerformed(java.awt.event.ActionEvent evt) {
00205 jButton1ActionPerformed(evt);
00206 }
00207 });
00208
00209 jPanel2.add(jButton1);
00210
00211 bStrobeDelay.setText("StrobeDelay");
00212 bStrobeDelay.addActionListener(new java.awt.event.ActionListener() {
00213 public void actionPerformed(java.awt.event.ActionEvent evt) {
00214 bStrobeDelayActionPerformed(evt);
00215 }
00216 });
00217
00218 jPanel2.add(bStrobeDelay);
00219
00220 bNMask.setText("NMask");
00221 bNMask.addActionListener(new java.awt.event.ActionListener() {
00222 public void actionPerformed(java.awt.event.ActionEvent evt) {
00223 bNMaskActionPerformed(evt);
00224 }
00225 });
00226
00227 jPanel2.add(bNMask);
00228
00229 bThreePt.setText("ThreePointGain");
00230 bThreePt.addActionListener(new java.awt.event.ActionListener() {
00231 public void actionPerformed(java.awt.event.ActionEvent evt) {
00232 bThreePtActionPerformed(evt);
00233 }
00234 });
00235
00236 jPanel2.add(bThreePt);
00237
00238 gridBagConstraints = new java.awt.GridBagConstraints();
00239 gridBagConstraints.gridx = 0;
00240 gridBagConstraints.gridy = 1;
00241 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
00242 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
00243 gridBagConstraints.weightx = 1.0;
00244 gridBagConstraints.weighty = 1.0;
00245 add(jPanel2, gridBagConstraints);
00246
00247 }
00248
00249 private void bThreePtActionPerformed(java.awt.event.ActionEvent evt) {
00250 CalibrationController cc = si.getCalibrationController();
00251 if (cc == null) {
00252 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00253 return;
00254 }
00255 cc.doTest(cc.getTestLibrary().getTestRequestByName("ThreePointGain"));
00256 }
00257
00258 private void bNMaskActionPerformed(java.awt.event.ActionEvent evt) {
00259 CalibrationController cc = si.getCalibrationController();
00260 if (cc == null) {
00261 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00262 return;
00263 }
00264 cc.doTest(cc.getTestLibrary().getTestRequestByName("NMask"));
00265 }
00266
00267 private void bStrobeDelayActionPerformed(java.awt.event.ActionEvent evt) {
00268 CalibrationController cc = si.getCalibrationController();
00269 if (cc == null) {
00270 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00271 return;
00272 }
00273 cc.doTest(cc.getTestLibrary().getTestRequestByName("StrobeDelay"));
00274 }
00275
00276 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
00277 CalibrationController cc = si.getCalibrationController();
00278 if (cc == null) {
00279 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00280 return;
00281 }
00282 ExampleSequenceRequest r = new ExampleSequenceRequest(cc);
00283 SequenceRequest tr = r._this(ipc.Core.getORB());
00284 cc.doSequence(tr);
00285 }
00286
00287 private void bThresholdActionPerformed(java.awt.event.ActionEvent evt) {
00288 CalibrationController cc = si.getCalibrationController();
00289 if (cc == null) {
00290 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00291 return;
00292 }
00293 ExampleTestRequest r = new ExampleTestRequest();
00294 TestRequest tr = r._this(ipc.Core.getORB());
00295 cc.doTest(tr);
00296 }
00297
00298 private void bResponseActionPerformed(java.awt.event.ActionEvent evt) {
00299 CalibrationController cc = si.getCalibrationController();
00300 if (cc == null) {
00301 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00302 return;
00303 }
00304 cc.doTest(cc.getTestLibrary().getTestRequestByName("ResponseCurve"));
00305 }
00306
00307 private void bCharacterActionPerformed(java.awt.event.ActionEvent evt) {
00308 CalibrationController cc = si.getCalibrationController();
00309 if (cc == null) {
00310 taMessages.append("No handle to CalibrationController. Please run and hit refresh\n");
00311 return;
00312 }
00313 cc.doSequence(cc.getSequenceLibrary().characterizationSequence());
00314 }
00315
00316 private void bPingActionPerformed(java.awt.event.ActionEvent evt) {
00317 CalibrationController cc = si.getCalibrationController();
00318 if (cc != null) {
00319 ipc.servantPackage.info info = cc.information();
00320 taMessages.append("CalibrationController running: " + info.pid + " by " + info.owner + " on " +info.host + " since " + info.time + "\n");
00321 } else {
00322 taMessages.append("CalibrationController not running\n");
00323 }
00324 }
00325
00326 private void bRefreshActionPerformed(java.awt.event.ActionEvent evt) {
00327 this.si.refresh();
00328 myInitComponents();
00329 }
00330
00331
00332 void updateStatus(CalibrationControllerStatus status) {
00333 if (status == null) {
00334 tStatus.getModel().setValueAt("UNAVAILABLE", 0, 1);
00335 tStatus.getModel().setValueAt("", 1, 1);
00336 tStatus.getModel().setValueAt("", 2, 1);
00337 tStatus.getModel().setValueAt("", 3, 1);
00338 } else {
00339 switch (status.status) {
00340 case CalibrationControllerStatus.LOADED:
00341 tStatus.getModel().setValueAt("LOADED", 0, 1);
00342 break;
00343 case CalibrationControllerStatus.INCONTROL:
00344 tStatus.getModel().setValueAt("INCONTROL", 0, 1);
00345 break;
00346 case CalibrationControllerStatus.BUSY:
00347 tStatus.getModel().setValueAt("BUSY", 0, 1);
00348 break;
00349 default:
00350 tStatus.getModel().setValueAt("UNKNOWN", 0, 1);
00351 }
00352 tStatus.getModel().setValueAt(status.currentSequence, 1, 1);
00353 tStatus.getModel().setValueAt(status.currentTest, 2, 1);
00354 tStatus.getModel().setValueAt("" + status.currentScanIndex, 3, 1);
00355 }
00356 }
00357
00358 public void infoCreated(is.InfoEvent infoEvent) {
00359 try {
00360 CalibrationControllerStatus status = new CalibrationControllerStatus();
00361 infoEvent.getValue(status);
00362 updateStatus(status);
00363 } catch (InfoNotCompatibleException e) {
00364 taMessages.append("Unable to read IS object - not a CalibrationControllerStatus: " + e.getMessage() + "\n");
00365 }
00366 }
00367
00368 public void infoDeleted(is.InfoEvent infoEvent) {
00369 updateStatus(null);
00370 }
00371
00372
00373 public void infoUpdated(is.InfoEvent infoEvent) {
00374 infoCreated(infoEvent);
00375 }
00376
00377
00378 private javax.swing.JButton bCharacter;
00379 private javax.swing.JButton bNMask;
00380 private javax.swing.JButton bPing;
00381 private javax.swing.JButton bRefresh;
00382 private javax.swing.JButton bResponse;
00383 private javax.swing.JButton bStrobeDelay;
00384 private javax.swing.JButton bThreePt;
00385 private javax.swing.JButton bThreshold;
00386 private javax.swing.JButton jButton1;
00387 private javax.swing.JLabel jLabel1;
00388 private javax.swing.JPanel jPanel1;
00389 private javax.swing.JPanel jPanel2;
00390 private javax.swing.JTable tStatus;
00391
00392 private JTextArea taMessages;
00393 private SystemInterface si;
00394 }