Page 1 of 1

How to get UserData from an instance designed by UaModeler?

Posted: 04 Sep 2020, 08:24
by blair.long
Hi Dear Friends,

Thanks for your attention in advance.

I defined a custom type "AirContionerType" on UaModeler, and I created an instance under "Objects" named "AirContioner1" by UaModeler. I set many default value for each variable of AirContioner1.and then I generated the .Net Standard OPC UA Server code.

I would like to get the AirConditioner1Model directly on my generated NodeManager to get the default value I set by UaModeler, I see the parent class BaseNodeManager provide a method "GetNodeUserNode" which will return a model directly, So I write below code to try to get it. But It always null.

Code: Select all

NodeId airConditioner1NodeId = ObjectIds.AirConditioner1.ToNodeId(this.Server.NamespaceUris);
var airConditioner1Model = (AirConditioner1Model)GetNodeUserData(airConditioner1NodeId);
I found the SDK document describe how to create an instance on NodeManager (see http://documentation.unified-automation.com/uasdkdotnet/3.0.5/html/L4ServerTutGSLess02Step07.html ). But for the instance created by UaModeler, will UaModeler create the related model directly? If yes, how can I get it directly?

Best Regards,
Blair

Re: How to get UserData from an instance designed by UaModeler?

Posted: 04 Sep 2020, 09:24
by blair.long
Let me clarify an user case for my question here:

We would like to define an condition type event, when a temperature > a configured alarm value(e.g. temperature > 100℃), then report a alarm.

So we need find a way to configure the “a configured alarm value”。 we found the "LimitAlarmType" event type, we can add an object instance of this type(Let's call it "LimitConditionForTemperature). and set the “a configured alarm value”(100℃) on "HighLimit" property.

On my opc ua server, I need write code to get the "LimitConditionForTemperature" and get it's "HighLimit" property's value.
So I can compare the temperature with the "HighLimit"'s value.

I know I can directly search the "HighLimit" node. But there may many properties of "LimitAlarmType" we set the default value.

So Is there a quick way to get the object model "LimitConditionForTemperature" directly? So I can get the "HighLimit" from "LimitConditionForTemperature" easily.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 04 Sep 2020, 16:03
by Support Team
Hello,

Did you have a look at lesson06 "Adding Support for Alarms & Conditions" (http://documentation.unified-automation.com/uasdkdotnet/3.0.5/html/L3ServerTutGSLess06.html)?

This example shows how to create an instance of an alarm and how to use LinkModelToNode to access the properties.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 07 Sep 2020, 03:20
by blair.long
Thanks for your replying.

Yes, I have read the lesson6, Actually, I known I can follow such way to reach my target. But that's is my concern actually.
In this way, we need new an instance with all field are empty firstly on NodeManager, then we need parse the fields nodes(e.g. HighLimit, LowLimit) of the object instance "LimitConditionForTemperature" I defined on UaModeler, then get the default value of these nodes and set their default value to the empty instance. At the last, call the "LinkModelToNode" to bind the model to the node. That's is exactly below method did, It looks like redundant.

My question is want to find a straightforward way to allow us don't need to do such fussy things. Since we already defined the object instance on UaModeler, Is there a straightforward way to get the “OffNormalAlarmModel” with the default value we set on UaModeler directly ?

Code: Select all

private void SetAlarmCondition(BlockConfiguration block)
        {
            NodeId alarmId = new NodeId(block.Name + "." + yourorganisation.BA.BrowseNames.StateCondition, InstanceNamespaceIndex);
            // Create off normal alarm data object
            OffNormalAlarmModel alarm = new OffNormalAlarmModel();
            alarm.NodeId = alarmId;
            alarm.EventType = ObjectTypeIds.OffNormalAlarmType;
            alarm.SourceNode = new NodeId(block.Name, InstanceNamespaceIndex);
            alarm.SourceName = block.Name;
            alarm.Severity = (ushort)EventSeverity.Low;
            alarm.ConditionName = "StateCondition";
            alarm.ConditionClassId = ObjectTypeIds.ProcessConditionClassType;
            alarm.ConditionClassName = BrowseNames.ProcessConditionClassType;
            alarm.Retain = false;
            alarm.EnabledState.Value = ConditionStateNames.Enabled;
            alarm.EnabledState.Id = true;
            alarm.AckedState.Value = ConditionStateNames.Acknowledged;
            alarm.AckedState.Id = true;
            alarm.ActiveState.Value = ConditionStateNames.Inactive;
            alarm.ActiveState.Id = false;
            alarm.SuppressedOrShelved = false;
            // Link alarm data object to nodes in address space
            LinkModelToNode(alarmId, alarm, null, null, 500);
        }

Re: How to get UserData from an instance designed by UaModeler?

Posted: 11 Sep 2020, 10:16
by blair.long
Support Team wrote:
04 Sep 2020, 16:03
Hello,

Did you have a look at lesson06 "Adding Support for Alarms & Conditions" (http://documentation.unified-automation.com/uasdkdotnet/3.0.5/html/L3ServerTutGSLess06.html)?

This example shows how to create an instance of an alarm and how to use LinkModelToNode to access the properties.
Hello Dear Friends,

Any feedback on my clarification for your post?

Best Regards,
Blair

Re: How to get UserData from an instance designed by UaModeler?

Posted: 16 Sep 2020, 17:07
by Support Team
Hello,

Currently you have to set all properties in code.

I have written a feature request to use the default values from model. However we do not plan to implement this feature in one of the next releases.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 17 Sep 2020, 01:55
by blair.long
Support Team wrote:
16 Sep 2020, 17:07
Hello,

Currently you have to set all properties in code.

I have written a feature request to use the default values from model. However we do not plan to implement this feature in one of the next releases.
Thanks for you reply. got it. look forward to this feature.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 31 Jul 2022, 13:14
by Unknown User
Support Team wrote:
16 Sep 2020, 17:07
Hello,

Currently you have to set all properties in code.

I have written a feature request to use the default values from model. However we do not plan to implement this feature in one of the next releases.
Hello UA Support Team,

has there been an update on this feature request by any chance?

I have got to be honest here, this is a really basic scenario, which I would expect your SDK to support out of the box.
Instead the users of the SDK have to jump through hoop after hoop to get the simplest of things accomplished.

Sorry for the rant, but I have just spent weeks getting the most basic use-cases implemented, which should really not have taken more than 2 or 3 days (Yes, I have worked through the tutorials and this is not my first rodeo with OPC UA). As you might imagine I am quite frustrated.

I really hope there is an update on at least the above feature.

Best regards,
Stefan

Re: How to get UserData from an instance designed by UaModeler?

Posted: 02 Sep 2022, 14:07
by Support Team
Hi,

in the .NET SDK recently released version 3.2.0, the method LinkModelToNode() was extended by an optional parameter useValuesFromAddressspace. If you set this to true, the initial values from the node (if not null) will be set to the model during the linkage.
Sorry for the rant, but I have just spent weeks getting the most basic use-cases implemented, which should really not have taken more than 2 or 3 days (Yes, I have worked through the tutorials and this is not my first rodeo with OPC UA). As you might imagine I am quite frustrated.
No need to apologize, we feel your pain. There is always plenty room for improvement. We, actually, have some plans to ease the model integration.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 04 Apr 2023, 11:08
by Support Team
Hi Blair and Stefan,

we just released version 3.3 of the .NET SDK. In this version we have introduced a new mechanism called BindModel, which is far superior to the existing LinkModelToNode. Not only simple DA functionality is supported, but also events, alarms, methods, state machines and dynamically created objects, which can be used e.g. in lists. The alarm system has been enhanced to the extent that Spec-compliant alarms can now be generated with just a few lines of code.

You can find a tutorial here:
https://documentation.unified-automation.com/uasdknet/3.3.0/html/L2ServerTutMachineDemoServer.html

The UaModeler version containing the new templates for version 3.3 will be released in the coming weeks. However, the example already contains the generated source code and can therefore be tested without having the latest the UaModeler.

Re: How to get UserData from an instance designed by UaModeler?

Posted: 02 May 2023, 13:32
by barry_fip
Support Team wrote:
04 Apr 2023, 11:08

The UaModeler version containing the new templates for version 3.3 will be released in the coming weeks. However, the example already contains the generated source code and can therefore be tested without having the latest the UaModeler.
Hi Support team,

Do you have a timeline for the release of the new UaModeler? I am trying to create a server with the tutorial model + source code, but I have trouble with the binding. ActivateModel(RequestContext context) is not being called automatically by the bindmodel feature and I can't solve it at the moment. I suspect this code will be generated with the next release?

Best Regards,
Barry

Re: How to get UserData from an instance designed by UaModeler?

Posted: 12 May 2023, 16:27
by Support Team
Hi,

Sorry for the delay, we finally released the version 1.6.9 of the UaModeler.
This version contains the templates for the .NET SDK 3.3.