use of jmri.jmrit.logix.OBlock in project JMRI by JMRI.
the class LocoLabelXml method store.
/**
* Default implementation for storing the contents of a PositionableShape
*
* @param o Object to store, of type PositionableShape
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
LocoLabel p = (LocoLabel) o;
if (!p.isActive()) {
// if flagged as inactive, don't store
return null;
}
Element element = new Element("LocoLabel");
storeCommonAttributes(p, element);
Element elem = new Element("size");
elem.setAttribute("width", "" + p.getWidth());
elem.setAttribute("height", "" + p.getHeight());
element.addContent(elem);
elem = new Element("OBlock");
OBlock block = p.getBlock();
elem.setAttribute("systemName", "" + block.getSystemName());
elem.setAttribute("trainName", "" + block.getValue());
element.addContent(elem);
element.setAttribute("class", "jmri.jmrit.display.controlPanelEditor.shape.configurexml.LocoLabelXml");
return element;
}
use of jmri.jmrit.logix.OBlock in project JMRI by JMRI.
the class OBlockManagerXml method store.
/**
* Store the contents of a OBlockManager.
*
* @param o Object to store, of type BlockManager
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
Element blocks = new Element("oblocks");
blocks.setAttribute("class", "jmri.jmrit.logix.configurexml.OBlockManagerXml");
OBlockManager manager = (OBlockManager) o;
Iterator<String> iter = manager.getSystemNameList().iterator();
while (iter.hasNext()) {
String sname = iter.next();
OBlock block = manager.getBySystemName(sname);
String uname = block.getUserName();
if (log.isDebugEnabled()) {
log.debug("OBlock: sysName= " + sname + ", userName= " + uname);
}
Element elem = new Element("oblock");
elem.setAttribute("systemName", sname);
if (uname != null && uname.length() > 0) {
// doing this for compatibility during 2.9.* series
elem.setAttribute("userName", uname);
elem.addContent(new Element("userName").addContent(uname));
}
String comment = block.getComment();
if (comment != null) {
Element c = new Element("comment");
c.addContent(comment);
elem.addContent(c);
}
elem.setAttribute("length", "" + block.getLengthMm());
elem.setAttribute("units", block.isMetric() ? "true" : "false");
elem.setAttribute("curve", "" + block.getCurvature());
if (block.getNamedSensor() != null) {
Element se = new Element("sensor");
se.setAttribute("systemName", block.getNamedSensor().getName());
elem.addContent(se);
}
if (block.getNamedErrorSensor() != null) {
Element se = new Element("errorSensor");
se.setAttribute("systemName", block.getNamedErrorSensor().getName());
elem.addContent(se);
}
if (block.getReporter() != null) {
Element se = new Element("reporter");
se.setAttribute("systemName", block.getReporter().getSystemName());
se.setAttribute("reportCurrent", block.isReportingCurrent() ? "true" : "false");
elem.addContent(se);
}
elem.setAttribute("permissive", block.getPermissiveWorking() ? "true" : "false");
elem.setAttribute("speedNotch", block.getBlockSpeed());
List<Path> paths = block.getPaths();
for (int j = 0; j < paths.size(); j++) {
elem.addContent(storePath((OPath) paths.get(j)));
}
List<Portal> portals = block.getPortals();
for (int i = 0; i < portals.size(); i++) {
elem.addContent(storePortal(portals.get(i)));
}
// and put this element out
blocks.addContent(elem);
}
return blocks;
}
use of jmri.jmrit.logix.OBlock in project JMRI by JMRI.
the class OBlockManagerXml method storePortal.
private static Element storePortal(Portal portal) {
Element elem = new Element("portal");
elem.setAttribute("systemName", portal.getSystemName());
elem.setAttribute("portalName", portal.getName());
OBlock block = portal.getFromBlock();
if (block != null) {
Element fromElem = new Element("fromBlock");
fromElem.setAttribute("blockName", block.getSystemName());
List<OPath> paths = portal.getFromPaths();
if (paths != null) {
for (int i = 0; i < paths.size(); i++) {
OPath path = paths.get(i);
fromElem.addContent(storePathKey(path));
}
}
elem.addContent(fromElem);
} else {
log.error("Portal \"" + portal.getName() + "\" has no fromBlock!");
}
NamedBean signal = portal.getFromSignal();
if (signal != null) {
Element fromElem = new Element("fromSignal");
fromElem.setAttribute("signalName", signal.getSystemName());
fromElem.setAttribute("signalDelay", "" + portal.getFromSignalOffset());
elem.addContent(fromElem);
}
block = portal.getToBlock();
if (block != null) {
Element toElem = new Element("toBlock");
toElem.setAttribute("blockName", block.getSystemName());
List<OPath> paths = portal.getToPaths();
if (paths != null) {
for (int i = 0; i < paths.size(); i++) {
OPath path = paths.get(i);
toElem.addContent(storePathKey(path));
}
}
elem.addContent(toElem);
} else {
log.error("Portal \"" + portal.getName() + "\" has no toBlock!");
}
signal = portal.getToSignal();
if (signal != null) {
Element toElem = new Element("toSignal");
toElem.setAttribute("signalName", signal.getSystemName());
toElem.setAttribute("signalDelay", "" + portal.getToSignalOffset());
elem.addContent(toElem);
}
return elem;
}
use of jmri.jmrit.logix.OBlock in project JMRI by JMRI.
the class PortalListTest method testCTor.
@Test
public void testCTor() {
PortalList t = new PortalList(new OBlock("OB1", "Test"));
Assert.assertNotNull("exists", t);
}
use of jmri.jmrit.logix.OBlock in project JMRI by JMRI.
the class IndicatorTrackIconXml method store.
/**
* Default implementation for storing the contents of a IndicatorTrackIcon
*
* @param o Object to store, of type IndicatorTrackIcon
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
IndicatorTrackIcon p = (IndicatorTrackIcon) o;
if (!p.isActive()) {
// if flagged as inactive, don't store
return null;
}
Element element = new Element("indicatortrackicon");
storeCommonAttributes(p, element);
NamedBeanHandle<OBlock> b = p.getNamedOccBlock();
if (b != null) {
element.addContent(storeNamedBean("occupancyblock", b));
}
NamedBeanHandle<Sensor> s = p.getNamedOccSensor();
if (b == null && s != null) {
// only write sensor if no OBlock, don't write double sensing
element.addContent(storeNamedBean("occupancysensor", s));
}
/*
s = p.getErrSensor();
if (s!=null) {
element.addContent(storeBean("errorsensor", s));
}
*/
Element elem = new Element("showTrainName");
String show = "no";
if (p.showTrain()) {
show = "yes";
}
elem.addContent(show);
element.addContent(elem);
HashMap<String, NamedIcon> iconMap = p.getIconMap();
Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator();
elem = new Element("iconmap");
String family = p.getFamily();
if (family != null) {
elem.setAttribute("family", family);
}
while (it.hasNext()) {
Entry<String, NamedIcon> entry = it.next();
elem.addContent(storeIcon(entry.getKey(), entry.getValue()));
}
element.addContent(elem);
elem = new Element("paths");
ArrayList<String> paths = p.getPaths();
if (paths != null) {
for (int i = 0; i < paths.size(); i++) {
Element e = new Element("path");
e.addContent(paths.get(i));
elem.addContent(e);
}
element.addContent(elem);
}
element.setAttribute("class", "jmri.jmrit.display.configurexml.IndicatorTrackIconXml");
return element;
}
Aggregations