Search in sources :

Example 11 with XBeeConnectionMemo

use of jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo in project JMRI by JMRI.

the class NodeConfigActionTest method testDefaultCtor.

@Test
public void testDefaultCtor() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    XBeeConnectionMemo memo = new XBeeConnectionMemo();
    XBeeTrafficController tc = new XBeeTrafficController() {

        @Override
        public void setInstance() {
        }

        @Override
        protected jmri.jmrix.AbstractMRReply newReply() {
            return null;
        }

        @Override
        public jmri.jmrix.ieee802154.IEEE802154Node newNode() {
            return null;
        }
    };
    InstanceManager.setDefault(XBeeConnectionMemo.class, memo);
    NodeConfigAction action = new NodeConfigAction();
    Assert.assertNotNull("exists", action);
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) Test(org.junit.Test)

Example 12 with XBeeConnectionMemo

use of jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo in project JMRI by JMRI.

the class NodeConfigActionTest method testMemoCtor.

@Test
public void testMemoCtor() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    NodeConfigAction action = new NodeConfigAction(new XBeeConnectionMemo());
    Assert.assertNotNull("exists", action);
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) Test(org.junit.Test)

Example 13 with XBeeConnectionMemo

use of jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo in project JMRI by JMRI.

the class NodeConfigActionTest method testStringCtor.

@Test
public void testStringCtor() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    XBeeConnectionMemo memo = new XBeeConnectionMemo();
    XBeeTrafficController tc = new XBeeTrafficController() {

        @Override
        public void setInstance() {
        }

        @Override
        protected jmri.jmrix.AbstractMRReply newReply() {
            return null;
        }

        @Override
        public jmri.jmrix.ieee802154.IEEE802154Node newNode() {
            return null;
        }
    };
    InstanceManager.setDefault(XBeeConnectionMemo.class, memo);
    NodeConfigAction action = new NodeConfigAction("IEEE 802.15.4 test Action");
    Assert.assertNotNull("exists", action);
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) Test(org.junit.Test)

Example 14 with XBeeConnectionMemo

use of jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo in project JMRI by JMRI.

the class PacketGenActionTest method testCTor.

@Test
public void testCTor() {
    XBeeTrafficController tc = new XBeeInterfaceScaffold();
    XBeeConnectionMemo m = new XBeeConnectionMemo();
    InstanceManager.store(m, XBeeConnectionMemo.class);
    PacketGenAction t = new PacketGenAction();
    Assert.assertNotNull("exists", t);
}
Also used : XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeInterfaceScaffold(jmri.jmrix.ieee802154.xbee.XBeeInterfaceScaffold) Test(org.junit.Test)

Example 15 with XBeeConnectionMemo

use of jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo in project JMRI by JMRI.

the class ConnectionConfigXml method unpackElement.

@Override
protected void unpackElement(Element shared, Element perNode) {
    List<Element> l = shared.getChildren("node");
    // Trigger initialization of this Node to reflect these parameters
    XBeeConnectionMemo xcm = (XBeeConnectionMemo) adapter.getSystemConnectionMemo();
    XBeeTrafficController xtc = (XBeeTrafficController) xcm.getTrafficController();
    for (int i = 0; i < l.size(); i++) {
        Element n = l.get(i);
        byte[] GUID = jmri.util.StringUtil.bytesFromHexString(findParmValue(n, "GUID"));
        XBee64BitAddress guid = new XBee64BitAddress(GUID);
        byte[] addr = jmri.util.StringUtil.bytesFromHexString(findParmValue(n, "address"));
        XBee16BitAddress address = new XBee16BitAddress(addr);
        String Identifier = findParmValue(n, "name");
        // create the RemoteXBeeDevice for the node.
        RemoteXBeeDevice remoteDevice = new RemoteXBeeDevice(xtc.getXBee(), guid, address, Identifier);
        // Check to see if the node is a duplicate, if it is, move 
        // to the next one.
        // get a XBeeNode corresponding to this node address if one exists
        XBeeNode curNode = (XBeeNode) xtc.getNodeFromXBeeDevice(remoteDevice);
        if (curNode != null) {
            log.info("Read duplicate node {} from file", remoteDevice);
            continue;
        }
        try {
            // and then add it to the network
            xtc.getXBee().getNetwork().addRemoteDevice(remoteDevice);
            // create node (they register themselves)
            XBeeNode node = new XBeeNode(remoteDevice);
            String polled = findParmValue(n, "polled");
            node.setPoll(polled.equals("yes"));
            xtc.registerNode(node);
            // if there is a stream port controller stored for this
            // node, we need to load that after the node starts running.
            // otherwise, the IOStream associated with the node has not
            // been configured.
            String streamController = findParmValue(n, "StreamController");
            if (streamController != null) {
                try {
                    // Class.forName cast is unchecked at this point
                    @SuppressWarnings("unchecked") java.lang.Class<jmri.jmrix.AbstractStreamPortController> T = (Class<AbstractStreamPortController>) Class.forName(streamController);
                    node.connectPortController(T);
                } catch (java.lang.ClassNotFoundException cnfe) {
                    log.error("Unable to find class for stream controller : {}", streamController);
                }
            }
        } catch (TimeoutException toe) {
            log.error("Timeout adding node {} from configuration file.", remoteDevice);
        } catch (XBeeException xbe) {
            log.error("Exception adding node {} from configuration file.", remoteDevice);
        }
    }
}
Also used : XBee64BitAddress(com.digi.xbee.api.models.XBee64BitAddress) XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) Element(org.jdom2.Element) RemoteXBeeDevice(com.digi.xbee.api.RemoteXBeeDevice) XBee16BitAddress(com.digi.xbee.api.models.XBee16BitAddress) XBeeException(com.digi.xbee.api.exceptions.XBeeException) XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) AbstractStreamPortController(jmri.jmrix.AbstractStreamPortController) XBeeNode(jmri.jmrix.ieee802154.xbee.XBeeNode) TimeoutException(com.digi.xbee.api.exceptions.TimeoutException)

Aggregations

XBeeConnectionMemo (jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo)15 XBeeTrafficController (jmri.jmrix.ieee802154.xbee.XBeeTrafficController)11 Test (org.junit.Test)8 XBeeInterfaceScaffold (jmri.jmrix.ieee802154.xbee.XBeeInterfaceScaffold)5 Before (org.junit.Before)4 AbstractStreamPortController (jmri.jmrix.AbstractStreamPortController)2 XBeeNode (jmri.jmrix.ieee802154.xbee.XBeeNode)2 Element (org.jdom2.Element)2 RemoteXBeeDevice (com.digi.xbee.api.RemoteXBeeDevice)1 TimeoutException (com.digi.xbee.api.exceptions.TimeoutException)1 XBeeException (com.digi.xbee.api.exceptions.XBeeException)1 XBee16BitAddress (com.digi.xbee.api.models.XBee16BitAddress)1 XBee64BitAddress (com.digi.xbee.api.models.XBee64BitAddress)1