<?xml version="1.0" encoding="UTF-8"?>
<tdl xmlns="http://www.nema.org/1997/C1219TDLSchema" xmlns:xi="http://www.w3.org/1999/XML/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nema.org/1997/C1219TDLSchema
 C1219TDLSchema.xsd">
	<decade name="EXT_UDT_DEC" number="14" label="Extended User Defined Tables">
		<description>The extended user defined tables enable the C12.19 application to make selections from other tables that are present or implied to be present in an end device and redirect the resulting values into a user defined table. The values gathered may then be retrieved from a desired user defined table as if the Standard provided an explicit table and descriptive syntax to express the resulting table structure. The following general features are available to the application through the use of the Extended User Defined Tables:

- All elements and sub-elements may be reference for inclusion in a user-defined table.
- The element referenced can be directed into any one of 2040 user defined tables.
- The elements are packed in accordance with the base-type packing rules.
- It is possible to define pseudo BIT FIELD records for selecting bit field ranges from other tables and mapping them into BIT FIELD records within the Extended User Defined Tables. Two mapping methods are supplied for bit fields:

1. Index method, which maps terminal-elements and sub-elements only.
2. Offset method, which maps any bit range of a terminal element.

It is important to note that the Extended User Defined Tables are presumed not to be real tables inside the end device. Logically they should be thought of as if they are:
- Constructed on-the-fly by an end-device in response to a read or write request
- Build at the at the time of issuance of a blurt from a talk-only end-device.

From a security point of view, each element of an Extended User Defined Table shares the access attributes of the corresponding referenced element in the source table. As such users have read or write access to Extended User Defined Tables only when they have access permissions to all the referenced elements of those tables for the desired operation.</description>
		<table name="DIM_EUDT_TBL" number="140" type="EUDT_LIMITS_RCD" label="Extended User Defined Tables Function Limiting Table">
			<description>This table contains the maximum limits for values and control parameters for the extended user defined tables.</description>
			<bitField name="EUDT_BFLD" type="UINT8">
				<description>Defines possible data source selection mechanisms.</description>
				<subElement name="DATA_ACCESS_METHOD" type="UINT" startBitInclusive="0" endBitInclusive="1">
					<description>Designates the allowable methods for selecting table entries for placement in an extended user defined table.</description>
					<enumerator>
						<enum value="0" text="Only complete tables can be mapped into user tables. Partial tables cannot be mapped."/>
						<enum value="1" text="Octet-Offset/Octet-count and bit-offset/bit-count access method is supported."/>
						<enum value="2" text="Index/element-count access method is supported."/>
						<enum value="3" text="Access methods 2 and 3 are supported."/>
					</enumerator>
				</subElement>
				<subElement name="INDEX_DEPTH" type="UINT" startBitInclusive="2" endBitInclusive="5" min="1" max="9">
					<description>The maximum depth (number) of indices supported.</description>
				</subElement>
				<subElement name="FILLER" type="FILL" startBitInclusive="6" endBitInclusive="7"/>
			</bitField>
			<packedRecord name="EUDT_LIMITS_RCD">
				<element name="EUDT_CTRL" type="DIM_EUDT_BFLD"/>
				<element name="NBR_EUDT" type="UINT16" min="1" max="2040">
					<description>Maximum number of extended user defined tables.</description>
				</element>
				<element name="NBR_INSTANCES" type="UINT16">
					<description>Maximum number of end device table instances (virtual devices) available for selections.</description>
				</element>
				<element name="MAX_NBR_SELECTIONS" type="UINT32">
					<description>Maximum number of sources that can be selected from within the end device tables across all instances and all extended user defined tables.</description>
				</element>
				<element name="NBR_SELECTIONS_PER_EUDT" type="UINT16">
					<description>MAximum number of selections per extended user defined table</description>
				</element>
			</packedRecord>
		</table>
		<table name="ACT_EUDT_TBL" number="141" type="EUDT_LIMITS_RCD" label="Extended User Defined Tables Actual Limits Table">
			<description>This table contains the actual limits for values and control parameters for the extended user defined tables.</description>
			<bitField name="EUDT_BFLD" type="UINT8" redefine="DIM_EUDT_TBL.EUDT_BFLD">
				<description>States actual data source selection mechanism.</description>
				<subElement name="DATA_ACCESS_METHOD" type="UINT" startBitInclusive="0" endBitInclusive="1">
					<description>Designates the method used for selecting table entries for placement in an extended user defined table.</description>
					<enumerator>
						<enum value="0" text="Complete tables are mapped into user tables. Partial tables cannot be mapped."/>
						<enum value="1" text="Octet-Offset/Octet-count and bit-offset/bit-count access method is used."/>
						<enum value="2" text="Index/element-count access method is used."/>
					</enumerator>
				</subElement>
				<subElement name="INDEX_DEPTH" type="UINT" startBitInclusive="2" endBitInclusive="5" min="1" max="9">
					<description>The maximum depth (number) of indices supported.</description>
				</subElement>
				<subElement name="FILLER" type="FILL" startBitInclusive="6" endBitInclusive="7"/>
			</bitField>
			<packedRecord name="EUDT_LIMITS_RCD" redefine="DIM_EUDT_TBL.EUDT_LIMITS_RCD">
				<element name="EUDT_CTRL" type="EUDT_BFLD"/>
				<element name="NBR_EUDT" type="UINT16" min="1" max="2040">
					<description>Actual number of extended user defined tables that can be defined.</description>
				</element>
				<element name="NBR_INSTANCES" type="UINT16">
					<description>Actual number of end device table instances (virtual devices) available for selections.</description>
				</element>
				<element name="MAX_NBR_SELECTIONS" type="UINT32">
					<description>Actual number of sources that can be selected from within the end device tables across all instances and all extended user defined tables.</description>
				</element>
				<element name="NBR_SELECTIONS_PER_EUDT" type="UINT16">
					<description>Actual number of selections per extended user defined table</description>
				</element>
			</packedRecord>
		</table>
		<table name="EUDT_SELECTIONS_TBL" number="142" type="EUDT_RCD" label="Extended User Defined Selections Table">
			<description>This table contains the extended user defined selections for constructing the extended user defined tables records. These selections enable the end-device application to direct the placement of table objects, elements, terminal elements, sub-elements and bit fields from of element into any extended user defined table.</description>
			<bitField name="EUDT_MAPPING_BFLD" type="UINT16">
				<subElement name="SOURCE_UNIT_SIZE" type="UINT" startBitInclusive="0" endBitInclusive="3">
					<description>Defines the element size of a selection from a table indicated by SOURCE_TABLE_ID. For example, when BIT_OFFSET=5 and COUNT=3, a selection from a 16 bit wide element will collect bits starting at source bit position 4 (where the  first bit is in position 0) to bit position 6, inclusive. This is independent of the DATA_ORDER value found  in GEN_CONFIG_TBL.  It is possible toi select more than one element size unit.</description>
					<enumerator>
						<enum value="0" text="  8 bit element"/>
						<enum value="1" text="16 bit element"/>
						<enum value="2" text="24 bit element"/>
						<enum value="3" text="32 bit element"/>
						<enum value="4" text="40 bit element"/>
						<enum value="5" text="48 bit element"/>
						<enum value="6" text="64 bit element"/>
					</enumerator>
				</subElement>
				<subElement name="SOURCE_SIGNED" type="BOOL" startBitInclusive="4">
					<description>When the number of bits in the destination element is larger than the source element then the most significant bits are signed extende if true:</description>
					<enumerator>
						<enum value="true" text="Sign Extension required"/>
						<enum value="false" text="Leading zero fiil extension required"/>
					</enumerator>
				</subElement>
				<subElement name="TARGET_PRODUCTION_CTRL" type="UINT" startBitInclusive="5" endBitInclusive="7">
					<description>Controls the bit-packing, bit-filling extension and sizing of a target EUDT element.</description>
					<enumerator>
						<enum value="0" text="Copy octest starting at source bit to target with zero padding"/>
						<enum value="1" text="Copy octest starting at source bit to target with zero leading"/>
						<enum value="2" text="First member of a BIT FIELD OF UINT8"/>
						<enum value="3" text="First member of a BIT FIELD OF UINT16"/>
						<enum value="4" text="First member of a BIT FIELD OF UINT32"/>
						<enum value="5" text="Next BIT FIELD member in sequence"/>
					</enumerator>
				</subElement>
				<subElement name="TARGET_ELEMENT_SIZE" type="UINT" startBitInclusive="8" endBitInclusive="15">
					<description>Size of target sub-element in bits. When the target elemet size is smaller than the source element only fitting bits will be transffered. When the source element size is smaller than the target element size then the target will be 0 filled (source is UINT type) or sign extended (source is INT type)</description>
				</subElement>
			</bitField>
			<packedRecord name="EUDT_ITEM_RCD">
				<element name="SOURCE_TABLE_ID" type="TABLE_IDB_BFLD"/>
				<if condition="ACT_EUDT_TBL.NBR_INSTANCES > 1">
					<then>
						<element name="SOURCE_INSTANCE_NBR" type="UINT8">
							<description>The end device table instance number used for selecting the source table. The instance number refers to a logical table set number that exists inside the same physical device.</description>
						</element>
					</then>
				</if>
				<switch selection="ACT_EUDT_TBL.DATA_ACCESS_METHOD">
					<case value="1">
						<element name="BYTE_OFFSET" type="UINT24">
							<description>Offset in octets to the beginning of an element relative to the beginning of the table which contains the source element.</description>
						</element>
						<element name="BIT_OFFSET" type="UINT8">
							<description>Offset in bits to the beginning of a bit sequence relative to the beginning of the selected terminal element. This offset is independent of the DATA_ORDER, since bit offset zero (0) points to bit position zero (the least significant bit) of the selected element. The compliant application shall logically expand the terminal element referred to by the BYTE_OFFSET before applying the BIT_OFFSET. This operation is independent of the DATA_ORDER (See GEN_CONFIG_TBL) Where the bit offset indicated BIT_OFFSET = 0 is the offset to bit zero (0) of the terminal element, when logically expanded.</description>
						</element>
						<element name="COUNT" type="UINT16">
							<description>When the associated SELECTION _TYPE = 1, then it is the number of octets selected. Otherwise it is the number of bits selected.</description>
						</element>
					</case>
					<case value="2">
						<array name="INDEX" type="UINT16" dimension="ACT_EUDT_TBL.NBR_INDEX_LEVEL">
							<description>An array containing ACT_EUDT_TBL.INDEX_LEVEL indices that represent the source of an element to be placed in the next available slot of the desired extended user defined table. The element may be any table object, table element, terminal element or a sub-element. The index value of FFFFH represents the end of the list.</description>
						</array>
						<element name="ELEMENT_COUNT" type="UINT16">
							<description>The number of elements selected from the source.</description>
						</element>
					</case>
				</switch>
			</packedRecord>
			<packedRecord name="EUDT_RCD">
				<element name="TARGET_EUDT" type="TABLE_IDB_BFLD">
					<description>The extended user defined table that is a collection of elements from other tables from within the end-device that have been selected for transmission via the TARGET_EUDT extended user defined table.</description>
				</element>
				<array name="SELECTIONS" type="EUDT_ITEM_RCD" dimension="ACT_EUDT_TBL.NBR_SELECTIONS">
					<description>An array that contains SOURCE_ITEM_RCD, the ACT_EUDT_TBL.NBR_SELECTIONS, the super set of selections that select, collect and direct table values to any extended user defined table. The extended user defined tables are populated sequentially based on these selections. When a constructed element from a selection is not a bit-field member, than it shall align on the next octet boundary with zero fill. Collections of bit fields are grouped into BIT_FIELD types for transmission in accordance with the type defined in SELECTION_TYPE and DATA_ORDER for the BIT FIELD type. These are collected into the extended user defined BIT FIELD table element starting with target bit field position 0.</description>
				</array>
			</packedRecord>
		</table>
	</decade>
</tdl>

