发表于:2011-05-09 22:42:52
2楼
提供性能稳定,易开发,价格低廉的OPC开发套件,支持DA 1.0,2.0,3.0,包括服务器端和客户端开发包Ver3.8
OPC服务器端开发包下载地址:http://www.xdowns.com/soft/38/110/2011/Soft_72907.html
OPC客户端端开发包下载地址:http://www.oyksoft.com/soft/18132.html
OPC开发包详情:http://item.taobao.com/item.htm?id=9474686238
//OPC服务器端API部分接口定义
/// <summary>
/// 初始化系统运行参数和分配服务器资源
/// </summary>
/// <param name="lpCLSID_Svr">服务器标示,以NULL结尾</param>
/// <param name="uServerRate">服务器支持的客户端最快异步刷新速率</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall CreateServer(LPCSTR lpCLSID_Svr, unsigned long uServerRate);
/// <summary>
/// 释放服务器资源
/// </summary>
/// <returns>void</returns>
BmOpcDaSvr_API VOID __stdcall FreeServer();
/// <summary>
/// 构造服务器地址空间(标签列表的组织形式)
/// </summary>
/// <param name="hTag">父标签句柄,对于构造平面型地址空间(只有一层的地址空间),hTag=0;对于树型地址空间的第一层节点,hTag=0</param>
/// <param name="lpName">标签名称</param>
/// <param name="Value">标签的初始值,其中vt域所定义的数据类型被自动认为为该标签的标准数据类型,如果想修改改标签数据类型,请调用SetTagProperty函数</param>
/// <param name="wQuality">标签的初始数据质量</param>
/// <param name="AccessRight">访问权限,0-不能读写(例如树型空间的枝干节点),1-只读,2-只写,3-可读可写</param>
/// <returns>标签句柄</returns>
BmOpcDaSvr_API unsigned long __stdcall RegTag(unsigned long hTag,LPCSTR lpName,VARIANT Value,unsigned short wQuality,unsigned short AccessRight);
/// <summary>
/// 构造服务器地址空间(标签列表的组织形式)
/// 函数增加新节点,设置标签数据类型和初始化标签值(按照给定数据类型),设置数据质量=64(不确定)
/// </summary>
/// <param name="hTag">父标签句柄,对于构造平面型地址空间(只有一层的地址空间),hTag=0;对于树型地址空间的第一层节点,hTag=0</param>
/// <param name="lpName">标签名称</param>
/// <param name="wDatatype">标签的数据类型,3-Integer 4-Single 5-Double 8-String 11-Boolean</param>
/// <param name="AccessRight">访问权限,0-不能读写(例如树型空间的枝干节点),1-只读,2-只写,3-可读可写</param>
/// <returns>标签句柄</returns>
BmOpcDaSvr_API unsigned long __stdcall RegTagEx(unsigned long hTag,LPCSTR lpName,unsigned short wDatatype,unsigned short AccessRight);
/// <summary>
/// 删除标签,尽量避免调用此函数
/// </summary>
/// <param name="hTag">服务器标识</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall UnregTag(unsigned long hTag);
/// <summary>
/// 设置地址空间路径分隔符
/// </summary>
/// <param name="Qualifier">树型地址空间标签全路径分隔符,默认为‘.‘</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall SetTagQualifier(char Qualifier);
/// <summary>
/// 增加标签支持的属性
/// </summary>
/// <param name="hTag">标签句柄</param>
/// <param name="lpName">属性名称</param>
/// <param name="dwPropertyID">属性标识,默认支持6个属性,例如报警限、说明、条件等</param>
/// <param name="lpDescription">属性描述</param>
/// <param name="value">属性值</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall AddTagProperty(unsigned long hTag,LPCSTR lpName,unsigned long dwPropertyID,LPCSTR lpDescription,VARIANT value);
/// <summary>
/// 增加标签支持的属性
/// 属性值按照属性值数据类型进行初始化
/// </summary>
/// <param name="hTag">标签句柄</param>
/// <param name="lpName">属性名称</param>
/// <param name="dwPropertyID">属性标识,默认支持6个属性,例如报警限、说明、条件等</param>
/// <param name="lpDescription">属性描述</param>
/// <param name="wDataType">属性值数据类型</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall AddTagPropertyEx(unsigned long hTag,LPCSTR lpName,unsigned long dwPropertyID,LPCSTR lpDescription,unsigned short wDataType);
/// <summary>
/// 更新标签的属性值
/// </summary>
/// <param name="hTag">标签句柄</param>
/// <param name="dwPropertyID">属性标识</param>
/// <param name="Value">属性值</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall SetTagProperty(unsigned long hTag, unsigned long dwPropertyID, VARIANT Value);
/// <summary>
/// 更新标签的数据值和时间戳
/// </summary>
/// <param name="hTag">标签句柄</param>
/// <param name="Value">标签值</param>
/// <param name="wQuality">标签值质量</param>
/// <param name="TimeStamp">标签刷新时间</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall UpdateTagWithTimeStamp(unsigned long hTag , VARIANT Value,unsigned short wQuality,FILETIME TimeStamp);
/// <summary>
/// 更新标签的数据值
/// 标签的刷新时间按照OPC服务器时间设定
/// </summary>
/// <param name="hTag">标签句柄</param>
/// <param name="Value">标签值</param>
/// <param name="wQuality">标签值质量</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall UpdateTag(DWORD hTag, VARIANT Value,unsigned short wQuality);
/// <summary>
/// 设置工具包写节点的回调函数
/// </summary>
/// <param name="lpCallback">回调函数指针</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall SetWriteCallback(WRITECALLBACK lpCallback);
/// <summary>
/// 设置工具包写节点的回调函数,支持值之外的属性值回写
/// </summary>
/// <param name="lpCallback">回调函数指针</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaSvr_API BOOL __stdcall SetWriteCallbackEx(WRITECALLBACKEX lpCallback);
//OPC客户端API部分接口定义
/// <summary>
/// 初始化系统运行参数和分配资源,调用此函数初始化工具包参数,分配资源等。调用此函数后工具才能正常工作。
/// </summary>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_Init();
/// <summary>
/// 释放工具包占用的资源等
/// </summary>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_Uninit();
/// <summary>
/// 连接OPC服务器, 本机访问ComputerName 设为NULL即可
/// </summary>
/// <param name="ComputerName">主机名称或IP地址</param>
/// <param name="ServerClassID">服务器标识,是一个GUID</param>
/// <param name="Version">版本标志</param>
/// <returns>服务器连接句柄</returns>
BmOpcDaClt_API DWORD __stdcall BMDAC_Connect(LPCSTR ComputerName, LPCSTR ServerClassID, DWORD Version);
/// <summary>
/// 断开服务器连接
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_Disconnect(DWORD ServerHandle);
/// <summary>
/// 获取计算机上注册的OPC服务器
/// </summary>
/// <param name="ComputerName">主机名称或IP地址</param>
/// <param name="Version">服务器启动时间</param>
/// <param name="ServerNames">服务器当前时间</param>
/// <param name="ServerClassIDs">最后数据更新时间</param>
/// <returns>服务器数量</returns>
BmOpcDaClt_API DWORD __stdcall BMDAC_GetServers(LPCSTR ComputerName, DWORD Version, VARIANT* ServerNames, VARIANT* ServerClassIDs);
/// <summary>
/// 获取服务器的地址空间类型
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="NameSpace">服务器启动时间,OPC_NS_HIERARCHIAL=1;树型地址空间 OPC_NS_FLAT=2;平面型地址空间</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_GetNameSpace(DWORD ServerHandle,WORD* NameSpace);
/// <summary>
/// 移动当前浏览节点
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="Direction">移动方向,OPC_BROWSE_UP =1 移动到上级节点,忽略NodeName OPC_BROWSE_DOWN =2 移动到下级节点 OPC_BROWSE_TO =3 直接移动到某一个节点</param>
/// <param name="NodeName">节点名称</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_ChangeBrowsePosition(DWORD ServerHandle,WORD Direction,LPCSTR NodeName);
/// <summary>
/// 过滤检索节点
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="FilterType">节点类型过滤,1 枝节点, 2 叶节点</param>
/// <param name="FilterString">节点名称过滤</param>
/// <param name="FilterDataType">数据类型过滤</param>
/// <param name="FilterAccessRight">访问权限过滤, 0- 不能读写 1- 只读 2- 只写 3- 可读可写</param>
/// <param name="ItemNames">节点名称</param>
/// <returns>返回满足条件的节点个数</returns>
BmOpcDaClt_API DWORD __stdcall BMDAC_BrowseItems(DWORD ServerHandle,WORD FilterType,LPCSTR FilterString,WORD FilterDataType,WORD FilterAccessRight,VARIANT* ItemNames);
/// <summary>
/// 增加组
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="Name">标签全名</param>
/// <param name="Active">属性标识</param>
/// <param name="UpdateRate">属性值</param>
/// <param name="TimeBias">属性值</param>
/// <param name="DeadBand">属性值</param>
/// <param name="dsLCID">属性值</param>
/// <returns>组句柄</returns>
BmOpcDaClt_API DWORD __stdcall BMDAC_AddGroup(DWORD ServerHandle, LPCSTR Name, BOOL Active, DWORD UpdateRate, DWORD TimeBias,float DeadBand, DWORD dsLCID);
/// <summary>
/// 注册标签
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="GroupHandle">组句柄</param>
/// <param name="ItemFullName">标签全名</param>
/// <returns>标签句柄</returns>
BmOpcDaClt_API DWORD __stdcall BMDAC_AddItem(DWORD ServerHandle,DWORD GroupHandle,LPCSTR ItemFullName);
/// <summary>
/// 写入标签
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="GroupHandle">组句柄</param>
/// <param name="ItemHandle">标签句柄</param>
/// <param name="Value">写入值</param>
/// <param name="DoAsync">写入方式,true 异步写入 false 同步写入</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_WriteItem(DWORD ServerHandle,DWORD GroupHandle,DWORD ItemHandle,VARIANT Value, BOOL DoAsync);
/// <summary>
/// 读取标签
/// </summary>
/// <param name="ServerHandle">服务器连接句柄</param>
/// <param name="GroupHandle">组句柄</param>
/// <param name="ItemHandle">标签句柄</param>
/// <param name="Value">标签句柄</param>
/// <param name="pTimeStamp">标签句柄</param>
/// <param name="pQuality">标签句柄</param>
/// <returns>TRUE成功,FALSE失败</returns>
BmOpcDaClt_API BOOL __stdcall BMDAC_ReadItem(DWORD ServerHandle,DWORD GroupHandle,DWORD ItemHandle,VARIANT* Value, FILETIME* pTimeStamp,WORD* pQuality);