001package jmri.jmrit.logixng.actions.configurexml;
002
003import jmri.InstanceManager;
004import jmri.Memory;
005import jmri.configurexml.JmriConfigureXmlException;
006import jmri.jmrit.logixng.AnalogActionManager;
007import jmri.jmrit.logixng.actions.AnalogActionMemory;
008import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectNamedBeanXml;
009
010import org.jdom2.Element;
011
012/**
013 * Handle XML configuration for ActionLightXml objects.
014 *
015 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010
016 * @author Daniel Bergqvist Copyright (C) 2019
017 */
018public class AnalogActionMemoryXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
019
020    public AnalogActionMemoryXml() {
021    }
022
023    /**
024     * Default implementation for storing the contents of a SE8cSignalHead
025     *
026     * @param o Object to store, of type TripleLightSignalHead
027     * @return Element containing the complete info
028     */
029    @Override
030    public Element store(Object o) {
031        AnalogActionMemory p = (AnalogActionMemory) o;
032
033        Element element = new Element("AnalogActionMemory");
034        element.setAttribute("class", this.getClass().getName());
035        element.addContent(new Element("systemName").addContent(p.getSystemName()));
036
037        storeCommon(p, element);
038
039        var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Memory>();
040        element.addContent(selectNamedBeanXml.store(p.getSelectNamedBean(), "namedBean"));
041
042        return element;
043    }
044
045    @Override
046    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {     // Test class that inherits this class throws exception
047        String sys = getSystemName(shared);
048        String uname = getUserName(shared);
049        AnalogActionMemory h;
050        h = new AnalogActionMemory(sys, uname);
051
052        loadCommon(h, shared);
053
054        var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<Memory>();
055        selectNamedBeanXml.load(shared.getChild("namedBean"), h.getSelectNamedBean());
056        selectNamedBeanXml.loadLegacy(shared, h.getSelectNamedBean(), "memory");
057
058        InstanceManager.getDefault(AnalogActionManager.class).registerAction(h);
059        return true;
060    }
061
062//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(AnalogActionMemoryXml.class);
063}