use of org.jdom2.Element in project JMRI by JMRI.
the class ConnectionConfigXml method makeParameter.
protected Element makeParameter(String name, String value) {
Element p = new Element("parameter");
p.setAttribute("name", name);
p.addContent(value);
return p;
}
use of org.jdom2.Element 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;
}
}
use of org.jdom2.Element in project JMRI by JMRI.
the class ConnectionConfigXml method makeParameter.
protected Element makeParameter(String name, String value) {
Element p = new Element("parameter");
p.setAttribute("name", name);
p.addContent(value);
return p;
}
use of org.jdom2.Element in project JMRI by JMRI.
the class ConnectionConfigXml method makeParameter.
protected Element makeParameter(String name, String value) {
Element p = new Element("parameter");
p.setAttribute("name", name);
p.addContent(value);
return p;
}
use of org.jdom2.Element 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("transmissiondelay", "" + InputBits.getTimeoutTime()));
n.addContent(makeParameter("inputbits", "" + InputBits.getNumInputBits()));
n.addContent(makeParameter("senddelay", "" + OutputBits.getSendDelay()));
n.addContent(makeParameter("outputbits", "" + OutputBits.getNumOutputBits()));
// n.addContent(makeParameter("pulsewidth", ""+node.getPulseWidth()));
// look for the next node
node = (SerialNode) SerialTrafficController.instance().getNode(index);
index++;
}
}
Aggregations