001package jmri.jmrit.logixng.actions.configurexml; 002 003import java.util.*; 004 005import jmri.*; 006import jmri.configurexml.JmriConfigureXmlException; 007import jmri.jmrit.logixng.DigitalActionManager; 008import jmri.jmrit.logixng.actions.ActionRequestUpdateAllSensors; 009 010import org.jdom2.Element; 011 012/** 013 * Handle XML configuration for ActionRequestUpdateAllSensors objects. 014 * 015 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 016 * @author Daniel Bergqvist Copyright (C) 2022 017 */ 018public class ActionRequestUpdateAllSensorsXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML { 019 020 public ActionRequestUpdateAllSensorsXml() { 021 } 022 023 /** 024 * Default implementation for storing the contents of a ExpressionSlotUsage 025 * 026 * @param o Object to store, of type TripleTurnoutSignalHead 027 * @return Element containing the complete info 028 */ 029 @Override 030 public Element store(Object o) { 031 ActionRequestUpdateAllSensors p = (ActionRequestUpdateAllSensors) o; 032 033 Element element = new Element("ActionRequestUpdateAllSensors"); 034 element.setAttribute("class", this.getClass().getName()); 035 element.addContent(new Element("systemName").addContent(p.getSystemName())); 036 037 storeCommon(p, element); 038 039 if (p.getMemo() != null) { 040 element.addContent(new Element("systemConnection") 041 .addContent(p.getMemo().getSystemPrefix())); 042 } 043 044 return element; 045 } 046 047 @Override 048 public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException { // Test class that inherits this class throws exception 049 String sys = getSystemName(shared); 050 String uname = getUserName(shared); 051 ActionRequestUpdateAllSensors h = new ActionRequestUpdateAllSensors(sys, uname, null); 052 053 loadCommon(h, shared); 054 055 Element systemConnection = shared.getChild("systemConnection"); 056 if (systemConnection != null) { 057 String systemConnectionName = systemConnection.getTextTrim(); 058 List<SystemConnectionMemo> systemConnections = 059 jmri.InstanceManager.getList(SystemConnectionMemo.class); 060 061 for (SystemConnectionMemo memo : systemConnections) { 062 if (memo.getSystemPrefix().equals(systemConnectionName)) { 063 h.setMemo(memo); 064 break; 065 } 066 } 067 } 068 069 InstanceManager.getDefault(DigitalActionManager.class).registerAction(h); 070 return true; 071 } 072 073// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ActionRequestUpdateAllSensorsXml.class); 074}