惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
有赞技术团队
有赞技术团队
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
雷峰网
雷峰网
T
Tor Project blog
博客园_首页
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
V
Vulnerabilities – Threatpost
Project Zero
Project Zero
J
Java Code Geeks
AWS News Blog
AWS News Blog
Security Latest
Security Latest
Spread Privacy
Spread Privacy
T
Threatpost
博客园 - 三生石上(FineUI控件)
I
Intezer
G
Google Developers Blog
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Hacker News
The Hacker News
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
A
Arctic Wolf
F
Full Disclosure
P
Proofpoint News Feed
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
B
Blog
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
Know Your Adversary
Know Your Adversary

博客园 - 祥子哥哥

纪念一下我的20年的博客园。 推荐一个.Net的轻型RPC服务UcAsp.RPC Lucene.Net Kmeans++算是DONet实现 tinymce上传文件插件。 C#中图片处理中定义显示区域[或者可以称为蒙板效果] C#生成的图片如何设置DPI Jpg保存图片确认质量 Flex在子控件操作父窗口函数 Flex 不同 application 之间传参数(转) - 祥子哥哥 刚刚写的一个加密算法 如何在DropDownList第一項加入新項目 2003服务器中出现"请求的资源在使用中"错误的解决方法 如何在.Net中访问MySQL数据库 MS SQL日志清理代码 Server Application Error Javascript检测Flash插件是否安装及版本号 最近ASP.NET WAP开发的一些情况! 数据库备份
[转]OPC.Client for DA and UA 使用C#开发库UcAsp.OPC.Client使用案例
祥子哥哥 · 2017-09-21 · via 博客园 - 祥子哥哥

UCAsp.OPC是一个基于OPC基金会的库的支持DA和UA的OPC客户端C#的中间件,可以在不同的协议中轻松、透明地执行OPC Server操作。

UcAsp.Opc C#的客户端API共有15个,支持.Net 4.0~4.6;

一、如何连接一个OPC服务器:

DA:

 OpcClient client = new OpcClient(new Uri("opcda://127.0.0.1/Matrikon.OPC.Simulation.1"));

UA:

OpcClient client = new OpcClient(new Uri("opc.tcp://127.0.0.1:26543/Workstation.RobotServer"));
 

在使用中通过Url的Scheme区分是DA还UA,开发者不用需要关心UA还是DA;

二、如何读取对应节点的值:

string r = client.Read("Random.String");

三、如何写入一个节点的值:

 1 client.Write("Robot1.Axis1", 2.0090f); 

上面两个环节UA和DA没有差别

四、节点变化监听:

   该库采用的建立Group的方式监听组的变化情况,实现代码如下

 1 public void UAGroup()
 2         {
 3             OpcClient client = new OpcClient(new Uri("opc.tcp://127.0.0.1:26543/Workstation.RobotServer"));
 4             OpcGroup group = client.AddGroup("Test");
 5             client.AddItems("Test", new string[] { "Robot1.Axis1", "Robot1.Axis2" });
 6             group.DataChange += Group_DataChange;
 7             Console.WriteLine(group);
 8         }
 9 
10         private void Group_DataChange(object sender, System.Collections.Generic.List e)
11         {
12             foreach (OpcItemValue o in e)
13             {
14                 Console.WriteLine(o.Value);
15             }
16         }

 

如上图就是利用UcAsp.Opc制作的一个WWB SCADA的演示模型;

原文地址:http://www.ucasp.net/opc/opcda-opcua-Csharp.shtml