OPCclient在VC環(huán)境下編程_第1頁(yè)
OPCclient在VC環(huán)境下編程_第2頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余20頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、OPC client在VC環(huán)境下編程一( 連接使用到變量的說(shuō)明類型 說(shuō)明HRESULT 函數(shù)返回值, 用來(lái)檢測(cè)函數(shù)返回值(如:初始化 COM 庫(kù), 查找 CLSID,創(chuàng) 建 OPCK務(wù)等),提供函數(shù)執(zhí)行情況CLSID 全球唯一標(biāo)示符,用來(lái)確定 OPCK務(wù)的標(biāo)識(shí),從注冊(cè)表查找獲得LPWSTR LPST 和 LPWST 是 Win32 和 VC+所使用的一種字符串?dāng)?shù)據(jù)類型。LPSTF 被定義成是一個(gè)指向以 NULL 0)結(jié)尾的 8 位 ANSI 字符數(shù)組指針,而 LPWST 是一個(gè)指向以NULL 結(jié)尾的 16 位雙字節(jié)字符數(shù)組指針OPC 接口說(shuō)明IOPCServer *m_IOPCServer;I

2、OPCServer 接口及成員函數(shù)主要用于對(duì)組對(duì)象進(jìn)行創(chuàng)建 , 刪除,枚 舉和獲取當(dāng) 前狀態(tài)等操作 . 是OPC 服務(wù)器對(duì)象的主要接口 接口及成員IOPCItemMgt *m_IOPCItemMgt;lOPCItemMgt 接口及成員函數(shù)用于 OPC 客戶程序添加、刪除 和組對(duì)象中組員等控制操作。IOPCSyncIO *m_IOPCSyncIO;IOPCSyncIO 用于同步數(shù)據(jù)訪問(wèn)。OPCITEMDEF m_Items1;OPCITEMDE 數(shù)組,包含著項(xiàng)的存取路徑,定義和被請(qǐng)求的數(shù)據(jù)類OPCITEMRESULT *m_ItemResult;OPCITEMRESU數(shù)組, 服務(wù)器用來(lái)告訴客戶關(guān)

3、于項(xiàng)的附加的信息(項(xiàng)句柄和規(guī) 范的數(shù)據(jù)類型 )OPCHANDLE m_GrpSrvHandle;OPCI艮務(wù)的句柄,在多個(gè)函數(shù)中都會(huì)用到使用到的函數(shù)說(shuō)明CoInitialize(NULL);初始化 COM 庫(kù)CoInitialize是 Windows 提供的 API 函數(shù),用來(lái)告訴 Windows 以單線程的方式創(chuàng)建 com 對(duì)象。應(yīng)用程序調(diào)用 com 庫(kù)函數(shù)(除 CoGetMalloc 和內(nèi)存分配函數(shù))之前 必須初始化com 庫(kù)。返回值 S_OK :該線程中 COM 庫(kù)初始化成功 S_FALSE 該線程中 COM 庫(kù)已經(jīng)被初 始化CoInitialize ()標(biāo)明以單線程方式創(chuàng)建。使用 Co

4、Initialize創(chuàng)建可以使對(duì)象直接與線程連接,得到最高的性能。CoInitialize并不裝載 COM 庫(kù),它只用來(lái)初始化當(dāng)前線程使用什么樣的套間。使用這個(gè)函數(shù)后,線程就和一個(gè)套間建立了對(duì)應(yīng)關(guān)系。線程的套間模式?jīng)Q定了 該線程如何調(diào)用 COM 寸象,是否需要列集等。CoInitialize () 并不會(huì)干擾客戶和服務(wù)器之間的通信,它所做的事情是讓線 程注冊(cè)一個(gè)套間,而線程運(yùn)行過(guò)程中必然在此套間。CoInitialize 和 CoUninitialize 必須成對(duì)使用查找 OPCI 艮務(wù)CLSIDFromProglD(LOPQ 艮務(wù)的名稱,&clsid);通過(guò) ProgID, 查找注冊(cè)

5、表中的相關(guān) CLSID參數(shù):1. 服務(wù)的名稱2. CLSID 型變量,用來(lái)接收注冊(cè)表中查找到的 CLSID創(chuàng)建 OPC 服務(wù)器對(duì)象CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER ,IID_IOPCServer,(void*)&m_IOPCServer);創(chuàng)建 OPC 服務(wù)器對(duì)象,并查詢對(duì)象的 IID_IOPCServer 接口參數(shù):1. CLSID 型變量,使用 CLSIDFromProgID 函數(shù)查找到的 CLSID2.3.函數(shù)功能描述:用指定的類標(biāo)識(shí)符創(chuàng)建一個(gè) Com 對(duì)象,用指定的類標(biāo)識(shí)符創(chuàng)建一 個(gè)未初始化的對(duì)象。當(dāng)在本機(jī)中只

6、創(chuàng)建一個(gè)對(duì)象時(shí),可以調(diào)用 CoCreateInstance; 在遠(yuǎn)程系統(tǒng)中創(chuàng)建一個(gè)對(duì)象時(shí),可以調(diào)用 CoCreateInstanceEx;創(chuàng)建多個(gè)同一 CLSID 的對(duì)象時(shí),可以參考 CoGetClassObject 函數(shù)。函數(shù)原形:STDAPI CoCreateInstance(REFCLSID rclsid, / 創(chuàng)建的 Com 對(duì)象的類標(biāo)識(shí)符(CLSID)LPUNKNOWN pUnkOuter,指向接口 IUnknown 的指針DWORD dwClsContext, / 運(yùn)行可執(zhí)行代碼的上下文REFIID riid, / 創(chuàng)建的 Com 對(duì)象的接口標(biāo)識(shí)符LPVOID * ppv /用來(lái)接

7、收指向 Com 對(duì)象接口地址的指針變量);參數(shù):rclsidin用來(lái)唯一標(biāo)識(shí)一個(gè)對(duì)象的 CLSID(128 位),需要用它來(lái)創(chuàng)建指定對(duì)象。pUnkOuterin 如果為 NULL, 表明此對(duì)象不是聚合式對(duì)象一部分。如果不是 NULL, 則指 針指向一個(gè)聚合式對(duì)象的 IUnknown 接口。dwClsContextin 組件類別.可使用 CLSCT 敕舉器中預(yù)定義的值.riidin 引用接口標(biāo)識(shí)符 , 用來(lái)與對(duì)象通信。ppvout 用來(lái)接收指向接口地址的指針變量。如果函數(shù)調(diào)用成功 ,*ppv 包括請(qǐng)求 的接口指針。返回值:S_OK指定的 Com 對(duì)象實(shí)例被成功創(chuàng)建。REGDB_E_CLASSNO

8、TREG指定的類沒(méi)有在注冊(cè)表中注冊(cè) . 也可能是指定的 dwClsContext 沒(méi)有注冊(cè)或注 冊(cè)表中的服務(wù)器類型損壞CLASS_E_NOAGGREGATION 這個(gè)類不能創(chuàng)建為聚合型。E_NOINTERFACE指定的類沒(méi)有實(shí)現(xiàn)請(qǐng)求的接口,或者是 IUnknown 接口沒(méi)有暴露請(qǐng)求的接口 .注釋:CoCreatelnstanee 幫助者函數(shù)通過(guò)使用對(duì)象的 CLSID,提供了一種便潔的方式 與類對(duì)象連接 ,創(chuàng)建未初始化的實(shí)例 , 以及釋放類對(duì)象。它封裝了以下的功能 :CoGetClassObjeet(relsid, dwClsContext, NULL, IID_IClassFaetory,&a

9、mp;pCF);hresult = pCF-CreateInstance(pUnkOuter, riid, ppvObj);pCF-Release();當(dāng)在本機(jī)中只創(chuàng)建一個(gè)對(duì)象時(shí),調(diào)用 CoCreateInstance 是最方便的 ; 如果要在 遠(yuǎn)程系統(tǒng)中創(chuàng)建一個(gè)對(duì)象時(shí),可以調(diào)用 CoCreateInstanceEx; 創(chuàng)建多個(gè)同一 CLSID 的對(duì)象時(shí) , 可以參考CoGetClassObject 函數(shù);如果創(chuàng)建多個(gè)對(duì)象實(shí)例 , 可以獲得類 對(duì)象的 IClassFactory 接口指針,并使用需要的方法 , 可以使用 CoGetClassObject 函數(shù)。在 CLSCT 救舉器中,你可以指

10、定用來(lái)管理對(duì)象的服務(wù)器類型.這些常量可以是CLSCTX_INPROC_SERVER, CLSCTX_INPROC_HANDLER, CLSCTX_LOCAL_SERVER或是它們的任何組合.常量 CLSCTX_AL 被定義為這三個(gè)值的組合.想獲得更 多的有關(guān)這些常量的用法 , 請(qǐng)參考 CLSCTX.添加組到 OPC 服務(wù)器m_IOPCServer-AddGroup(Lgrp1, / in 組名TRUE, / in 活動(dòng)狀態(tài)500, / in 向服務(wù)器發(fā)送請(qǐng)求的刷新率1, / in 客戶端的操作句柄&TimeBias, / in 與標(biāo)準(zhǔn)時(shí)間的校正值&PercentDeadband

11、, / in 要舍棄的數(shù)據(jù)LOCALE_ID, / in 服務(wù)器使用的語(yǔ)言&m_GrpSrvHandle, / out 添加組以后服務(wù)器返回的組句柄&RevisedUpdateRate, / out 服務(wù)器的數(shù)據(jù)刷新率IID_IOPCItemMgt, / in 添加組的接口類型(LPUNKNOWN*)&m_IOPCItemMgt); / out 服務(wù)器返回的接口對(duì)象指針AddGroup 函數(shù)的說(shuō)明HRESULT AddGroup(in, string LPCWSTR szName,in BOOL bActive,in DWORD dwRequestedUpdateRat

12、e,in OPCHANDLE hClientGroup,unique, in LONG *pTimeBias,in FLOAT * pPercentDeadband,in DWORD dwLCID,out OPCHANDLE * phServerGroup,out DWORD *pRevisedUpdateRate,in REFIID riid,out, iid_is(riid) LPUNKNOWN * ppUnk);Parameters DescriptionszName Name of the group. The name must be unique among the other g

13、roups created bythis client. If no name is provided (szName is pointer to a NUL string) the server will generatea unique name. The server generated name will also be unique relative to any existing publicgroups. bActive FALSE if the Group is to be created as inactive.TRUE if the Group is to be creat

14、ed as active.dwRequestedUpdateRate Client Specifies the fastest rate at which data changesmay be sent to OnDataChange for items in this group.This also indicates the desired accuracy of Cached Data.This is intended only to control the behavior of the interface. How the server deals with theupdate ra

15、te and how often it actually polls the hardware internally is an implementation detail.Passing 0 indicates the server should use the fastest practical rate. The rate is specified inmilliseconds.hClientGroup Client provided handle for this group. refer to descriptionof data types, parameters, and str

16、uctures for moreinformation about this parameterpTimeBias Pointer to Long containing the initial TimeBias (in minutes) for the Group. Pass aNULL Pointer if you wish the group to use the default system TimeBias. See discussion ofTimeBias in General Properties Section See Comments below.pPercentDeadba

17、nd The percent change in an item value that will cause asubscription callback for that value to a client. This parameter only applies to items in thegroup that have dwEUType of Analog. See discussion of PercentDeadband in General Properties Section. A NULLpointer is equivalent to 0.0.dwLCID The lang

18、uage to be used by the server when returning values (including EUenumeration s) as textforoperations on this group. This could also include such things as alarm or status conditions ordigital contact states.phServerGroup Place to store the unique server generated handle to thenewly created group. Th

19、e client will use the serverprovided handle for many of the subsequent functions that the client requests the server toperform on the group. pRevisedUpdateRate The server returns the value it will actually use fortheUpdateRate which may differ from theRequestedUpdateRate.Note that this may also be s

20、lower than the rate at which the server is internally obtaining thedata and updating the cache.In general the server shouldround up the requested rateto the next available supported rate. The rate is specified in milliseconds. Server returnsHRESULT ofOPC_S_UNSUPPORTEDRATE when it returns a valuein r

21、evisedUpdateRate that is different thanRequestedUpdateRate.riid The type of interface desired (e.g. IID_IOPCItemMgt) ppUnk Where to store the returnedinterface pointer. NULL is returned for any FAILED HRESULT.添加項(xiàng)目 m_IOPCItemMgt-AddItems(1, / in 添加 1 個(gè) item m_Items, / in 添加的 item 的指針 &m_ItemResul

22、t, / out 添加 item 的結(jié)果 &m_pErrors); / out 發(fā)生的錯(cuò)誤 m_Items 的說(shuō)明定義:OPCITEMDEF mtems1;這個(gè)參數(shù)為 OPCITEMDE 結(jié)構(gòu),包含著項(xiàng)的存取路徑,定義和被請(qǐng)求的數(shù)據(jù)類 AddItems 函數(shù)說(shuō)明HRESULT AddItems( in DWORD dwCount,in, size_is(dwCount) OPCITEMDEF * pItemArray,out, size_is(,dwCount) OPCITEMRESULT * ppAddResults,out, size_is(,dwCount) HRESULT *

23、ppErrors);Parameters Description dwCount The number of items to be addedpItemArray Array of OPCITEMDEFs. These tell the servereverything it needs to know about the item including the access path, definition andrequested datatype ppAddResults Array of OPCITEMRESULTs. This tells the client additionali

24、nformation about the item including the server assigned item handle and the canonical datatype.ppErrors Array of HRESULTs. This tells the client which of the items was successfully added.For any item which failed it provides a reason.OPCITEMDE 結(jié)構(gòu)說(shuō)明typedef struct string LPWSTR szAccessPath; /OPC 服務(wù)器存

25、取路徑string LPWSTR szItemID; /item 的名稱 BOOL bActive ; / 活動(dòng)狀態(tài)OPCHANDLE hClient; / 操作句柄 DWORD dwBlobSize; /item 的 pBlob 大小size_is(dwBlobSize) BYTE * pBlob; / 二進(jìn)制指針 VARTYPE vtRequestedDataType; / 數(shù)據(jù)類型由客戶端請(qǐng)求 WORD wReserved; / 保留字 OPCITEMDEF;Member Used by DescriptionszAccessPath both The access path the s

26、erver should associate with this item. Byconvention a pointer to a NUL string specifies that the server should select the access path.Support for accesspath is optionalNOTE: version 1 indicated that a NULL pointer would allow the server to pick the pathhowever passing a NULL pointer will cause a fau

27、lt in the proxy/stub code and thus is notallowed.szItemID both A null-terminated string that uniquely identifies the OPC data item. See theItem ID discussion and the AddItems function for specific information about the contents ofthis field.bActive add This Boolean value a ffects the behavior variou

28、s methods as describedelsewhere in this specification.hClient add The handle the client wishes to associate with the item. See the OPCHANDLE formore specific information about the contents of this field.dwBlobSize both The size of the pBlob for this item. pBlob both pBlob is a pointer to the Blob.vt

29、RequestedDataType both The data type requested by the client. An error isreturned (See Additems or ValidateItems) if the server cannot provide the item in this format.Passing VT_EMPTY means the client will accept the servers canonical datatype. 查詢同步接口m_IOPCItemMgt-QueryInterface(IID_IOPCSyncIO, (voi

30、d*)&m_IOPCSyncIO);參數(shù):1. IID_IOPCSyncIO 同步接口2. 服務(wù)器返回的用于操作同步接口的指針。同步接口讀取數(shù)據(jù)m_IOPCSyncIO-Read(OPC_DS_DEVICE, 1, phServer, &pItemValue,&pErrors);參數(shù):1(0PC_DS_DEVIC 從 OPC 設(shè)備讀取 另一個(gè)選擇是 OPC_DS_CAC 從爰存讀取2( 讀取的數(shù)量3( 這個(gè) item 的服務(wù)句柄返回值的 OPCITEMSTATE 構(gòu)數(shù)值指針 4(5( 返回的錯(cuò)誤指針HRESULT Read(in OPCDATASOURCE dwSour

31、ce,in DWORD dwCount,in, size_is(dwCount) OPCHANDLE * phServer,out, size_is(,dwCount) OPCITEMSTATE * ppItemValues,out, size_is(,dwCount) HRESULT * ppErrors);Parameters DescriptiondwSource The data source ; OPC_DS_CACHE orOPC_DS_DEVICEdwCount The number of items to be read.phServer The list of server

32、item handles for the items to be readppItemValues Array of structures in which the item values are returned.ppErrors Array of HRESULTs indicating the success of the individual item reads. The errorscorrespond to the handles passed in phServer. This indicates whether the read succeeded inobtaining a

33、defined value, quality and timestamp. NOTE any FAILED error code indicatesthat the corresponding Value, Quality and Time stamp are UNDEFINED.OPCITEMSTATE 構(gòu)說(shuō)明typedef struct OPCHANDLE hClient; FILETIME ftTimeStamp;WORD wQuality;WORD wReserved;VARIANT vDataValue; OPCITEMSTATE;Member Description hClient

34、 the client provided handle for this item ftTimeStamp UTCTimeStamp for this items value. If the device cannot provide a timestamp then the servershould provide one.wQuality The quality of this item.vDataValue The value itself as a variant./ 釋放同步接口m_IOPCSyncIO-Release(); m_IOPCSyncIO = NULL;/ 釋放 item

35、 管理接口 m_IOPCItemMgt-Release();m_IOPCItemMgt = NULL;/釋放 OPC 服務(wù)器m_IOPCServer-Release(); m_IOPCServer = NULL;/關(guān)閉 COM 庫(kù)CoUninitialize();異步 OPC 數(shù)據(jù)讀取查詢 group 對(duì)象的異步接口 m_IOPCItemMgt-QueryInterface(IID_IOPCAsyncIO2,(void*)&m_IOPCAsyncIO2); 參數(shù):1. IID_IOPCAsyncIO2 異步 2.0 接口2. 服務(wù)器返回的用于操作異步接口的指針。獲得 IOPCGroup

36、StateMgt 接口m_IOPCItemMgt-QueryInterface(IID_IOPCGroupStateMgt,(void*)&m_IOPCGroupStateMgt); 參數(shù):1. IID_IOPCGroupStateMgt 組狀態(tài)接口2. 服務(wù)器返回的用于操作接口的指針。建立異步回調(diào)CComObject* pCOPCDataCallback; / 回調(diào)對(duì)象的指針 通過(guò) ATL 模板創(chuàng)建回調(diào)對(duì)象的實(shí)例CComObject:CreateInstance(&pCOPCDataCallback);查詢 IUnknown 接口LPUNKNOWN pCbUnk;pCbUnk

37、 = pCOPCDataCallback-GetUnknown(); 建立一個(gè)服務(wù)器的連接點(diǎn)與客戶程序接收器之間的連接AtlAdvise 函數(shù)告訴一個(gè)可連接對(duì)象客戶想從此可連接對(duì)象接收事件 . 該函數(shù) 封裝實(shí)現(xiàn)接收事件 HRESULT hRes = AtlAdvise( m_IOPCGroupStateMgt, / in 獲得的 IOPCGroupStateMgt 接口指針pCbUnk, / in IUnknown 接口指針I(yè)ID_IOPCDataCallback, / in 回調(diào)接口&m_dwAdvise / out 服務(wù)器返回的回調(diào)接口的標(biāo)識(shí)); 異步 OPC 數(shù)據(jù)釋放退出連接點(diǎn)時(shí)

38、使用 AtlUnadviseHRESULT hRes = AtlUnadvise(m_IOPCGroupStateMgt, IID_IOPCDataCallback,m_dwAdvise); m_IOPCGroupStateMgt-Release();/異步的以下釋放類似同步的 OPC?放m_IOPCItemMgt-RemoveItems( 1, / in刪除項(xiàng)目phServer, / in被刪除項(xiàng)目的服務(wù)句柄&pErrors / out有錯(cuò)誤時(shí)的指針);m_IOPCAsyncIO2-Release();/ 釋放異步接口m_IOPCAsyncIO2 = NULL;mOPCItemMgt

39、-Release(); 釋放 ITEM 接口m_IOPCItemMgt = NULL;m0PCServer-Release(); 釋放 OPCjj 艮務(wù) m_IOPCServer = NULL;CoUninitialize();/ 釋放 COM 用于客戶端的異步回調(diào)定義功能: 客戶提供用來(lái)操作組的數(shù)據(jù)變化和刷新IOPCDataCallbackIOPCDataCallback:OnDataChangeHRESULT OnDataChange(in DWORD dwTransid,in OPCHANDLE hGroup,in HRESULT hrMasterquality,in HRESULT h

40、rMastererror,in DWORD dwCount,in, sizeis(dwCount) OPCHANDLE * phClientItems,in, sizeis(dwCount) VARIANT * pvValues,in, sizeis(dwCount) WORD * pwQualities,in, sizeis(dwCount) FILETIME * pftTimeStamps,in, sizeis(dwCount) HRESULT *pErrors);參數(shù)描述dwTransid 事務(wù)標(biāo)識(shí)符,如果是一般的回調(diào),此值為0。 hGroup 組的客戶句 柄。hrMasterquali

41、ty S_OK ,如果 OPC_QUALITY_MA 是 OPC_QUALITY_GO 否則 為S_FALSE 。hrMastererror 如果無(wú)錯(cuò)誤,返回 S_OK 否則返回 S_FALSE. dwCount 讀取 的在客戶句柄表里的項(xiàng)數(shù)目。phClientItems 數(shù)據(jù)發(fā)生變化的項(xiàng)的客戶句柄表。 .pvValues 數(shù)據(jù)發(fā)生變化的項(xiàng)的 VARIANTS 類型數(shù)據(jù)表。 pwQualities 讀取的 項(xiàng)的品質(zhì)值的表。pftTimeStamps 讀取的項(xiàng)的時(shí)間戳表。pErrors 項(xiàng)的 HRESULT 表。如果數(shù)據(jù)項(xiàng)的品質(zhì)變?yōu)?UNCERTAIN 或者 BAD,這 里返回附加的服務(wù)器提供的

42、更有用的錯(cuò)誤信息。Parameters DescriptiondwTransid 0 if the call is the result of an ordinary subscription.If the call is the result of a call to Refresh2 then thisis the value passed to Refresh2.hGroup The Client handle of the grouphrMasterquality S_OK if OPC_QUALITY_MASK for all qualities are OPC_QUALITY_GO

43、OD, S_FALSE otherwise.hrMastererror S_OK if allerrors are S_OK, S_FALS E otherwise.dwCount The number of items in the client handle listphClientItems The list of client handles for the items which have changed.pvValues A List of VARIANTS containing the values (inRequestedDataType) for the items whic

44、h havechanged.pwQualities A List of Quality values for the items pftTimeStamps A list of TimeStamps for theitems pErrors A list of HRESULTS for the items. If the quality of a data item has changed toUNCERTAIN or BAD., this field allows the server to return additional server specific errorswhich prov

45、ide more useful information to the user. See below.HRESULT 返回碼返回碼描述S_OK 客戶總是返回 S_OK ppErrors 返回碼 返回碼描述S_OK 項(xiàng)的數(shù)據(jù)的品質(zhì)是好的(OPC_QUALITY_GOQD) E_FAIL 項(xiàng)的操作失敗。OPC_E_BADRIGHTS 作的項(xiàng)是不可讀的。OPC_E_UNKNOWNITE 項(xiàng)在)月艮務(wù)器的地址空間是不可用的。S_xxx, E_xxxS_xxx -賣方特殊信息。賣方指定的特殊錯(cuò)誤。E_xxx -對(duì)于所有的 S_xxx 錯(cuò)誤碼,客戶需要假設(shè)相應(yīng)的值,品質(zhì)和時(shí)間戳都 已經(jīng)定義好了,不管品質(zhì)是

46、 UNCERTAIN 或者 BAD 建議服務(wù)器賣主提 供關(guān)于 UNCRTAIN 或 BAD 項(xiàng)的附加的信息?;卣{(diào)發(fā)生在以下情況 :一個(gè)或者多個(gè)的數(shù)據(jù)變化事件。 事件在活動(dòng) Group 中的活動(dòng)項(xiàng)的值或 者品質(zhì)發(fā)生變化時(shí)發(fā)生?;卣{(diào)不會(huì)以超過(guò)刷新速率的速度發(fā)生。一般而 言,除非值或者品質(zhì)發(fā)生變化,否則回調(diào)不會(huì)發(fā)生。 transaction ID 為 0 通過(guò) AsyncIO2 接口的刷新請(qǐng)求。一旦請(qǐng)求發(fā)生,在活動(dòng) Group中的 活動(dòng)項(xiàng)都會(huì)刷新。 Transaction ID 不為 0。OPCDataCallback:OnReadCompleteHRESULT OnReadComplete(in

47、DWORD dwTransid, / 事務(wù)標(biāo)識(shí)符,如果是一般的回調(diào),此值為 0。in OPCHANDLE hGroup, / 組的客戶句柄。in HRESULT hrMasterquality, S_OK,如果 OPC_QUALITY_MA 是OPC_QUALITY_GOOD!J為 S_FALSE 。in HRESULT hrMastererror, / 如果無(wú)錯(cuò)誤,返回 S_OK 否則返回S_FALSE。.in DWORD dwCount, / 客戶句柄里的項(xiàng)數(shù)目in, sizeis(dwCount) OPCHANDLE * phClientItems, /in, sizeis(dwCoun

48、t) VARIANT * pvValues, /VARIANTS 類型數(shù)據(jù)表in, sizeis(dwCount) WORD * pwQualities,/讀取的項(xiàng)的品質(zhì)值的表。in, sizeis(dwCount) FILETIME * pftTimeStamps,/讀取的項(xiàng)的時(shí)間戳表。in, sizeis(dwCount) HRESULT *pErrors /項(xiàng)的 HRESULT 表。如果數(shù)據(jù)項(xiàng)的品質(zhì)變?yōu)?UNCERTAIN 或者 BAD,這里返回附加的服務(wù)器提供的更有用的錯(cuò)誤信息項(xiàng)的客戶句柄表數(shù)據(jù)發(fā)生變化的項(xiàng)的);DescriptionThis method is provided by

49、 the client to handle notifications fromthe OPC Group on completion of Async Reads.Parameters DescriptiondwTransid The TransactionID returned to the client when the Read was initiated.hGroup The Client handle of the grouphrMasterqualityS_OK if OPC_QUALITY_MASK for all qualities areOPC_QUALITY_GOOD,

50、S_FALSE otherwise.hrMastererror S_OK if allerrors are S_OK, S_FAL SE otherwise.dwCount The number of items in the client handle, values, qualities, times and errors lists.This may be less than the number of items passed to Read. Items for whic errors weredetected and returned from Read are not inclu

51、ded in the callback.phClientItems The list of client handles for the items which wereread. This is NOT guarenteed to be in any particularorder although it will match the values, qualities,times and errors array.pvValues A List of VARIANTS containing the values (in RequestedDataType) for the items.pwQualities A List of Quality values for the itemspftTimeStamps A list of TimeStamps for the itemspErrors A list of HRESULTS for the items. If the system isunable to return data for an item, this field allows theserver to retur

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論