-
Notifications
You must be signed in to change notification settings - Fork 3
Types
Several properties of classes of the COMET Data Model have properties that do not explicitly exist as a Type
in C#. These specific Types have been added to the COMET-SDK for convenience.
Containment, or composite aggregation, is an important aspect of the COMET Data Model. These containment structures are implemented in C# by subclassing the List<T>
class. The plain List<T>
is used for properties that have a multiplicity larger than 1 and that are not a composite aggregation.
The ContainerList<T>
is subclasses the List<T>
class where T
is constrained to Thing
. The ContainerList<T>
is initialized using the container Thing
. Each time contained Things
are added to this list, the container property of the Things
is set to the Container
property of the ContainerList<T>
.
Several properties of the COMET Data Model represent and ordered list. These properties are implemented using the OrderedItemList<T>
class. The OrderedItemList<T>
class can be used for both composite aggregations or plain references. The OrderedItemList<T>
maintains the keys that are used to maintain the order of the items in the list. Annex C specifies the protocol used to update these ordered lists. This protocol supports multiple add, delete and move operations from concurrent sessions.
The OrderedItemList<T>
makes use of the OrderedItem
class to maintain order. The OrderedItem
class has the following properties:
- K: the key (index) as a
long
. - V: the object that is stored in the slot specified by K.
- M: the index to which an object should be moved
Note: the
M
property of the OrderedItem is read-only and is used for serialization purposes. In order to move an item to a new index, use theMoveItem
method.
The MoveItem
method should be moved to re-order items in the OrderedItemList<T>
A ValueArray<T>
is a special object designed to hold all values of a ParameterValueSetBase
in the Computed
, Formula
, Manual
, Published
and Reference
properties of that class. In fact, in all cases only ValueArray<string>
is used, which means that all values of parameters are stored as strings in this object independent of their type. This is done to keep homogeneity where types can be mixed in cases like CompoundParameterType
.
When a parameter is of a ScalarParameterType
the size of the array is always 1. I.e., the parameter manual value mass=5kg
is an array represented by {"5"}
as an array of a single string. For a CompoundParameterType
the size is the number of components that makes up that CompoundParameterType
. Keep in mind that this summation might be recursive if the components themselves are compound! Matrix-like CompoundParameterType
are flattened to a single array and need to be recomposed for display based on their dimensions.
Some examples:
vector1=[x , 2, -, true, 25/04/2023 02:59:59]
=> {"x", "2", "-", "true", "25/04/2023 02:59:59"}
matrix1(2x3)=[x, 2, -; true, 25/04/2023 02:59:59, 4.5]
=> {"x", "2", "-", "true", "25/04/2023 02:59:59", "4.5"}
In the database the entire array is stored as one large escaped string that starts with {
and ends with }
and all the "
characters of the underlying string values of the array are escaped. The separator is ;
.
Some examples:
"Published"=>"{\"6.54\"}"
"Published"=>"{\"6.54\"}"
Over the wire, the array is transported as a string
that looks like an escaped array (note the square brackets in this case instead of curly and the separator is ,
):
"manual":"[\"4\"]"
this same value is stored in the database as "Manual"=>"{\"4\"}"
"manual":"[\"4\",\"5.4\",\"3\"]"
this same value is stored in the database as "Manual"=>"{\"4\";\"5.4\";\"3\"}"
In another example let's take a compound value with several types (Enums and QuantityKinds):
"manual":"[\"Active\",\"Internal\",\"5\",\"2\"]"
and in database "Manual"=>"{\"Active\";\"Internal\";\"5\";\"2\"}"
Lastly, an example of a complex multidimensional (2x3) ArrayParameterType
:
"manual":"[\"1\",\"sometext\",\"true\",\"2\",\"25/04/2023 02:59:59\",\"4\"]"
in database: "Manual"=>"{\"1\";\"sometext\";\"true\";\"2\";\"25/04/2023 02:59:59\";\"4\"}"
The first three values are from row 1 and last 3 are from row 2 of the matrix.
Keep in mind that some values might contain "
characters inside of them, so they need to be double escaped not to confuse the parsers. Thus if we take the example above and insert some "
into the text component of the ArrayParameterType
you will get the following:
"manual":"[\"1\",\"sometext that contains \\\"quoted\\\" stuff\",\"true\",\"2\",\"25/04/2023 02:59:59\",\"4\"]"
and in database: "Manual"=>"{\"1\";\"sometext that contains \\\"quoted\\\" stuff\";\"true\";\"2\";\"25/04/2023 02:59:59\";\"4\"}"
« CDP4Common-CE Cache — Documentation overview — CDP4Common-CE Meta Data »
copyright @ Starion Group S.A.