16:34, EEST
February 21, 2014
Good afternoon.
I have created a custom structure DataType with 2 subtypes, for instance:
MyStructredBaseDataType
– MyStructuredSubDataTypeA
– MyStructuredSubDataTypeB
and want to expose a single array containing a mixture of MyStructuredSubDataTypeA and MyStructuredSubDataTypeB on a (Prosys based) OPC UA Server. I tried to generate code from this setup but the code did not reflect my intention. I also tried this with the baseDataType being abstract or non-abstract..
My question now is whether this can work at all conceptually, because a client attempting to read the array would certainly also need the related encodings. If the array has been typed with the BaseStructuredDataType (as a super type), does a client have any chance of decoding array elements having the subTypes? Something which does work is creating 2 arrays, one each per subtype. But then the original ordering of the mixed typed array would need to be reconstructed by introducing a dedicated index field (NB: The wording of the mixed array elements is critical to the application).
Thank you very much
11:42, EEST
April 3, 2012
Hi,
It is a bit unclear do you mean directly in a node Value (i.e. you give the ‘structure-array’ directly to Variant) or do you have a Structure that has the structure-array as a field. Since you do mention “2 arrays” and “index field”, maybe the latter, but that too was more about “work at all conceptually” so I’m not sure. Though, both ways should work, but the latter one needs probably more explanations.
In the case of having the structure-array directly in a node (i.e. you use it to make the Value Variant). Structures within Variant are encoded (in the binary transit) as ExtensionObjects (builtintype 22). An array of Structures becomes an array of ExtensionObjects, basically each element has their own type info (as part of the ExtensionObject encoding). This also has the side-effect that on the “encodings-level” an empty array of structures doesn’t have a type (SDK patches this info in some cases once we are in the “node datatype level”). Also, the decoder will choose the most-subtyped version of the array that can fit the elements. Thus if they are all MyStructuredSubDataTypeB then it is MyStructuredSubDataTypeB[] (which might cause issues if you then try to assign MyStructuredSubDataTypeA). Could be some room for improvements..
In the case of having the structure-array as a field in a structure, it should work, but you must either have a “normal structure” and i=22 (the raw ‘Structure’ DataType) as the field type OR have a “StructureWithSubtypedValues structure” and mark the field as AllowSubTypes true and then have the base MyStructredBaseDataType as the field DataType. However! Note that Codegen will create an ExtensionObject[] field in both cases. This is because currently generated structure types in the SDK cannot represent their subtypes and it is possible a non-generated model extends a generated Structure thus it would be impossible java-wise to set ‘DynamicStructure’ representing the non-generated subtype as an element of a generated structure type array (ExtensionObject is the only thing that can handle both). Thus you will need to handle this data as ExtensionObject[] and take the structures by ExtensionObject.getObject() (they should be decoded as long as the client knows the types either by codegen or has read them during connect).
14:13, EEST
February 21, 2014
I am sorry for being a little in-precise in my description..
MyBaseStructureDataType
– Element: UInt32 Index
– more elements
– SubType MyStructuredSubDataTypeA
– SubType MyStructuredSubDataTypeB
CustomParentDataStructure
– Element: UInt32 Index
– more Elements
– Element: MyBaseStructureDataType[] Params ## populated with ExtensionObjects values of the subtypes of MyBaseStructureDataType
(Server) Variable: CustomVariable, DataType: CustomParentDataStructure
I changed the array to type MyBaseStructureDataType with subtypes allowed, as you suggested, and put the individual array elements of the encoded sub-typed structures as ExtensionObjects into the array. (basically an ExtensionObject[] matching the generated code)
UaExpert can now successfully decode the individual array elements successfully, while the Prosys OPC UA Browser (v5.0.0-173) shows the array elements as ExtensionObjects. I assume the latter is to be expected if I interpret your description above correctly.
Originally, I marked the “MyBaseStructureDataType” as abstract, because there can only be instances of its subtypes. UaModeler then does not generate encodings for the abstract data structure type, which I think is correct, but some clients developed with other SDKs can’t work without those encodings. So I had to make the “MyBaseStructureDataType” non-abstract again.
Thank you very much for your support – as always 🙂
12:09, EEST
April 3, 2012
Hmm.. seems UaExpert is better in this regard, I’ll mark this as an improvement idea for Browser. Like technically the data is visible in the tooltip (or if you copy it to clipboard), though this is mostly a side-effect (of ExtensionObject.toString), anyway not very usable… but we should probably show it the same way (or make it expandable at least).
Most Users Ever Online: 1919
Currently Online:
41 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 726
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1