<?xml version = "1.0" encoding = "UTF-8"?>

<Schema name = "FDTModbusChannelParameterSchema"
	 xmlns = "urn:schemas-microsoft-com:xml-data"
	 xmlns:dt = "urn:schemas-microsoft-com:datatypes"
	 xmlns:fdt = "x-schema:FDTDataTypesSchema.xml"
	 xmlns:appId = "x-schema:FDTApplicationIdSchema.xml">

	<!--FDT channel parameter schema V1.0 for Modbus protocol -->


	<!--Definition of Attributes-->
	
	<AttributeType name = "schemaVersion" dt:type = "number" default = "1.0"/>
	<AttributeType name = "address" dt:type = "ui2"/>
	<AttributeType name = "modbusDataTypes"  dt:type = "enumeration" dt:values = "coil discreteInput holdingRegister inputRegister"/>
	<AttributeType name = "quantity" dt:type = "ui2"/>
	<AttributeType name = "protectedByChannelAssignment" dt:type = "boolean"/>
	<AttributeType name = "frameApplicationTag" dt:type = "string"/>
	<AttributeType name = "scaleValue" dt:type = "string"/>
    <AttributeType name="statusChannel" dt:type="boolean"/>
    <AttributeType name="gatewayBusCategory" dt:type="uuid"/>




	<!--All elements of the enumeration represent data types specified in IEC 61131-3 -->
	<AttributeType name = "iecDataType"  dt:type = "enumeration" dt:values = "BOOL SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL TIME DATE TimeOfDay DateAndTime STRING BYTE WORD DWORD LWORD WSTRING"/>


	<!--Definition of Elements-->


	<!--Definition of Modbus access data element-->	
	
	<ElementType name = "ModbusAccessData" content = "empty" model = "closed">
		<attribute type = "fdt:nodeId"/>
		<!-- Starting address of the discrete input/coil/register -->
		<attribute type = "address" required = "yes"/>
		<!-- Type of data to be accessed -->
		<attribute type = "modbusDataTypes" required = "yes"/>
		<!-- Number of discrete inputs/coils/registers to be accessed -->
		<attribute type = "quantity" required = "yes"/>
		<!-- Access right for reading the Modbus data -->
		<attribute type="fdt:readAccess" required="no"/>
		<!-- Access right forwriting the Modbus data -->
		<attribute type="fdt:writeAccess" required="no"/>
	</ElementType>

	<!--Definition of UnitScaling element-->
	<ElementType name = "UnitScaling" content = "empty" model = "closed">
		<attribute type = "scaleValue" required = "yes"/>
	</ElementType>


	<ElementType name = "FDTChannel" content = "eltOnly" order = "seq" model = "closed">

		<attribute type = "fdt:nodeId"/>
		<!-- Unique identifier for a device, module or channel -->
		<attribute type = "fdt:tag" required = "yes"/>
		<!-- Unique identifier for an element within the device namespace -->
		<attribute type = "fdt:id" required = "yes"/>
		<!-- Human readable description within the context of a element -->
		<attribute type = "fdt:descriptor"/>
		<!-- TRUE if the channels is set to read only by the Frame Application -->
		<attribute type = "protectedByChannelAssignment" required = "yes"/>
		<!-- Standard FDT data type --> 
		<attribute type = "fdt:dataType" required = "yes"/>
		<!-- Standard IEC 61131-3 data types --> 
		<attribute type = "iecDataType" required = "no"/>
		<!-- Specifies a signal as input or output -->
		<attribute type = "fdt:signalType" required = "yes"/>
		<!-- Frame Application specific tag used for identification and navigation. -->
		<!-- The DTM should display this tag at channel specific user interfaces -->
		<attribute type = "frameApplicationTag"/>
		<!-- The appearance and the functionality of a DTM user interface is controlled by the  -->
		<!-- entry of the element applicationId, functionId, and operationPhase -->
		<attribute type = "appId:applicationId"/>
		<!-- TODO SemanticIDs need to be defined  -->
		<element type = "fdt:SemanticInformation" minOccurs = "0" maxOccurs = "*"/>
		<!-- Collection of EnumerationEntry   -->
		<element type = "fdt:BitEnumeratorEntries" minOccurs = "0" maxOccurs = "1"/>
		<!-- Enumeration element   -->
		<element type = "fdt:EnumeratorEntries" minOccurs = "0" maxOccurs = "1"/>
		<!-- Current unit and the collection of possible units of a process variable  -->
		<element type = "fdt:Unit" minOccurs = "0" maxOccurs = "1"/>
		<!-- scale value for the grapical representation of the process value -->
		<element type = "UnitScaling" minOccurs = "0" maxOccurs = "1"/>
		<!-- Address information needed to directly access the process data in the target device via Modbus  -->
		<element type = "ModbusAccessData" minOccurs = "0" maxOccurs = "1"/>
		<!-- Collection of alarms specified in FDT  -->
		<element type="fdt:Alarms" minOccurs="0" maxOccurs="1"/>
		<!-- Collection of ranges specified in FDT, which describe the valid range of a process value  -->
		<element type="fdt:Ranges" minOccurs="0" maxOccurs="1"/>
		<!-- Deadband is the amount of value changes that triggers for example new trend values.-->
		<element type = "fdt:Deadband" minOccurs = "0" maxOccurs = "1"/>
		<!-- Describes a substitute value which is used in combination of the behavior of disturbed channel values -->
		<element type="fdt:SubstituteValue" minOccurs="0" maxOccurs="1"/>
		<!-- should be used if the data type is structured -->
		<element type = "fdt:StructuredElements" minOccurs = "0" maxOccurs = "1"/>
	</ElementType>

	<ElementType name = "FDTChannelType" content = "eltOnly" order = "seq" model = "closed">
		<attribute type = "fdt:nodeId"/>
		<element type = "fdt:VersionInformation"/>
        <!-- Unique identifier for a supported bus type like Profibus or HART according to the FDT specific CATID -->
        <attribute type="gatewayBusCategory" required="no"/>
        <!-- TRUE if the channel is for status information only -->
        <attribute type="statusChannel" required="no"/>
	</ElementType>

	<ElementType name = "FDT" content = "eltOnly" order = "seq" model = "closed">
		<attribute type = "schemaVersion"/>
		<attribute type = "fdt:nodeId"/>
		<element type = "FDTChannelType" minOccurs="1" maxOccurs="1"/>
		<element type = "FDTChannel" minOccurs="1" maxOccurs="1"/>
	</ElementType>
</Schema>

