Missing properties of instances imported from file
Posted: 14 Nov 2022, 17:21
Hi,
I'm trying to get a small OPC-UA server running (in .NET 6, with the .NET SDK 3.1.0 eval license), which should load its complete node set from XML files. I've modified the GettingStarted server example and removed the creation of nodes by code; instead, I'm importing my nodes like this
This works just fine and I can run the server and load the following test file:
The problem I'm having is: All nodes are created as expected, except for ns=1;s=testInstance.testProperty, which is simply missing. The testInstance node is created as expected, however. It looks like the "Mandatory" modelling rule defined for ns=1;s=testType.testProperty isn't respected.
Is there a way for me to make sure that the server creates all components of the instances defined in the XML file on or after import?
I'm trying to get a small OPC-UA server running (in .NET 6, with the .NET SDK 3.1.0 eval license), which should load its complete node set from XML files. I've modified the GettingStarted server example and removed the creation of nodes by code; instead, I'm importing my nodes like this
Code: Select all
public override void Startup()
{
try
{
Console.WriteLine("Starting NodeManager.");
base.Startup();
InstanceNamespaceIndex = AddNamespaceUri("urn:Testsite:TestNS");
Console.WriteLine("Loading XML files ...");
if (!String.IsNullOrEmpty(XmlPath))
{
DirectoryInfo xmlDir = new DirectoryInfo(XmlPath);
foreach (FileInfo file in xmlDir.GetFiles("*.xml"))
{
Console.WriteLine($" Loading {file} ...");
ImportUaNodeset(file);
}
Console.WriteLine("Done.");
}
<--- snip --->
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<UANodeSet xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd">
<NamespaceUris>
<Uri>urn:Testsite:TestNS</Uri>
</NamespaceUris>
<UAObjectType NodeId="ns=1;s=testType" BrowseName="1:testType">
<DisplayName Locale="en">testType</DisplayName>
<Description Locale="en">testType</Description>
<References>
<Reference ReferenceType="i=45" IsForward="false">i=58</Reference>
</References>
</UAObjectType>
<UAVariable NodeId="ns=1;s=testType.testProperty" BrowseName="1:testProperty" DataType="i=12" ValueRank="-1">
<DisplayName Locale="en">testProperty</DisplayName>
<Description Locale="en">testProperty</Description>
<References>
<Reference ReferenceType="i=47" IsForward="false">ns=1;s=testType</Reference>
<Reference ReferenceType="i=40">i=62</Reference>
<Reference ReferenceType="i=37">i=78</Reference>
</References>
<Value>
<uax:String>HelloWorld</uax:String>
</Value>
</UAVariable>
<UAObject NodeId="ns=1;s=testInstance" BrowseName="1:testInstance">
<DisplayName Locale="en">testInstance</DisplayName>
<Description Locale="en">testInstance</Description>
<References>
<Reference ReferenceType="i=45" IsForward="false">i=85</Reference>
<Reference ReferenceType="i=40">ns=1;s=testType</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;s=testInstance.testProperty" BrowseName="1:testProperty">
<Value>
<String>Test</String>
</Value>
</UAVariable>
</UANodeSet>
Is there a way for me to make sure that the server creates all components of the instances defined in the XML file on or after import?