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);
}
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);
}
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);
}
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);
}
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);
}
}
}
Aggregations