use of jmri.TurnoutOperationManager in project JMRI by JMRI.
the class TurnoutOperationManagerXml method load.
@Override
public boolean load(Element sharedOperations, Element perNodeOperations) {
boolean result = true;
TurnoutOperationManager manager = TurnoutOperationManager.getInstance();
if (sharedOperations.getAttribute("automate") != null) {
try {
manager.setDoOperations(sharedOperations.getAttribute("automate").getValue().equals("true"));
} catch (NumberFormatException ex) {
result = false;
}
}
List<Element> operationsList = sharedOperations.getChildren("operation");
if (log.isDebugEnabled()) {
log.debug("Found " + operationsList.size() + " operations");
}
for (int i = 0; i < operationsList.size(); i++) {
TurnoutOperationXml.loadOperation(operationsList.get(i));
}
return result;
}
use of jmri.TurnoutOperationManager in project JMRI by JMRI.
the class TurnoutOperationManagerXml method store.
@Override
public Element store(Object o) {
Element elem = new Element("operations");
if (o instanceof TurnoutOperationManager) {
TurnoutOperationManager manager = (TurnoutOperationManager) o;
elem.setAttribute("automate", String.valueOf(manager.getDoOperations()));
TurnoutOperation[] operations = manager.getTurnoutOperations();
for (int i = 0; i < operations.length; ++i) {
TurnoutOperation op = operations[i];
if (!op.isNonce()) {
// nonces are stored with their respective turnouts
TurnoutOperationXml adapter = TurnoutOperationXml.getAdapter(op);
if (adapter != null) {
Element opElem = adapter.store(op);
if (opElem != null) {
elem.addContent(opElem);
}
}
}
}
}
return elem;
}
Aggregations