001package jmri.jmrit.logixng.expressions.configurexml;
002
003import jmri.*;
004import jmri.jmrit.logixng.AnalogExpressionManager;
005import jmri.jmrit.logixng.expressions.TimeSinceMidnight;
006
007import org.jdom2.Element;
008
009/**
010 * Handle XML configuration for ActionLightXml objects.
011 *
012 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010
013 * @author Daniel Bergqvist Copyright (C) 2019
014 */
015public class TimeSinceMidnightXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML {
016
017    public TimeSinceMidnightXml() {
018    }
019    
020    /**
021     * Default implementation for storing the contents of a SE8cSignalHead
022     *
023     * @param o Object to store, of type TripleLightSignalHead
024     * @return Element containing the complete info
025     */
026    @Override
027    public Element store(Object o) {
028        TimeSinceMidnight p = (TimeSinceMidnight) o;
029
030        Element element = new Element("TimeSinceMidnight");
031        element.setAttribute("class", this.getClass().getName());
032        element.addContent(new Element("systemName").addContent(p.getSystemName()));
033
034        storeCommon(p, element);
035
036        element.addContent(new Element("type").addContent(p.getType().name()));
037
038        return element;
039    }
040    
041    @Override
042    public boolean load(Element shared, Element perNode) {
043        String sys = getSystemName(shared);
044        String uname = getUserName(shared);
045        TimeSinceMidnight h = new TimeSinceMidnight(sys, uname);
046
047        loadCommon(h, shared);
048
049        Element type = shared.getChild("type");
050        if (type != null) {
051            h.setType(TimeSinceMidnight.Type.valueOf(type.getTextTrim()));
052        }
053        
054        InstanceManager.getDefault(AnalogExpressionManager.class).registerExpression(h);
055        return true;
056    }
057    
058//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TimeSinceMidnightXml.class);
059}