00001
00002
00003
00004
00005
00006
00007 package DisplayGUI;
00008
00009 import javax.swing.*;
00010 import Sct_CalibrationController.*;
00011 import Sct.IS.SctNames;
00012 import is.*;
00013
00019 public class CalibrationControllerPanel2 extends javax.swing.JPanel implements InfoListener, displayParams {
00020
00021 gui guiControl;
00022 CalibrationControllerStatus status;
00023 int currentBin=-1;
00024 int maxBin=-1;
00025
00026 public CalibrationControllerPanel2(gui parent) {
00027 guiControl=parent;
00028 setBackground(new java.awt.Color(255, 255, 255));
00029 is = GuiComponents.System.ISInterface.getInstance();
00030 initComponents();
00031 myInitComponents();
00032 addMouseListener(new ccMouseAdapter());
00033 }
00034
00035 private void myInitComponents() {
00036
00037 try {
00038 status = new CalibrationControllerStatus();
00039 is.getRepository().getValue(SctNames.getControlISServer() + ".Status", status);
00040 updateStatus();
00041 } catch (RuntimeException e) {
00042 status=null;
00043 System.err.println("Couldn't get CalibrationController Status: " + e.getMessage());
00044 updateStatus();
00045 }
00046
00047
00048 try {
00049 is.subscribe(SctNames.getControlISServer(), "Status", false, this);
00050 } catch (RuntimeException e) {
00051 System.err.println("Couldn't subscribe to ControlData IS Server: " + e.getMessage());
00052 }
00053
00054 try {
00055 is.subscribe("SCTAPIServer","currentBin",false,this);
00056 is.subscribe("SCTAPIServer","maxBin",false,this);
00057 } catch (RuntimeException e2) {
00058 System.err.println("Couldn't subscribe to SCTAPIServer: " + e2.getMessage());
00059 }
00060
00061 }
00062
00066 void close() {
00067
00068 try {
00069 is.unsubscribe(SctNames.getControlISServer(), "Status");
00070 } catch (RuntimeException e) {
00071 System.err.println("Couldn't unsubscribe from ControlData IS Server: " + e.getMessage());
00072 }
00073 try {
00074 is.unsubscribe("SCTAPIServer","currentBin");
00075 is.unsubscribe("SCTAPIServer","maxBin");
00076 } catch (RuntimeException e2) {
00077 System.err.println("Couldn't unsubscribe from SCTAPIServer: " + e2.getMessage());
00078 }
00079 }
00080
00081
00082 private void initComponents() {
00083
00084 jLabel1 = new javax.swing.JLabel();
00085 statusField = new javax.swing.JTextField();
00086 jLabel2 = new javax.swing.JLabel();
00087 testField = new javax.swing.JTextField();
00088 jLabel3 = new javax.swing.JLabel();
00089 sequenceField = new javax.swing.JTextField();
00090 jLabel4 = new javax.swing.JLabel();
00091 scanIndexField = new javax.swing.JTextField();
00092 jLabel5 = new javax.swing.JLabel();
00093
00094 progressBar = new javax.swing.JProgressBar();
00095
00096 progressBar.setStringPainted(true);
00097 progressBar.setString("");
00098 progressBar.setMaximum(100);
00099 progressBar.setValue(0);
00100
00101 progressBar.setForeground(darkBlueColor);
00102
00103 setLayout(new java.awt.GridLayout(5, 2));
00104
00105 setBackground(backgroundColor);
00106 jLabel1.setFont(displayCCBoldFont);
00107 jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00108 jLabel1.setText("CalibrationController Status : ");
00109 add(jLabel1);
00110
00111 statusField.setBackground(backgroundColor);
00112 statusField.setColumns(15);
00113 statusField.setEditable(false);
00114 statusField.setFont(displayCCFont);
00115 statusField.addMouseListener(new ccMouseAdapter());
00116 statusField.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00117 statusField.setDisabledTextColor(new java.awt.Color(255, 255, 255));
00118 add(statusField);
00119
00120 jLabel2.setFont(displayCCBoldFont);
00121 jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00122 jLabel2.setText("Current Test : ");
00123 add(jLabel2);
00124
00125 testField.setBackground(backgroundColor);
00126 testField.setColumns(15);
00127 testField.setEditable(false);
00128 testField.setFont(displayCCFont);
00129 testField.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00130 testField.setDisabledTextColor(new java.awt.Color(255, 255, 255));
00131 testField.addMouseListener(new ccMouseAdapter());
00132 add(testField);
00133
00134 jLabel3.setFont(displayCCBoldFont);
00135 jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00136 jLabel3.setText("Current Sequence : ");
00137 add(jLabel3);
00138
00139 sequenceField.setBackground(backgroundColor);
00140 sequenceField.setColumns(15);
00141 sequenceField.setEditable(false);
00142 sequenceField.setFont(displayCCFont);
00143 sequenceField.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00144 sequenceField.setDisabledTextColor(new java.awt.Color(255, 255, 255));
00145 sequenceField.addMouseListener(new ccMouseAdapter());
00146 add(sequenceField);
00147
00148 jLabel4.setFont(displayCCBoldFont);
00149 jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00150 jLabel4.setText("Current Scan Index : ");
00151 add(jLabel4);
00152
00153 scanIndexField.setBackground(backgroundColor);
00154 scanIndexField.setColumns(15);
00155 scanIndexField.setEditable(false);
00156 scanIndexField.setFont(displayCCFont);
00157 scanIndexField.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00158 scanIndexField.setDisabledTextColor(new java.awt.Color(255, 255, 255));
00159 scanIndexField.addMouseListener(new ccMouseAdapter());
00160 add(scanIndexField);
00161
00162 jLabel5.setFont(displayCCBoldFont);
00163 jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
00164 jLabel5.setText("Scan Progress : ");
00165 add(jLabel5);
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 progressBar.setBackground(backgroundColor);
00176
00177 progressBar.setFont(displayCCFont);
00178 progressBar.setBorderPainted(false);
00179 progressBar.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
00180
00181 progressBar.addMouseListener(new ccMouseAdapter());
00182 add(progressBar);
00183
00184
00185
00186 setBorder(new javax.swing.border.TitledBorder(null, "Scan Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 0, 153)));
00187
00188 }
00189
00190
00191 void updateStatus() {
00192
00193 javax.swing.SwingUtilities.invokeLater(new Runnable() {
00194 public void run() {
00195
00196 if (status == null) {
00197 statusField.setText("UNAVAILABLE");
00198 statusField.setForeground(java.awt.Color.red);
00199 guiControl.menuBar.enableCCMenuItems(false);
00200 } else {
00201 switch (status.status) {
00202 case CalibrationControllerStatus.LOADED:
00203 statusField.setText("LOADED");
00204 statusField.setForeground(darkGreenColor);
00205 guiControl.menuBar.enableCCMenuItems(false);
00206 break;
00207 case CalibrationControllerStatus.INCONTROL:
00208 statusField.setText("INCONTROL");
00209 statusField.setForeground(darkGreenColor);
00210 guiControl.menuBar.enableCCMenuItems(true);
00211 break;
00212 case CalibrationControllerStatus.BUSY:
00213 statusField.setText("BUSY");
00214 statusField.setForeground(java.awt.Color.orange);
00215 guiControl.menuBar.enableCCMenuItems(false);
00216 break;
00217 case CalibrationControllerStatus.ERROR:
00218 statusField.setText("ERROR");
00219 statusField.setForeground(java.awt.Color.orange);
00220 guiControl.menuBar.enableCCMenuItems(false);
00221 break;
00222 default:
00223 statusField.setText("UNKNOWN");
00224 statusField.setForeground(java.awt.Color.red);
00225 guiControl.menuBar.enableCCMenuItems(false);
00226 }
00227 sequenceField.setText(status.currentSequence);
00228 testField.setText(status.currentTest);
00229 scanIndexField.setText(Integer.toString(status.currentScanIndex));
00230 guiControl.menuBar.checkCCUpdateMode();
00231 }
00232 }
00233 });
00234 }
00235
00236 void updateProgressBar() {
00237
00238 javax.swing.SwingUtilities.invokeLater(new Runnable() {
00239 public void run() {
00240 if(maxBin==-1) progressBar.setMaximum(1000);
00241 else progressBar.setMaximum(maxBin);
00242 if(currentBin==-1) {
00243 progressBar.setValue(0);
00244 progressBar.setString("");
00245 }
00246 else {
00247 progressBar.setValue(currentBin);
00248 if(maxBin==-1) progressBar.setString(Integer.toString(currentBin));
00249 else {
00250 progressBar.setString(Integer.toString(currentBin)+" out of "+Integer.toString(maxBin)+" bins");
00251 if(maxBin==currentBin) progressBar.setForeground(darkGreenColor);
00252 else progressBar.setForeground(darkBlueColor);
00253 }
00254 }
00255 }
00256 });
00257 }
00258
00259
00260 public void infoCreated(is.InfoEvent infoEvent) {
00261 String objectName = infoEvent.getName();
00262 if(objectName.equals(SctNames.getControlISServer() + ".Status")) {
00263 try {
00264 status = new CalibrationControllerStatus();
00265 infoEvent.getValue(status);
00266 updateStatus();
00267 } catch (InfoNotCompatibleException e) {
00268 System.err.println("Unable to read IS object - not a CalibrationControllerStatus: " + e.getMessage());
00269 }
00270 }
00271 else {
00272 try {
00273 is.AnyInfo theValue = new is.AnyInfo();
00274 infoEvent.getValue(theValue);
00275 if(objectName.equals("SCTAPIServer.currentBin")) currentBin=((Integer) theValue.getAttribute(0)).intValue();
00276 else if(objectName.equals("SCTAPIServer.maxBin")) maxBin=((Integer) theValue.getAttribute(0)).intValue();
00277 updateProgressBar();
00278 }catch(Exception e2){
00279 System.err.println("Unable to update progressBar - "+e2.toString());
00280 }
00281
00282 }
00283
00284
00285 }
00286
00287 public void infoDeleted(is.InfoEvent infoEvent) {
00288 if(infoEvent.getName().equals(SctNames.getControlISServer() + ".Status")) {
00289 status=null;
00290 updateStatus();
00291 }
00292 else {
00293 currentBin=-1;
00294 maxBin=-1;
00295 updateProgressBar();
00296 }
00297 }
00298
00299
00300 public void infoUpdated(is.InfoEvent infoEvent) {
00301 infoCreated(infoEvent);
00302 }
00303
00304
00305
00306 private javax.swing.JLabel jLabel1;
00307 private javax.swing.JLabel jLabel2;
00308 private javax.swing.JLabel jLabel3;
00309 private javax.swing.JLabel jLabel4;
00310 private javax.swing.JLabel jLabel5;
00311 private javax.swing.JTextField scanIndexField;
00312 private javax.swing.JTextField sequenceField;
00313 private javax.swing.JTextField statusField;
00314 private javax.swing.JTextField testField;
00315
00316 private javax.swing.JProgressBar progressBar;
00317
00318 private GuiComponents.System.ISInterface is;
00319
00320 class ccMouseAdapter extends java.awt.event.MouseAdapter {
00321 public void mouseClicked(java.awt.event.MouseEvent e) {
00322 switch(e.getModifiers()) {
00323 case java.awt.event.InputEvent.BUTTON2_MASK:
00324 case java.awt.event.InputEvent.BUTTON3_MASK:
00325 guiControl.menuBar.showCCPopupMenu(e);
00326 break;
00327 default:
00328 }
00329 }
00330 }
00331
00332 }
00333
00334