OPCUaClient 2.0.0
dotnet add package OPCUaClient --version 2.0.0
NuGet\Install-Package OPCUaClient -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OPCUaClient" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OPCUaClient --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OPCUaClient, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OPCUaClient as a Cake Addin #addin nuget:?package=OPCUaClient&version=2.0.0 // Install OPCUaClient as a Cake Tool #tool nuget:?package=OPCUaClient&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
OPCUaClient
Client for OPC UA Server
Build with
OPC UA Foundation library
Certificates
The certificates are in the same folder the application executable.
How to use
Install
dotnet add package OPCUaClient
Import
using OPCUaClient;
Create a instance
UaClient client = new UaClient("test", "opc.tcp://localhost:52240", true, true);
UaClient auth = new UaClient("test", "opc.tcp://localhost:52240", true, true, "admin", "password");
Create a session on the server
int timeOut = 30;
client.Connect(timeOut, true);
Close session
client.Disconnect();
Read a tag
Tag tag = client.Read("Device.Counter.OK");
//Or
tag = await client.Read("Device.Counter.OK");
Console.WriteLine($"Name: {tag.Name}");
Console.WriteLine($"Address: {tag.Address}");
Console.WriteLine($"Value: {tag.Value}");
Console.WriteLine($"Quality: {tag.Quality}");
Console.WriteLine($"Code: {tag.Code}");
int value = client.Read<int>("Device.Counter.Number");
value = await client.ReadAsync<int>("Device.Counter.Number");
Read multiple tags
var address = new List<String>
{
"Device.Counter.OK",
"Device.Counter.NG",
"Device.Counter.Model",
"Device.Counter.CycleTime"
}
var tags = client.Read(address);
//Or
tags await = client.ReadAsync(address);
foreach(var tag in tags)
{
Console.WriteLine($"Name: {tag.Name}");
Console.WriteLine($"Address: {tag.Address}");
Console.WriteLine($"Value: {tag.Value}");
Console.WriteLine($"Quality: {tag.Quality}");
Console.WriteLine($"Code: {tag.Code}");
}
Write a tag
client.Write("Device.Counter.Model", "NewModel");
//Or
await client.WriteAsync("Device.Counter.Model", "NewModel");
Write multiple tags
var tags = new List<Tag>
{
new Tag {
Address = "Device.Counter.OK",
Value = 0,
},
new Tag {
Address = "Device.Counter.NG",
Value = 0,
},
new Tag {
Address = "Device.Counter.Model",
Value = "OtherModel",
},
new Tag {
Address = "Device.Counter.CycleTime",
Value = 10,
},
}
client.Write(tags);
//Or
await client.WriteAsync(tags);
Monitoring a tag
client.Monitoring("Device.Counter.OK", 500, (_, e) => {
// Anything you need to be executed when the value changes
// Get the value of the tag being monitored
var monitored = (MonitoredItemNotification)e.NotificationValue;
Console.WriteLine(monitored.Value);
});
Scan OPC UA Server
var devices = client.Devices(true);
//Or
devices = await client.DevicesAsync(true);
foreach(var device in devices)
{
Console.WriteLine($"Name: {device.Name}");
Console.WriteLine($"Address: {device.Address}");
Console.WriteLine($"Groups: {device.Groups.Count()}");
Console.WriteLine($"Tags: {device.Tags.Count()}");
}
Scan group
var groups = client.Group("Device", true);
//Or
groups = await client.GroupAsync("Device", true);
foreach(var group in groups)
{
Console.WriteLine($"Name: {group.Name}");
Console.WriteLine($"Address: {group.Address}");
Console.WriteLine($"Groups: {group.Groups.Count()}");
Console.WriteLine($"Tags: {group.Tags.Count()}");
}
Scan an address and recovery the tags
var tags = client.Tags("Device.Counter");
//Or
tags = await client.TagsAsync("Device.Counter");
foreach(var tag in tags)
{
Console.WriteLine($"Name: {tag.Name}");
Console.WriteLine($"Address: {tag.Address}");
}
License
Icon for Freepik
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- OPCFoundation.NetStandard.Opc.Ua (>= 1.4.372.106)
- OPCFoundation.NetStandard.Opc.Ua.Client (>= 1.4.372.106)
- OPCFoundation.NetStandard.Opc.Ua.Configuration (>= 1.4.372.106)
- OPCFoundation.NetStandard.Opc.Ua.Core (>= 1.4.372.106)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OPCUaClient:
Package | Downloads |
---|---|
OPCUACoreClass.Net6.OPCLib
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Add new read function.
Add bugs to fix later.