Пример #1
0
 private static Element storePath(OPath path) {
   Element elem = new Element("path");
   elem.setAttribute("pathName", path.getName());
   elem.setAttribute("blockName", "" + path.getBlock().getSystemName());
   Portal portal = path.getFromPortal();
   if (portal != null) {
     elem.setAttribute("fromPortal", portal.getName());
   }
   portal = path.getToPortal();
   if (portal != null) {
     elem.setAttribute("toPortal", portal.getName());
   }
   List<BeanSetting> list = path.getSettings();
   for (int i = 0; i < list.size(); i++) {
     BeanSetting bs = list.get(i);
     Element e = new Element("setting");
     // Turnout to = (Turnout)bs.getBean();
     e.setAttribute("turnout", bs.getBeanName());
     e.setAttribute("set", "" + bs.getSetting());
     elem.addContent(e);
   }
   elem.setAttribute("fromDirection", "" + path.getFromBlockDirection());
   elem.setAttribute("toDirection", "" + path.getToBlockDirection());
   elem.setAttribute("length", "" + path.getLengthMm());
   return elem;
 }
Пример #2
0
 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;
 }