接下来的这一节,我们将讨论 OPC Serve 的重点,也就是每一组接口的定义,以及它所提供的功能。
OPCServer 提供的接口:
IOPCCommon
HRESULT SetLocaleID ( dwLcid ) 设定位置信息
HRESULT GetLocaleID ( pdwLcid ) 取得位置信息
HRESULT QueryAvailableLocaleIDs ( pdwCount, pdwLcid ) 查询可用的位置ID
HRESULT GetErrorString ( dwError, ppString) 取得
错误信息字符串
HRESULT SetClientName (szName)设定Clinet的名称
IOPCServer
HRESULT AddGroup(szName, bActive, dwRequestedUpdateRate, hClientGroup, pTimeBias, pPercentDeadband, dwLCID, phServerGroup, pRevisedUpdateRate, riid, ppUnk) 新增一个
OPCGroup
HRESULT GetErrorString(dwError, dwLocale, ppString) 取得
错误信息字符串
HRESULT GetGroupByName(szName, riid, ppUnk) 依据名称取得
OPCGroup的介面
HRESULT GetStatus(ppServerStatus) 取得 OPCServer的状态信息
HRESULT SetClientName (szName)设定Clinet的名称RemoveGroup(hServerGroup, bForce)移除一个
OPCGroup
HRESULT CreateGroupEnumerator(dwScope, riid, ppUnk) 产生一个
OPCGroup列举器
IConnectionPointContainer
HRESULT EnumConnectionPoints( IEnumConnectionPoints ppEnum) 列举所有的 Connection Points
HRESULT FindConnectionPoint( REFIID riid, IConnectionPoint ppCP)找出一个 Connection Point
HRESULT QueryAvailableProperties(szItemID, pdwCount,ppPropertyIDs, ppDescriptions, ppvtDataTypes ); 查询可用的
OPCItem属性
HRESULT GetItemProperties (szItemID, dwCount, pdwPropertyIDs,ppvData, ppErrors ) 取得
OPCItem的属性
HRESULT LookupItemIDs( szItemID, dwCount, pdwPropertyIDs,ppszNewItemIDs, ppErrors )使用名称查询
OPCItem的 ID
IOPCBrowseServerAddressSpace (optional)
HRESULT QueryOrganization(pNameSpaceType )查询组织名称
HRESULT ChangeBrowsePosition(dwBrowseDirection, szString )变更浏览的位置
HRESULT Browse
OPCItemIDs( dwBrowseFilterType, szFilterCriteria, vtDataTypeFilter, dwAccessRightsFilter, ppIEnumString )浏览 OPCServer 内所有定义的
OPCItem
HRESULT GetItemID( szItemDataID, szItemID ) 取得
OPCItem的 ID
HRESULT BrowseAccessPaths( szItemID, ppIEnumString )浏览存取
OPCItem的路径
HRESULT GetState(pUpdateRate, pActive, ppName, pTimeBias, pPercentDeadband, pLCID, phClientGroup, phServerGroup)取得
OPCGroup的状态即设定信息
HRESULT SetState(pRequestedUpdateRate, pRevisedUpdateRate, pActive, pTimeBias, pPercentDeadband, pLCID, phClientGroup)设定
OPCGroup的状态信息
HRESULT CloneGroup(szName, riid, ppUnk) 复制一个
OPCGroup
IOPCSyncIO
HRESULT Read(dwSource, dwCount, phServer, ppItemValues, ppErrors); 以同步方式读取
OPCGroup内的
OPCItem(s) 的值
HRESULT GetItemProperties (szItemID, dwCount, pdwPropertyIDs,ppvData, ppErrors ) 取得
OPCItem的属性
HRESULT Write(dwCount, phServer, pItemValues, ppErrors) 以同步方式将值写入
OPCGroup内的
OPCItem(s)
IOPCAsyncIO2
HRESULT Read(dwCount, phServer, dwTransactionID, pdwCancelID, ppErrors,) 以非同步方式读取
OPCGroup内的
OPCItem(s)的值,值会在读取硬件的动作结束后以callback的形式传回
HRESULT SetState(pRequestedUpdateRate, pRevisedUpdateRate, pActive, pTimeBias, pPercentDeadband, pLCID, phClientGroup)设定
OPCGroup的状态信息
HRESULT Write(dwCount, phServer, pItemValues, dwTransactionID, pdwCancelID, ppErrors)以非同步方式将值写入OPCGroup内的
OPCItem(s)
HRESULT Cancel2 (dwCancelID) 取消前一次的非同步读取/写入
HRESULT Refresh2(dwSource, dwTransactionID, pdwCancelID) 更新
OPCGroup内 OPCItem(s) 的值
HRESULT SetEnable(bEnable) 将
OPCGroup设为 Enable
HRESULT GetEnable(pbEnable) 传回
OPCGroup是否为 Enable
IOPCItemMgt
HRESULT AddItems(dwCount, pItemArray, ppAddResults, ppErrors); 在
OPCGroup内新增OPCItem(s)
HRESULT ValidateItems(dwCount, pItemArray, bBlobUpdate, ppValidationResults, ppErrors)检查
OPCItem(s)的名称是否可用
HRESULT SetActiveState(dwCount, phServer, bActive, ppErrors)高定
OPCItem(s)是否为Avtive
HRESULT SetClientHandles(dwCount, phServer, phClient, ppErrors)设定
OPCItem(s) 的 handle
HRESULT SetDatatypes(dwCount, phServer, pRequestedDatatypes, ppErrors) 设定OPCItem(s)的
数据类型
HRESULT CreateEnumerator(riid, ppUnk)产生OPCItems的列举器
IConnectionPointContainer
HRESULT EnumConnectionPoints( IEnumConnectionPoints ppEnum)列举所有的 Connection Points
HRESULT FindConnectionPoint( REFIID riid, IConnectionPoint ppCP)找出一个Connection Point