001package jmri.jmrix.openlcb.configurexml; 002 003import jmri.InstanceManager; 004import jmri.configurexml.JmriConfigureXmlException; 005import jmri.jmrix.openlcb.OlcbConfigurationManager; 006 007import org.jdom2.Element; 008 009/** 010 * Provides load and store functionality for configuring OlcbSensorManagers. 011 * <p> 012 * Uses the store method from the abstract base class, but provides a load 013 * method here. 014 * 015 * @author Bob Jacobsen Copyright: Copyright (c) 2008, 2010 016 * @since 2.3.1 017 */ 018public class OlcbSensorManagerXml extends jmri.managers.configurexml.AbstractSensorManagerConfigXML { 019 020 public OlcbSensorManagerXml() { 021 super(); 022 } 023 024 @Override 025 public void setStoreElementClass(Element sensors) { 026 sensors.setAttribute("class", this.getClass().getName()); 027 } 028 029 @Override 030 public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException { 031 boolean result; 032 // We tell the Sensor managers that we will be loading Sensors from XML and they should 033 // expect additional property set sequences. This is somewhat tricky in the face of 034 // possibly multiple OpenLCB buses registered. 035 for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager 036 .class)) { 037 cfg.getSensorManager().startLoad(); 038 } 039 040 // load individual sensors 041 result = loadSensors(shared); 042 043 // Notifies OpenLCB Sensor managers that the loading of XML is complete. 044 for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager 045 .class)) { 046 cfg.getSensorManager().finishLoad(); 047 } 048 049 return result; 050 } 051 052// private final static Logger log = LoggerFactory.getLogger(OlcbSensorManagerXml.class); 053}