PROPOSED FOR 4.0
structure - Built-in multipart data structure
Built-in multipart data structures are used to collect multiple object properties under a single name that can be referenced.
GLM
To define a new member of a class in a GLM file, use the class directive. For example
class my_class { structure { double a[kW]; complex b[kVA]; } c; }
creates a structure named c with two members a and b having units compatible with Watts.
Structure member can be set three ways in GLM files.
- Formal definition
- The formal definition of a structure uses a pair of curly braces to enclose the data in a structure in a form that is generally compatible with the object (directive). For example:
object my_class { c { a 1200 W; b 1.2+0.1j kVA; }; }
- String definition
- The string definition of a structure uses a quoted string to represent the data in a form that is compatible with the string output of data for XML and other general data exchange formats. For example:
object my_class { name d; c "a:1200 W; b:1.2+0.1j kVA"; }
- Note that the string form does not support nested structure definitions.
- Serial definition
- The serial definition of a structure uses a comma-separated series of values that is compatible with the serial output of data for legacy system data exchange. For example:
object my_class { name d; c "1.2, 1.2+0.1j"; }
- Note that the serial form does support nested structure definitions, but assumes that value are presented in the order in which they are declared.
ASCII Conversion
When directed to output a structure, GridLAB-D by default uses the string form. For example:
object recorder { target d; property c; }
will output
a: 1.2 W; b: 1.2+0.1j
when the structure_format global variable is set to STRING.
If the structure_format global variable is set to SERIAL, then the output takes the form
1.2, 1.2+0.1j
If the structure_format global variable is set to FORMAT, then the output takes the form
{ a 1.2 kW; b 1.2+0.1j kVA; }