h-opc-net
1.0.0.100
dotnet add package h-opc-net --version 1.0.0.100
NuGet\Install-Package h-opc-net -Version 1.0.0.100
<PackageReference Include="h-opc-net" Version="1.0.0.100" />
paket add h-opc-net --version 1.0.0.100
#r "nuget: h-opc-net, 1.0.0.100"
// Install h-opc-net as a Cake Addin #addin nuget:?package=h-opc-net&version=1.0.0.100 // Install h-opc-net as a Cake Tool #tool nuget:?package=h-opc-net&version=1.0.0.100
h-opc-net
An Opc Library and a command line to perform OPC operations with ease and transparency among different protocols. Currently supports synchronous operation over UA and DA protocols. This fork is a netstandard2.0 port with minor improvements, will see if furthur maintenance will be carried out.
Table of Contents
Use
To install h-Opc-net
, run the following command in the Package Manager Console:
PM> Install-Package h-opc-net
To install the command line interface, head to the nuget gallery
.
Documentation
to use the UA Client simply...
using (var client = new UaClient(new Uri("opc.tcp://host-url")))
{
client.Connect();
// Use `client` here
}
or with options...
var options = new UaClientOptions {
UserIdentity = new Opc.Ua.UserIdentity("<your-username>", "<your-password>")
};
using (var client = new UaClient(new Uri("opc.tcp://host-url")), options)
{
client.Connect();
// Use `client` here
}
and to use the DA Client instead:
using (var client = new DaClient(new Uri("opcda://host-url")))
{
client.Connect();
// Use `client` here
}
Exploring the nodes
You can get a reference to a node with...
var node = client.FindNode("path.to.my.node");
This will get you a reference to the node node
in the folder path.to.my
.
You can use the node reference to explore the hieriarchy of nodes with the properties Parent
and SubNodes
. For example...
Node parentNode = node.Parent;
IEnumerable<Node> children = client.ExploreFolder(node.Tag);
IENumerable<Node> grandChildren = children.SelectMany(m => client.ExploreFolder(m.Tag));
Read a node
Reading a variable? As simple as...
var myString = client.Read<string>("path.to.string").Value;
var myInt = client.Read<int>("path.to.num").Value;
The example above will read a string from the tags string
and num
in the folder path.to
Writing to a node
To write a value just...
client.Write("path.to.string", "My new value");
client.Write("path.to.num", 42);
Monitoring a tag
Dead-simple monitoring:
client.Monitor<string>("path.to.string", (readEvent, unsubscribe) =>
{
DoSomethingWithYourValue(readEvent.Value);
if(ThatsEnough == true)
unsubscribe();
});
The second parameter is an Action<T, Action>
that has two parameter:
readEvent
contains all the information relevant to the event such as timestamps, quality and the valueunsubscribe
is a function that unsubscribes the current monitored item. It's very handy when you want to terminate your callback
it's important that you either enclose the client into a using
statement or call Dispose()
when you are finished, to unsubscribe all the monitored items and terminate the connection!
Go Asynchronous!
Each method as an asynchornous counterpart that can be used with the async/await syntax. The asynchronous syntax is recommended over the synchronous one (maybe the synchronous one will be deprecated one day).
Command line
You can also use the command line interface project to quickly test your an OPC. Build the h-opc-cli
project or download it from the release
page of this repository, then run:
h-opc-cli.exe [OpcType] [server-url]
Where OpcType
is the type of opc to use (e.g: "UA", "DA"). Once the project is running, you can use the internal command to manipulate the variable. To have more information aboute the internal commands, type help
or ?
Roadmap
- ...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- OPCFoundation.NetStandard.Opc.Ua.Client (>= 1.5.374.126)
- Quick.OpcNetApi (>= 2.1.108)
- Quick.OpcNetApi.Com (>= 2.1.108)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0.100 | 3 | 1/9/2025 |
1.0.0 | 125 | 11/11/2024 |
1.0.0-alpha | 95 | 11/11/2024 |
Upgrade to netstandard2.0;
Minor changes and corrections to original OpcClient;