1   /*
2    * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
3    * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
4    *
5    * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
6    * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
7    * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
8    * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9    * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
11   * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
12   * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
13   * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
14   * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
15   * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
16   * OR MODIFICATIONS.
17   * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
18   * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
19   * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
20   * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
21   */
22  
23  package de.desy.acop.demo;
24  
25  import java.util.*;
26  import javax.swing.JFrame;
27  import de.desy.tine.client.*;
28  import de.desy.tine.dataUtils.*;
29  import de.desy.tine.definitions.*;
30  import de.desy.tine.queryUtils.*;
31  import de.desy.tine.structUtils.*;
32  import de.desy.tine.types.*;
33  import de.desy.acop.chart.*;
34  
35  /**
36   * @author duval To change the template for this generated type comment go to
37   *         Window>Preferences>Java>Code Generation>Code and Comments
38   */
39  public class InstantBrowser extends JFrame
40  {
41    private javax.swing.JPanel jContentPane = null;
42    private Acop acop = null;
43    private TPropertyQuery[] xpqs = null;
44    private int nxpqs = 0;
45    private int ptrxpqs = 0;
46    private int debugLevel = 0;
47    private javax.swing.JMenuBar browserMenu = null;
48    private javax.swing.JMenu browserOptions = null;
49    private javax.swing.JCheckBoxMenuItem supressQueryProperties = null;
50    private javax.swing.JCheckBoxMenuItem propertyQueryPrecedence = null;
51    private javax.swing.JCheckBoxMenuItem deviceQueryPrecedence = null;
52    private javax.swing.JMenuItem flushAddressCache = null;
53    private javax.swing.JMenuItem reloadNames = null;
54    private javax.swing.JComboBox deviceContextCombo = null;
55    private javax.swing.JTextField deviceContrextText = null;
56    private javax.swing.JTextField deviceServerText = null;
57    private javax.swing.JTextField deviceSubsystemText = null;
58    private javax.swing.JTextField deviceNameText = null;
59    private javax.swing.JTextField devicePropertyText = null;
60    private javax.swing.JCheckBox stockPropertiesChecked = null;
61    private javax.swing.JComboBox deviceServerCombo = null;
62    private javax.swing.JComboBox deviceSubsystemCombo = null;
63    private javax.swing.JComboBox deviceNameCombo = null;
64    private javax.swing.JComboBox devicePropertyCombo = null;
65    private javax.swing.JTextField dataSizeText = null;
66    private javax.swing.JTextField dataTypeText = null;
67    private javax.swing.JTextField propertyDescriptionText = null;
68    private javax.swing.JTextField timeoutText = null;
69    private javax.swing.JTextArea dataSizeInput = null;
70    private javax.swing.JComboBox dataTypeCombo = null;
71    private javax.swing.JTextArea timeoutInput = null;
72    private javax.swing.JButton readButton = null;
73    private javax.swing.JButton pollButton = null;
74    private javax.swing.JTextField drawModeText = null;
75    private javax.swing.JComboBox drawModeCombo = null;
76    private javax.swing.JCheckBox autoscaleChecked = null;
77    private javax.swing.JCheckBox logScaleChecked = null;
78    private java.awt.Color bkgColor = new java.awt.Color(124, 151, 223);
79    private java.awt.Color bkgTextColor = new java.awt.Color(218, 229, 247);
80    private boolean isSwitching = false;
81    private static int PANEL_XEXTENT_SMALL = 567;
82    private static int PANEL_XEXTENT_LARGE = 750;
83    private static int PANEL_YEXTENT_SMALL = 388;
84    private static InstantBrowser browserInstance;
85    private BrowserCallback browserCallback = new BrowserCallback();
86    private TLink browserLink = null;
87    private TDataType dataOut = null;
88    private TDataType dataIn = null;
89    private String[] devlist = null;
90    public static void main(String[] args)
91    {
92      browserInstance = new InstantBrowser();
93      browserInstance.setTitle("browserInstance");
94      browserInstance.setVisible(true);
95    }
96    /**
97     * This is the default constructor
98     */
99    public InstantBrowser()
100   {
101     super();
102     initialize();
103   }
104   private void fillInContexts()
105   {
106     deviceContextCombo.removeAllItems();
107     deviceContextCombo.addItem("DEFAULT");
108     String[] contexts = TQuery.getContexts();
109     if (contexts != null)
110     {
111       Arrays.sort(contexts);
112       for (int i = 0; i < contexts.length; i++)
113       {
114         deviceContextCombo.addItem(contexts[i]);
115       }
116     }
117   }
118   public String[] SubSystemString = {"ALL", "Diagnostics", "Vaccum", "RF", "Magnets", "Timing", "Feedback",
119       "Tunes", "Injection", "QuenchProtection", "Experiments", "Services", "Subsystems", "Netmex", "Archive",
120       "Daemons", "Tests"};
121   public String[] SubSystemTag = {"ALL", "DIA", "VAC", "RF", "MAG", "TIM", "FB", "TUN", "INJ", "QPS", "EXP",
122       "SER", "SUB", "MEX", "HST", "DMN", "TST"};
123   private void fillInSubsystems()
124   {
125     deviceSubsystemCombo.removeAllItems();
126     for (int i = 0; i < SubSystemString.length; i++)
127     {
128       deviceSubsystemCombo.addItem(SubSystemString[i]);
129     }
130   }
131   /**
132    * This method initializes this
133    * 
134    * @return void
135    */
136   private void initialize()
137   {
138     this.setSize(560, 388);
139     this.setContentPane(getJContentPane());
140     this.setTitle("Java Instant Client");
141     this.addWindowListener(new java.awt.event.WindowAdapter()
142     {
143       public void windowClosing(java.awt.event.WindowEvent e)
144       {
145         System.exit(0);
146       }
147     });
148     fillInSubsystems();
149     fillInContexts();
150   }
151   /**
152    * This method initializes jContentPane
153    * 
154    * @return javax.swing.JPanel
155    */
156   private javax.swing.JPanel getJContentPane()
157   {
158     if (jContentPane == null)
159     {
160       jContentPane = new javax.swing.JPanel();
161       jContentPane.setLayout(null);
162       jContentPane.add(getAcop(), null);
163       jContentPane.add(getBrowserMenu(), null);
164       jContentPane.add(getReadButton(), null);
165       jContentPane.add(getPollButton(), null);
166       jContentPane.add(getDrawModeText(), null);
167       jContentPane.add(getDrawModeCombo(), null);
168       jContentPane.add(getAutoscaleChecked(), null);
169       jContentPane.add(getLogScaleChecked(), null);
170       jContentPane.add(getDeviceContextCombo(), null);
171       jContentPane.add(getDeviceContrextText(), null);
172       jContentPane.add(getDeviceServerText(), null);
173       jContentPane.add(getDeviceSubsystemText(), null);
174       jContentPane.add(getDeviceNameText(), null);
175       jContentPane.add(getDevicePropertyText(), null);
176       jContentPane.add(getStockPropertiesChecked(), null);
177       jContentPane.add(getDeviceServerCombo(), null);
178       jContentPane.add(getDeviceSubsystemCombo(), null);
179       jContentPane.add(getDeviceNameCombo(), null);
180       jContentPane.add(getDevicePropertyCombo(), null);
181       jContentPane.add(getDataSizeText(), null);
182       jContentPane.add(getDataTypeText(), null);
183       jContentPane.add(getPropertyDescriptionText(), null);
184       jContentPane.add(getTimeoutText(), null);
185       jContentPane.add(getDataSizeInput(), null);
186       jContentPane.add(getDataTypeCombo(), null);
187       jContentPane.add(getTimeoutInput(), null);
188       jContentPane.add(getHistoryCheckBox(), null);
189       jContentPane.add(getInputPanelCheckBox(), null);
190       jContentPane.add(getWriteAccessSelected(), null);
191       jContentPane.add(getInputDataTypeCombo(), null);
192       jContentPane.add(getInputDataTypeText(), null);
193       jContentPane.add(getInputPanelText(), null);
194       jContentPane.add(getDevicePropertyToggleButton(), null);
195       jContentPane.setBackground(bkgColor);
196     }
197     return jContentPane;
198   }
199   /**
200    * This method initializes acop
201    * 
202    * @return acop.Acop
203    */
204   private Acop getAcop()
205   {
206     if (acop == null)
207     {
208       acop = new Acop();
209       acop.setBounds(11, 141, 451, 212);
210       acop.setFrameRightOffset(-20);
211       acop.setFrameLeftOffset(20);
212       acop.getAcopTransport().setAccessProtocol("TINE");
213       acop.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12));
214       acop.setDrawWidth(2);
215       acop.setFrameFont(new java.awt.Font("Tahoma", java.awt.Font.BOLD, 12));
216       acop.setBackground(java.awt.Color.white);
217       acop.setCaption("");
218       acop.setLeftYLabel(true);
219       acop.setFrameTopOffset(-10);
220       acop.setFrameBottomOffset(10);
221       acop.setFrameForeColor(java.awt.Color.black);
222       acop.setTextDepth(1);
223       acop.setScreenDepth(1);
224       acop.setYBestScale(true);
225       acop.setXBestScale(true);
226     }
227     return acop;
228   }
229   /**
230    * This method initializes jJMenuBar
231    * 
232    * @return javax.swing.JMenuBar
233    */
234   private javax.swing.JMenuBar getBrowserMenu()
235   {
236     if (browserMenu == null)
237     {
238       browserMenu = new javax.swing.JMenuBar();
239       browserMenu.add(getBrowserOptions());
240       browserMenu.add(getDebugOptionsMenu());
241       browserMenu.setBounds(3, 3, 555, 21);
242       browserMenu.setName("BrowserMenu");
243       browserMenu.setBackground(bkgColor);
244     }
245     return browserMenu;
246   }
247   /**
248    * This method initializes jMenu
249    * 
250    * @return javax.swing.JMenu
251    */
252   private javax.swing.JMenu getBrowserOptions()
253   {
254     if (browserOptions == null)
255     {
256       browserOptions = new javax.swing.JMenu();
257       browserOptions.add(getSupressQueryProperties());
258       browserOptions.add(getPropertyQueryPrecedence());
259       browserOptions.add(getDeviceQueryPrecedence());
260       browserOptions.add(getFlushAddressCache());
261       browserOptions.add(getReloadNames());
262       browserOptions.setName("BrowserOptions");
263       browserOptions.setText("Options");
264       browserOptions.setBackground(bkgColor);
265     }
266     return browserOptions;
267   }
268   /**
269    * This method initializes jCheckBoxMenuItem
270    * 
271    * @return javax.swing.JCheckBoxMenuItem
272    */
273   private javax.swing.JCheckBoxMenuItem getSupressQueryProperties()
274   {
275     if (supressQueryProperties == null)
276     {
277       supressQueryProperties = new javax.swing.JCheckBoxMenuItem();
278       supressQueryProperties.setText("Supress Query Properties");
279       supressQueryProperties.setName("SupressQueryProperties");
280       supressQueryProperties.setSelected(true);
281       supressQueryProperties.addItemListener(new java.awt.event.ItemListener()
282       {
283         public void itemStateChanged(java.awt.event.ItemEvent e)
284         {
285           fillInDeviceProperties();
286         }
287       });
288     }
289     return supressQueryProperties;
290   }
291   /**
292    * This method initializes jCheckBoxMenuItem1
293    * 
294    * @return javax.swing.JCheckBoxMenuItem
295    */
296   private javax.swing.JCheckBoxMenuItem getPropertyQueryPrecedence()
297   {
298     if (propertyQueryPrecedence == null)
299     {
300       propertyQueryPrecedence = new javax.swing.JCheckBoxMenuItem();
301       propertyQueryPrecedence.setName("PropertyQueryPrecedence");
302       propertyQueryPrecedence.setText("Property Query Precedence");
303       propertyQueryPrecedence.setSelected(false);
304       propertyQueryPrecedence.addItemListener(new java.awt.event.ItemListener()
305       {
306         public void itemStateChanged(java.awt.event.ItemEvent e)
307         {
308           if (deviceQueryPrecedence.isSelected() && propertyQueryPrecedence.isSelected())
309             deviceQueryPrecedence.setSelected(false);
310         }
311       });
312     }
313     return propertyQueryPrecedence;
314   }
315   /**
316    * This method initializes jCheckBoxMenuItem2 *
317    * 
318    * @return javax.swing.JCheckBoxMenuItem
319    */
320   private javax.swing.JCheckBoxMenuItem getDeviceQueryPrecedence()
321   {
322     if (deviceQueryPrecedence == null)
323     {
324       deviceQueryPrecedence = new javax.swing.JCheckBoxMenuItem();
325       deviceQueryPrecedence.setName("DeviceQueryPrecedence");
326       deviceQueryPrecedence.setText("Device Query Precedence");
327       deviceQueryPrecedence.addItemListener(new java.awt.event.ItemListener()
328       {
329         public void itemStateChanged(java.awt.event.ItemEvent e)
330         {
331           if (deviceQueryPrecedence.isSelected() && propertyQueryPrecedence.isSelected())
332             propertyQueryPrecedence.setSelected(false);
333         }
334       });
335     }
336     return deviceQueryPrecedence;
337   }
338   /**
339    * This method initializes jMenuItem
340    * 
341    * @return javax.swing.JMenuItem
342    */
343   private javax.swing.JMenuItem getFlushAddressCache()
344   {
345     if (flushAddressCache == null)
346     {
347       flushAddressCache = new javax.swing.JMenuItem();
348       flushAddressCache.setName("FlushAddressCache");
349       flushAddressCache.setText("Flush Address Cache");
350       flushAddressCache.addActionListener(new java.awt.event.ActionListener()
351       {
352         public void actionPerformed(java.awt.event.ActionEvent e)
353         {
354           // System.out.println("actionPerformed()"); // TODO Auto-generated
355           // Event stub actionPerformed()
356         }
357       });
358     }
359     return flushAddressCache;
360   }
361   /**
362    * This method initializes jMenuItem1
363    * 
364    * @return javax.swing.JMenuItem
365    */
366   private javax.swing.JMenuItem getReloadNames()
367   {
368     if (reloadNames == null)
369     {
370       reloadNames = new javax.swing.JMenuItem();
371       reloadNames.setText("Reload Names");
372       reloadNames.setName("ReloadNames");
373       reloadNames.addActionListener(new java.awt.event.ActionListener()
374       {
375         public void actionPerformed(java.awt.event.ActionEvent e)
376         {
377           fillInSubsystems();
378           fillInContexts();
379         }
380       });
381     }
382     return reloadNames;
383   }
384   private void fillInDeviceServers()
385   {
386     if (deviceContextCombo.getSelectedIndex() < 0) return;
387     if (deviceSubsystemCombo.getSelectedIndex() < 0) return;
388     propertyQueryPrecedence.setSelected(false);
389     deviceQueryPrecedence.setSelected(false);
390     deviceServerCombo.removeAllItems();
391     String[] svrs = TQuery.getDeviceServers(deviceContextCombo.getSelectedItem().toString(),
392         SubSystemTag[deviceSubsystemCombo.getSelectedIndex()]);
393     if (svrs == null) return;
394     Arrays.sort(svrs);
395     for (int i = 0; i < svrs.length; i++)
396     {
397       deviceServerCombo.addItem(svrs[i]);
398     }
399   }
400   /**
401    * This method initializes jComboBox
402    * 
403    * @return javax.swing.JComboBox
404    */
405   private javax.swing.JComboBox getDeviceContextCombo()
406   {
407     if (deviceContextCombo == null)
408     {
409       deviceContextCombo = new javax.swing.JComboBox();
410       deviceContextCombo.setBounds(10, 40, 150, 20);
411       deviceContextCombo.setName("DeviceContextCombo");
412       deviceContextCombo.setMaximumRowCount(8);
413       deviceContextCombo.setLightWeightPopupEnabled(false);
414       deviceContextCombo.setEditable(false);
415       deviceContextCombo.setAutoscrolls(true);
416       deviceContextCombo.setFocusCycleRoot(false);
417       deviceContextCombo.setBackground(bkgTextColor);
418       deviceContextCombo.addActionListener(new java.awt.event.ActionListener()
419       {
420         public void actionPerformed(java.awt.event.ActionEvent e)
421         {
422           fillInDeviceServers();
423         }
424       });
425     }
426     return deviceContextCombo;
427   }
428   /**
429    * This method initializes jTextField
430    * 
431    * @return javax.swing.JTextField
432    */
433   private javax.swing.JTextField getDeviceContrextText()
434   {
435     if (deviceContrextText == null)
436     {
437       deviceContrextText = new javax.swing.JTextField();
438       deviceContrextText.setBounds(12, 24, 93, 15);
439       deviceContrextText.setName("DeviceContrextText");
440       deviceContrextText.setText("Device Context");
441       deviceContrextText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
442       deviceContrextText.setBackground(bkgColor);
443       deviceContrextText.setEditable(false);
444     }
445     return deviceContrextText;
446   }
447   /**
448    * This method initializes jTextField1
449    * 
450    * @return javax.swing.JTextField
451    */
452   private javax.swing.JTextField getDeviceServerText()
453   {
454     if (deviceServerText == null)
455     {
456       deviceServerText = new javax.swing.JTextField();
457       deviceServerText.setBounds(10, 60, 91, 15);
458       deviceServerText.setName("DeviceServerText");
459       deviceServerText.setText("Device Server");
460       deviceServerText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
461       deviceServerText.setBackground(bkgColor);
462       deviceServerText.setEditable(false);
463     }
464     return deviceServerText;
465   }
466   /**
467    * This method initializes jTextField2
468    * 
469    * @return javax.swing.JTextField
470    */
471   private javax.swing.JTextField getDeviceSubsystemText()
472   {
473     if (deviceSubsystemText == null)
474     {
475       deviceSubsystemText = new javax.swing.JTextField();
476       deviceSubsystemText.setBounds(174, 24, 114, 15);
477       deviceSubsystemText.setName("DeviceSubsystemText");
478       deviceSubsystemText.setText("Device Subsystem");
479       deviceSubsystemText.setBackground(bkgColor);
480       deviceSubsystemText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
481       deviceSubsystemText.setEditable(false);
482     }
483     return deviceSubsystemText;
484   }
485   /**
486    * This method initializes jTextField3
487    * 
488    * @return javax.swing.JTextField
489    */
490   private javax.swing.JTextField getDeviceNameText()
491   {
492     if (deviceNameText == null)
493     {
494       deviceNameText = new javax.swing.JTextField();
495       deviceNameText.setBounds(176, 60, 87, 15);
496       deviceNameText.setName("DeviceNameText");
497       deviceNameText.setText("Device Name");
498       deviceNameText.setBackground(bkgColor);
499       deviceNameText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
500       deviceNameText.setEditable(false);
501     }
502     return deviceNameText;
503   }
504   /**
505    * This method initializes jTextField4
506    * 
507    * @return javax.swing.JTextField
508    */
509   private javax.swing.JTextField getDevicePropertyText()
510   {
511     if (devicePropertyText == null)
512     {
513       devicePropertyText = new javax.swing.JTextField();
514       devicePropertyText.setBounds(365, 60, 99, 15);
515       devicePropertyText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
516       devicePropertyText.setBackground(bkgColor);
517       devicePropertyText.setName("DevicePropertyText");
518       devicePropertyText.setText("Device Property");
519       devicePropertyText.setEditable(false);
520     }
521     return devicePropertyText;
522   }
523   /**
524    * This method initializes jCheckBox
525    * 
526    * @return javax.swing.JCheckBox
527    */
528   private javax.swing.JCheckBox getStockPropertiesChecked()
529   {
530     if (stockPropertiesChecked == null)
531     {
532       stockPropertiesChecked = new javax.swing.JCheckBox();
533       stockPropertiesChecked.setBounds(365, 35, 149, 24);
534       stockPropertiesChecked.setName("StockPropertiesChecked");
535       stockPropertiesChecked.setText("Show Stock Proprties");
536       stockPropertiesChecked.setBackground(bkgColor);
537       stockPropertiesChecked.addItemListener(new java.awt.event.ItemListener()
538       {
539         public void itemStateChanged(java.awt.event.ItemEvent e)
540         {
541           fillInDeviceProperties();
542         }
543       });
544     }
545     return stockPropertiesChecked;
546   }
547   private void fillInDeviceNames()
548   {
549     String[] devs = null;
550     if (deviceNameCombo.getItemCount() > 0) deviceNameCombo.removeAllItems();
551     if (!propertyQueryPrecedence.isSelected())
552     {
553       devs = TQuery.getDeviceNames(deviceContextCombo.getSelectedItem().toString(), deviceServerCombo
554           .getSelectedItem().toString());
555       if (TQuery.devices_have_query_function) propertyQueryPrecedence.setSelected(true);
556     }
557     else
558     {
559       if (devicePropertyCombo.getSelectedIndex() < 0) return;
560       devs = TQuery.getDeviceNames(deviceContextCombo.getSelectedItem().toString(), deviceServerCombo
561           .getSelectedItem().toString(), devicePropertyCombo.getSelectedItem().toString());
562     }
563     if (devs == null || devs.length == 0)
564     {
565       deviceNameCombo.addItem("#0");
566     }
567     else
568     {
569       for (int i = 0; i < devs.length; i++)
570       {
571         deviceNameCombo.addItem(devs[i]);
572       }
573     }
574     devlist = devs;
575   }
576   /**
577    * This method initializes jComboBox1
578    * 
579    * @return javax.swing.JComboBox
580    */
581   private javax.swing.JComboBox getDeviceServerCombo()
582   {
583     if (deviceServerCombo == null)
584     {
585       deviceServerCombo = new javax.swing.JComboBox();
586       deviceServerCombo.setBounds(10, 75, 150, 20);
587       deviceServerCombo.setName("DeviceServerCombo");
588       deviceServerCombo.setLightWeightPopupEnabled(false);
589       deviceServerCombo.setEditable(false);
590       deviceServerCombo.setBackground(bkgTextColor);
591       deviceServerCombo.addActionListener(new java.awt.event.ActionListener()
592       {
593         public void actionPerformed(java.awt.event.ActionEvent e)
594         {
595           if (deviceServerCombo.getSelectedIndex() < 0) return; // removeAll
596                                                                 // will also
597                                                                 // generate this
598                                                                 // event
599           propertyQueryPrecedence.setSelected(false);
600           deviceQueryPrecedence.setSelected(false);
601           fillInDeviceNames();
602           fillInDeviceProperties();
603         }
604       });
605     }
606     return deviceServerCombo;
607   }// @jve:visual-info decl-index=0 visual-constraint="23,15"
608   /**
609    * This method initializes jComboBox2
610    * 
611    * @return javax.swing.JComboBox
612    */
613   private javax.swing.JComboBox getDeviceSubsystemCombo()
614   {
615     if (deviceSubsystemCombo == null)
616     {
617       deviceSubsystemCombo = new javax.swing.JComboBox();
618       deviceSubsystemCombo.setBounds(177, 40, 160, 20);
619       deviceSubsystemCombo.setName("DeviceSubsystemCombo");
620       deviceSubsystemCombo.setLightWeightPopupEnabled(false);
621       deviceSubsystemCombo.setEditable(false);
622       deviceSubsystemCombo.setBackground(bkgTextColor);
623       deviceSubsystemCombo.addActionListener(new java.awt.event.ActionListener()
624       {
625         public void actionPerformed(java.awt.event.ActionEvent e)
626         {
627           if (deviceSubsystemCombo.getSelectedIndex() < 0) return;
628           fillInDeviceServers();
629         }
630       });
631     }
632     return deviceSubsystemCombo;
633   }
634   private void fillInDeviceProperties()
635   {
636     String con, dev, srv;
637     if (deviceServerCombo.getSelectedIndex() < 0) return;
638     con = (deviceContextCombo.getSelectedIndex() < 0) ? "" : deviceContextCombo.getSelectedItem().toString();
639     dev = (deviceNameCombo.getSelectedIndex() < 0) ? "#0" : deviceNameCombo.getSelectedItem().toString();
640     srv = deviceServerCombo.getSelectedItem().toString();
641     if (devicePropertyCombo.getItemCount() > 0) devicePropertyCombo.removeAllItems();
642     String[] prps = TQuery.getDeviceProperties(con, srv, dev);
643     if (prps == null) return;
644     if (TQuery.properties_have_query_function)
645     {
646       deviceQueryPrecedence.setSelected(true);
647       propertyQueryPrecedence.setSelected(false);
648     }
649     if (stockPropertiesChecked.isSelected())
650     {
651       String[] sprps = TQuery.getStockProperties(con, srv);
652       if (sprps != null)
653       {
654         Arrays.sort(sprps);
655         devicePropertyCombo.setForeground(java.awt.Color.red);
656         for (int i = 0; i < sprps.length; i++)
657         	try {
658           devicePropertyCombo.addItem(sprps[i]);
659         	} catch(Exception e) {
660         		System.out.println("error");
661         	}
662         devicePropertyCombo.setForeground(java.awt.Color.black);
663       }
664     }
665     Arrays.sort(prps);
666     for (int i = 0; i < prps.length; i++)
667     {
668       if (supressQueryProperties.isSelected())
669       {
670         if (prps[i].endsWith(".NAM")) continue;
671         if (prps[i].endsWith(".HIST")) continue;
672         if (prps[i].endsWith(".EGU")) continue;
673       }
674       devicePropertyCombo.addItem(prps[i]);
675     }
676   }
677   /**
678    * This method initializes jComboBox3
679    * 
680    * @return javax.swing.JComboBox
681    */
682   private javax.swing.JComboBox getDeviceNameCombo()
683   {
684     if (deviceNameCombo == null)
685     {
686       deviceNameCombo = new javax.swing.JComboBox();
687       deviceNameCombo.setBounds(176, 75, 162, 20);
688       deviceNameCombo.setName("DeviceNameCombo");
689       deviceNameCombo.setLightWeightPopupEnabled(false);
690       deviceNameCombo.setEditable(true);
691       deviceNameCombo.setBackground(bkgTextColor);
692       deviceNameCombo.addActionListener(new java.awt.event.ActionListener()
693       {
694         public void actionPerformed(java.awt.event.ActionEvent e)
695         {
696           if (deviceNameCombo.getSelectedIndex() < 0) return;
697           if (deviceQueryPrecedence.isSelected()) fillInDeviceProperties();
698         }
699       });
700     }
701     return deviceNameCombo;
702   }
703   void fillInPropertyInfoCombos(String con, String srv)
704   {
705     dataSizeInput.setText("" + xpqs[ptrxpqs].prpSize);
706     dataTypeCombo.setSelectedIndex(getDataTypeComboIndex(xpqs[ptrxpqs].prpFormat));
707     propertyDescriptionText.setText(" " + xpqs[ptrxpqs].prpDescription);
708     if (xpqs[ptrxpqs].prpFormat == TFormat.CF_STRUCT)
709     {
710       if (xpqs[ptrxpqs].prpTag.length() > 0) // tagged structure
711       {
712         TQuery.AcquireAndRegisterStructInfo(con, srv, xpqs[ptrxpqs].prpTag);
713       }
714     }
715     logScaleChecked.setSelected(xpqs[ptrxpqs].prpGraphType == 1);
716     if (xpqs[ptrxpqs].prpSize > 1024)
717     {
718       drawModeCombo.setSelectedIndex(1);
719     }
720     else if ((xpqs[ptrxpqs].prpArrayType & TArrayType.AT_SPECTRUM) == TArrayType.AT_SPECTRUM)
721     {
722       drawModeCombo.setSelectedIndex(0); // polyline
723     }
724     else if ((xpqs[ptrxpqs].prpArrayType & TArrayType.AT_CHANNEL) == TArrayType.AT_CHANNEL)
725     {
726       drawModeCombo.setSelectedIndex(2); // histogram
727     }
728     else
729     {
730       drawModeCombo.setSelectedIndex(7); // text
731     }
732     if (xpqs[ptrxpqs].prpSizeIn > 0)
733     {
734       inputDataTypeCombo.setSelectedIndex(getDataTypeComboIndex(xpqs[ptrxpqs].prpFormatIn));
735     }
736     else if (xpqs[ptrxpqs].prpSize > 0)
737     {
738       inputDataTypeCombo.setSelectedIndex(getDataTypeComboIndex(xpqs[ptrxpqs].prpFormat));
739     }
740     else
741     {
742       inputDataTypeCombo.setSelectedIndex(getDataTypeComboIndex(TFormat.CF_TEXT));
743     }
744   }
745   void fillInPropertyInformation(String prp)
746   {
747     String con = "";
748     String dev = "#0";
749     if (deviceServerCombo.getSelectedIndex() < 0) return;
750     String srv = deviceServerCombo.getSelectedItem().toString();
751     if (deviceContextCombo.getSelectedIndex() >= 0) con = deviceContextCombo.getSelectedItem().toString();
752     if (deviceNameCombo.getSelectedIndex() >= 0) dev = deviceNameCombo.getSelectedItem().toString();
753     nxpqs = 0;
754     ptrxpqs = 0;
755     xpqs = TQuery.getPropertyInformation(con, srv, dev, prp);
756     if (xpqs == null || xpqs.length == 0 || xpqs[0] == null)
757     {
758       xpqs = TQuery.getStockPropertyInformation(con, srv, dev, prp);
759       if (xpqs == null || xpqs.length == 0 || xpqs[0] == null) return;
760     }
761     nxpqs = xpqs.length;
762     fillInPropertyInfoCombos(con, srv);
763     historyCheckBox.setVisible(xpqs[ptrxpqs].prpHistoryDepthShort > 0);
764     historyCheckBox.setSelected(false);
765     devicePropertyToggleButton.setVisible(xpqs[ptrxpqs].prpNumOverloads > 1);
766   }
767   /**
768    * This method initializes jComboBox4
769    * 
770    * @return javax.swing.JComboBox
771    */
772   private javax.swing.JComboBox getDevicePropertyCombo()
773   {
774     if (devicePropertyCombo == null)
775     {
776       devicePropertyCombo = new javax.swing.JComboBox();
777       devicePropertyCombo.setBounds(365, 75, 176, 20);
778       devicePropertyCombo.setName("DevicePropertyCombo");
779       devicePropertyCombo.setLightWeightPopupEnabled(false);
780       devicePropertyCombo.setEditable(true);
781       devicePropertyCombo.setBackground(bkgTextColor);
782       devicePropertyCombo.addActionListener(new java.awt.event.ActionListener()
783       {
784         public void actionPerformed(java.awt.event.ActionEvent e)
785         {
786           if (devicePropertyCombo.getSelectedIndex() < 0) return;
787           if (propertyQueryPrecedence.isSelected()) fillInDeviceNames();
788           fillInPropertyInformation(devicePropertyCombo.getSelectedItem().toString());
789         }
790       });
791     }
792     return devicePropertyCombo;
793   }
794   /**
795    * This method initializes jTextField5
796    * 
797    * @return javax.swing.JTextField
798    */
799   private javax.swing.JTextField getDataSizeText()
800   {
801     if (dataSizeText == null)
802     {
803       dataSizeText = new javax.swing.JTextField();
804       dataSizeText.setBounds(14, 99, 61, 15);
805       dataSizeText.setBackground(bkgColor);
806       dataSizeText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
807       dataSizeText.setName("DataSizeText");
808       dataSizeText.setText("Data Size");
809     }
810     return dataSizeText;
811   }
812   /**
813    * This method initializes jTextField6
814    * 
815    * @return javax.swing.JTextField
816    */
817   private javax.swing.JTextField getDataTypeText()
818   {
819     if (dataTypeText == null)
820     {
821       dataTypeText = new javax.swing.JTextField();
822       dataTypeText.setBounds(79, 99, 67, 15);
823       dataTypeText.setBackground(bkgColor);
824       dataTypeText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
825       dataTypeText.setName("DataTypeText");
826       dataTypeText.setText("Data Type");
827     }
828     return dataTypeText;
829   }
830   /**
831    * This method initializes jTextField7
832    * 
833    * @return javax.swing.JTextField
834    */
835   private javax.swing.JTextField getPropertyDescriptionText()
836   {
837     if (propertyDescriptionText == null)
838     {
839       propertyDescriptionText = new javax.swing.JTextField();
840       propertyDescriptionText.setBounds(177, 103, 306, 26);
841       propertyDescriptionText.setBackground(bkgTextColor);
842       propertyDescriptionText.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
843       propertyDescriptionText.setName("PropertyDescriptionText");
844     }
845     return propertyDescriptionText;
846   }
847   /**
848    * This method initializes jTextField8
849    * 
850    * @return javax.swing.JTextField
851    */
852   private javax.swing.JTextField getTimeoutText()
853   {
854     if (timeoutText == null)
855     {
856       timeoutText = new javax.swing.JTextField();
857       timeoutText.setBounds(489, 96, 54, 16);
858       timeoutText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
859       timeoutText.setBackground(bkgColor);
860       timeoutText.setName("TimeoutText");
861       timeoutText.setText("Timeout");
862     }
863     return timeoutText;
864   }
865   /**
866    * This method initializes jTextArea
867    * 
868    * @return javax.swing.JTextArea
869    */
870   private javax.swing.JTextArea getDataSizeInput()
871   {
872     if (dataSizeInput == null)
873     {
874       dataSizeInput = new javax.swing.JTextArea();
875       dataSizeInput.setBounds(13, 115, 43, 18);
876       dataSizeInput.setBackground(bkgColor);
877       dataSizeInput.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
878       dataSizeInput.setName("DataSizeInput");
879       dataSizeInput.setText("1");
880     }
881     return dataSizeInput;
882   }
883   private int[] dataTypeComboXref;
884   private void fillInDataTypes(javax.swing.JComboBox cb)
885   {
886     int i;
887     if (dataTypeComboXref == null)
888     {
889       dataTypeComboXref = new int[TFormat.availableFormats.length];
890       for (i = 0; i < TFormat.availableFormats.length; i++)
891         dataTypeComboXref[i] = TFormat.getFormatCode(TFormat.availableFormats[i]);
892     }
893     if (cb.getItemCount() > 0) cb.removeAllItems();
894     for (i = 0; i < TFormat.availableFormats.length; i++)
895     {
896       cb.addItem(TFormat.availableFormats[i]);
897     }
898   }
899   private int getDataTypeComboIndex(int code)
900   {
901     int i;
902     for (i = 0; i < dataTypeComboXref.length; i++)
903     {
904       if (dataTypeComboXref[i] == code) return i;
905     }
906     return -1;
907   }
908   /**
909    * This method initializes jComboBox5
910    * 
911    * @return javax.swing.JComboBox
912    */
913   private javax.swing.JComboBox getDataTypeCombo()
914   {
915     if (dataTypeCombo == null)
916     {
917       dataTypeCombo = new javax.swing.JComboBox();
918       dataTypeCombo.setBounds(80, 115, 86, 20);
919       dataTypeCombo.setName("DataTypeCombo");
920       dataTypeCombo.setLightWeightPopupEnabled(false);
921       dataTypeCombo.setBackground(bkgColor);
922       fillInDataTypes(dataTypeCombo);
923       dataTypeCombo.addActionListener(new java.awt.event.ActionListener()
924       {
925         public void actionPerformed(java.awt.event.ActionEvent e)
926         {
927           // System.out.println("actionPerformed()"); // TODO Auto-generated
928           // Event stub actionPerformed()
929         }
930       });
931     }
932     return dataTypeCombo;
933   }
934   /**
935    * This method initializes jTextArea1
936    * 
937    * @return javax.swing.JTextArea
938    */
939   private javax.swing.JTextArea getTimeoutInput()
940   {
941     if (timeoutInput == null)
942     {
943       timeoutInput = new javax.swing.JTextArea();
944       timeoutInput.setBounds(499, 112, 42, 18);
945       timeoutInput.setBackground(bkgColor);
946       timeoutInput.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
947       timeoutInput.setName("TimeoutInput");
948       timeoutInput.setText("1000");
949     }
950     return timeoutInput;
951   }
952   public class BrowserCallback implements TLinkCallback
953   {
954     public void callback(TLink lnk)
955     {
956       int cc;
957       if ((cc = lnk.getLinkStatus()) != 0)
958       {
959         String msg = new String("Link Error : " + lnk.getProperty() + " -> " + lnk.getLastError());
960         acop.printText(msg);
961         System.out.println(msg);
962         return;
963       }
964       displayDataForSelectedProperty(cc);
965     }
966   }
967   private void displayDataForSelectedProperty(int cc)
968   {
969     int id = -1;
970     acop.clearScreen();
971     acop.clearText();
972     if (cc == 0)
973     {
974       if (dataOut == null) return;
975       long dts = browserLink.getLastTimeStamp();
976       int ms = (int) (dts % 1000);
977       String add = ms < 10 ? ".00" : ms < 100 ? ".0" : ".";
978       Date td = new Date(dts);
979       String ts = td.toString().substring(11, 19) + add + ms;
980       acop.setCaption(browserLink.getFullDeviceName() + " " + xpqs[ptrxpqs].prpName + " @ " + ts);
981       if (drawModeCombo.getSelectedIndex() != 7) // text
982       {
983         Object o = dataOut.getDataObject();
984         long timestamp = dataOut.getDataTimeStamp();
985         int siz = dataOut.dCompletionLength;
986         acop.setXMax(siz);
987         acop.setXMin(0);
988         acop.setYMax(xpqs[ptrxpqs].prpMaxValue);
989         acop.setYMin(xpqs[ptrxpqs].prpMinValue);
990         acop.setYAxisLabel(xpqs[ptrxpqs].prpUnits);
991         acop.setXAxisLabel(xpqs[ptrxpqs].rngUnits);
992         if ((xpqs[ptrxpqs].prpArrayType & TArrayType.AT_CHANNEL) == TArrayType.AT_CHANNEL)
993         {
994           id = acop.draw(o, null, null, devlist);
995         }
996         else
997         {
998           id = acop.draw(o);
999         }
1000         if (autoscaleChecked.isSelected()) acop.autoScale(false, false, true, true, id);
1001       }
1002       else
1003       {
1004         dataOut.setArrayDelimiter("\n");
1005         id = acop.draw(dataOut.toString().trim());
1006       }
1007     }
1008     else
1009     {
1010       String err = browserLink.getLastError();
1011       if (err == null || err.length() == 0) err = TErrorList.getErrorString(cc);
1012       if (drawModeCombo.getSelectedIndex() != 7) // text
1013       {
1014         if (browserLink != null) acop.printText(err);
1015       }
1016       else
1017       {
1018         String[] aerr = new String[1];
1019         aerr[0] = err;
1020         id = acop.draw(aerr);
1021       }
1022     }
1023   }
1024   private int getDataForSelectedProperty(int mode)
1025   {
1026     int id = -1, cc = 0;
1027     int to = (new Integer(getTimeoutInput().getText())).intValue() ;
1028     String fmt = dataTypeCombo.getSelectedItem().toString();
1029     short ifmt = TFormat.getFormatCode(fmt);
1030     int siz = (new Integer(getDataSizeInput().getText())).intValue();
1031     try
1032     {
1033       String con = deviceContextCombo.getSelectedItem().toString();
1034       String srv = deviceServerCombo.getSelectedItem().toString();
1035       String dev = deviceNameCombo.getSelectedItem().toString();
1036       String prp = devicePropertyCombo.getSelectedItem().toString();
1037       if (historyCheckBox.isSelected()) prp += ".HIST";
1038       String tgt;
1039       tgt = srv + "/" + dev;
1040       if (con.length() > 0 && con.compareTo("DEFAULT") != 0)
1041       {
1042         tgt = "/" + con + "/" + tgt;
1043       }
1044       if (ifmt == TFormat.CF_STRUCT)
1045       {
1046         drawModeCombo.setSelectedIndex(7); // text
1047         int ssiz = TStructRegistry.getSizeInBytes(xpqs[ptrxpqs].prpTag);
1048         if (ssiz != -1)   
1049         {
1050           ssiz *= xpqs[ptrxpqs].prpSize;
1051           byte[] sdata = new byte[ssiz];
1052           dataOut = new TDataType(sdata, xpqs[ptrxpqs].prpTag);
1053         }
1054         else
1055         {
1056           ssiz = xpqs[ptrxpqs].prpSize;
1057           byte[] sdata = new byte[ssiz];
1058           dataOut = new TDataType(sdata);
1059         }
1060       }
1061       else
1062       {
1063         dataOut = new TDataType(siz, ifmt);
1064       }
1065       if (browserLink != null) browserLink.cancel();
1066       
1067       dataIn = getInputData();
1068       short access = TAccess.CA_READ;
1069       if (writeAccessSelected.isSelected()) access |= TAccess.CA_WRITE;
1070       browserLink = new TLink(tgt, prp, dataOut, dataIn, access);
1071       if (debugLevel != browserLink.getDebugLevel()) browserLink.setDebugLevel(debugLevel);
1072       if ((mode & 0xff) == TMode.CM_SINGLE)
1073       {
1074         cc = browserLink.execute(to, true);
1075         displayDataForSelectedProperty(cc);
1076         browserLink.cancel();
1077         return cc;
1078       }
1079       if ((mode & 0xff) == TMode.CM_POLL)
1080       {
1081         id = browserLink.attach((short) mode, browserCallback, to);
1082         return id < 0 ? id : 0;
1083       }
1084     }
1085     catch (Exception e)
1086     {
1087       if (debugLevel > 0) e.printStackTrace();      
1088     }
1089     return 0;
1090   }
1091   /**
1092    * This method initializes jButton
1093    * 
1094    * @return javax.swing.JButton
1095    */
1096   private javax.swing.JButton getReadButton()
1097   {
1098     if (readButton == null)
1099     {
1100       readButton = new javax.swing.JButton();
1101       readButton.setBounds(465, 143, 80, 25);
1102       readButton.setName("ReadButton");
1103       readButton.setText("Read");
1104       readButton.addActionListener(new java.awt.event.ActionListener()
1105       {
1106         public void actionPerformed(java.awt.event.ActionEvent e)
1107         {
1108           int cc = getDataForSelectedProperty(TMode.CM_SINGLE);
1109         }
1110       });
1111     }
1112     return readButton;
1113   }
1114   /**
1115    * This method initializes jButton1
1116    * 
1117    * @return javax.swing.JButton
1118    */
1119   private javax.swing.JButton getPollButton()
1120   {
1121     if (pollButton == null)
1122     {
1123       pollButton = new javax.swing.JButton();
1124       pollButton.setBounds(465, 172, 80, 25);
1125       pollButton.setName("PollButton");
1126       pollButton.setText("Poll");
1127       pollButton.addActionListener(new java.awt.event.ActionListener()
1128       {
1129         public void actionPerformed(java.awt.event.ActionEvent e)
1130         {
1131           if (pollButton.getText().compareTo("Stop") == 0)
1132           {
1133             if (browserLink != null) browserLink.cancel();
1134             pollButton.setText("Poll");
1135             readButton.setEnabled(true);
1136             return;
1137           }
1138           int id = getDataForSelectedProperty(TMode.CM_POLL);
1139           if (id != 0)
1140           {
1141         	  acop.printText(acop.getAcopTransport().getStatus());
1142 //            acop.PrintText(acop.getStatus());
1143           }
1144           else
1145           {
1146             pollButton.setText("Stop");
1147             readButton.setEnabled(false);
1148           }
1149         }
1150       });
1151     }
1152     return pollButton;
1153   }
1154   /**
1155    * This method initializes jTextField9
1156    * 
1157    * @return javax.swing.JTextField
1158    */
1159   private javax.swing.JTextField getDrawModeText()
1160   {
1161     if (drawModeText == null)
1162     {
1163       drawModeText = new javax.swing.JTextField();
1164       drawModeText.setBounds(480, 202, 67, 15);
1165       drawModeText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
1166       drawModeText.setBackground(bkgColor);
1167       drawModeText.setName("DrawModeText");
1168       drawModeText.setText("Draw Mode");
1169     }
1170     return drawModeText;
1171   }
1172   public String[] drawModes = {"PolyLine", "BarLine", "Histogram", "Dots", "AdjHisto", "Rects", "Circles",
1173       "Text" // ,"LineDots","BarDots","HistoDots"
1174   };
1175   private javax.swing.JCheckBox historyCheckBox = null;
1176   private javax.swing.JCheckBox inputPanelCheckBox = null;
1177   private javax.swing.JCheckBox writeAccessSelected = null;
1178   private javax.swing.JComboBox inputDataTypeCombo = null;
1179   private javax.swing.JTextArea inputDataTypeText = null;
1180   private javax.swing.JEditorPane inputPanelText = null;
1181   private javax.swing.JButton devicePropertyToggleButton = null;
1182   private javax.swing.JMenu debugOptionsMenu = null;
1183   private javax.swing.JMenuItem showFecInfoOption = null;
1184   private javax.swing.JRadioButtonMenuItem debugOnOption = null;
1185   private void fillInDrawModes()
1186   {
1187     if (drawModeCombo.getItemCount() > 0) drawModeCombo.removeAll();
1188     for (int i = 0; i < drawModes.length; i++)
1189     {
1190       drawModeCombo.addItem(drawModes[i]);
1191     }
1192   }
1193   /**
1194    * This method initializes jComboBox6
1195    * 
1196    * @return javax.swing.JComboBox
1197    */
1198   private javax.swing.JComboBox getDrawModeCombo()
1199   {
1200     if (drawModeCombo == null)
1201     {
1202       drawModeCombo = new javax.swing.JComboBox();
1203       drawModeCombo.setBounds(468, 218, 80, 20);
1204       drawModeCombo.setName("DrawModeCombo");
1205       drawModeCombo.setLightWeightPopupEnabled(false);
1206       drawModeCombo.setBackground(bkgColor);
1207       drawModeCombo.setMaximumRowCount(5);
1208       fillInDrawModes();
1209       drawModeCombo.addActionListener(new java.awt.event.ActionListener()
1210       {
1211         public void actionPerformed(java.awt.event.ActionEvent e)
1212         {
1213           acop.setDisplayMode(drawModeCombo.getSelectedIndex());
1214         }
1215       });
1216     }
1217     return drawModeCombo;
1218   }
1219   /**
1220    * This method initializes jCheckBox1
1221    * 
1222    * @return javax.swing.JCheckBox
1223    */
1224   private javax.swing.JCheckBox getAutoscaleChecked()
1225   {
1226     if (autoscaleChecked == null)
1227     {
1228       autoscaleChecked = new javax.swing.JCheckBox();
1229       autoscaleChecked.setBounds(465, 245, 87, 20);
1230       autoscaleChecked.setName("AutoscaleChecked");
1231       autoscaleChecked.setText("Autoscale");
1232       autoscaleChecked.setBackground(bkgColor);
1233       autoscaleChecked.addItemListener(new java.awt.event.ItemListener()
1234       {
1235         public void itemStateChanged(java.awt.event.ItemEvent e)
1236         {
1237           displayDataForSelectedProperty(0);
1238         }
1239       });
1240     }
1241     return autoscaleChecked;
1242   }
1243   /**
1244    * This method initializes jCheckBox2
1245    * 
1246    * @return javax.swing.JCheckBox
1247    */
1248   private javax.swing.JCheckBox getLogScaleChecked()
1249   {
1250     if (logScaleChecked == null)
1251     {
1252       logScaleChecked = new javax.swing.JCheckBox();
1253       logScaleChecked.setBounds(465, 270, 87, 20);
1254       logScaleChecked.setName("LogScaleChecked");
1255       logScaleChecked.setText("Log Scale");
1256       logScaleChecked.setBackground(bkgColor);
1257       logScaleChecked.addItemListener(new java.awt.event.ItemListener()
1258       {
1259         public void itemStateChanged(java.awt.event.ItemEvent e)
1260         {
1261           if (logScaleChecked.isSelected())
1262             acop.setGraphStyle(1);
1263           else
1264             acop.setGraphStyle(0);
1265           displayDataForSelectedProperty(0);
1266         }
1267       });
1268     }
1269     return logScaleChecked;
1270   }
1271   /**
1272    * This method initializes jCheckBox
1273    * 
1274    * @return javax.swing.JCheckBox
1275    */
1276   private javax.swing.JCheckBox getHistoryCheckBox()
1277   {
1278     if (historyCheckBox == null)
1279     {
1280       historyCheckBox = new javax.swing.JCheckBox();
1281       historyCheckBox.setBounds(465, 295, 87, 20);
1282       historyCheckBox.setName("historyCheckBox");
1283       historyCheckBox.setText("History");
1284       historyCheckBox.setBackground(bkgColor);
1285       historyCheckBox.addItemListener(new java.awt.event.ItemListener()
1286       {
1287         public void itemStateChanged(java.awt.event.ItemEvent e)
1288         {
1289           if (historyCheckBox.isSelected())
1290           {
1291             drawModeCombo.setSelectedIndex(0); // polyline
1292             dataSizeInput.setText("" + xpqs[ptrxpqs].prpHistoryDepthShort);
1293           }
1294           else
1295           {
1296             if (xpqs[ptrxpqs].prpSize > 1024)
1297             {
1298               drawModeCombo.setSelectedIndex(0);
1299             }
1300             else if ((xpqs[ptrxpqs].prpArrayType & TArrayType.AT_SPECTRUM) == TArrayType.AT_SPECTRUM)
1301             {
1302               drawModeCombo.setSelectedIndex(0); // polyline
1303             }
1304             else if ((xpqs[ptrxpqs].prpArrayType & TArrayType.AT_CHANNEL) == TArrayType.AT_CHANNEL)
1305             {
1306               drawModeCombo.setSelectedIndex(2); // histogram
1307             }
1308             else
1309             {
1310               drawModeCombo.setSelectedIndex(7); // text
1311             }
1312             dataSizeInput.setText("" + xpqs[ptrxpqs].prpSize);
1313           }
1314         }
1315       });
1316     }
1317     return historyCheckBox;
1318   }
1319   /**
1320    * This method initializes jCheckBox1
1321    * 
1322    * @return javax.swing.JCheckBox
1323    */
1324   private javax.swing.JCheckBox getInputPanelCheckBox()
1325   {
1326     if (inputPanelCheckBox == null)
1327     {
1328       inputPanelCheckBox = new javax.swing.JCheckBox();
1329       inputPanelCheckBox.setBounds(465, 320, 87, 20);
1330       inputPanelCheckBox.setName("inputPanelCheckBox");
1331       inputPanelCheckBox.setText("InputPane");
1332       inputPanelCheckBox.setBackground(bkgColor);
1333       inputPanelCheckBox.addItemListener(new java.awt.event.ItemListener()
1334       {
1335         public void itemStateChanged(java.awt.event.ItemEvent e)
1336         {
1337           inputDataTypeText.setText("");
1338           if (inputPanelCheckBox.isSelected())
1339           {
1340             browserInstance.setSize(PANEL_XEXTENT_LARGE, PANEL_YEXTENT_SMALL);
1341             inputPanelText.setVisible(true);
1342             inputDataTypeCombo.setVisible(true);
1343             writeAccessSelected.setVisible(true);
1344             inputDataTypeText.setVisible(true);
1345           }
1346           else
1347           {
1348             browserInstance.setSize(PANEL_XEXTENT_SMALL, PANEL_YEXTENT_SMALL);
1349             inputPanelText.setVisible(false);
1350             inputDataTypeCombo.setVisible(false);
1351             writeAccessSelected.setVisible(false);
1352             inputDataTypeText.setVisible(false);
1353             readButton.setText("Read");
1354           }
1355         }
1356       });
1357     }
1358     return inputPanelCheckBox;
1359   }
1360   /**
1361    * This method initializes jCheckBox
1362    * 
1363    * @return javax.swing.JCheckBox
1364    */
1365   private javax.swing.JCheckBox getWriteAccessSelected()
1366   {
1367     if (writeAccessSelected == null)
1368     {
1369       writeAccessSelected = new javax.swing.JCheckBox();
1370       writeAccessSelected.setBounds(621, 39, 108, 16);
1371       writeAccessSelected.setName("writeAccessSelected");
1372       writeAccessSelected.setText("Write Access");
1373       writeAccessSelected.setVisible(false);
1374       writeAccessSelected.setBackground(bkgColor);
1375       writeAccessSelected.addActionListener(new java.awt.event.ActionListener()
1376       {
1377         public void actionPerformed(java.awt.event.ActionEvent e)
1378         {
1379           if (writeAccessSelected.isSelected())
1380             readButton.setText("Write");
1381           else
1382             readButton.setText("Read");
1383         }
1384       });
1385     }
1386     return writeAccessSelected;
1387   }
1388   /**
1389    * This method initializes jComboBox
1390    * 
1391    * @return javax.swing.JComboBox
1392    */
1393   private javax.swing.JComboBox getInputDataTypeCombo()
1394   {
1395     if (inputDataTypeCombo == null)
1396     {
1397       inputDataTypeCombo = new javax.swing.JComboBox();
1398       inputDataTypeCombo.setBounds(638, 76, 89, 17);
1399       inputDataTypeCombo.setName("inputDataTypeCombo");
1400       fillInDataTypes(inputDataTypeCombo);
1401       inputDataTypeCombo.setVisible(false);
1402       inputDataTypeCombo.setBackground(bkgColor);
1403     }
1404     return inputDataTypeCombo;
1405   }
1406   private TDataType getInputData()
1407   {
1408     if (!inputPanelCheckBox.isSelected()) return null;
1409     String fmt = inputDataTypeCombo.getSelectedItem().toString();
1410     String txt = inputPanelText.getText().trim();
1411     if (txt.length() == 0) return null;
1412     String del = " ";
1413     if (txt.indexOf(',') != -1) del = ",";
1414     String[] vars = new String[txt.length()]; // = txt.split(del);
1415     String[] v = txt.split("\n");
1416     int siz = 0;
1417     for (int n = 0; n < v.length; n++)
1418     {
1419       String[] sv = v[n].trim().split(del);
1420       for (int p = 0; p < sv.length; p++)
1421         vars[siz++] = sv[p].trim();
1422     }
1423     // int siz = vars.length;
1424     int i = 0, retrycnt = 2;
1425     while (retrycnt-- > 0)
1426     {
1427       try
1428       {
1429         switch (TFormat.getFormatCode(fmt))
1430         {
1431           case TFormat.CF_DOUBLE:
1432           {
1433             double[] vals = new double[siz];
1434             for (i = 0; i < siz; i++)
1435               vals[i] = new Double(vars[i]).doubleValue();
1436             return new TDataType(vals);
1437           }
1438           case TFormat.CF_SHORT:
1439           {
1440             short[] vals = new short[siz];
1441             for (i = 0; i < siz; i++)
1442               vals[i] = new Short(vars[i]).shortValue();
1443             return new TDataType(vals);
1444           }
1445           case TFormat.CF_LONG:
1446           {
1447             int[] vals = new int[siz];
1448             for (i = 0; i < siz; i++)
1449               vals[i] = new Integer(vars[i]).intValue();
1450             return new TDataType(vals);
1451           }
1452           case TFormat.CF_FLOAT:
1453           {
1454             float[] vals = new float[siz];
1455             for (i = 0; i < siz; i++)
1456               vals[i] = new Float(vars[i]).floatValue();
1457             return new TDataType(vals);
1458           }
1459           case TFormat.CF_BYTE:
1460           {
1461             byte[] vals = new byte[siz];
1462             for (i = 0; i < siz; i++)
1463               vals[i] = new Byte(vars[i]).byteValue();
1464             return new TDataType(vals);
1465           }
1466           case TFormat.CF_TEXT:
1467           {
1468             return new TDataType(txt);
1469           }
1470           case TFormat.CF_NAME8:
1471           {
1472             NAME8[] vals = new NAME8[siz];
1473             for (i = 0; i < siz; i++)
1474               vals[i] = new NAME8(vars[i]);
1475             return new TDataType(vals);
1476           }
1477           case TFormat.CF_NAME16:
1478           {
1479             NAME16[] vals = new NAME16[siz];
1480             for (i = 0; i < siz; i++)
1481               vals[i] = new NAME16(vars[i]);
1482             return new TDataType(vals);
1483           }
1484           case TFormat.CF_NAME32:
1485           {
1486             NAME32[] vals = new NAME32[siz];
1487             for (i = 0; i < siz; i++)
1488               vals[i] = new NAME32(vars[i]);
1489             return new TDataType(vals);
1490           }
1491           case TFormat.CF_NAME48:
1492           {
1493             NAME48[] vals = new NAME48[siz];
1494             for (i = 0; i < siz; i++)
1495               vals[i] = new NAME48(vars[i]);
1496             return new TDataType(vals);
1497           }
1498           case TFormat.CF_NAME64:
1499           {
1500             NAME64[] vals = new NAME64[siz];
1501             for (i = 0; i < siz; i++)
1502               vals[i] = new NAME64(vars[i]);
1503             return new TDataType(vals);
1504           }
1505           case TFormat.CF_NAME16I:
1506           {
1507             NAME16I[] vals = new NAME16I[siz];
1508             for (i = 0; i < siz / 2; i++)
1509               vals[i] = new NAME16I(vars[i * 2], new Integer(vars[i * 2 + 1]).intValue());
1510             return new TDataType(vals);
1511           }
1512           case TFormat.CF_NAME32I:
1513           {
1514             NAME32I[] vals = new NAME32I[siz];
1515             for (i = 0; i < siz / 2; i++)
1516               vals[i] = new NAME32I(vars[i * 2], new Integer(vars[i * 2 + 1]).intValue());
1517             return new TDataType(vals);
1518           }
1519           case TFormat.CF_NAME48I:
1520           {
1521             NAME48I[] vals = new NAME48I[siz];
1522             for (i = 0; i < siz / 2; i++)
1523               vals[i] = new NAME48I(vars[i * 2], new Integer(vars[i * 2 + 1]).intValue());
1524             return new TDataType(vals);
1525           }
1526           case TFormat.CF_NAME64I:
1527           {
1528             NAME64I[] vals = new NAME64I[siz];
1529             for (i = 0; i < siz / 2; i++)
1530               vals[i] = new NAME64I(vars[i * 2], new Integer(vars[i * 2 + 1]).intValue());
1531             return new TDataType(vals);
1532           }
1533           case TFormat.CF_LNGINT:
1534           {
1535             LNGINT[] vals = new LNGINT[siz];
1536             for (i = 0; i < siz / 2; i++)
1537               vals[i] = new LNGINT(new Integer(vars[i * 2]).intValue(), new Integer(vars[i * 2 + 1])
1538                   .intValue());
1539             return new TDataType(vals);
1540           }
1541           case TFormat.CF_FLTINT:
1542           {
1543             FLTINT[] vals = new FLTINT[siz];
1544             for (i = 0; i < siz / 2; i++)
1545               vals[i] = new FLTINT(new Float(vars[i * 2]).floatValue(), new Integer(vars[i * 2 + 1])
1546                   .intValue());
1547             return new TDataType(vals);
1548           }
1549           case TFormat.CF_FLTFLT:
1550           {
1551             FLTFLT[] vals = new FLTFLT[siz];
1552             for (i = 0; i < siz / 2; i++)
1553               vals[i] = new FLTFLT(new Float(vars[i * 2]).floatValue(), new Float(vars[i * 2 + 1])
1554                   .floatValue());
1555             return new TDataType(vals);
1556           }
1557           case TFormat.CF_DBLDBL:
1558           {
1559             DBLDBL[] vals = new DBLDBL[siz];
1560             for (i = 0; i < siz / 2; i++)
1561               vals[i] = new DBLDBL(new Double(vars[i * 2]).doubleValue(), new Double(vars[i * 2 + 1])
1562                   .doubleValue());
1563             return new TDataType(vals);
1564           }
1565           case TFormat.CF_NAME16FI:
1566           {
1567             NAME16FI[] vals = new NAME16FI[siz];
1568             for (i = 0; i < siz / 3; i++)
1569               vals[i] = new NAME16FI(vars[i * 3], new Integer(vars[i * 3 + 2]).intValue(), new Float(
1570                   vars[i * 3 + 1]).floatValue());
1571             return new TDataType(vals);
1572           }
1573           case TFormat.CF_FLTFLTINT:
1574           {
1575             FLTFLTINT[] vals = new FLTFLTINT[siz];
1576             for (i = 0; i < siz / 3; i++)
1577               vals[i] = new FLTFLTINT(new Float(vars[i * 3]).floatValue(), new Float(vars[i * 3 + 1])
1578                   .floatValue(), new Integer(vars[i * 3 + 2]).intValue());
1579             return new TDataType(vals);
1580           }
1581           case TFormat.CF_FLTINTINT:
1582           {
1583             FLTINTINT[] vals = new FLTINTINT[siz];
1584             for (i = 0; i < siz / 3; i++)
1585               vals[i] = new FLTINTINT(new Float(vars[i * 3]).floatValue(), new Integer(vars[i * 3 + 1])
1586                   .intValue(), new Integer(vars[i * 3 + 2]).intValue());
1587             return new TDataType(vals);
1588           }
1589           case TFormat.CF_INTFLTFLTFLT:
1590           {
1591             INTFLTFLTFLT[] vals = new INTFLTFLTFLT[siz];
1592             for (i = 0; i < siz / 4; i++)
1593               vals[i] = new INTFLTFLTFLT(new Integer(vars[i * 4]).intValue(), new Float(vars[i * 4 + 1])
1594                   .floatValue(), new Float(vars[i * 4 + 2]).floatValue(), new Float(vars[i * 4 + 3])
1595                   .floatValue());
1596             return new TDataType(vals);
1597           }
1598           case TFormat.CF_INTFLTINT:
1599           {
1600             INTFLTINT[] vals = new INTFLTINT[siz];
1601             for (i = 0; i < siz / 3; i++)
1602               vals[i] = new INTFLTINT(new Integer(vars[i * 3]).intValue(), new Float(vars[i * 3 + 1])
1603                   .floatValue(), new Integer(vars[i * 3 + 2]).intValue());
1604             return new TDataType(vals);
1605           }
1606           case TFormat.CF_INTINTFLTFLT:
1607           {
1608             INTINTFLTFLT[] vals = new INTINTFLTFLT[siz];
1609             for (i = 0; i < siz / 4; i++)
1610               vals[i] = new INTINTFLTFLT(new Float(vars[i * 4 + 2]).floatValue(), new Float(vars[i * 4 + 3])
1611                   .floatValue(), new Integer(vars[i * 4]).intValue(), new Integer(vars[i * 4 + 1]).intValue());
1612             return new TDataType(vals);
1613           }
1614           case TFormat.CF_INTINTINTINT:
1615           {
1616             INTINTINTINT[] vals = new INTINTINTINT[siz];
1617             for (i = 0; i < siz / 4; i++)
1618               vals[i] = new INTINTINTINT(new Integer(vars[i * 4]).intValue(), new Integer(vars[i * 4 + 1])
1619                   .intValue(), new Integer(vars[i * 4 + 2]).intValue(), new Integer(vars[i * 4 + 3])
1620                   .intValue());
1621             return new TDataType(vals);
1622           }
1623         }
1624         return null;
1625       }
1626       catch (NumberFormatException e)
1627       {
1628         siz = i;
1629       }
1630     }
1631     return null;
1632   }
1633   /**
1634    * This method initializes jTextArea
1635    * 
1636    * @return javax.swing.JTextArea
1637    */
1638   private javax.swing.JTextArea getInputDataTypeText()
1639   {
1640     if (inputDataTypeText == null)
1641     {
1642       inputDataTypeText = new javax.swing.JTextArea();
1643       inputDataTypeText.setBounds(613, 58, 116, 14);
1644       inputDataTypeText.setBackground(bkgColor);
1645       inputDataTypeText.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
1646       inputDataTypeText.setName("inputDataTypeText");
1647       inputDataTypeText.setText("Input Data Type");
1648       inputDataTypeText.setVisible(false);
1649       inputDataTypeText.setEditable(false);
1650     }
1651     return inputDataTypeText;
1652   }
1653   /**
1654    * This method initializes jEditorPane
1655    * 
1656    * @return javax.swing.JEditorPane
1657    */
1658   private javax.swing.JEditorPane getInputPanelText()
1659   {
1660     if (inputPanelText == null)
1661     {
1662       inputPanelText = new javax.swing.JEditorPane();
1663       inputPanelText.setBounds(568, 101, 161, 240);
1664       inputPanelText.setVisible(false);
1665       inputPanelText.setName("InputPanelText");
1666       inputPanelText.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
1667     }
1668     return inputPanelText;
1669   }
1670   /**
1671    * This method initializes jButton
1672    * 
1673    * @return javax.swing.JButton
1674    */
1675   private javax.swing.JButton getDevicePropertyToggleButton()
1676   {
1677     if (devicePropertyToggleButton == null)
1678     {
1679       devicePropertyToggleButton = new javax.swing.JButton();
1680       devicePropertyToggleButton.setBounds(464, 60, 78, 13);
1681       devicePropertyToggleButton.setText("toggle");
1682       devicePropertyToggleButton.setName("devicePropertyToggleButton");
1683       devicePropertyToggleButton.setVisible(false);
1684       devicePropertyToggleButton.setBackground(bkgColor);
1685       devicePropertyToggleButton.addActionListener(new java.awt.event.ActionListener()
1686       {
1687         public void actionPerformed(java.awt.event.ActionEvent e)
1688         {
1689           if (nxpqs > 1) ptrxpqs = (ptrxpqs + 1) % nxpqs;
1690           String srv = deviceServerCombo.getSelectedItem().toString();
1691           String con = deviceContextCombo.getSelectedItem().toString();
1692           fillInPropertyInfoCombos(con, srv);
1693         }
1694       });
1695     }
1696     return devicePropertyToggleButton;
1697   }
1698   /**
1699    * This method initializes jMenu
1700    * 
1701    * @return javax.swing.JMenu
1702    */
1703   private javax.swing.JMenu getDebugOptionsMenu()
1704   {
1705     if (debugOptionsMenu == null)
1706     {
1707       debugOptionsMenu = new javax.swing.JMenu();
1708       debugOptionsMenu.add(getShowFecInfoOption());
1709       debugOptionsMenu.add(getDebugOnOption());
1710       debugOptionsMenu.setText("Debug Options");
1711       debugOptionsMenu.setName("debugOptions");
1712       debugOptionsMenu.setBackground(bkgColor);
1713     }
1714     return debugOptionsMenu;
1715   }
1716   /**
1717    * This method initializes jMenuItem
1718    * 
1719    * @return javax.swing.JMenuItem
1720    */
1721   private javax.swing.JMenuItem getShowFecInfoOption()
1722   {
1723     if (showFecInfoOption == null)
1724     {
1725       showFecInfoOption = new javax.swing.JMenuItem();
1726       showFecInfoOption.setName("showFecInfoOption");
1727       showFecInfoOption.setText("Show Fec Information");
1728       showFecInfoOption.addActionListener(new java.awt.event.ActionListener()
1729       {
1730         public void actionPerformed(java.awt.event.ActionEvent e)
1731         {
1732           drawModeCombo.setSelectedIndex(7);
1733           String srv = deviceServerCombo.getSelectedItem().toString();
1734           String con = deviceContextCombo.getSelectedItem().toString();
1735           String s = TQuery.getModuleAddressInfo(srv, con);
1736           String sa[] = s.split("\n");
1737           String sb[] = new String[sa.length + 3];
1738           int i;
1739           for (i = 0; i < sa.length; i++)
1740             sb[i] = sa[i];
1741           sb[i++] = TQuery.getTineVersion(con, srv);
1742           sb[i++] = TQuery.getAppVersion(con, srv);
1743           sb[i++] = TQuery.getAppDate(con, srv);
1744           acop.clearScreen();
1745           acop.clearText();
1746           acop.draw(sb);
1747         }
1748       });
1749     }
1750     return showFecInfoOption;
1751   }
1752   /**
1753    * This method initializes jRadioButtonMenuItem
1754    * 
1755    * @return javax.swing.JRadioButtonMenuItem
1756    */
1757   private javax.swing.JRadioButtonMenuItem getDebugOnOption()
1758   {
1759     if (debugOnOption == null)
1760     {
1761       debugOnOption = new javax.swing.JRadioButtonMenuItem();
1762       debugOnOption.setText("Debug On");
1763       debugOnOption.setName("debugOnOption");
1764       debugOnOption.addItemListener(new java.awt.event.ItemListener()
1765       {
1766         public void itemStateChanged(java.awt.event.ItemEvent e)
1767         {
1768           debugLevel = debugOnOption.isSelected() ? 2 : 0;
1769         }
1770       });
1771     }
1772     return debugOnOption;
1773   }
1774 } // @jve:visual-info decl-index=0 visual-constraint="23,15"