use of jmri.jmrix.oaktree.SerialNode in project JMRI by JMRI.
the class ConnectionConfigXml method unpackElement.
@Override
protected void unpackElement(Element shared, Element perNode) {
List<Element> l = shared.getChildren("node");
for (int i = 0; i < l.size(); i++) {
Element n = l.get(i);
int addr = Integer.parseInt(n.getAttributeValue("name"));
int type = Integer.parseInt(findParmValue(n, "nodetype"));
// create node (they register themselves)
SerialNode node = new SerialNode(addr, type);
// Trigger initialization of this Node to reflect these parameters
SerialTrafficController.instance().initializeSerialNode(node);
}
}
use of jmri.jmrix.oaktree.SerialNode in project JMRI by JMRI.
the class NodeConfigFrame method addButtonActionPerformed.
/**
* Method to handle add button
*/
public void addButtonActionPerformed() {
// Check that a node with this address does not exist
int nodeAddress = readNodeAddress();
if (nodeAddress < 0) {
return;
}
// get a SerialNode corresponding to this node address if one exists
curNode = (SerialNode) SerialTrafficController.instance().getNodeFromAddress(nodeAddress);
if (curNode != null) {
statusText1.setText(rb.getString("Error1") + Integer.toString(nodeAddress) + rb.getString("Error2"));
statusText1.setVisible(true);
errorInStatus1 = true;
resetNotes2();
return;
}
nodeType = nodeTypeBox.getSelectedIndex();
// all ready, create the new node
curNode = new SerialNode(nodeAddress, nodeType);
if (curNode == null) {
statusText1.setText(rb.getString("Error3"));
statusText1.setVisible(true);
log.error("Error creating Serial Node, constructor returned null");
errorInStatus1 = true;
resetNotes2();
return;
}
// configure the new node
setNodeParameters();
// register any orphan sensors that this node may have
SerialSensorManager.instance().registerSensorsForNode(curNode);
// reset after succefully adding node
resetNotes();
changedNode = true;
// provide user feedback
statusText1.setText(rb.getString("FeedBackAdd") + " " + Integer.toString(nodeAddress));
errorInStatus1 = true;
}
use of jmri.jmrix.oaktree.SerialNode 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) {
SerialNode node = (SerialNode) SerialTrafficController.instance().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("nodetype", "" + node.getNodeType()));
// look for the next node
node = (SerialNode) SerialTrafficController.instance().getNode(index);
index++;
}
}
Aggregations