use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class WiThrottlePreferences method store.
@Override
public Element store() {
if (this.isDirty()) {
this.isRestartRequired = true;
}
Element element = new Element("WiThrottlePreferences");
element.setAttribute("isUseEStop", "" + isUseEStop());
this.asLoadedUseEStop = this.isUseEStop();
element.setAttribute("getEStopDelay", "" + getEStopDelay());
this.asLoadedEStopDelay = this.getEStopDelay();
element.setAttribute("isUseMomF2", "" + isUseMomF2());
this.asLoadedUseMomF2 = this.isUseMomF2();
element.setAttribute("getPort", "" + getPort());
this.asLoadedPort = this.getPort();
element.setAttribute("isAllowTrackPower", "" + isAllowTrackPower());
this.asLoadedAllowTrackPower = this.isAllowTrackPower();
element.setAttribute("isAllowTurnout", "" + isAllowTurnout());
this.asLoadedAllowTurnout = this.isAllowTurnout();
element.setAttribute("isAllowRoute", "" + isAllowRoute());
this.asLoadedAllowRoute = this.isAllowRoute();
element.setAttribute("isAllowConsist", "" + isAllowConsist());
this.asLoadedAllowConsist = this.isAllowConsist();
element.setAttribute("isUseWiFiConsist", "" + isUseWiFiConsist());
this.asLoadedUseWiFiConsist = this.isUseWiFiConsist();
return element;
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class AbstractConnectionConfigXml method saveOptions.
protected void saveOptions(Element e, PortAdapter adapter) {
Element element = new Element("options");
String[] options = adapter.getOptions();
for (String i : options) {
Element elem = new Element("option");
elem.addContent(new Element("name").addContent(i));
elem.addContent(new Element("value").addContent(adapter.getOptionState(i)));
element.addContent(elem);
}
e.addContent(element);
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class AbstractSerialConnectionConfigXml method store.
/**
* Default implementation for storing the static contents of the serial port
* implementation
*
* @param object Object to store, of type AbstractSerialConnectionConfig
* @return Element containing the complete info
*/
@Override
public Element store(Object object) {
getInstance(object);
Element e = new Element("connection");
if (adapter == null) {
log.warn("No adapter found while saving serial port configuration {}", object.toString());
return null;
}
// many of the following are required by the DTD; failing to include
// them makes the XML file unreadable, but at least the next
// invocation of the program can then continue.
storeCommon(e, adapter);
if (adapter.getCurrentPortName() != null) {
e.setAttribute("port", adapter.getCurrentPortName());
} else {
e.setAttribute("port", rb.getString("noneSelected"));
}
if (adapter.getCurrentBaudRate() != null) {
e.setAttribute("speed", adapter.getCurrentBaudRate());
} else {
e.setAttribute("speed", rb.getString("noneSelected"));
}
e.setAttribute("class", this.getClass().getName());
extendElement(e);
return e;
}
use of com.zhan_dui.utils.m3u8.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 com.zhan_dui.utils.m3u8.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;
}
}
Aggregations