Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

CalibrationControllerPanel.java

00001 /*
00002  * CalibrationControllerPanel.java
00003  *
00004  * Created on 30 July 2003, 23:01
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         //Get Status from IS if it is there
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         //Now subscribe to IS server
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         //Unsubscribe from IS
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() {//GEN-BEGIN: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     }//GEN-END:initComponents
00248 
00249     private void bThreePtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bThreePtActionPerformed
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().threePointGain());
00256     }//GEN-LAST:event_bThreePtActionPerformed
00257 
00258     private void bNMaskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bNMaskActionPerformed
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().nmask());
00265     }//GEN-LAST:event_bNMaskActionPerformed
00266 
00267     private void bStrobeDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bStrobeDelayActionPerformed
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().strobeDelay());
00274     }//GEN-LAST:event_bStrobeDelayActionPerformed
00275 
00276     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
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     }//GEN-LAST:event_jButton1ActionPerformed
00286 
00287     private void bThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bThresholdActionPerformed
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     }//GEN-LAST:event_bThresholdActionPerformed
00297 
00298     private void bResponseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bResponseActionPerformed
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().responseCurve());
00305     }//GEN-LAST:event_bResponseActionPerformed
00306 
00307     private void bCharacterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCharacterActionPerformed
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     }//GEN-LAST:event_bCharacterActionPerformed
00315 
00316     private void bPingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bPingActionPerformed
00317         ipc.InfoHolder infoHolder = new ipc.InfoHolder();
00318         CalibrationController cc = si.getCalibrationController();
00319         if (cc != null)  {
00320             cc.get_info(infoHolder);
00321             ipc.Info info = infoHolder.value;
00322             taMessages.append("CalibrationController running: " + info.pid + " by " + info.owner + " on " +info.host + " since " + info.time + "\n");
00323         } else {
00324             taMessages.append("CalibrationController not running\n");
00325         }
00326     }//GEN-LAST:event_bPingActionPerformed
00327 
00328     private void bRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bRefreshActionPerformed
00329         this.si.refresh();
00330         myInitComponents();
00331     }//GEN-LAST:event_bRefreshActionPerformed
00332     
00333     
00334     void updateStatus(CalibrationControllerStatus status) {
00335         if (status == null) {
00336             tStatus.getModel().setValueAt("UNAVAILABLE", 0, 1);
00337             tStatus.getModel().setValueAt("", 1, 1);
00338             tStatus.getModel().setValueAt("", 2, 1);
00339             tStatus.getModel().setValueAt("", 3, 1);
00340         } else {
00341             switch (status.status) {
00342                 case CalibrationControllerStatus.LOADED:
00343                     tStatus.getModel().setValueAt("LOADED", 0, 1);
00344                     break;
00345                 case CalibrationControllerStatus.INCONTROL:
00346                     tStatus.getModel().setValueAt("INCONTROL", 0, 1);
00347                     break;
00348                 case CalibrationControllerStatus.BUSY:
00349                     tStatus.getModel().setValueAt("BUSY", 0, 1);
00350                     break;
00351                 default:
00352                     tStatus.getModel().setValueAt("UNKNOWN", 0, 1);
00353             }
00354             tStatus.getModel().setValueAt(status.currentSequence, 1, 1);
00355             tStatus.getModel().setValueAt(status.currentTest, 2, 1);
00356             tStatus.getModel().setValueAt("" + status.currentScanIndex, 3, 1);
00357         }
00358     }
00359     
00360     public void infoCreated(is.InfoEvent infoEvent) {
00361         try {
00362             CalibrationControllerStatus status = new CalibrationControllerStatus();
00363             infoEvent.getValue(status);
00364             updateStatus(status);
00365         } catch (InfoNotCompatibleException e) {
00366             taMessages.append("Unable to read IS object - not a CalibrationControllerStatus: " + e.getMessage() + "\n");
00367         }
00368     }
00369     
00370     public void infoDeleted(is.InfoEvent infoEvent) {
00371         updateStatus(null);
00372     }
00373     
00374     //Pass to infoCreated
00375     public void infoUpdated(is.InfoEvent infoEvent) {
00376         infoCreated(infoEvent);
00377     }
00378     
00379     // Variables declaration - do not modify//GEN-BEGIN:variables
00380     private javax.swing.JButton bCharacter;
00381     private javax.swing.JButton bNMask;
00382     private javax.swing.JButton bPing;
00383     private javax.swing.JButton bRefresh;
00384     private javax.swing.JButton bResponse;
00385     private javax.swing.JButton bStrobeDelay;
00386     private javax.swing.JButton bThreePt;
00387     private javax.swing.JButton bThreshold;
00388     private javax.swing.JButton jButton1;
00389     private javax.swing.JLabel jLabel1;
00390     private javax.swing.JPanel jPanel1;
00391     private javax.swing.JPanel jPanel2;
00392     private javax.swing.JTable tStatus;
00393     // End of variables declaration//GEN-END:variables
00394     private JTextArea taMessages;
00395     private SystemInterface si;
00396 }

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