use of jmri.implementation.LsDecSignalHead in project JMRI by JMRI.
the class LsDecSignalHeadXml method store.
/**
* Default implementation for storing the contents of a LsDecSignalHead
*
* @param o Object to store, of type LsDecSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
LsDecSignalHead p = (LsDecSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen().getName(), p.getGreenState()));
element.addContent(addTurnoutElement(p.getYellow().getName(), p.getYellowState()));
element.addContent(addTurnoutElement(p.getRed().getName(), p.getRedState()));
element.addContent(addTurnoutElement(p.getFlashGreen().getName(), p.getFlashGreenState()));
element.addContent(addTurnoutElement(p.getFlashYellow().getName(), p.getFlashYellowState()));
element.addContent(addTurnoutElement(p.getFlashRed().getName(), p.getFlashRedState()));
element.addContent(addTurnoutElement(p.getDark().getName(), p.getDarkState()));
return element;
}
use of jmri.implementation.LsDecSignalHead in project JMRI by JMRI.
the class LsDecSignalHeadXml method load.
@Override
public boolean load(Element shared, Element perNode) {
List<Element> l = shared.getChildren("turnout");
NamedBeanHandle<Turnout> green = loadTurnout(l.get(0));
NamedBeanHandle<Turnout> yellow = loadTurnout(l.get(1));
NamedBeanHandle<Turnout> red = loadTurnout(l.get(2));
NamedBeanHandle<Turnout> flashgreen = loadTurnout(l.get(3));
NamedBeanHandle<Turnout> flashyellow = loadTurnout(l.get(4));
NamedBeanHandle<Turnout> flashred = loadTurnout(l.get(5));
NamedBeanHandle<Turnout> dark = loadTurnout(l.get(6));
int greenstatus = loadTurnoutStatus(l.get(0));
int yellowstatus = loadTurnoutStatus(l.get(1));
int redstatus = loadTurnoutStatus(l.get(2));
int flashgreenstatus = loadTurnoutStatus(l.get(3));
int flashyellowstatus = loadTurnoutStatus(l.get(4));
int flashredstatus = loadTurnoutStatus(l.get(5));
int darkstatus = loadTurnoutStatus(l.get(6));
// put it together
String sys = getSystemName(shared);
String uname = getUserName(shared);
SignalHead h;
if (uname == null) {
h = new LsDecSignalHead(sys, green, greenstatus, yellow, yellowstatus, red, redstatus, flashgreen, flashgreenstatus, flashyellow, flashyellowstatus, flashred, flashredstatus, dark, darkstatus);
} else {
h = new LsDecSignalHead(sys, uname, green, greenstatus, yellow, yellowstatus, red, redstatus, flashgreen, flashgreenstatus, flashyellow, flashyellowstatus, flashred, flashredstatus, dark, darkstatus);
}
loadCommon(h, shared);
InstanceManager.getDefault(jmri.SignalHeadManager.class).register(h);
return true;
}
Aggregations