Accessing data for writing and reading from the server side|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Accessing data for writing and reading from the server side
Avatar
Cristian Denti
Member
Members
Forum Posts: 22
Member Since:
10/29/2021
sp_UserOfflineSmall Offline
1
01/26/2022 - 02:58
sp_Permalink sp_Print sp_EditHistory

Dear OpcUa,

i’m new in opcua. I need to access for writing and reading to the nodes values from the server side (so that any client who has the session active will be updated too).

How should I do it?

I have added 3 nodes in the object Line –> Machine that are Proximity (only Value of the type double), Temperature (only Value of the type double)  and Conveyor (one value of the type double and 2 calls) and I want to access to them. The calls seems to work.

I’m working in .NET environment, language C#

I found something in the Forum: 

Updating Server Object Property values | OPC UA Implementation: Stacks, Tools, and Samples | Forum

but from the code I use it seems it doesn’t work

BaseVariableState bvs = (BaseVariableState)Server.DiagnosticsNodeManager.FindPredefinedNode(VariableIds.Server_ServiceLevel, typeof(BaseVariableState));
bvs.Value = 200;

I found that calling should be (so that the compiler works):

ExpandedNodeId ExpNId = OPCUAServer.VariableIds.OPCUAServer1_Machine_Proximity_Value;
NamespaceTable Nm = new NamespaceTable();
NodeId NId = ExpandedNodeId.ToNodeId(ExpNId,Nm);

if (NId != null)
{
      BaseVariableState I = (BaseVariableState)m_Server.CurrentInstance.DiagnosticsNodeManager.FindPredefinedNode(NId,typeof(BaseVariableState));
      I.Value = 200;
}

But I still have a problem.. NId is Null. I think I should initialize NamespaceTable with something… What?

This is because OPCUAServer1_Machine_Proximity_Value has been taken from OPCUAServer.Classes.cs.

Is there the possibility to take the NodeId from the string of the NodeId Name (in this case it should be “ns=2;i=90”)?

Why?

 

Thanks,

Cristian 

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
01/26/2022 - 08:55
sp_Permalink sp_Print

Use the context inside NodeManager calls to look up namespaces.

You can also use the Server property on the base NodeManager.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 21
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4891