Search in sources :

Example 1 with ClientActions

use of jmri.jmrix.openlcb.swing.ClientActions in project JMRI by JMRI.

the class OpenLcbCanSendPane method initComponents.

@Override
public void initComponents(CanSystemConnectionMemo memo) {
    super.initComponents(memo);
    iface = memo.get(OlcbInterface.class);
    actions = new ClientActions(iface);
    tc = memo.getTrafficController();
    tc.addCanListener(this);
    connection = memo.get(org.openlcb.Connection.class);
    srcNodeID = memo.get(org.openlcb.NodeID.class);
    aliasMap = memo.get(org.openlcb.can.AliasMap.class);
    // register request for notification
    Connection.ConnectionListener cl = new Connection.ConnectionListener() {

        @Override
        public void connectionActive(Connection c) {
            log.debug("connection active");
            // load the alias field
            srcAliasField.setText(Integer.toHexString(aliasMap.getAlias(srcNodeID)));
        }
    };
    connection.registerStartNotification(cl);
    mcs = memo.get(MemoryConfigurationService.class);
    store = memo.get(MimicNodeStore.class);
    nodeSelector = new NodeSelector(store);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // handle single-packet part
    {
        JPanel pane1 = new JPanel();
        pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
        jLabel1.setText("Single Frame:  (Raw input format is [123] 12 34 56) ");
        jLabel1.setVisible(true);
        sendButton.setText("Send");
        sendButton.setVisible(true);
        sendButton.setToolTipText("Send frame");
        packetTextField.setToolTipText("Frame as hex pairs, e.g. 82 7D; standard header in (), extended in []");
        pane1.add(jLabel1);
        pane1.add(packetTextField);
        pane1.add(sendButton);
        pane1.add(Box.createVerticalGlue());
        sendButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                sendButtonActionPerformed(e);
            }
        });
        add(pane1);
    }
    add(new JSeparator());
    // Configure the sequence
    add(new JLabel("Send sequence of frames:"));
    JPanel pane2 = new JPanel();
    pane2.setLayout(new GridLayout2(MAXSEQUENCE + 2, 4));
    pane2.add(new JLabel(""));
    pane2.add(new JLabel("Send"));
    pane2.add(new JLabel("packet"));
    pane2.add(new JLabel("wait (msec)"));
    for (int i = 0; i < MAXSEQUENCE; i++) {
        pane2.add(new JLabel(Integer.toString(i + 1)));
        mUseField[i] = new JCheckBox();
        mPacketField[i] = new JTextField(10);
        mDelayField[i] = new JTextField(10);
        pane2.add(mUseField[i]);
        pane2.add(mPacketField[i]);
        pane2.add(mDelayField[i]);
    }
    // starts a new row in layout
    pane2.add(mRunButton);
    add(pane2);
    mRunButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            runButtonActionPerformed(e);
        }
    });
    // special packet forms
    add(new JSeparator());
    add(new JLabel("Send special frame:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    pane2.add(new JLabel("Src Node alias:"));
    pane2.add(srcAliasField);
    add(pane2);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    JButton b;
    b = new JButton("Send CIM");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendCimPerformed(e);
        }
    });
    pane2.add(b);
    // send OpenLCB messages
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB global message:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Verify Nodes Global");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendVerifyNodeGlobal(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Verify Node Global with NodeID");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendVerifyNodeGlobalID(e);
        }
    });
    pane2.add(b);
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB event message:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Request Consumers");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendReqConsumers(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Request Producers");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendReqProducers(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Event Produced");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendEventPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Event ID (8 bytes):"));
    pane2.add(sendEventField);
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB addressed message to:", nodeSelector));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Request Events");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendRequestEvents(e);
        }
    });
    pane2.add(b);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Datagram");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendDatagramPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Contents: "));
    pane2.add(datagramContentsField);
    b = new JButton("Send Datagram Reply");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendDatagramReply(e);
        }
    });
    pane2.add(b);
    // send OpenLCB Configuration message
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB Configuration Command:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    pane2.add(new JLabel("Memory Address: "));
    pane2.add(configAddressField);
    pane2.add(new JLabel("Address Space: "));
    pane2.add(addrSpace);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    pane2.add(new JLabel("Byte Count: "));
    pane2.add(configNumberField);
    b = new JButton("Read");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            readPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Data: "));
    pane2.add(readDataField);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Write");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            writePerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Data: "));
    // NOI18N
    writeDataField.setText("00 00");
    pane2.add(writeDataField);
    b = new JButton("Open CDI Config Tool");
    add(b);
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            openCdiPane();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) AliasMap(org.openlcb.can.AliasMap) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) NodeID(org.openlcb.NodeID) MimicNodeStore(org.openlcb.MimicNodeStore) GridLayout2(jmri.util.javaworld.GridLayout2) Connection(org.openlcb.Connection) JLabel(javax.swing.JLabel) OlcbInterface(org.openlcb.OlcbInterface) JCheckBox(javax.swing.JCheckBox) MemoryConfigurationService(org.openlcb.implementations.MemoryConfigurationService) NodeSelector(org.openlcb.swing.NodeSelector) ClientActions(jmri.jmrix.openlcb.swing.ClientActions)

Aggregations

FlowLayout (java.awt.FlowLayout)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JSeparator (javax.swing.JSeparator)1 JTextField (javax.swing.JTextField)1 ClientActions (jmri.jmrix.openlcb.swing.ClientActions)1 GridLayout2 (jmri.util.javaworld.GridLayout2)1 Connection (org.openlcb.Connection)1 MimicNodeStore (org.openlcb.MimicNodeStore)1 NodeID (org.openlcb.NodeID)1 OlcbInterface (org.openlcb.OlcbInterface)1 AliasMap (org.openlcb.can.AliasMap)1 MemoryConfigurationService (org.openlcb.implementations.MemoryConfigurationService)1 NodeSelector (org.openlcb.swing.NodeSelector)1