hongmao.HmExtension.Opc 1.0.5

dotnet add package hongmao.HmExtension.Opc --version 1.0.5                
NuGet\Install-Package hongmao.HmExtension.Opc -Version 1.0.5                
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="hongmao.HmExtension.Opc" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add hongmao.HmExtension.Opc --version 1.0.5                
#r "nuget: hongmao.HmExtension.Opc, 1.0.5"                
#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 hongmao.HmExtension.Opc as a Cake Addin
#addin nuget:?package=hongmao.HmExtension.Opc&version=1.0.5

// Install hongmao.HmExtension.Opc as a Cake Tool
#tool nuget:?package=hongmao.HmExtension.Opc&version=1.0.5                

简介

本项目旨在简化OPC的使用,提供了一个简单的API,使得用户可以通过简单的代码实现OPC的读写操作。

使用方法

1. 安装依赖

dotnet add package hongmao.HmExtension.Opc

2. 创建OPC客户端

var client = HmOpcClientFactory.CreateOpcDaClient();

3. 获取OPC服务器列表

var servers = client.GetServers(); // 获取本地OPC服务器列表
// var servers = client.GetServers("127.0.0.1")

4. 连接OPC服务器

client.Host = "127.0.0.1";
client.ServerName = "Kepware.KEPServerEX.V6";
client.Connect();

5. 浏览节点数据

var nodes = client.Browses(); // 浏览节点列表
var treeNodes = client.BrowseTrees(); // 浏览节点树
var node = client.GetOpcNode("Channel1.Device1.Tag1"); // 获取节点信息

6. 读取数据

var node = client.GetOpcNode("Channel1.Device1.Tag1"); // 获取节点信息
var value = client.ReadValue(node); // 读取节点数据

7. 写入数据

var node = client.GetOpcNode("Channel1.Device1.Tag1"); // 获取节点信息
client.WriteValue(100); // 写入节点数据

8. 监听数据变化

var node = client.GetOpcNode("Channel1.Device1.Tag1"); // 获取节点信息
client.OnDataChange += (groupName,oldValue,newValue)=>{
	Console.WriteLine($"数据变化:{groupName} {oldValue} -> {newValue}");
}

9. 断开连接

client.Disconnect();
Product 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  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 tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5 104 10/17/2024
1.0.3 110 9/4/2024
1.0.2 127 8/21/2024
1.0.1 122 8/21/2024
1.0.0 130 8/20/2024

兼容 .Net Standard 2.1