前段时间做一个实时数据的采集工作实时数据来自监控系统监控系统有西门子的winccABB公司等OPC是监控领域中最适合的数据集成方法查了很多资料都是VBVC等的编程资料基本找不到关于PB的OPC编程资料现在把它整理出来供大家参考
先从网上下载OPCDAEXE安装起来然后从网上找个OPC控件包(有DACLTSDKdllDACLTSDK_ActiveXocxOPC_AEPSDLLopccomn_psdllopchda_psdll
OPCPROXYDLLOpcRcwComndll)拷贝到%WINDIR%/System文件夹下然后执行命令注册
REGSVR /s %WINDIR%/System/opccomn_psdll
REGSVR /s %WINDIR%/System/opcproxydll
REGSVR /s %WINDIR%/System/opc_aepsdll
REGSVR /s %WINDIR%/System/opchda_psdll
REGSVR /s %WINDIR%/System/OpcRcwComndll
regsvr /s %WINDIR%/System/DACLTSDK_ActiveXocx
%WINDIR%/Opcenum /RegServer
在PB中创建一个opc控件名字为ole_初始化
TRY
if ole_objectConnect(hostserverid) then
try
if ole_objectAddgroup(GROUPupdateRate) then
return true
else
return false
end if
CATCH ( runtimeerror erAddgroup)
return false
END TRY
else
return false
end if
CATCH (runtimeerror erConnect)
return false
END TRY
然后加标签
TRY
IHandle=ole_objectAddItem(itemname)
if IHandle> then
return IHandle
else
return
end if
取值
Value=ole_objectreadItem(IHandle)
编辑推荐
ASP NET开发培训视频教程
Microsoft NET框架程序设计视频教程