I have a nodeSet.xml like below.
+++++++++++++++++ nodeSet.xml - Begin +++++++++++++++++++++++
<UAMethod ParentNodeId="ns=1;i=1003" NodeId="ns=1;i=7001" BrowseName="1:TransferData">
<DisplayName>TransferData</DisplayName>
<References>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6001</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6002</Reference>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1003</Reference>
</References>
</UAMethod>
<UAVariable DataType="Argument" ParentNodeId="ns=1;i=7001" ValueRank="1" NodeId="ns=1;i=6001" ArrayDimensions="1" BrowseName="InputArguments">
<DisplayName>InputArguments</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=7001</Reference>
</References>
<Value>
<uax:ListOfExtensionObject>
<uax:ExtensionObject>
<uax:TypeId>
<uax:Identifier>i=297</uax:Identifier>
</uax:TypeId>
<uax:Body>
<uax:Argument>
<uax:Name>Data</uax:Name>
<uax:DataType>
<uax:Identifier>i=15</uax:Identifier>
</uax:DataType>
<uax:ValueRank>-1</uax:ValueRank>
<uax:ArrayDimensions/>
<uax:Description/>
</uax:Argument>
</uax:Body>
</uax:ExtensionObject>
</uax:ListOfExtensionObject>
</Value>
</UAVariable>
+++++++++++++++++ nodeSet.xml - End +++++++++++++++++++++++
Then I use Opc.Ua.Export.UANodeSet to read this nodeSet.xml and convert to NodeStateCollection, like below.
+++++++++++++++++ Load xml - Begin +++++++++++++++++++++++
private void ImportXml(IDictionary<NodeId, IList<IReference>> externalReferences, string resourcepath)
{
NodeStateCollection predefinedNodes = new NodeStateCollection();
Stream stream = new FileStream(resourcepath, FileMode.Open);
Opc.Ua.Export.UANodeSet nodeSet = Opc.Ua.Export.UANodeSet.Read(stream);
foreach (string namespaceUri in nodeSet.NamespaceUris)
{
SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
}
nodeSet.Import(SystemContext, predefinedNodes);
for (int ii = 0; ii < predefinedNodes.Count; ii++)
{
AddPredefinedNode(SystemContext, predefinedNodes[ii]);
}
// ensure the reverse refernces exist.
AddReverseReferences(externalReferences);
}
+++++++++++++++++ Load xml - End +++++++++++++++++++++++
We can see the import function, for UAMethod, it just create a new methodState but not add InputArguments.
+++++++++++++++++ Import UAMethod - Begin +++++++++++++++++++++++
case NodeClass.Method:
{
UAMethod uAMethod = (UAMethod)node;
nodeState = new MethodState(null)
{
Executable = uAMethod.Executable,
UserExecutable = uAMethod.Executable,
MethodDeclarationId = ImportNodeId(uAMethod.MethodDeclarationId, context.NamespaceUris, lookupAlias: true)
};
break;
}
+++++++++++++++++ Import UAMethod - End+++++++++++++++++++++++ |