OPC UA - How to reach OPC Server Nodes via C# |OPC UA Standard|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
OPC UA - How to reach OPC Server Nodes via C#
Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
1
11/02/2022 - 05:33
sp_Permalink sp_Print

Hello,
I want to make a reporting program using C# and .NETFramework technologies. We have PLCs and our PLC tags are coming to Kepware's OPC server.

According to my research, it seems reasonable to use OPC UA, but I couldn't find any useful(uncomplicated) documentation. I just want to get the tree list from the OPC server and transfer it to treeview, which is a .NETFramework component.

Later, I want to log the tags I have determined by reading 1 per minute. Very detailed samples are too heavy for me.

Are there a method like GetStructors() or a small sample to get the tree structure and read a tag? Please help. 

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
11/02/2022 - 19:33
sp_Permalink sp_Print

This is a very simple sample:

https://github.com/OPCFoundati.....Program.cs

Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
3
11/03/2022 - 03:50
sp_Permalink sp_Print sp_EditHistory

I just tried that example and I get a result like

 

OPC UA Console Reference Client
OPC UA library: 1.4.370 @ 11/03/2022 08:49:12 -- 1.4.370
Connecting to... opc.tcp://10.0.254.195:49320/
BadCertificatePolicyCheckFailed 'SHA1 signed certificates are not trusted.'
Untrusted Certificate rejected. Subject = CN=KEPServerEX/UA Server, O=Unknown, C=US, DC=ISKIAATSRV
Create Session Error : SHA1 signed certificates are not trusted.
Could not connect to server! Retry in 10 seconds or Ctrl-C to quit.

 

I can connect with UA Reference/Reference Client but can't cannect with Console Reference Client. Please help thanks.

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
11/03/2022 - 04:27
sp_Permalink sp_Print

OPC UA has security turned on by default.

You are running into an issue because KepServer is using a Certificate with out of date algorithms that are no longer considered secure.

How old is the version you are using?

Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
5
11/03/2022 - 04:54
sp_Permalink sp_Print

I am using KEPServerEX6, I can connect with Reference Client but can't connect with Console Reference Client.

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
11/03/2022 - 23:55
sp_Permalink sp_Print

Not good that KEPServerEX6 is using out of date certificates.

You may want to contact Kepware support and ask about this.

At a minimum they should provide guidance on how to configure

Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
7
11/04/2022 - 07:08
sp_Permalink sp_Print

Are there a simple browse tree and read a tag sample or any video about this?

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
8
11/04/2022 - 07:23
sp_Permalink sp_Print sp_EditHistory

Sample with a simple tree view here:

https://github.com/OPCFoundati.....ess/Client

Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
9
11/10/2022 - 05:54
sp_Permalink sp_Print

Hi again, I found a simple sample on this; most people know this sample.

link: click

This is a console app and it gives tag values, I moved them to the windows form app. But there is a problem with that.

Here is a function call subscription.Create();

It gives tag values that are in the monitored item list per PublishingInterval time. When I run it on the windows form app it gives an error. Because the windows form app can't run it like a console app. How can we return these values like subscription.Create(); method. 

Any information you provide will be very useful for all of us, thanks.

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
10
11/10/2022 - 06:50
sp_Permalink sp_Print

What error exactly?

Avatar
Mert Atmaca_1
Member
Members
Forum Posts: 6
Member Since:
10/26/2022
sp_UserOfflineSmall Offline
11
11/10/2022 - 07:05
sp_Permalink sp_Print

On Console App

var subscription = new Subscription(session.DefaultSubscription) { PublishingInterval = 1000 };

Console.WriteLine("Step 5 - Add a list of items you wish to monitor to the subscription.");
var list = new List<MonitoredItem>();

MonitoredItem CikisDebi = new MonitoredItem(subscription.DefaultItem)
{
DisplayName = "Cikis Debi",
StartNodeId = "ns=2;s=AATSRV.AATSRV.@LOCALMACHINE::.List of all tags.B080Cikis_Debi"
};

MonitoredItem GirisSeviye = new MonitoredItem(subscription.DefaultItem)
{
DisplayName = "Giris Seviye",
StartNodeId = "ns=2;s=AATSRV.AATSRV.@LOCALMACHINE::.List of all tags.B080Giris_Seviye1"
};

list.Add(GirisSeviye);
list.Add(CikisDebi);

list.ForEach(i => i.Notification += OnNotification);
subscription.AddItems(list);

Console.WriteLine("Step 6 - Add the subscription to the session.");
session.AddSubscription(subscription);

subscription.Create();

Console.WriteLine("Press any key to remove subscription...");
Console.ReadKey(true);
}

 

There is no Console.WriteLine method but this subscription.Create(); method prints the values per { PublishingInterval = 1000 }; ms.

WinForms doesn't have a property for run this method. 

I mean how can we run it like subscription.Create();

 

picture example about subscription.Create(); how its running: 

exampleImage Enlarger

Thanks for your replies.

Avatar
Randy Armstrong
Admin
Forum Posts: 1123
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
12
11/11/2022 - 04:52
sp_Permalink sp_Print sp_EditHistory

I don't understand what the issue it.

Using WinForms has no impact on the OPC UA APIs that are available.

The only difference between a Console OPC UA client and a WinForms OPC UA client are mechanisms used to provide feedback to the user.

Questions about those user interface APIs are a .NET framework question rather than an OPC UA question.

Forum Timezone: America/Phoenix
Most Users Ever Online: 202
Currently Online:
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1165
Posts: 3807