001package jmri.jmrix.ieee802154.xbee.swing.packetgen;
002
003import com.digi.xbee.api.packet.GenericXBeePacket;
004import com.digi.xbee.api.packet.XBeeAPIPacket;
005import jmri.jmrix.ieee802154.xbee.XBeeMessage;
006import jmri.jmrix.ieee802154.xbee.XBeeTrafficController;
007
008/**
009 * Frame for user input of Xbee ieee802154 messages
010 *
011 * @author Bob Jacobsen Copyright (C) 2001,2002
012 */
013public class PacketGenFrame extends jmri.jmrix.swing.AbstractPacketGenFrame {
014
015    final java.util.ResourceBundle rb = java.util.ResourceBundle.getBundle("jmri.jmrix.ieee802154.IEEE802154ActionListBundle");
016
017    /**
018     * {@inheritDoc}
019     */
020    @Override
021    public void initComponents() {
022        super.initComponents();
023
024        // all we need to do is set the title
025        setTitle(rb.getString("jmri.jmrix.ieee802154.xbee.swing.packetgen.PacketGenAction"));
026
027        // pack to cause display
028        pack();
029    }
030
031    /**
032     * {@inheritDoc}
033     */
034    @Override
035    public void sendButtonActionPerformed(java.awt.event.ActionEvent e) {
036        String packetString = packetTextField.getSelectedItem().toString();
037        byte[] packetByteArray = jmri.util.StringUtil.bytesFromHexString(packetString);
038        XBeeAPIPacket packet = GenericXBeePacket.createPacket(packetByteArray);
039        tc.sendXBeeMessage(new XBeeMessage(packet),null);
040    }
041
042    // connect to the TrafficController
043    public void connect(XBeeTrafficController t) {
044        tc = t;
045    }
046
047    // private data
048    private XBeeTrafficController tc = null;
049
050}