001package jmri.jmrit.logixng.actions.configurexml;
002
003import jmri.InstanceManager;
004import jmri.configurexml.JmriConfigureXmlException;
005import jmri.jmrit.logixng.DigitalActionManager;
006import jmri.jmrit.logixng.actions.ShutdownComputer;
007
008import org.jdom2.Element;
009
010import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectEnumXml;
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 ShutdownComputerXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
019
020    public ShutdownComputerXml() {
021    }
022
023    /**
024     * Default implementation for storing the contents of a SE8cSignalHead
025     *
026     * @param o Object to store, of type TripleSensorSignalHead
027     * @return Element containing the complete info
028     */
029    @Override
030    public Element store(Object o) {
031        ShutdownComputer p = (ShutdownComputer) o;
032
033        Element element = new Element("ShutdownComputer");
034        element.setAttribute("class", this.getClass().getName());
035        element.addContent(new Element("systemName").addContent(p.getSystemName()));
036
037        storeCommon(p, element);
038
039        var selectEnumXml = new LogixNG_SelectEnumXml<ShutdownComputer.Operation>();
040        element.addContent(selectEnumXml.store(p.getSelectEnum(), "shutdownOperation"));
041
042        return element;
043    }
044
045    @Override
046    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {
047        String sys = getSystemName(shared);
048        String uname = getUserName(shared);
049
050        ShutdownComputer h = new ShutdownComputer(sys, uname);
051
052        loadCommon(h, shared);
053
054        var selectEnumXml = new LogixNG_SelectEnumXml<ShutdownComputer.Operation>();
055
056        selectEnumXml.load(shared.getChild("shutdownOperation"), h.getSelectEnum());
057        selectEnumXml.loadLegacy(
058                shared, h.getSelectEnum(),
059                null,
060                "operation",
061                null,
062                null,
063                null);
064
065        InstanceManager.getDefault(DigitalActionManager.class).registerAction(h);
066        return true;
067    }
068
069//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ShutdownComputerXml.class);
070}