00001
00012 package dndtester;
00013 import javax.swing.*;
00014 import javax.swing.event.*;
00015 import java.awt.*;
00016 import java.awt.event.*;
00017 import java.util.*;
00018
00019
00026 public class DaqPanel extends JPanel{
00028 boolean isConnected = false;
00029
00031 DaqTests daqTests;
00032
00034 static DaqPanel curDaqPanel;
00035
00037 JRootPane rootPane;
00038
00040 JScrollBar scroller;
00041
00043 ConnectionPanel connectPanel;
00044
00046 TestPanel testPanel;
00047
00049 final SSPanel sspanel;
00051 ResetDebugPanel rDPanel;
00052
00054 Hashtable openPorts;
00055
00063 class ConnectionPanel extends JPanel{
00065 public static final int MAXTEXT = 15;
00066
00068 public static final int PORTTEXT = 5;
00069
00074 JButton connection;
00075
00079 JButton disconnect;
00080
00082 JLabel daqMachine;
00083
00085 JLabel labelComPort;
00086
00090 JTextField daqServer;
00091
00095 JTextField commandPort;
00096
00098 JLabel connectStat;
00099
00104 public ConnectionPanel(){
00105
00106 connectStat = new JLabel("offline ");
00107 connectStat.setForeground(Color.red);
00108 labelComPort = new JLabel("Command Port");
00109 commandPort = new JTextField(PORTTEXT);
00110 commandPort.setHorizontalAlignment(JTextField.RIGHT);
00111 commandPort.setText("55055");
00112 daqMachine = new JLabel("DAQ Machine");
00113 daqServer = new JTextField(MAXTEXT);
00114 daqServer.setText("localhost");
00115 connection = new JButton("Connect");
00116 disconnect = new JButton("Disconnect");
00117
00118 setLayout(new FlowLayout());
00119
00120
00121
00122 add(connectStat);
00123 add(labelComPort);
00124 add(commandPort);
00125 add(daqMachine);
00126 add(daqServer);
00127 add(connection);
00128 add(disconnect);
00129 }
00130 }
00131
00136 class TestPanel extends JPanel{
00138 JTextField commandText;
00146 JTextField resultText;
00147
00149 JLabel commandLabel;
00150
00152 JLabel resultLabel;
00153
00155 JButton commandTestB;
00156
00158 JLabel dataNumLabel;
00159
00161 JTextField readDataNum;
00162
00167 JTextField suiteRuns;
00168
00170 JButton readDataB;
00171
00173 JButton testSuiteB;
00174
00176 JLabel suiteRunsL;
00177
00184 public TestPanel(){
00185 GridBagLayout gbl = new GridBagLayout();
00186 GridBagConstraints gbc = new GridBagConstraints();
00187 setLayout(gbl);
00188 commandText = new JTextField(10);
00189 resultText = new JTextField(10);
00190 commandTestB = new JButton("Test");
00191 commandLabel = new JLabel("Command to test: ");
00192 resultLabel = new JLabel("Known result");
00193 dataNumLabel = new JLabel("Times to read Data: ");
00194 readDataNum = new JTextField(4);
00195 readDataNum.setHorizontalAlignment(JTextField.RIGHT);
00196 readDataNum.setText("1");
00197 readDataB = new JButton("Read Data");
00198 testSuiteB = new JButton("Run DAQ test suite");
00199 suiteRunsL = new JLabel("Test Runs: ");
00200 suiteRuns = new JTextField(3);
00201
00202 suiteRuns.setHorizontalAlignment(JTextField.RIGHT);
00203 suiteRuns.setText("1");
00204
00205 gbc.gridwidth = GridBagConstraints.REMAINDER;
00206 gbc.anchor = GridBagConstraints.WEST;
00207 gbc.insets = new Insets(0,15,0,5);
00208
00209
00210 add(commandLabel,gbc);
00211 add(commandText,gbc);
00212 add(resultLabel,gbc);
00213 add(resultText,gbc);
00214
00215 gbc.insets = new Insets(0,40,5,0);
00216 add(commandTestB,gbc);
00217
00218 gbc.insets = new Insets(0,10,0,5);
00219 add(dataNumLabel,gbc);
00220
00221 gbc.insets = new Insets(0,50,0,5);
00222 add(readDataNum,gbc);
00223
00224 gbc.insets = new Insets(0,22,5,0);
00225 add(readDataB, gbc);
00226
00227 gbc.insets = new Insets(0,25,5,0);
00228 gbc.gridwidth = 1;
00229 add(suiteRunsL,gbc);
00230
00231 gbc.gridwidth = GridBagConstraints.REMAINDER;
00232 add(suiteRuns,gbc);
00233 gbc.insets = new Insets(0,0,0,0);
00234 add(testSuiteB,gbc);
00235 }
00236 }
00237
00242 class ResetDebugPanel extends JPanel{
00243
00245 JButton reset = new JButton("reset");
00246
00250 JButton resetAll = new JButton("reset All");
00251
00253 JCheckBox debugInfo;
00254
00256 JCheckBox showDebugInf;
00257
00263 public ResetDebugPanel(){
00264 GridBagLayout gbl = new GridBagLayout();
00265 GridBagConstraints gbc = new GridBagConstraints();
00266 setLayout(gbl);
00267 reset = new JButton("reset");
00268 resetAll = new JButton("reset All");
00269 debugInfo = new JCheckBox("Log debugging Info");
00270 showDebugInf = new JCheckBox("Show debugging Info");
00271 gbc.insets = new Insets(0,0,0,80);
00272 add(resetAll, gbc);
00273 gbc.insets = new Insets(0,0,0,50);
00274 add(debugInfo,gbc);
00275 gbc.insets = new Insets(0,0,0,75);
00276 add(showDebugInf,gbc);
00277 add(reset);
00278 }
00279
00280 }
00286 public void paint(Graphics graphics){
00287 Dimension pref = sspanel.getPreferredSize();
00288 Dimension size = sspanel.getSize();
00289 int extent = size.height, max = pref.height;
00290 int value = Math.max(0, Math.min(scroller.getValue(), max - extent));
00291 scroller.setVisible(extent < max);
00292 scroller.setUnitIncrement(sspanel.getUnitHeight());
00293 scroller.setBlockIncrement(extent - scroller.getUnitIncrement());
00294 scroller.setValues(value, extent, 0, max);
00295 super.paint(graphics);
00296 }
00309 public DaqPanel(JRootPane root){
00310 rootPane = root;
00311
00312
00313 GridBagLayout gbl= new GridBagLayout();
00314
00315
00316 GridBagConstraints gbc = new GridBagConstraints();
00317 setLayout(gbl);
00318 curDaqPanel = this;
00319
00320
00321 if(root == null){
00322 System.out.println("ERROR abnormar execution");
00323 System.exit(0);
00324 }
00325
00326 openPorts = new Hashtable();
00327
00328
00329 connectPanel = new ConnectionPanel();
00330
00331 gbc.anchor = GridBagConstraints.WEST;
00332 gbc.gridwidth = GridBagConstraints.REMAINDER;
00333
00334 gbc.fill = GridBagConstraints.HORIZONTAL;
00335 add(connectPanel, gbc);
00336
00337
00338 testPanel = new TestPanel();
00339
00340 gbc.fill = GridBagConstraints.NONE;
00341 gbc.gridwidth = 1;
00342
00343 gbc.insets = new Insets(0,15,0,0);
00344 add(testPanel, gbc);
00345
00346
00347 sspanel = new SSPanel();
00348 sspanel.setLayout(new BorderLayout());
00349
00350
00351 scroller = new JScrollBar(JScrollBar.VERTICAL);
00352 sspanel.add(scroller,BorderLayout.EAST);
00353 sspanel.setScroller(scroller);
00354
00355
00356 scroller.addAdjustmentListener(new AdjustmentListener(){
00357 public void adjustmentValueChanged(AdjustmentEvent event){
00358 JScrollBar scrollbar = (JScrollBar)event.getSource();
00359
00360
00361 sspanel.setTopIndexByPixelValue(scrollbar.getValue());
00362
00363 sspanel.repaint();
00364 }
00365 });
00366
00367 sspanel.addMouseWheelListener(new MouseWheelListener(){
00368 public void mouseWheelMoved(MouseWheelEvent event){
00369
00370 if(event.getWheelRotation() > 0){
00371
00372 scroller.setValue(sspanel.incrementTopIndex());
00373 scroller.setValue(sspanel.incrementTopIndex());
00374 }
00375 else{
00376
00377 scroller.setValue(sspanel.decrementTopIndex());
00378 scroller.setValue(sspanel.decrementTopIndex());
00379 }
00380 sspanel.repaint();
00381 }
00382 });
00383
00384 sspanel.setBackground(Color.white);
00385
00386
00387 gbc.anchor = GridBagConstraints.CENTER;
00388 gbc.gridwidth = GridBagConstraints.REMAINDER;
00389 gbc.fill = GridBagConstraints.BOTH;
00390 gbc.insets = new Insets(15,15,0,15);
00391 add(sspanel, gbc);
00392
00393
00394 rDPanel = new ResetDebugPanel();
00395
00396 gbc.anchor = GridBagConstraints.WEST;
00397 gbc.gridwidth = GridBagConstraints.REMAINDER;
00398 gbc.gridheight = GridBagConstraints.REMAINDER;
00399 gbc.fill = GridBagConstraints.BOTH;
00400 add(rDPanel,gbc);
00401
00402
00403 rDPanel.reset.addActionListener(new ActionListener(){
00404 public void actionPerformed(ActionEvent event){
00405 sspanel.reset();
00406 repaint();
00407 }
00408 });
00409
00410
00411 rDPanel.reset.addFocusListener(new FocusListener(){
00412 public void focusGained(FocusEvent event){
00413 rootPane.setDefaultButton(rDPanel.reset);
00414 }
00415
00416 public void focusLost(FocusEvent event){}
00417 });
00418
00419
00420
00421
00422
00423 rDPanel.resetAll.addActionListener(new ActionListener(){
00424 public void actionPerformed(ActionEvent event){
00425 connectPanel.commandPort.setText("55055");
00426 connectPanel.daqServer.setText("localhost");
00427 testPanel.commandText.setText("");
00428 testPanel.resultText.setText("");
00429 testPanel.suiteRuns.setText("1");
00430 testPanel.readDataNum.setText("1");
00431 sspanel.reset();
00432 repaint();
00433 }
00434 });
00435
00436
00437 rDPanel.resetAll.addFocusListener(new FocusListener(){
00438 public void focusGained(FocusEvent event){
00439 rootPane.setDefaultButton(rDPanel.resetAll);
00440 }
00441
00442 public void focusLost(FocusEvent event){}
00443 });
00444
00445
00446
00447
00448 rDPanel.debugInfo.addActionListener(new ActionListener(){
00449 public void actionPerformed(ActionEvent event){
00450 if(rDPanel.debugInfo.isSelected()){
00451 DaqDriverTest.debug = true;
00452 }
00453 else{
00454 DaqDriverTest.debug = false;
00455 }
00456 }
00457 });
00458
00459
00460
00461 rDPanel.showDebugInf.addActionListener(new ActionListener(){
00462 public void actionPerformed(ActionEvent event){
00463 if(rDPanel.showDebugInf.isSelected()){
00464 sspanel.showDebugging();
00465 }
00466 else{
00467 sspanel.hideDebugging();
00468 }
00469 sspanel.repaint();
00470 }
00471 });
00472
00473
00474 connectPanel.connection.setRolloverEnabled(true);
00475 connectPanel.disconnect.setRolloverEnabled(true);
00476 testPanel.commandTestB.setRolloverEnabled(true);
00477 testPanel.readDataB.setRolloverEnabled(true);
00478 testPanel.testSuiteB.setRolloverEnabled(true);
00479 testPanel.readDataB.setRolloverEnabled(true);
00480
00481
00482
00483 connectPanel.commandPort.addActionListener(new ActionListener(){
00484 public void actionPerformed(ActionEvent event){
00485 connectPanel.connection.doClick();
00486 }
00487 });
00488 connectPanel.daqServer.addActionListener(new ActionListener(){
00489 public void actionPerformed(ActionEvent event){
00490 connectPanel.connection.doClick();
00491 }
00492 });
00493
00494 testPanel.commandText.addActionListener(new ActionListener(){
00495 public void actionPerformed(ActionEvent event){
00496 testPanel.commandTestB.doClick();
00497 }
00498 });
00499
00500 testPanel.resultText.addActionListener(new ActionListener(){
00501 public void actionPerformed(ActionEvent event){
00502 testPanel.commandTestB.doClick();
00503 }
00504 });
00505
00506
00507
00508 connectPanel.connection.addActionListener(new ActionListener(){
00509 public void actionPerformed(ActionEvent event){
00510 if(isConnected){
00511 daqTests.disconnect();
00512 daqTests = null;
00513 }
00514 int commandPort = 0;
00515 try{
00516 commandPort = Integer.parseInt(connectPanel.commandPort.getText().trim());
00517 if (commandPort < 0){
00518 throw new NumberFormatException();
00519 }
00520 }
00521 catch(NumberFormatException exception){
00522 JOptionPane.showMessageDialog(null, "Invalid port number: "
00523 + connectPanel.commandPort.getText().trim() +
00524 "\nat 'Command Port'",
00525 "Invalid Number", JOptionPane.INFORMATION_MESSAGE);
00526 return;
00527 }
00528
00529 DaqTests.setPorts(commandPort);
00530
00531 daqTests = new DaqTests(connectPanel.daqServer.getText());
00532
00533 updateConnectionStatus();
00534 }
00535 });
00536
00537
00538 connectPanel.connection.addChangeListener(new ChangeListener(){
00539 public void stateChanged(ChangeEvent event){
00540 ButtonModel model = connectPanel.connection.getModel();
00541 if(model.isRollover()){
00542 rootPane.setDefaultButton(connectPanel.connection);
00543 }
00544 }
00545 });
00546
00547
00548 connectPanel.connection.addFocusListener(new FocusListener(){
00549 public void focusGained(FocusEvent event){
00550 rootPane.setDefaultButton(connectPanel.connection);
00551 }
00552
00553 public void focusLost(FocusEvent event){}
00554 });
00555
00556
00557
00558 connectPanel.disconnect.addActionListener(new ActionListener(){
00559 public void actionPerformed(ActionEvent event){
00560 if(daqTests != null){
00561 daqTests.disconnect();
00562 daqTests = null;
00563 }
00564 updateConnectionStatus();
00565 }
00566 });
00567
00568
00569 connectPanel.disconnect.addChangeListener(new ChangeListener(){
00570 public void stateChanged(ChangeEvent event){
00571 ButtonModel model = connectPanel.disconnect.getModel();
00572 if(model.isRollover()){
00573 rootPane.setDefaultButton(connectPanel.disconnect);
00574 }
00575 }
00576 });
00577
00578
00579 connectPanel.disconnect.addFocusListener(new FocusListener(){
00580 public void focusGained(FocusEvent event){
00581 rootPane.setDefaultButton(connectPanel.disconnect);
00582 }
00583 public void focusLost(FocusEvent event){}
00584 });
00585
00586
00587 testPanel.readDataB.addActionListener(new ActionListener(){
00588 public void actionPerformed(ActionEvent event){
00589 if(!isConnected){
00590 JOptionPane.showMessageDialog(null, "must stablish connection",
00591 "Error", JOptionPane.ERROR_MESSAGE);
00592 return;
00593 }
00594 if(openPorts.size() == 0){
00595 JOptionPane.showMessageDialog(null, "A port must be open",
00596 "Error", JOptionPane.ERROR_MESSAGE);
00597 return;
00598 }
00599 String str = testPanel.readDataNum.getText();
00600 int runs = 0;
00601
00602 try{
00603 runs = Integer.parseInt(str.trim());
00604 if (runs < 0){
00605 throw new NumberFormatException();
00606 }
00607 }
00608 catch(NumberFormatException e1){
00609 JOptionPane.showMessageDialog(null, "Invalid run number: "
00610 + str.trim() +
00611 "\nat 'Times to read Data'",
00612 "Invalid Number",
00613 JOptionPane.ERROR_MESSAGE);
00614 return;
00615 }
00616
00617
00618
00619
00620
00621 final int runsb = runs;
00622
00623 final JDialog dialog = new JDialog(new JFrame(), "Reading Data", true);
00624 final StopThread test = new StopThread(){
00625 public void run(){
00626 StringTokenizer dataTokens = null;
00627 String str2 = "";
00628 try{
00629 for(int j = 0;j < runsb ; j++){
00630
00631 if(((StopThread)Thread.currentThread()).isStopped()){
00632 return;
00633 }
00634 str2 = daqTests.readingData();
00635 dataTokens = new StringTokenizer(str2);
00636 while(dataTokens.hasMoreElements()){
00637
00638 if(((StopThread)Thread.currentThread()).isStopped()){
00639 return;
00640 }
00641 str2 = "";
00642 while(true){
00643
00644 if(((StopThread)Thread.currentThread()).isStopped()){
00645 return;
00646 }
00647 if(!dataTokens.hasMoreElements()){
00648 break;
00649 }
00650 str2 = str2 + dataTokens.nextToken() + " ";
00651 if(str2.length() >= 60){
00652 break;
00653 }
00654 }
00655 if(str2 != ""){
00656 sspanel.logString(str2);
00657 }
00658 }
00659
00660
00661 repaint();
00662 }
00663 }catch(TestSuiteException exception){
00664 dialog.dispose();
00665 exception.run();
00666 updateConnectionStatus();
00667 return;
00668 }
00669 updateConnectionStatus();
00670 dialog.dispose();
00671 }
00672 };
00673
00674 Container dialogContentPane = dialog.getContentPane();
00675 JButton cancel = new JButton("Stop Reading Data");
00676 dialogContentPane.setLayout(new FlowLayout());
00677 dialogContentPane.add(cancel);
00678 test.start();
00679 dialog.pack();
00680 dialog.setLocationRelativeTo(curDaqPanel);
00681 cancel.addActionListener(new ActionListener(){
00682 public void actionPerformed(ActionEvent event){
00683 test.stopThread();
00684 test.interrupt();
00685 try{
00686 Thread.sleep(500);
00687 }
00688 catch(InterruptedException e){
00689 Thread.currentThread().yield();
00690 }
00691 if(test.isAlive()){
00692 daqTests.disconnect();
00693 updateConnectionStatus();
00694 }
00695 dialog.dispose();
00696 }
00697 });
00698 dialog.show();
00699
00700 }
00701 });
00702
00703
00704
00705 testPanel.readDataB.addChangeListener(new ChangeListener(){
00706 public void stateChanged(ChangeEvent event){
00707 ButtonModel model = testPanel.readDataB.getModel();
00708 if(model.isRollover()){
00709 rootPane.setDefaultButton(testPanel.readDataB);
00710 }
00711 }
00712 });
00713
00714
00715 testPanel.readDataB.addFocusListener(new FocusListener(){
00716 public void focusGained(FocusEvent event){
00717 rootPane.setDefaultButton(testPanel.readDataB);
00718 }
00719 public void focusLost(FocusEvent event){}
00720 });
00721
00722
00723
00724
00725
00726 testPanel.commandTestB.addActionListener(new ActionListener(){
00727 public void actionPerformed(ActionEvent event){
00728 String strCommand = testPanel.commandText.getText().trim();
00729 String strResult = testPanel.resultText.getText().trim();
00730 String data[] = null;
00731 if(strCommand != "" && strCommand.startsWith("open-port")){
00732
00733 String key = strCommand.replaceAll(" ", "");
00734 if(!openPorts.contains(key)){
00735 openPorts.put(key,key);
00736 }
00737 }
00738 if(strCommand != "" && strCommand.startsWith("close-port")){
00739 String key = strCommand.replaceAll(" ", "").replaceAll("close", "open");
00740 if(openPorts.contains(key)){
00741 openPorts.remove(key);
00742 }
00743 }
00744
00745 if(!isConnected){
00746 JOptionPane.showMessageDialog(null, "must stablish connection",
00747 "Error", JOptionPane.ERROR_MESSAGE);
00748 return;
00749 }
00750
00751 else if(strCommand.length() == 0){
00752 JOptionPane.showMessageDialog(null, "Command cannot be 'null' or blank string",
00753 "Error", JOptionPane.ERROR_MESSAGE);
00754 return;
00755 }
00756 else if(strResult.length() > 0){
00757 TestResult result = null;
00758 try{
00759 result = daqTests.testCommand(strCommand + "\n", strResult);
00760 }
00761 catch(TestSuiteException e1){
00762 e1.run();
00763
00764 updateConnectionStatus();
00765 result = new TestResult();
00766 result.pass = false;
00767 result.different = "";
00768 updateConnectionStatus();
00769 }
00770 if(result.pass){
00771 data = new String[1];
00772 data[0] = "Command being tested: " + strCommand + " PASS";
00773 }
00774 else{
00775 String str = "Expected result: " + strResult +
00776 " DAQ return: " + result.different;
00777 data = new String[str.length() / SSPanel.MAXLINE + 2];
00778 data[0] = "Command being tested: " + strCommand + " FAIL";
00779 for(int i = 0; i < data.length - 1; i++){
00780 if(i == 0){
00781 data[i + 1] = str.substring(i * SSPanel.MAXLINE,
00782 Math.min(SSPanel.MAXLINE*(i + 1),str.length()));
00783 }
00784 else{
00785 data[i + 1] = " " +
00786 str.substring(i * SSPanel.MAXLINE, Math.min(SSPanel.MAXLINE*(i + 1),str.length()));
00787 }
00788 }
00789 }
00790
00791 }
00792
00793
00794 else{
00795 String str = "";
00796 try{
00797 str = daqTests.testCommand(strCommand + "\n");
00798 }
00799 catch(TestSuiteException e2){
00800 e2.run();
00801 updateConnectionStatus();
00802 }
00803 data = new String[str.length() / SSPanel.MAXLINE + 2];
00804 for(int i = 0; i < data.length - 1; i++){
00805 if(i == 0){
00806 data[i + 1] = str.substring(i * SSPanel.MAXLINE,
00807 Math.min(SSPanel.MAXLINE*(i + 1),str.length()));
00808 }
00809 else{
00810 data[i + 1] = " " +
00811 str.substring(i * SSPanel.MAXLINE, Math.min(SSPanel.MAXLINE*(i + 1),str.length()));
00812 }
00813 }
00814 data[1] = "Result: " + data[1];
00815 data[data.length - 1] = data[data.length - 1];
00816 data[0] = "Command being tested: " + strCommand;
00817 }
00818 sspanel.logCommand(data);
00819 sspanel.repaint();
00820 }
00821 });
00822
00823
00824 testPanel.commandTestB.addChangeListener(new ChangeListener(){
00825 public void stateChanged(ChangeEvent event){
00826 ButtonModel model = testPanel.commandTestB.getModel();
00827 if(model.isRollover()){
00828 rootPane.setDefaultButton(testPanel.commandTestB);
00829 }
00830 }
00831 });
00832
00833
00834 testPanel.commandTestB.addFocusListener(new FocusListener(){
00835 public void focusGained(FocusEvent event){
00836 rootPane.setDefaultButton(testPanel.commandTestB);
00837 }
00838 public void focusLost(FocusEvent event){}
00839 });
00840
00841
00842
00843 testPanel.testSuiteB.addActionListener(new ActionListener(){
00844 public void actionPerformed(ActionEvent event){
00845
00846 openPorts = new Hashtable();
00847
00848 if(!isConnected){
00849 JOptionPane.showMessageDialog(null, "must stablish connection",
00850 "Error", JOptionPane.ERROR_MESSAGE);
00851 return;
00852 }
00853 sspanel.reset();
00854 repaint();
00855
00856 String str = testPanel.suiteRuns.getText();
00857 int runs = 0;
00858
00859 try{
00860 runs = Integer.parseInt(str.trim());
00861 if (runs < 0){
00862 throw new NumberFormatException();
00863 }
00864 }
00865 catch(NumberFormatException exception){
00866 JOptionPane.showMessageDialog(null, "Invalid run number: "
00867 + str.trim() +
00868 "\nat 'Test Runs'",
00869 "Invalid Number",
00870 JOptionPane.ERROR_MESSAGE);
00871 return;
00872 }
00873
00874
00875 final int runsb = runs;
00876
00877 final JDialog dialog = new JDialog(new JFrame(), "Testing Progress", true);
00878 final JProgressBar progressBar = new JProgressBar();
00879 progressBar.setStringPainted(true);
00880
00881 final StopThread test = new StopThread(){
00882 public void run(){
00883 int counter = 0;
00884 try{
00885 for(int j = 0;j < runsb ; j++){
00886 if(((StopThread)Thread.currentThread()).isStopped()){
00887 daqTests.flushBuffers(curDaqPanel, sspanel, true);
00888 return;
00889 }
00890 if(!daqTests.testSuite(curDaqPanel, sspanel, progressBar, runsb)){
00891 counter++;
00892 }
00893 }
00894 if(((StopThread)Thread.currentThread()).isStopped()){
00895 daqTests.flushBuffers(curDaqPanel, sspanel, true);
00896 return;
00897 }
00898 if(runsb > 1){
00899 if(counter > 0){
00900 sspanel.logString("Out of " + runsb + " Runs " +
00901 counter + " FAIL");
00902 }
00903 else{
00904 sspanel.logString("All " + runsb + "Runs PASS");
00905 }
00906 }
00907 }catch(TestSuiteException exception){
00908 dialog.dispose();
00909 exception.run();
00910 updateConnectionStatus();
00911 return;
00912 }
00913 updateConnectionStatus();
00914 dialog.dispose();
00915 }
00916 };
00917
00918 Container dialogContentPane = dialog.getContentPane();
00919 JButton cancel = new JButton("Stop testing");
00920 dialogContentPane.setLayout(new FlowLayout());
00921 dialogContentPane.add(progressBar);
00922 dialogContentPane.add(cancel);
00923 test.start();
00924 dialog.pack();
00925 dialog.setLocationRelativeTo(curDaqPanel);
00926 cancel.addActionListener(new ActionListener(){
00927 public void actionPerformed(ActionEvent event){
00928 test.stopThread();
00929 try{
00930 Thread.sleep(5000);
00931 }
00932 catch(InterruptedException e){
00933 Thread.currentThread().yield();
00934 }
00935 if(test.isAlive()){
00936 daqTests.disconnect();
00937 updateConnectionStatus();
00938 }
00939 dialog.dispose();
00940 }
00941 });
00942 dialog.show();
00943 }
00944 });
00945
00946 testPanel.testSuiteB.addChangeListener(new ChangeListener(){
00947 public void stateChanged(ChangeEvent event){
00948 ButtonModel model = testPanel.testSuiteB.getModel();
00949 if(model.isRollover()){
00950 rootPane.setDefaultButton(testPanel.testSuiteB);
00951 }
00952 }
00953 });
00954
00955
00956 testPanel.testSuiteB.addFocusListener(new FocusListener(){
00957 public void focusGained(FocusEvent event){
00958 rootPane.setDefaultButton(testPanel.testSuiteB);
00959 }
00960 public void focusLost(FocusEvent event){}
00961 });
00962
00963
00964
00965 rootPane.setDefaultButton(connectPanel.connection);
00966
00967 }
00968
00976 public void updateConnectionStatus(){
00977 if(daqTests != null
00978 && daqTests.validConnect){
00979 connectPanel.connectStat.setText("Connected");
00980 connectPanel.connectStat.setForeground(Color.green);
00981 isConnected = true;
00982 }
00983 else{
00984 connectPanel.connectStat.setText("offline ");
00985 connectPanel.connectStat.setForeground(Color.red);
00986 isConnected = false;
00987 openPorts = new Hashtable();
00988 }
00989 }
00990 }