How to get UserData from an instance designed by UaModeler?

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

Moderator: uasdknet

Post Reply
blair.long
Full Member
Full Member
Posts: 5
Joined: 25 Aug 2020, 12:51

How to get UserData from an instance designed by UaModeler?

Post 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
Last edited by blair.long on 04 Sep 2020, 09:30, edited 1 time in total.

blair.long
Full Member
Full Member
Posts: 5
Joined: 25 Aug 2020, 12:51

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

Post 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.

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

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

Post 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.
Best regards
Unified Automation Support Team

blair.long
Full Member
Full Member
Posts: 5
Joined: 25 Aug 2020, 12:51

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

Post 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);
        }

blair.long
Full Member
Full Member
Posts: 5
Joined: 25 Aug 2020, 12:51

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

Post 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

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

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

Post 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.
Best regards
Unified Automation Support Team

blair.long
Full Member
Full Member
Posts: 5
Joined: 25 Aug 2020, 12:51

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

Post 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.

Unknown User
Full Member
Full Member
Posts: 5
Joined: 05 Jul 2021, 16:44

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

Post 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

Post Reply