<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="../schema2xhtml.xsl" type="text/xsl"?>

<!-- $Id: signalmastlogics.xsd 23262 2013-04-22 15:32:37Z kevin-dickerson $ -->

<!-- This schema is part of JMRI. Copyright 2009.                           -->
<!--                                                                        -->
<!-- JMRI is free software; you can redistribute it and/or modify it under  -->
<!-- the terms of version 2 of the GNU General Public License as published  -->
<!-- by the Free Software Foundation. See the "COPYING" file for a copy     -->
<!-- of this license.                                                       -->
<!--                                                                        -->
<!-- JMRI is distributed in the hope that it will be useful, but WITHOUT    -->
<!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  -->
<!-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License  -->
<!-- for more details.                                                      -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:docbook="http://docbook.org/ns/docbook"
           xmlns:jmri="http://jmri.org/xml/schema/JMRIschema"
           xsi:schemaLocation="
                http://jmri.org/xml/schema/JMRIschema http://jmri.org/xml/schema/JMRIschema.xsd
                http://docbook.org/ns/docbook http://jmri.org/xml/schema/docbook/DocBook.xsd
            "
        >
    <xs:complexType name="SignalMastLogicManagerType">
      <xs:annotation>
        <xs:documentation>
          Define the XML stucture for storing the contents of a SignalMastLogicManager implementation.
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="true">jmri.managers.configurexml.DefaultSignalMastLogicManagerXml</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:sequence>
        <xs:element name="logicDelay" type="xs:string" minOccurs="0" maxOccurs="1"/>
        <xs:element name="signalmastlogic" type="SignalMastLogicType" minOccurs="0" maxOccurs="unbounded" />      
      </xs:sequence>
      <xs:attribute name="class" type="classType" use="required" />
    </xs:complexType>

    <xs:complexType name="SignalMastLogicType">
      <xs:annotation>
        <xs:documentation>
          Define the XML stucture for storing the contents of one SignalMast Logic implementation.
          Generally dealt with by the manager implemenation
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="true">jmri.managers.configurexml.DefaultSignalMastLogicManagerXml</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:sequence>
        <xs:element name="sourceSignalMast" minOccurs="1" maxOccurs="1"/>
        <xs:element name="destinationMast" type="SignalMastLogicDestinationType" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="source" type="xs:string"/>
    </xs:complexType>
    
    <xs:complexType name="SignalMastLogicDestinationType">
      <xs:annotation>
        <xs:documentation>
          Define the XML stucture for storing the contents of one SignalMast Logic implementation.
          Generally dealt with by the manager implemenation
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="true">jmri.managers.configurexml.DefaultSignalMastLogicManagerXml</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:sequence>
        <xs:element name="destinationSignalMast" minOccurs="1" maxOccurs="1"/>
        <xs:element name="comment" type="commentType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="enabled" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="allowAutoMaticSignalMastGeneration" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="useLayoutEditor" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="useLayoutEditorTurnouts" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="useLayoutEditorBlocks" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="associatedSection" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="lockTurnouts" type="yesNoType" minOccurs="0" maxOccurs="unbounded" />
        
        <xs:element name="blocks" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="block" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="blockName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="blockState" minOccurs="1" maxOccurs="1">
                      <xs:simpleType>
                        <xs:restriction base="xs:token">
                          <xs:enumeration value="unoccupied"/>
                          <xs:enumeration value="occupied"/>
                          <xs:enumeration value="anyState"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
        <xs:element name="turnouts" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="turnout" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="turnoutName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="turnoutState" minOccurs="1" maxOccurs="1">
                      <xs:simpleType>
                        <xs:restriction base="xs:token">
                          <xs:enumeration value="thrown"/>
                          <xs:enumeration value="closed"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
        <xs:element name="sensors" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="sensor" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="sensorName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="sensorState" minOccurs="1" maxOccurs="1">
                      <xs:simpleType>
                        <xs:restriction base="xs:token">
                          <xs:enumeration value="inActive"/>
                          <xs:enumeration value="active"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
        <xs:element name="masts" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="mast" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="mastName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="mastState" type="xs:string" minOccurs="1" maxOccurs="1"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="destination" type="xs:string"/>

    </xs:complexType>

</xs:schema>
