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