How to initialize (generated) C# object model with default v

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
chris
Jr. Member
Jr. Member
Posts: 1
Joined: 29 Aug 2018, 10:57

How to initialize (generated) C# object model with default v

Post by chris »

Hello,

We are currently developing an OPC-UA server based on the code files generated with UaModeler from an OPC-UA model. We define default configuration values directly in the OPC-UA Model. Starting the server as generated yields the expected result of those default values being displayed as defined (when browsing the object model with UaExpert client).
To update the values provided by our server, we now create an instance of the object model generated and link it using LinkModelToNode on the "root" object node.
However, creating an instance of the "root object" using its default constructor initializes all values with the C# default values, not the default values configured on the model.

Code: Select all

        public override void Startup()        {
            Console.WriteLine("TestProjectWrapper (OpcUa Nodes) startup");
            base.Startup();
            var testModel= new TestModel();
            lock (InMemoryNodeLock)
            {
                  LinkModelToNode(
                  new NodeId(TestModel, DefaultNamespaceIndex),
                  testModel, null, null, 500);
            }
       }

Is there a way to initialize the object model with the default values defined in the information model, or set the object models values from the ObjectNode representation of the OPC-UA model?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: How to initialize (generated) C# object model with defau

Post by Support Team »

Hello,

currently there is no option to get the values from the NodeSet file to instnaces of the model files.
Best regards
Unified Automation Support Team

Post Reply