Hello, I’ve just recently started reading through all the standards and now started to try out some modelling tools.
One main point that I struggle with is the value of variables, DataTypes and consistency between Type Definitions and Variable Types. For complex variables that are modeled using structures (instead of the “Object” approach as listed in the Annex), I feel that there is some kind of redundancy, e.g.: ServerStatusType.
The ServerStatusType is a VariableType that models a structure with several children. This ServerStatusType also has the “Data Type” ServerStatusDataType which is a subtype of Structure and lists the very same children that the ServerStatusType has.
Now in my Objects, I can create a Variable with the “Type Definition” ServerStatusType, and therefore also have to use the ServerStatusDataType as “Data Type”. This automatically gives me a Variable with all the children from the ServerStatusType.
However:
- In my Variable I could also add additional children – wouldn’t I violate the Data Type by doing this?
- Associating the ServerStatusDataType to my ServerStatusType seems to be completely optional. I could also create additional Children in the ServerStatusType (if it was my definition) or not have any of the Children as specified in the ServerStatusDataType
- If I’d associate a BaseType to my ServerStatusType I could even select a Boolean Data Type for my Variable.
So what I don’t seem to completely grasp yet is the relation between Children of a Variable and the Value Attribute of a Variable. The only way to explain this to myself is the following:
- When creating a structure that is atomically updated by the server I must start with a CustomStructureDataType definition and define all my children there.
- Now I have two options: Define a Variable of BaseDataVariableType directly and give it the Data Type CustomStructureDataType or create a new Variable Type. The downside of a BaseDataVariableType is that a Client always has to read the full value of my structure.
- If I want my Client to be able to read individual members (children) of my structure I need to create a Variable Type CustomStructureType and set its Attribute Data Type to CustomStructureDataType.
- Now I can create a Variable with the Type Definition CustomStructureType and the Data Type CustomStructureDataType, which automatically inherits all the child nodes.
- The client has now the possibility to read the Variable as a whole or only one child. If the variable was writable, writing to my Variable of type CustomStructureType would also set the value of its children?
The key sentence I’ve found in the standard is this: “Data types are used to describe the structure of the Value Attribute of Variables and their VariableTypes”. However, the duplicity remains: For a complex variable like the ServerStatusType, what is the content of the Value Attribute? Are the values stored by the Variable itself or its children?
Maybe my confusing question allows someone to point out how structures are really defined, I could not grasp this concept completely yet.
05/30/2017
For a complex variable like the ServerStatusType, what is the content of the Value Attribute? Are the values stored by the Variable itself or its children?
The Nodes are window into your system. How the information is stored is a implementation detail, however, the expectation is the value of the field in the structure is the same as the value read from the corresponding component variable.
A server could implement this behavior by having a single ‘source of truth’ internally that is accessed whenever a read operation occurs.
Another could server could decide that it can keep multiple copies of the value in sync.
In either case, the client does not care as long as the server behaves as if the value is the same whether the variable or structure is accessed.
Ah ok – understood, so essentially
- ServerStatusDataType could be used as Data Type for a simple variable that can be read by any client and always contains the full structure
- ServerStatusType is a complex variable, when reading the value of variable the client would get return the same value as if it was read from a simple variable with the Data Type ServerStatusDataType. At the same time this complex variable exposes sub-fields as separate (possibly simple) variables, but the consistency between reading the value of the child or the complex variable must be guaranteed by the server (same data source).
Thanks a lot for the very fast reply!
05/30/2017
In the majority of cases, structures are used with simple variables.
The complex variables with fields exposed as component variables are for special cases.
There is no requirement that all fields be exposed as component variables – servers can pick a subset that makes sense.
Properties which are not fields in the structure can also exist on complex variables.
Any target if a HasComponent reference has the same name same name as field in the structure then the value/datatype has to be the same.
1 Guest(s)