001package jmri.jmrix.maple.nodeconfig;
002
003import java.awt.Container;
004import java.awt.FlowLayout;
005import javax.swing.BorderFactory;
006import javax.swing.BoxLayout;
007import javax.swing.JButton;
008import javax.swing.JLabel;
009import javax.swing.JOptionPane;
010import javax.swing.JPanel;
011import javax.swing.JSpinner;
012import javax.swing.JTextField;
013import javax.swing.SpinnerNumberModel;
014import javax.swing.border.Border;
015import jmri.jmrix.maple.InputBits;
016import jmri.jmrix.maple.MapleSystemConnectionMemo;
017import jmri.jmrix.maple.OutputBits;
018import jmri.jmrix.maple.SerialNode;
019
020/**
021 * Frame for user configuration of Maple panel nodes.
022 * <p>
023 * Note: Currently anything to do with pulse width for pulsing a turnout is
024 * commented out. This code from the C/MRI version was not deleted in case it is
025 * needed in the future.
026 *
027 * @author Bob Jacobsen Copyright (C) 2004, 2008
028 * @author Dave Duchamp Copyright (C) 2004, 2009
029 */
030public class NodeConfigFrame extends jmri.util.JmriJFrame {
031
032    protected JSpinner nodeAddrSpinner;
033    protected JLabel nodeAddrStatic = new JLabel("000");
034    protected JTextField pollTimeoutField = new JTextField(3);
035    protected JTextField sendDelayField = new JTextField(3);
036//    protected JTextField pulseWidthField = new JTextField(4);
037    protected JTextField numInputField = new JTextField(4);
038    protected JTextField numOutputField = new JTextField(4);
039
040    protected JButton addButton = new JButton(Bundle.getMessage("ButtonAdd"));
041    protected JButton editButton = new JButton(Bundle.getMessage("ButtonEdit"));
042    protected JButton deleteButton = new JButton(Bundle.getMessage("ButtonDelete"));
043    protected JButton doneButton = new JButton(Bundle.getMessage("ButtonDone"));
044    protected JButton updateButton = new JButton(Bundle.getMessage("ButtonUpdate"));
045    protected JButton cancelButton = new JButton(Bundle.getMessage("ButtonCancel"));
046
047    protected JLabel statusText1 = new JLabel();
048    protected JLabel statusText2 = new JLabel();
049    protected JLabel statusText3 = new JLabel();
050
051    protected JPanel panel2 = new JPanel();
052    protected JPanel panel2a = new JPanel();
053
054    protected boolean changedNode = false;  // true if a node was changed, deleted, or added
055    protected boolean editMode = false;     // true if in edit mode
056
057    protected SerialNode curNode = null;    // Serial Node being editted
058    protected int nodeAddress = 0;          // Node address
059    protected int pollTimeoutTime = 2000;   // reply timeout time
060    protected int sendDelay = 200;   // delay time after send commands
061    // protected int pulseWidth = 500;   // pulse width for turnout control (milliseconds)
062    protected int inputBits = 40;   // maximum number of input bits - all nodes
063    protected int outputBits = 40;   // maximum number of output bits - all nodes
064
065    protected boolean errorInStatus1 = false;
066    protected boolean errorInStatus2 = false;
067    protected String stdStatus1 = Bundle.getMessage("NotesStd1");
068    protected String stdStatus2 = Bundle.getMessage("NotesStd2");
069    protected String stdStatus3 = Bundle.getMessage("NotesStd3");
070    protected String editStatus1 = Bundle.getMessage("NotesEdit1");
071    protected String editStatus2 = Bundle.getMessage("NotesEdit2");
072    protected String editStatus3 = Bundle.getMessage("NotesEdit3");
073
074    private MapleSystemConnectionMemo _memo = null;
075
076    /**
077     * Constructor method.
078     * @param memo system connection.
079     */
080    public NodeConfigFrame(MapleSystemConnectionMemo memo) {
081        super();
082        _memo = memo;
083
084        addHelpMenu("package.jmri.jmrix.maple.nodeconfig.NodeConfigFrame", true);
085    }
086
087    /**
088     * Initialize the config window
089     */
090    @Override
091    public void initComponents() {
092        setTitle(Bundle.getMessage("WindowTitle"));
093        inputBits = InputBits.getNumInputBits();
094        pollTimeoutTime = InputBits.getTimeoutTime();
095        outputBits = OutputBits.getNumOutputBits();
096        sendDelay = OutputBits.getSendDelay();
097
098        Container contentPane = getContentPane();
099        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
100
101        // Set up node address
102        JPanel panel1 = new JPanel();
103        panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
104        JPanel panel11 = new JPanel();
105        panel11.setLayout(new FlowLayout());
106        panel11.add(new JLabel(Bundle.getMessage("LabelNodeAddress") + " "));
107        nodeAddrSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 99, 1));
108        panel11.add(nodeAddrSpinner);
109        nodeAddrSpinner.setToolTipText(Bundle.getMessage("TipNodeAddress"));
110        panel11.add(nodeAddrStatic);
111        nodeAddrStatic.setVisible(false);
112        JPanel panel12 = new JPanel();
113        panel12.setLayout(new FlowLayout());
114        panel12.add(new JLabel(Bundle.getMessage("LabelPollTimeout") + " "));
115        panel12.add(pollTimeoutField);
116        panel12.add(new JLabel(Bundle.getMessage("LabelMilliseconds")));
117        pollTimeoutField.setToolTipText(Bundle.getMessage("TipPollTimeout"));
118        pollTimeoutField.setText("" + pollTimeoutTime);
119        JPanel panel120 = new JPanel();
120        panel120.setLayout(new FlowLayout());
121        panel120.add(new JLabel(Bundle.getMessage("LabelSendDelay") + " "));
122        panel120.add(sendDelayField);
123        panel120.add(new JLabel(Bundle.getMessage("LabelMilliseconds")));
124        sendDelayField.setToolTipText(Bundle.getMessage("TipSendDelay"));
125        sendDelayField.setText("" + sendDelay);
126//        JPanel panel13 = new JPanel();
127//        panel13.setLayout(new FlowLayout());
128//        panel13.add(new JLabel(Bundle.getMessage("LabelPulseWidth")+" "));
129//        panel13.add(pulseWidthField);
130//        pulseWidthField.setToolTipText(Bundle.getMessage("TipPulseWidth"));
131//        pulseWidthField.setText("500");
132//        panel13.add(new JLabel(Bundle.getMessage("LabelMilliseconds")));
133        JPanel panel14 = new JPanel();
134        panel14.setLayout(new FlowLayout());
135        panel14.add(new JLabel(Bundle.getMessage("LabelNumInputBits") + " "));
136        panel14.add(numInputField);
137        numInputField.setToolTipText(Bundle.getMessage("TipInputBits"));
138        numInputField.setText("" + inputBits);
139        JPanel panel15 = new JPanel();
140        panel15.setLayout(new FlowLayout());
141        panel15.add(new JLabel(Bundle.getMessage("LabelNumOutputBits") + " "));
142        panel15.add(numOutputField);
143        numOutputField.setToolTipText(Bundle.getMessage("TipOutputBits"));
144        numOutputField.setText("" + outputBits);
145
146        panel1.add(panel11);
147        panel1.add(panel12);
148        panel1.add(panel120);
149//  panel1.add(panel13);
150        panel1.add(panel14);
151        panel1.add(panel15);
152        contentPane.add(panel1);
153
154        // Set up the notes panel
155        JPanel panel3 = new JPanel();
156        panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));
157        JPanel panel31 = new JPanel();
158        panel31.setLayout(new FlowLayout());
159        statusText1.setText(stdStatus1);
160        statusText1.setVisible(true);
161        panel31.add(statusText1);
162        JPanel panel32 = new JPanel();
163        panel32.setLayout(new FlowLayout());
164        statusText2.setText(stdStatus2);
165        statusText2.setVisible(true);
166        panel32.add(statusText2);
167        JPanel panel33 = new JPanel();
168        panel33.setLayout(new FlowLayout());
169        statusText3.setText(stdStatus3);
170        statusText3.setVisible(true);
171        panel33.add(statusText3);
172        panel3.add(panel31);
173        panel3.add(panel32);
174        panel3.add(panel33);
175        Border panel3Border = BorderFactory.createEtchedBorder();
176        Border panel3Titled = BorderFactory.createTitledBorder(panel3Border,
177                Bundle.getMessage("BoxLabelNotes"));
178        panel3.setBorder(panel3Titled);
179        contentPane.add(panel3);
180
181        // Set up buttons
182        JPanel panel4 = new JPanel();
183        panel4.setLayout(new FlowLayout());
184        addButton.setText(Bundle.getMessage("ButtonAdd"));
185        addButton.setVisible(true);
186        addButton.setToolTipText(Bundle.getMessage("TipAddButton"));
187        addButton.addActionListener(new java.awt.event.ActionListener() {
188            @Override
189            public void actionPerformed(java.awt.event.ActionEvent e) {
190                addButtonActionPerformed();
191            }
192        });
193        panel4.add(addButton);
194        editButton.setText(Bundle.getMessage("ButtonEdit"));
195        editButton.setVisible(true);
196        editButton.setToolTipText(Bundle.getMessage("TipEditButton"));
197        panel4.add(editButton);
198        editButton.addActionListener(new java.awt.event.ActionListener() {
199            @Override
200            public void actionPerformed(java.awt.event.ActionEvent e) {
201                editButtonActionPerformed();
202            }
203        });
204        panel4.add(deleteButton);
205        deleteButton.setText(Bundle.getMessage("ButtonDelete"));
206        deleteButton.setVisible(true);
207        deleteButton.setToolTipText(Bundle.getMessage("TipDeleteButton"));
208        panel4.add(deleteButton);
209        deleteButton.addActionListener(new java.awt.event.ActionListener() {
210            @Override
211            public void actionPerformed(java.awt.event.ActionEvent e) {
212                deleteButtonActionPerformed();
213            }
214        });
215        panel4.add(doneButton);
216        doneButton.setText(Bundle.getMessage("ButtonDone"));
217        doneButton.setVisible(true);
218        doneButton.setToolTipText(Bundle.getMessage("TipDoneButton"));
219        panel4.add(doneButton);
220        doneButton.addActionListener(new java.awt.event.ActionListener() {
221            @Override
222            public void actionPerformed(java.awt.event.ActionEvent e) {
223                doneButtonActionPerformed();
224            }
225        });
226        panel4.add(updateButton);
227        updateButton.setText(Bundle.getMessage("ButtonUpdate"));
228        updateButton.setVisible(true);
229        updateButton.setToolTipText(Bundle.getMessage("TipUpdateButton"));
230        panel4.add(updateButton);
231        updateButton.addActionListener(new java.awt.event.ActionListener() {
232            @Override
233            public void actionPerformed(java.awt.event.ActionEvent e) {
234                updateButtonActionPerformed();
235            }
236        });
237        updateButton.setVisible(false);
238        panel4.add(cancelButton);
239        cancelButton.setText(Bundle.getMessage("ButtonCancel"));
240        cancelButton.setVisible(true);
241        cancelButton.setToolTipText(Bundle.getMessage("TipCancelButton"));
242        panel4.add(cancelButton);
243        cancelButton.addActionListener(new java.awt.event.ActionListener() {
244            @Override
245            public void actionPerformed(java.awt.event.ActionEvent e) {
246                cancelButtonActionPerformed();
247            }
248        });
249        cancelButton.setVisible(false);
250        contentPane.add(panel4);
251
252        // pack for display
253        pack();
254    }
255
256    /**
257     * Handle Add button.
258     */
259    public void addButtonActionPerformed() {
260        // Check that a node with this address does not exist
261        int nodeAddress = readNodeAddress();
262        if (nodeAddress < 0) {
263            return;
264        }
265        // get a SerialNode corresponding to this node address if one exists
266        curNode = (SerialNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress);
267        if (curNode != null) {
268            statusText1.setText(Bundle.getMessage("Error1", Integer.toString(nodeAddress)));
269            statusText1.setVisible(true);
270            errorInStatus1 = true;
271            resetNotes2();
272            return;
273        }
274        // get node information from window
275        if (!readPollTimeout()) {
276            return;
277        }
278        if (!readSendDelay()) {
279            return;
280        }
281//  if ( !readPulseWidth() ) return;
282        if (!readNumInputBits()) {
283            return;
284        }
285        if (!readNumOutputBits()) {
286            return;
287        }
288        // all ready, create the new node
289        curNode = new SerialNode(nodeAddress, 0, _memo.getTrafficController() );
290        // configure the new node
291        setNodeParameters();
292//        // register any orphan sensors that this node may have
293//        _memo.getSensorManager().registerSensorsForNode(curNode);
294        // reset after succefully adding node
295        resetNotes();
296        changedNode = true;
297        // provide user feedback
298        statusText1.setText(Bundle.getMessage("FeedBackAdd") + " "
299                + Integer.toString(nodeAddress));
300        errorInStatus1 = true;
301    }
302
303    /**
304     * Handle Edit button.
305     */
306    public void editButtonActionPerformed() {
307        // Find Serial Node address
308        nodeAddress = readNodeAddress();
309        if (nodeAddress <= 0) {
310            return;
311        }
312        // get the SerialNode corresponding to this node address
313        curNode = (SerialNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress);
314        if (curNode == null) {
315            statusText1.setText(Bundle.getMessage("Error4"));
316            statusText1.setVisible(true);
317            errorInStatus1 = true;
318            resetNotes2();
319            return;
320        }
321        // Set up static node address
322        nodeAddrStatic.setText(Integer.toString(nodeAddress));
323        nodeAddrSpinner.setVisible(false);
324        nodeAddrStatic.setVisible(true);
325        // set up pulse width
326//        pulseWidth = curNode.getPulseWidth();
327//        pulseWidthField.setText(Integer.toString(pulseWidth));
328        // set up number of input and output bits
329        inputBits = InputBits.getNumInputBits();
330        numInputField.setText(Integer.toString(inputBits));
331        outputBits = OutputBits.getNumOutputBits();
332        numOutputField.setText(Integer.toString(outputBits));
333        // set up poll timeout and send delay
334        pollTimeoutTime = InputBits.getTimeoutTime();
335        pollTimeoutField.setText(Integer.toString(pollTimeoutTime));
336        sendDelay = OutputBits.getSendDelay();
337        sendDelayField.setText(Integer.toString(sendDelay));
338        // Switch buttons
339        editMode = true;
340        addButton.setVisible(false);
341        editButton.setVisible(false);
342        deleteButton.setVisible(false);
343        doneButton.setVisible(false);
344        updateButton.setVisible(true);
345        cancelButton.setVisible(true);
346        // Switch to edit notes
347        statusText1.setText(editStatus1);
348        statusText2.setText(editStatus2);
349        statusText3.setText(editStatus3);
350    }
351
352    /**
353     * Handle Delete button.
354     */
355    public void deleteButtonActionPerformed() {
356        // Find Serial Node address
357        int nodeAddress = readNodeAddress();
358        if (nodeAddress < 0) {
359            return;
360        }
361        // get the SerialNode corresponding to this node address
362        curNode = (SerialNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress);
363        if (curNode == null) {
364            statusText1.setText(Bundle.getMessage("Error4"));
365            statusText1.setVisible(true);
366            errorInStatus1 = true;
367            resetNotes2();
368            return;
369        }
370        // confirm deletion with the user
371        if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(
372                this, Bundle.getMessage("ConfirmDelete1") + " " + nodeAddress + "?",
373                Bundle.getMessage("ConfirmDeleteTitle"),
374                JOptionPane.OK_CANCEL_OPTION,
375                JOptionPane.WARNING_MESSAGE)) {
376            // delete this node
377            _memo.getTrafficController().deleteNode(nodeAddress);
378            // provide user feedback
379            resetNotes();
380            statusText1.setText(Bundle.getMessage("FeedBackDelete") + " "
381                    + Integer.toString(nodeAddress));
382            errorInStatus1 = true;
383            changedNode = true;
384        } else {
385            // reset as needed
386            resetNotes();
387        }
388    }
389
390    /**
391     * Handle Done button.
392     */
393    public void doneButtonActionPerformed() {
394        if (editMode) {
395            // Reset 
396            editMode = false;
397            curNode = null;
398            // Switch buttons
399            addButton.setVisible(true);
400            editButton.setVisible(true);
401            deleteButton.setVisible(true);
402            doneButton.setVisible(true);
403            updateButton.setVisible(false);
404            cancelButton.setVisible(false);
405            nodeAddrSpinner.setVisible(true);
406            nodeAddrStatic.setVisible(false);
407        }
408        if (changedNode) {
409            // Remind user to Save new configuration
410            JOptionPane.showMessageDialog(this,
411                    Bundle.getMessage("ReminderNode1") + "\n" + Bundle.getMessage("Reminder2"),
412                    Bundle.getMessage("ReminderTitle"),
413                    JOptionPane.INFORMATION_MESSAGE);
414        }
415        setVisible(false);
416        dispose();
417    }
418
419    /**
420     * Handle Update button.
421     */
422    public void updateButtonActionPerformed() {
423        // get node information from window
424        if (!readPollTimeout()) {
425            return;
426        }
427        if (!readSendDelay()) {
428            return;
429        }
430        //  if ( !readPulseWidth() ) return;
431        if (!readNumInputBits()) {
432            return;
433        }
434        if (!readNumOutputBits()) {
435            return;
436        }
437        // update node information
438        setNodeParameters();
439        changedNode = true;
440        // Reset Edit Mode
441        editMode = false;
442        curNode = null;
443        // Switch buttons
444        addButton.setVisible(true);
445        editButton.setVisible(true);
446        deleteButton.setVisible(true);
447        doneButton.setVisible(true);
448        updateButton.setVisible(false);
449        cancelButton.setVisible(false);
450        // make node address editable again 
451        nodeAddrSpinner.setVisible(true);
452        nodeAddrStatic.setVisible(false);
453        // refresh notes panel
454        statusText2.setText(stdStatus2);
455        statusText3.setText(stdStatus3);
456        // provide user feedback
457        statusText1.setText(Bundle.getMessage("FeedBackUpdate") + " "
458                + Integer.toString(nodeAddress));
459        errorInStatus1 = true;
460    }
461
462    /**
463     * Handle Cancel button.
464     */
465    public void cancelButtonActionPerformed() {
466        // Reset 
467        editMode = false;
468        curNode = null;
469        // Switch buttons
470        addButton.setVisible(true);
471        editButton.setVisible(true);
472        deleteButton.setVisible(true);
473        doneButton.setVisible(true);
474        updateButton.setVisible(false);
475        cancelButton.setVisible(false);
476        // make node address editable again 
477        nodeAddrSpinner.setVisible(true);
478        nodeAddrStatic.setVisible(false);
479        // refresh notes panel
480        statusText1.setText(stdStatus1);
481        statusText2.setText(stdStatus2);
482        statusText3.setText(stdStatus3);
483    }
484
485    /**
486     * Close the window when the close box is clicked.
487     */
488    @Override
489    public void windowClosing(java.awt.event.WindowEvent e) {
490        doneButtonActionPerformed();
491        super.windowClosing(e);
492    }
493
494    /**
495     * Set node parameters. The node must exist, and be in 'curNode'
496     * Also, the node type must be set and in 'nodeType'
497     */
498    void setNodeParameters() {
499        // following parameters are common for all node types
500        InputBits.setTimeoutTime(pollTimeoutTime);
501        OutputBits.setSendDelay(sendDelay);
502        InputBits.setNumInputBits(inputBits);
503        OutputBits.setNumOutputBits(outputBits);
504//        curNode.setPulseWidth(pulseWidth);
505    }
506
507    /**
508     * Reset the notes error text after error display.
509     */
510    private void resetNotes() {
511        if (errorInStatus1) {
512            if (editMode) {
513                statusText1.setText(editStatus1);
514            } else {
515                statusText1.setText(stdStatus1);
516            }
517            errorInStatus1 = false;
518        }
519        resetNotes2();
520    }
521
522    /**
523     * Reset the second line of Notes area.
524     */
525    private void resetNotes2() {
526        if (errorInStatus2) {
527            if (editMode) {
528                statusText1.setText(editStatus2);
529            } else {
530                statusText2.setText(stdStatus2);
531            }
532            errorInStatus2 = false;
533        }
534    }
535
536    /**
537     * Read node address and check for legal range.
538     * Range is protected by JSpinner, error dialogs removed.
539     *
540     * @return a node address in the range 1-99.
541     */
542    private int readNodeAddress() {
543        return (Integer) nodeAddrSpinner.getValue();
544    }
545
546    /**
547     * Read receive poll reply timeout time from window.
548     * If an error is detected, a suitable error message is placed
549     * in the Notes area.
550     *
551     * @return 'true' if successful, 'false' if an error was detected
552     */
553    protected boolean readPollTimeout() {
554        // get the timeout time
555        try {
556            pollTimeoutTime = Integer.parseInt(pollTimeoutField.getText());
557        } catch (Exception e) {
558            statusText1.setText(Bundle.getMessage("Error7"));
559            statusText1.setVisible(true);
560            pollTimeoutTime = 0;
561            errorInStatus1 = true;
562            resetNotes2();
563            return (false);
564        }
565        if (pollTimeoutTime <= 0) {
566            statusText1.setText(Bundle.getMessage("Error8"));
567            statusText1.setVisible(true);
568            pollTimeoutTime = 0;
569            errorInStatus1 = true;
570            resetNotes2();
571            return (false);
572        }
573        if (pollTimeoutTime > 10000) {
574            statusText1.setText(Bundle.getMessage("Error9"));
575            statusText1.setVisible(true);
576            pollTimeoutTime = 0;
577            errorInStatus1 = true;
578            resetNotes2();
579            return (false);
580        }
581        // successful
582        return true;
583    }
584
585    /**
586     * Read send delay time from window.
587     * If an error is detected, a suitable error message
588     * is placed in the Notes area.
589     *
590     * @return 'true' if successful, 'false' if an error was detected
591     */
592    protected boolean readSendDelay() {
593        // get the timeout time
594        try {
595            sendDelay = Integer.parseInt(sendDelayField.getText());
596        } catch (Exception e) {
597            statusText1.setText(Bundle.getMessage("Error19"));
598            statusText1.setVisible(true);
599            sendDelay = 0;
600            errorInStatus1 = true;
601            resetNotes2();
602            return (false);
603        }
604        if (sendDelay < 0) {
605            statusText1.setText(Bundle.getMessage("Error20"));
606            statusText1.setVisible(true);
607            sendDelay = 0;
608            errorInStatus1 = true;
609            resetNotes2();
610            return (false);
611        }
612        if (sendDelay > 65535) {
613            statusText1.setText(Bundle.getMessage("Error21"));
614            statusText1.setVisible(true);
615            sendDelay = 0;
616            errorInStatus1 = true;
617            resetNotes2();
618            return (false);
619        }
620        // successful
621        return true;
622    }
623
624    /**
625     * Read number of input bits from window.
626     * If an error is detected, a suitable error message is
627     * placed in the Notes area.
628     *
629     * @return 'true' if successful, 'false' if an error was detected
630     */
631    protected boolean readNumInputBits() {
632        // get the input bits
633        try {
634            inputBits = Integer.parseInt(numInputField.getText());
635        } catch (Exception e) {
636            statusText1.setText(Bundle.getMessage("Error10"));
637            statusText1.setVisible(true);
638            inputBits = 0;
639            errorInStatus1 = true;
640            resetNotes2();
641            return (false);
642        }
643        if (inputBits <= 0) {
644            statusText1.setText(Bundle.getMessage("Error11"));
645            statusText1.setVisible(true);
646            inputBits = 0;
647            errorInStatus1 = true;
648            resetNotes2();
649            return (false);
650        }
651        if (inputBits > 1000) {
652            statusText1.setText(Bundle.getMessage("Error12"));
653            statusText1.setVisible(true);
654            inputBits = 0;
655            errorInStatus1 = true;
656            resetNotes2();
657            return (false);
658        }
659        // successful
660        return true;
661    }
662
663    /**
664     * Read number of output bits from window.
665     * If an error is detected, a suitable error message is placed
666     * in the Notes area.
667     *
668     * @return 'true' if successful, 'false' if an error was detected
669     */
670    protected boolean readNumOutputBits() {
671        // get the output bits
672        try {
673            outputBits = Integer.parseInt(numOutputField.getText());
674        } catch (Exception e) {
675            statusText1.setText(Bundle.getMessage("Error13"));
676            statusText1.setVisible(true);
677            outputBits = 0;
678            errorInStatus1 = true;
679            resetNotes2();
680            return (false);
681        }
682        if (outputBits <= 0) {
683            statusText1.setText(Bundle.getMessage("Error14"));
684            statusText1.setVisible(true);
685            outputBits = 0;
686            errorInStatus1 = true;
687            resetNotes2();
688            return (false);
689        }
690        if (outputBits > 8000) {
691            statusText1.setText(Bundle.getMessage("Error15"));
692            statusText1.setVisible(true);
693            outputBits = 0;
694            errorInStatus1 = true;
695            resetNotes2();
696            return (false);
697        }
698        // successful
699        return true;
700    }
701
702//    /**
703//     * Read pulse width from window.
704//     * If an error is detected, a suitable error message is placed in the
705//     * Notes area.
706//     *
707//     * @return 'true' if successful, 'false' if an error was detected
708//     */
709//    protected boolean readPulseWidth() {
710//        // get the pulse width
711//        try 
712//        {
713//            pulseWidth = Integer.parseInt(pulseWidthField.getText());
714//        }
715//        catch (Exception e)
716//        {
717//            statusText1.setText(Bundle.getMessage("Error18"));
718//            statusText1.setVisible(true);
719//            pulseWidth = 500;
720//            errorInStatus1 = true;
721//            resetNotes2();
722//            return (false);
723//        }
724//        if (pulseWidth < 100) {
725//            statusText1.setText(Bundle.getMessage("Error16"));
726//            statusText1.setVisible(true);
727//            pulseWidth = 100;
728//   pulseWidthField.setText(Integer.toString(pulseWidth));
729//            errorInStatus1 = true;
730//            resetNotes2();
731//            return (false);
732//        }
733//        if (pulseWidth > 10000) {
734//            statusText1.setText(Bundle.getMessage("Error17"));
735//            statusText1.setVisible(true);
736//            pulseWidth = 500;
737//            pulseWidthField.setText(Integer.toString(pulseWidth));
738//            errorInStatus1 = true;
739//            resetNotes2();
740//            return (false);
741//        }
742//        // successful
743//        return true;
744//    }
745
746    // private final static Logger log = LoggerFactory.getLogger(NodeConfigFrame.class);
747
748}