Defining Structure Templates
The definition for a Design Pad G4 structure is accomplished within an XML structure template file. The file may be created and edited using a text editor like Notepad, as long as it is saved with a ".xml" file extension. You may open the XML file with a web browser to examine it for errors.
The XML file defines only the templates that structures may take the form of. As such, they do not create any particular instance of a structure (you must use Design Pad structure variables for that).
LIBRARYFILE, LIBRARY and STRUCTURE are keywords in the file. The named Structure is part of a Library of structures. More than one structure may be described within a library. One or more libraries exist in a Libraryfile. The Libraryfile name is used as a description once the XML file is applied to the module. Libraries are used to gather structures used together into a unit.
<LIBRARYFILE Name="RF Controller">
<LIBRARY Name="RF_Controller">
<STRUCTURE Name="PID_Gain_Struct">
<FLOAT Name="f_Kc"/>
<FLOAT Name="f_Ti"/>
<FLOAT Name="f_Td"/>
</STRUCTURE>
<STRUCTURE Name="RF_Controller_Struct">
<FLOAT Name="f_State"/>
<FLOAT Name="f_SetPoint"/>
<FLOAT Name="f_Temperature"/>
<FLOAT Name="f_FanSpeed"/>
<BOOL Name="b_EStop"/>
<Structure Name="PID_Gains" Data="PID_Gain_Struct">
</Structure>
</STRUCTURE>
<STRUCTURE Name="Ports">
<BOOL Name="b_InUse"/>
<U8 Name="f_Status"/>
<FLOAT Name="f_PortActivity"/>
<STRUCTURE Name="Port_Details">
<U32 Name="f_Errors"/>
<U16 Name="f_Resends"/>
<U16 Name="f_Failures"/>
</STRUCTURE>
</STRUCTURE>
</LIBRARY>
</LIBRARYFILE>
The file above defines two structures, PID_Gain_Struct and RF_Controller_Struct. Note that PID_Gain_Struct is defined first. This is required since it is referred to as a part of structure RF_Controller_Struct. Note also its inclusion is in lower case so a new structure is not defined instead, causing an error. In the second case, the Ports structure uses the Port_Details structure, which is defined within the Ports structure.
Each variable type allowed in the structure definition maps to a variable type in a Design Pad schema:
Structure type | Schema type |
BOOL | Boolean |
FLOAT | Float |
U8 | Float |
U16 | Float |
U32 | Float |
Note: The U32 data type cannot be translated to/from a FLOAT data type with complete accuracy unless the value is an integer between 0 and 16,777,216. FLOAT values, while having a large range, also have a limited precision of 23 bits. As a result numbers above this value will not resolve into an exact FLOAT value. For example, 16,777,216 or 16,777,217 when converted to FLOAT both resolve to the same number, 16,777,216. Literally, the number 16,777,217 does not exist in FLOAT as it cannot be represent by its limited precision. As the number increases towards the limit of a U32 (4,294,967,295) the quantity of "missing" values numbers will increase and the gaps between numbers that a FLOAT can represent will become wider. Apply both caution and logic to how you utilize U32 values.