Search in sources :

Example 1 with XBeeConnectionMemo

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

the class ConnectionConfigXml method extendElement.

/**
     * Write out the SerialNode objects too
     *
     * @param e Element being extended
     */
@Override
protected void extendElement(Element e) {
    XBeeConnectionMemo xcm;
    XBeeTrafficController xtc;
    try {
        xcm = (XBeeConnectionMemo) adapter.getSystemConnectionMemo();
        xtc = (XBeeTrafficController) xcm.getTrafficController();
    } catch (NullPointerException npe) {
        // The adapter doesn't have a memo, so no nodes can be defined.
        if (log.isDebugEnabled()) {
            log.debug("No memo defined; no nodes to save.");
        }
        return;
    }
    try {
        XBeeNode node = (XBeeNode) xtc.getNode(0);
        int index = 1;
        while (node != null) {
            // add node as an element
            Element n = new Element("node");
            n.setAttribute("name", "" + node.getNodeAddress());
            e.addContent(n);
            // add parameters to the node as needed
            n.addContent(makeParameter("address", "" + jmri.util.StringUtil.hexStringFromBytes(node.getUserAddress())));
            n.addContent(makeParameter("PAN", "" + jmri.util.StringUtil.hexStringFromBytes(node.getPANAddress())));
            n.addContent(makeParameter("GUID", "" + jmri.util.StringUtil.hexStringFromBytes(node.getGlobalAddress())));
            n.addContent(makeParameter("name", node.getIdentifier()));
            n.addContent(makeParameter("polled", node.getPoll() ? "yes" : "no"));
            jmri.jmrix.AbstractStreamPortController pc = null;
            if ((pc = node.getPortController()) != null) {
                n.addContent(makeParameter("StreamController", pc.getClass().getName()));
            }
            // look for the next node
            node = (XBeeNode) xtc.getNode(index);
            index++;
        }
    } catch (java.lang.NullPointerException npe2) {
        // no nodes defined.
        return;
    }
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) Element(org.jdom2.Element) AbstractStreamPortController(jmri.jmrix.AbstractStreamPortController) XBeeNode(jmri.jmrix.ieee802154.xbee.XBeeNode)

Example 2 with XBeeConnectionMemo

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

the class NodeConfigFrame method discoverButtonActionPerformed.

/**
     * Method to handle discover button
     */
public void discoverButtonActionPerformed() {
    if (xtc.getXBee().getNetwork().isDiscoveryRunning()) {
        log.debug("Discovery process already running");
        discoverButton.setEnabled(false);
        statusText1.setText(Bundle.getMessage("FeedBackDiscover"));
        return;
    }
    jmri.jmrix.ieee802154.IEEE802154SystemConnectionMemo memo = xtc.getAdapterMemo();
    if (memo instanceof XBeeConnectionMemo) {
        XBeeConnectionMemo m = (XBeeConnectionMemo) memo;
        // call the node discovery code in the node manager.
        m.getXBeeNodeManager().startNodeDiscovery();
        discoverButton.setEnabled(false);
    }
    // provide user feedback
    statusText1.setText(Bundle.getMessage("FeedBackDiscover"));
    errorInStatus1 = true;
    resetNotes2();
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo)

Example 3 with XBeeConnectionMemo

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

the class EditNodeFrameTest method setUp.

@Before
public void setUp() {
    JUnitUtil.resetInstanceManager();
    tc = new XBeeInterfaceScaffold();
    m = new XBeeConnectionMemo();
    m.setSystemPrefix("ABC");
    tc.setAdapterMemo(m);
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeInterfaceScaffold(jmri.jmrix.ieee802154.xbee.XBeeInterfaceScaffold) Before(org.junit.Before)

Example 4 with XBeeConnectionMemo

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

the class NodeConfigActionTest method testStringMemoCtor.

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

Example 5 with XBeeConnectionMemo

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

the class XBeeComponentFactoryTest method setUp.

@Before
public void setUp() {
    Log4JFixture.setUp();
    JUnitUtil.resetInstanceManager();
    tc = new XBeeTrafficController() {

        @Override
        public void setInstance() {
        }

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

        @Override
        public jmri.jmrix.ieee802154.IEEE802154Node newNode() {
            return null;
        }
    };
    m = new XBeeConnectionMemo();
    m.setSystemPrefix("ABC");
    tc.setAdapterMemo(m);
}
Also used : XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) Before(org.junit.Before)

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