• OPC客户端设计


    1. 开发环境配置

      要安装和开发OPC程序,安装必要的OPC代理/存根(Proxy/Stub)DLL是必需的,这些文件提供了OPC接口的数据结构定义,可以使OPC客户端程序和服务器程序之间进行有效的通信。

      所有文件必须安装在客户端机器和服务器端机器上。要将这些文件放置在system32系统文件夹下。

    需要文件:

      这些文件包括:

      opc_aeps.dll    //警报与时间服务器代理/存根

      opccomn_ps.dll   //公用的代理/存根(主要服务器都需要)

      opchda_ps.dll   //历史数据存取代理/存根

      aprxdist.exe     //运行环境需要

      opcenum.exe      //服务器类别搜索组建程序(都需要),如果没有,就无法在注册表中进行注册

    安装方法:

      将上述文件全部复制到windows\system32目录下。

      安装代理/存根:

        REGSVR32 opcproxy.dll

        REGSVR32 opccomn_ps.dll

        REGSVR32 opc_aeps.dll

        REGSVR32 opchda_ps.dll

      安装opcenum.exe

        opcenum /regserver

     

    //CComPtr: Smart pointer

    CComPtr<IOPCServerList> pOPCServerList;

    //Creates a single uninitialized object of the class associated with a specified CLSID.
    hr = pOPCServerList.CoCreateInstance( CLSID_OpcServerList );

    //A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.

    //to register, you need to run opcenum.exe

    if(REGDB_E_CLASSNOTREG == hr)
      return FALSE;

    if( FAILED( hr ) )
      return FALSE;

    The return value of function CoCreateInstance:
     
    ValueDescription

    S_OK

    An instance of the specified object class was successfully created.

    REGDB_E_CLASSNOTREG

    A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt.

    CLASS_E_NOAGGREGATION

    This class cannot be created as part of an aggregate.

  • 相关阅读:
    浅拷贝和深拷贝
    squeezenet
    7常用函数
    6表的约束
    5select的运用
    4操作符
    3基本数据操作
    2基本数据类型
    1mysql的安装
    16多态
  • 原文地址:https://www.cnblogs.com/johnpher/p/2720218.html
Copyright © 2020-2023  润新知