Hi all,

part of the new additions for mspec are the ability to reference discriminated 
subtypes directly.
However I think with this we opened pandora's box ;-)

We even noticed that it was already possible to reference sub-types as Ben was 
using it in his new OPC-UA driver.
The problem however is, that this only works if the parent type doesn't have 
any fields at all.
For BacNet however this doesn't apply. So to be correct, we need to not call 
"MyCoolSubtypeIO.staticParse", but we must call 
"MyCoolParentTypeIO.staticParse" and pass along the information needed to make 
it choose the "MyCoolSubtype" type.
So in general when referencing subtypes, we need to pass the arguments we would 
also need to pass along as if we were using the parent type. Mspec then 
automatically generates a type-cast in the end.

MyCoolSubtype coolValue = (MyCoolSubtype) 
MyCoolParentTypeIO.staticParse(readBuffer, someValue, someOtherValue);


For this to work in PLC4X in it's current state, the opc-ua mspec generation 
would need a minor tweak to change this:

['"15619"' PubSubConnectionDataType
    [simple PascalString 'name']
    [reserved uint 7 '0x00']
    [simple bit 'enabled']
    [simple Variant 'publisherId']
    [simple PascalString 'transportProfileUri']
    [simple ExtensionObject('true') 'address']
    [simple int 32 'noOfConnectionProperties']

    [array ExtensionObjectDefinition('"14535"') 'connectionProperties' count 
'noOfConnectionProperties']
    [simple ExtensionObject('true') 'transportSettings']
    [simple int 32 'noOfWriterGroups']
    [array PubSubGroupDataType  'writerGroups' count 'noOfWriterGroups']
    [simple int 32 'noOfReaderGroups']
    [array PubSubGroupDataType  'readerGroups' count 'noOfReaderGroups']

]


To something like this:

['"15619"' PubSubConnectionDataType
    [simple PascalString 'name']
    [reserved uint 7 '0x00']
    [simple bit 'enabled']
    [simple Variant 'publisherId']
    [simple PascalString 'transportProfileUri']
    [simple ExtensionObject('true') 'address']
    [simple int 32 'noOfConnectionProperties']

    [array ExtensionObjectDefinition('"14535"') 'connectionProperties' count 
'noOfConnectionProperties']
    [simple ExtensionObject('true') 'transportSettings']
    [simple int 32 'noOfWriterGroups']
    [array PubSubGroupDataType('"15611"')  'writerGroups' count 
'noOfWriterGroups']
    [simple int 32 'noOfReaderGroups']
    [array PubSubGroupDataType('"15611"')  'readerGroups' count 
'noOfReaderGroups']

]

Chris

Reply via email to