Skip to content

Commit

Permalink
Tweak opcua xslt a little bit.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <[email protected]>
  • Loading branch information
splatch committed Aug 22, 2024
1 parent 261881a commit 1df206e
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 57 deletions.
65 changes: 37 additions & 28 deletions protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@
[simple bit namespaceURISpecified]
[simple bit serverIndexSpecified]
[simple NodeIdTypeDefinition nodeId]
[virtual vstring '-1' identifier 'nodeId.identifier']
[optional PascalString namespaceURI 'namespaceURISpecified']
[optional uint 32 serverIndex 'serverIndexSpecified']
]



[type ExtensionObjectEncodingMask
[reserved int 5 '0x00']
[simple bit typeIdSpecified]
Expand Down Expand Up @@ -1058,6 +1059,24 @@
['318' UserIdentityToken
[simple PascalString policyId]
]
['321' AnonymousIdentityToken
[simple PascalString policyId]
]
['324' UserNameIdentityToken
[simple PascalString policyId]
[simple PascalString userName]
[simple PascalByteString password]
[simple PascalString encryptionAlgorithm]
]
['327' X509IdentityToken
[simple PascalString policyId]
[simple PascalByteString certificateData]
]
['940' IssuedIdentityToken
[simple PascalString policyId]
[simple PascalByteString tokenData]
[simple PascalString encryptionAlgorithm]
]
['467' ActivateSessionRequest
[simple RequestHeader('391') requestHeader]
[simple SignatureData('458') clientSignature]
Expand Down Expand Up @@ -2269,35 +2288,9 @@
[simple PascalString userName]
[simple int 64 annotationTime]
]

['316' UserIdentityToken
[implicit int 32 policyLength 'policyId.lengthInBytes + userIdentityTokenDefinition.lengthInBytes']
[simple PascalString policyId]
[simple UserIdentityTokenDefinition('policyId.stringValue') userIdentityTokenDefinition]
]
]
]

[discriminatedType UserIdentityTokenDefinition(vstring '-1' identifier)
[typeSwitch identifier
['"anonymous"' AnonymousIdentityToken
]
['"username"' UserNameIdentityToken
[simple PascalString userName]
[simple PascalByteString password]
[simple PascalString encryptionAlgorithm]
]
['"certificate"' X509IdentityToken
[simple PascalByteString certificateData]
]
['"identity"' IssuedIdentityToken
[simple PascalByteString tokenData]
[simple PascalString encryptionAlgorithm]
]
]
]


[discriminatedType Variant
[simple bit arrayLengthSpecified]
[simple bit arrayDimensionsSpecified]
Expand Down Expand Up @@ -2410,46 +2403,62 @@
[array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions']
]

// node type, with two leading reserved bytes
[enum uint 6 NodeIdType
['0' TwoByte ]
['1' FourByte ]
['2' Numeric ]
['3' String ]
['4' Guid ]
['5' ByteString ]
]

[discriminatedType NodeIdTypeDefinition
[abstract vstring '-1' identifier]
[abstract uint 16 namespace]
[discriminator NodeIdType nodeType]
[typeSwitch nodeType
['nodeIdTypeTwoByte' NodeIdTwoByte
[simple uint 8 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace '-1'] // cause an error
]
['nodeIdTypeFourByte' NodeIdFourByte
[simple uint 8 namespaceIndex]
[simple uint 16 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeNumeric' NodeIdNumeric
[simple uint 16 namespaceIndex]
[simple uint 32 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeString' NodeIdString
[simple uint 16 namespaceIndex]
[simple PascalString id]
[virtual vstring '-1' identifier 'id.stringValue']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeGuid' NodeIdGuid
[simple uint 16 namespaceIndex]
[array byte id count '16']
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeByteString' NodeIdByteString
[simple uint 16 namespaceIndex]
[simple PascalByteString id]
[virtual vstring '-1' identifier 'id.stringValue']
[virtual uint 16 namespace 'namespaceIndex']
]
]
]
[type NodeId
[reserved int 2 '0x00']
[simple NodeIdTypeDefinition nodeId]
[virtual vstring '-1' id 'nodeId.identifier']
]
[type PascalString
Expand Down
49 changes: 20 additions & 29 deletions protocols/opcua/src/main/xslt/opc-manual.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@
[simple bit namespaceURISpecified]
[simple bit serverIndexSpecified]
[simple NodeIdTypeDefinition nodeId]
[virtual vstring '-1' identifier 'nodeId.identifier']
[optional PascalString namespaceURI 'namespaceURISpecified']
[optional uint 32 serverIndex 'serverIndexSpecified']
]



[type ExtensionObjectEncodingMask
[reserved int 5 '0x00']
[simple bit typeIdSpecified]
Expand Down Expand Up @@ -239,39 +240,13 @@
['0' NullExtension
]

<xsl:for-each select="/opc:TypeDictionary/opc:StructuredType[((@BaseType = 'ua:ExtensionObject') or (starts-with(@BaseType, 'tns:') and not (@BaseType = 'tns:UserIdentityToken')))]">
<xsl:for-each select="/opc:TypeDictionary/opc:StructuredType[((@BaseType = 'ua:ExtensionObject') or (starts-with(@BaseType, 'tns:')))]">
<xsl:variable name="extensionName" select="@Name"/>
<xsl:apply-templates select="$file/node:UANodeSet/node:UADataType[@BrowseName=$extensionName]"/>
</xsl:for-each>

['316' UserIdentityToken
[implicit int 32 policyLength 'policyId.lengthInBytes + userIdentityTokenDefinition.lengthInBytes']
[simple PascalString policyId]
[simple UserIdentityTokenDefinition('policyId.stringValue') userIdentityTokenDefinition]
]
]
]

[discriminatedType UserIdentityTokenDefinition(vstring '-1' identifier)
[typeSwitch identifier
['"anonymous"' AnonymousIdentityToken
]
['"username"' UserNameIdentityToken
[simple PascalString userName]
[simple PascalByteString password]
[simple PascalString encryptionAlgorithm]
]
['"certificate"' X509IdentityToken
[simple PascalByteString certificateData]
]
['"identity"' IssuedIdentityToken
[simple PascalByteString tokenData]
[simple PascalString encryptionAlgorithm]
]
]
]


[discriminatedType Variant
[simple bit arrayLengthSpecified]
[simple bit arrayDimensionsSpecified]
Expand Down Expand Up @@ -384,46 +359,62 @@
[array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions']
]

// node type, with two leading reserved bytes
[enum uint 6 NodeIdType
['0' TwoByte ]
['1' FourByte ]
['2' Numeric ]
['3' String ]
['4' Guid ]
['5' ByteString ]
]

[discriminatedType NodeIdTypeDefinition
[abstract vstring '-1' identifier]
[abstract uint 16 namespace]
[discriminator NodeIdType nodeType]
[typeSwitch nodeType
['nodeIdTypeTwoByte' NodeIdTwoByte
[simple uint 8 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace '-1'] // cause an error
]
['nodeIdTypeFourByte' NodeIdFourByte
[simple uint 8 namespaceIndex]
[simple uint 16 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeNumeric' NodeIdNumeric
[simple uint 16 namespaceIndex]
[simple uint 32 id]
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeString' NodeIdString
[simple uint 16 namespaceIndex]
[simple PascalString id]
[virtual vstring '-1' identifier 'id.stringValue']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeGuid' NodeIdGuid
[simple uint 16 namespaceIndex]
[array byte id count '16']
[virtual vstring '-1' identifier 'id']
[virtual uint 16 namespace 'namespaceIndex']
]
['nodeIdTypeByteString' NodeIdByteString
[simple uint 16 namespaceIndex]
[simple PascalByteString id]
[virtual vstring '-1' identifier 'id.stringValue']
[virtual uint 16 namespace 'namespaceIndex']
]
]
]

[type NodeId
[reserved int 2 '0x00']
[simple NodeIdTypeDefinition nodeId]
[virtual vstring '-1' id 'nodeId.identifier']
]

[type PascalString
Expand Down
Loading

0 comments on commit 1df206e

Please sign in to comment.