通过本OPC Server程序接口可为用户提供以OPC标准接口访问远程GPRS/3G/以太网 RTU设备实时数据的方式。从而方便实现GPRS/3G/以太网 RTU设备与组态软件或DCS系统的对接。本程序提供源码,您只需几分钟即可让您的设备具有OPC 服务器接口。

GPRS RTU设备OPC Server接口C# 实现

通过本OPC Server程序可实现以TCP/UDP方式接收远程GPRS/3G/以太网 RTU设备的数据包,经对数据包进行解析处理后,向用户提供以OPC标准接口访问远程RTU设备实时数据的方式。

本程序支持OPC基金会指定的OPC数据规范1.0/2.0/3.0标准,可与国际主流组态软件或DCS系统对接,并支持将OPC客户端(组态软件或DCS系统)设置数据转发到远程GPRS/3G/以太网 RTU设备,实现对远端设备或系统的开关量或模拟量进行控制。

 GPRS RTU设备OPC Server接口C# 实现

GPRS RTU设备OPC Server接口C# 实现

GPRS RTU设备OPC Server接口C# 实现 

源码说明:https://item.taobao.com/item.htm?spm=686.1000925.0.0.wcBmvC&id=541464325986

OPC Server 接口开发

(1)注册OPC服务器

OPCSvrHelper.RegisterOPCSrv(string path,string UUID,

string OPCServerName)

此函数为静态函数,只注册一次即可,不用每次启动软件都注册。

参数含义如下:

l        path – 为本exe的路径

l        UUID – OPC服务器的唯一识别码,可自行设定

l        OPCServerName – OPC服务器的名称

(2)启动OPC服务器

InitOPCServer(string UUID)

 

(3)创建OPC 组及OPC Tag

CreateTag(string groupName,string tagName,object defaultVal,bool isWriteable)

 

l        groupName – OPC组名

l        tagName – OPC Tag名

l        defaultVal – OPC Tag的默认值

l        isWriteable – 是否可写

 

(4)更新OPC Tag的值

UpDateTagVal(string groupName,string tagName,object val)

本函数可以实现对指定组名和Tag的值进行更新

l        groupName – OPC组名

l        tagName – OPC Tag名

l        val – 更新的值

注意:若指定的groupName和tagName不存在,则会触发异常

(5)注销OPC服务器

OPCSvrHelper.UnRegisterOPCSrv(UUID, string OPCServerName)

静态函数

l        UUID – OPC服务器的唯一识别码,可自行设定

l        OPCServerName – OPC服务器的名称

 

(6)读取OPC Tag值

object ReadTag(string groupName,string tagName)

l        groupName – OPC组名

l        tagName – OPC Tag名

返回:object类型的值

注意:若指定的groupName和tagName不存在,则会触发异常

 

7)删除OPC Tag

RemvoeTag(string groupName,string tagName)

l        groupName – OPC组名

l        tagName – OPC Tag名

8)客户端写Tag值更新事件

事件名:TagWritedByClientEvt

事件原型:

delegate void TagWritedByClientDelegate(string TagName, Object Value, UInt32 ResultCode)

TagName -- OPC组名.OPCTag名

Value – 更新的值

ResultCode – 信号质量

相关文章:

  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2022-01-26
  • 2022-12-23
  • 2021-06-20
  • 2021-10-29
  • 2021-12-28
  • 2022-01-05
相关资源
相似解决方案