版權(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)建 OPC 服務(wù)等),提供函數(shù)執(zhí)行情況CLSID 全球唯一標(biāo)示符,用來(lái)確定 OPC 服務(wù)的標(biāo)識(shí),從注冊(cè)表查找獲得LPWSTR LPSTR 和 LPWSTR 是 Win32 和 VC+ 所使用的一種字符串?dāng)?shù)據(jù)類型。 LPSTR 被定義成是一個(gè)指向 以 NULL( 0結(jié))尾的 8 位 ANSI 字符數(shù)組指針,而 LPWSTR 是一個(gè)指向以 NULL 結(jié)尾的 16 位雙字 節(jié)字符數(shù)組指針OPC 接口說(shuō)明OPCITEMDEF m_Items1
2、;OPCITEMDEF 數(shù)組,包含著項(xiàng)的存取路徑 , 定義和被請(qǐng)求的數(shù)據(jù)類OPCITEMRESULT*m_ItemResult;OPCITEMRESULT 數(shù)組,服務(wù)器用來(lái)告訴客戶關(guān)于項(xiàng)的附加的信息(項(xiàng)句柄和規(guī)范的數(shù)據(jù)類型)OPCHANDLEm_GrpSrvHandle;OPC 服務(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ù))之前必須初始
3、化 com 庫(kù)。返回值 S_OK : 該線程中 COM 庫(kù)初始化成功 S_FALSE 該線程中 COM 庫(kù)已經(jīng)被初始化 CoInitialize () 標(biāo)明以單線程方式創(chuàng)建。使用 CoInitialize 創(chuàng)建可以使對(duì)象直接與線程連接,得到最高的性能。和一個(gè)套間建立了對(duì)應(yīng)關(guān)系。線程的套間模式?jīng)Q定了該線程如何調(diào)用 COM 對(duì)象,是否需要列集等。CoInitialize () 并不會(huì)干擾客戶和服務(wù)器之間的通信,它所做的事情是讓線程注冊(cè)一個(gè)套間,而線程運(yùn)行 過(guò)程中必然在此套間。CoInitialize 和 CoUninitialize 必須成對(duì)使用IOPCServerIOPCItemMgtIOPCS
4、yncIO*m_IOPCServer;IOPCServer 接口及成員函數(shù)主要用于對(duì)組對(duì)象進(jìn)行創(chuàng)建,刪除 , 枚 舉和獲取當(dāng)前狀態(tài)等操作 .是OPC 服務(wù)器對(duì)象的主要接口 .接口及成員*m_IOPCItemMgt;IOPCItemMgt 接口及成員函數(shù)用于 OPC 客戶程序添加、刪除 和組對(duì)象中組員等控制操作。*m_IOPCSyncIO;IOPCSyncIO 用于同步數(shù)據(jù)訪問。CoInitialize 并不裝載 COM 庫(kù),它只用來(lái)初始化當(dāng)前線程使用什么樣的套間。使用這個(gè)函數(shù)后,線程就查找 OPC 服務(wù)CLSIDFromProgID (LOPC 服務(wù)的名稱 , &clsid);通過(guò) P
5、rogID, 查找注冊(cè)表中的相關(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)建一
6、個(gè)未初始化的對(duì)象。 當(dāng)在本機(jī)中只創(chuàng)建一個(gè)對(duì)象時(shí),可以調(diào)用 CoCreateInstance; 在遠(yuǎn)程系統(tǒng)中創(chuàng)建一個(gè)對(duì)象時(shí),可以調(diào)用 CoCreateInstance Ex; 創(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ì)象
7、的接口標(biāo)識(shí)符LPVOID * ppv / 用來(lái)接收指向 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ì)象的 I Unknown 接口。dwClsContextin 組件類別 . 可使用 CLSCTX 枚舉器中預(yù)定義的值 riidin 引用接口標(biāo)識(shí)符 ,用來(lái)與對(duì)象通信。ppvout 用來(lái)接收指向接口地址的指針變量。如果函數(shù)調(diào)用成功 ,*ppv 包括請(qǐng)求的接口指針。返回值:S_OK 指定的 C
8、om 對(duì)象實(shí)例被成功創(chuàng)建。REGDB_E_CLASSNOTREG 指定的類沒有在注冊(cè)表中注冊(cè) . 也可能是指定的 dwClsContext 沒有注冊(cè)或注冊(cè)表中的服務(wù)器類型損壞 CLASS_E_NOAGGREGATION 這個(gè)類不能創(chuàng)建為聚合型。E_NOINTERFACE 指定的類沒有實(shí)現(xiàn)請(qǐng)求的接口 , 或者是 IUnknown 接口沒有暴露請(qǐng)求的接口 . 注釋:CoCreateInstance 幫助者函數(shù)通過(guò)使用對(duì)象的 CLSID, 提供了一種便潔的方式與類對(duì)象連接, 創(chuàng)建未初始化的實(shí)例 ,以及釋放類對(duì)象。它封裝了以下的功能 :CoGetClassObject(rclsid, dwClsCon
9、text, NULL, IID_IClassFactory, &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 接口指針,并使用需要的方法,可以使用 CoGe
10、tClassObject函數(shù)。在 CLSCTX 枚 舉 器 中 , 你 可 以 指 定 用 來(lái) 管 理 對(duì) 象 的 服 務(wù) 器 類 型 . 這 些 常 量 可 以 是 CLSCTX_INPROC_SERVER,CLSCTX_INPROC_HANDLER, CLSCTX_LOCAL_SERVER 或是它們的任何組合 . 常量 CLSCTX_ALL 被定義為這三個(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 客
11、戶端的操作句柄&TimeBias,/in 與標(biāo)準(zhǔn)時(shí)間的校正值&PercentDeadband,/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,i
12、n BOOL bActive,in DWORD dwRequestedUpdateRate,in OPCHANDLE hClie ntGroup, unique, in LONG *pTimeBias,in FLOAT * pPerce ntDeadba nd,in DWORD dwLCID,out OPCHANDLE * phServerGroup, out DWORD *pRevisedUpdateRate, in REFIID riid,out, iids(riid) LPUNKNOWN * ppU nk );ParametersDescriptionszNameName of the
13、group. The n ame must be unique among theother groups created by this clie nt. If no n ame is provided(szName is pointer to a NUL string) the server will gen erate aunique n ame. The server gen erated n ame will also beunique relative to any existi ng public groups.bActiveFALSEif the Group is to be
14、created as in active.TRUE if the Group is to be created as active.dwRequestedUpdateRateClient Specifies the fastest rate at which data changes maybe sent to OnDataChange for items in this group. This also indicates the desired accuracy of Cached Data. This isintended only to control the behavior of
15、the in terface. How theserver deals with the update rate and how ofte n it actuallypolls the hardware intern ally is an implementation detail.Passing 0 indicates the servershould use the fastest practical rate. The rate is specified inmillisec on ds.hClie ntGroupClient provided handle for this group
16、. refer to description ofdata types, parameters, and structures for more in formatio nabout this parameterpTimeBiasPointer to Long containing the initial TimeBias (in minutes) forthe Group. Pass a NULL Pointer if you wish the group to usethe default system TimeBias. See discussi on of TimeBias inGen
17、 eral Properties Section See Comments below.pPerce ntDeadba ndThe percent change in an item value that will cause asubscription callback for that value to a client. This parameteronly applies to items in the group that have dwEUType of Analog. See discussi on of Perce nt Deadba nd in Ge neralPropert
18、ies Sectio n. A NULL poin ter is equivale nt to 0.0.dwLCIDThe Ianguage to be used by the server when returning values(including EU enumeration a) text foroperati ons on this group. This could also in elude such thingsas alarm or status con diti ons or digital con tact states.phServerGroupPlace to st
19、ore the unique server gen erated han dle to thenewly created group. The client will use the server providedhan dle for many of the subseque nt functions that the clie ntrequests the server to perform on the group.pRevisedUpdateRateThe server returns the value it will actually use for theUpdateRatewh
20、ichmaydifferfromtheRequestedUpdateRate.Note that this may also be slower tha n the rate at which theserver is intern ally obta ining the data and updat ing thecache.In general the se rver should round up the requesto the n ext available supported rate. The rate is specified inmillisec on ds.Server r
21、eturns HRESULT ofOPC_S_UNSUPPORTEDRATE whe n it returns a value inrevisedUpdateRate that is differe nttha nRequestedUpdateRate.riidThe type of in terface desired (e.g. IID IOPCItemMgt)ppUnkWhere to store the returned in terface poin ter. NULL isreturned for any FAILED HRESULT.添加項(xiàng)目m0PCItemMgt- Addite
22、ms (1,mtems, &mtemResult, &m_pErrors);mtems的說(shuō)明定義:OPCITEMDEF 這個(gè)參數(shù)為OPCITEMDEFAddItems 函數(shù)說(shuō)明HRESULT AddItems(in DWORD dwCou nt,in, size_is(dwCount) OPCITEMDEF * pItemArray,out, size_is(,dwCou nt) OPCITEMRESULT * ppAddResults,out, size_is(,dwCou nt) HRESULT * ppErrors);ParametersDescripti ondwCo
23、untThe nu mber of items to be added/ in添加 1 個(gè) item/ in添加的 item 的指針/ out添加 item 的結(jié)果 out發(fā)生的錯(cuò)誤mtems1;結(jié)構(gòu),包含著項(xiàng)的存取路徑定義和被請(qǐng)求的數(shù)據(jù)類等。pItemArrayArray of OPCITEMDEFs. These tell the server everything it n eeds to know about the item in cludi ngthe access path, defi niti on and requested datatypeppAddResultsArray
24、 of OPCITEMRESULTs. This tells the clientadditional information about the item including theserver assigned item handle and the canonicaldatatype.ppErrorsArray of HRESULTs. This tells the client which of theitems was successfully added. For any item which failedit provides a reas on.OPCITEMDEF 結(jié)構(gòu)說(shuō)明t
25、ypedef struct stri ngLPWSTR szAccessPath;stri ngLPWSTR szItemID;BOOLbActive;OPCHANDLEDWORD dwBlobSize; size_is(dwBlobSize) BYTE * pBlob; VARTYPEMemberUsed byDescripti onszAccessPathbothThe access path the server should associate withthis item. By convention a pointer to a NUL stringspecifies that th
26、e server should select the accesspath. Support for accesspath is optional NOTE:version 1 in dicated that a NULL poi nter wouldallow the server to pick the path however pass ing aNULL poin ter will cause a fault i n the proxy/stubcode and thus is not allowed.szItemIDbothA null-terminated string that
27、uniquely identifies theOPC data item. See the Item ID discussion and theAddItems fun cti on for specific information aboutthe contents of this field.bActiveaddThis Boolea n value affects the behavior variousmethods as described elsewhere in this specification.hClie ntaddThe handle the client wishes
28、to associate with theitem. See the OPCHANDLE for more specificinformation about the contents of this field.dwBlobSizebothThe size of the pBlob for this item.pBlobbothpBlob is a poin ter to the Blob.OPC 服務(wù)器存取路徑/item 的名稱/活動(dòng)狀態(tài)/操作句柄/item 的 pBlob 大小/二進(jìn)制指針vtRequestedDataType; /數(shù)據(jù)類型由客戶端請(qǐng)求wReserved;/ 保留字WOR
29、D OPCITEMDEF;vtRequestedDataTypebothThe data type requested by the clie nt. An error isreturned (See Additems or ValidateItems) if theserver cannot provide the item in this format.Passing VT_EMPTY means the client will acceptthe servers canoni cal datatype.查詢同步接口m 0 PCItemMgt- Queryl nteface (IID_IO
30、PCSy nclO, (void*)&m O PCSy nclO); 參數(shù): 1. IID_IOPCSynclO同步接口2.服務(wù)器返回的用于操作同步接口的指針。同步接口讀取數(shù)據(jù)mOPCSyncIO- Read (OPC_DS_DEVICE, 1, phServer, &pItemValue, &pErrors);參數(shù):1 . OPC_DS_DEVICE 從 OPC 設(shè)備讀取另一個(gè)選擇是 OPC_DS_CACHE 從緩存讀取2 .讀取的數(shù)量3 .這個(gè) item 的服務(wù)句柄4 .返回值的 OPCITEMSTATE 結(jié)構(gòu)數(shù)值指針5 .返回的錯(cuò)誤指針HRESULT Read(i
31、n OPCDATASOURCE dwSource,in DWORD dwCou nt,in, size_is(dwCount) OPCHANDLE * phServer,out, size_is(,dwCount) OPCITEMSTA TE * ppItemValues,out, size_is(,dwCou nt) HRESULT * ppErrors);ParametersDescripti ondwSourceThe data source ; OPC_DS_CACHEorOPC DS DEVICEdwCo untThe nu mber of items to be read.phSe
32、rverThe list of server item handles for the items to be readppItemValuesArray of structures in which the item values arereturned.ppErrorsArray of HRESULTs in dicat ing the success of the individual item reads. The errors corresp ond to thehandles passed in phServer. This indicates whether theread su
33、cceeded in obtaining a defined value, quality andtimestamp. NOTE any FAILED error code in dicates thatthe corresp onding Value, Quality and Time stamp areUNDEFINED.OPCITEMSTATE 結(jié)構(gòu)說(shuō)明 typedef struct OPCHANDLE hClie nt; FILETIMEftTimeStamp;WORDwQuality;WORDwReserved;VARIANTvDataValue; OPCITEMSTA TE;Mem
34、berDescriptionhClie ntthe clie nt provided han dle for this itemftTimeStampUTC TimeStamp for this items value. If the device cannotprovide a timestamp then the server should provide one.wQualityThe quality of this item.vDataValueThe value itself as a varia nt./ 釋放同步接口mOPCS yn clO-Release(); mOPCS yn
35、 cIO = NULL;/ 釋放 item 管理接口mOPCItemMgt-Release(); mOPCItemMgt = NULL;/ 釋放 OPC 服務(wù)器mOPCServer-Release(); m_IOPCServer = NULL;關(guān)閉 COM 庫(kù)CoUnin itialize();異步 OPC 數(shù)據(jù)讀取 查詢 group 對(duì)象的異步接口m_IOPCItemMgt- QueryInterface (IID_IOPCAsyncIO2, (void*)&m_IOPCAsyncIO2); 參數(shù): 1.IID_IOPCAsyncIO2 異步 2.0 接口2.服務(wù)器返回的用于操作異步
36、接口的指針。獲得 IOPCGroupStateMgt 接口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 接口 LPU
37、NKNOWN pCbUnk;pCbUnk = pCOPCDataCallback-GetUnknown();建立一個(gè)服務(wù)器的連接點(diǎn)與客戶程序接收器之間的連接AtlAdvise 函數(shù)告訴一個(gè)可連接對(duì)象客戶想從此可連接對(duì)象接收事件HRESULT hRes = AtlAdvise ( m_IOPCGroupStateMgt, pCbUnk,IID_IOPCDataCallback,&m_dwAdvise);異步 OPC 數(shù)據(jù)釋放退出連接點(diǎn)時(shí)使用 AtlUnadviseHRESULT hRes = AtlUnadvise (m_IOPCGroupStateMgt, IID_IOPCDataCa
38、llback, 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;.該函數(shù)封裝實(shí)現(xiàn)接收事件/ in 獲得的 IOPCGroupStateMgt 接口指針/ in IUnknown 接口指針/ in回調(diào)接口/ out 服務(wù)器返回的回調(diào)
39、接口的標(biāo)識(shí)m0PCItemMgt-Release();釋放 ITEM 接口m0 PCItemMgt = NULL;m0PCServer-Release(); 釋放 OPC 服務(wù) m_IOPCServer = NULL;CoUninitialize(); 釋放 COM用于客戶端的異步回調(diào)定義功能:客戶提供用來(lái)操作組的數(shù)據(jù)變化和刷新lOPCDataCallbackIOPCDataCallback:O nDataCha ngeHRESULT On DataCha nge(in DWORD dwTra nsid,i n OPCHANDLE hGroup,in HRESULT hrMasterquali
40、ty,in HRESULT hrMastererror,in DWORD dwCou nt,in, sizeis(dwCount) OPCHANDLE * phClientItems,in, sizeis(dwCou nt) VARIANT * pvValues,in, sizeis(dwCou nt) WORD * pwQualities,in, sizeis(dwCou nt) FILETIME * pftTimeStamps, in,sizeis(dwCou nt) HRESULT *pErrors);參數(shù)描述事務(wù)標(biāo)識(shí)符,如果是一般的回調(diào),此值為0。組的客戶句柄。如果無(wú)錯(cuò)誤,返回 S_O
41、K,否則返回 S_FALSE.。dwCou nt讀取的在客戶句柄表里的項(xiàng)數(shù)目。phClie ntltems數(shù)據(jù)發(fā)生變化的項(xiàng)的客戶句柄表。pvValues數(shù)據(jù)發(fā)生變化的項(xiàng)的 VARIANTS 類型數(shù)據(jù)表。pwQualities讀取的項(xiàng)的品質(zhì)值的表。pErrors項(xiàng)的 HRESULTS 表。如果數(shù)據(jù)項(xiàng)的品質(zhì)變?yōu)閁NCERTAIN服務(wù)器提供的更有用的錯(cuò)誤信息。ParametersDescripti ondwTra nsid0 if the call is the result of an ordinary subscription.If the call is the result of a cal
42、l to Refresh2 the n this isthe value passed to Refresh2.hGroupThe Clie nt han dle of the grouphrMasterqualityS_OK if OPC_QUALITY_MASK for all qualitieare OPC QUALITY GOOD, S FALSE otherwise.hrMastererrorS OK if all errors are S OK, S FALSE otherwidwTransidhGrouphrMasterqualityS_OK,如果 OPC_QUALITY_MAS
43、K是 OPC_QUALITY_GOOD,否則為 S_FALSEhrMastererrorpftTimeStamps讀取的項(xiàng)的時(shí)間戳表。或者BAD,這里返回附加的dwCo untThe nu mber of items in the clie nt han dle listphClie ntltemsThe list of client handles for the items which havechanged.pvValuesA List of VARIANTS con tai ning the values (inRequestedDataType) for the items whic
44、h havechanged.pwQualitiesA List of Quality values for the itemspftTimeStampsA list of TimeStamps for the itemspErrorsA list of HRESULTS for the items. If the quality of a dataitem has changed to UNCERTAIN or BAD., this fieldallows the server to retur n additi onal server specificerrors which provide
45、 more useful information to theuser. See below.HRESULT 返回碼返回碼描述S_OK客戶總是返回 S_OK。ppErrors 返回碼返回碼描述S_xxx, E_xxxS_xxx -賣方特殊信息。E_xxx -賣方指定的特殊錯(cuò)誤。對(duì)于所有的 S_xxx 錯(cuò)誤碼,客戶需要假設(shè)相應(yīng)的值,品質(zhì)和時(shí)間戳都 已經(jīng)定義好了,不管品質(zhì)是 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ò)
46、刷新速率的速度發(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 On ReadComplete( in DWORDdwTra nsid,i n OPCHANDLE hGroup, inHRESULT hrMasterquality,事務(wù)標(biāo)識(shí)符,如果是一般的回調(diào),此值為0。/組的客戶句柄。S_OK,如果 OPC_QUALITY_MASK 是
47、OPC_QUALITY_GOOD,否則 為S_FALSE 。in HRESULT hrMastererror,/如果無(wú)錯(cuò)誤,返回 S_OK,否則返回 S_FALSE.。S_OKE_FAILOPC E BADRIGHTS項(xiàng)的數(shù)據(jù)的品質(zhì)是好的( 項(xiàng)的操作失敗。操作的項(xiàng)是不可讀的。OPC_QUALITY_GOODOPC_E_UNKNOWNITEMID項(xiàng)在服務(wù)器的地址空間是不可用的。in DWORDdwCou nt,II客戶句柄里的項(xiàng)數(shù)目i n, sizeis(dwCou nt) OPCHANDLE * phClie ntltems, / 項(xiàng)的客戶句柄表in, sizeis(dwCount) V AR
48、IANT * pvValues, / 數(shù)據(jù)發(fā)生變化的項(xiàng)的 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)的 HRESULTS 表。如果數(shù)據(jù)項(xiàng)的品質(zhì)變?yōu)閁NCERTAIN 或者 BAD,這里返回附加的服務(wù)器提供的更有用的錯(cuò)誤信息);Descriptio nThis method is provided by the client
49、 to handle notifications from the OPC Group oncompletion of Async Reads.ParametersDescripti ondwTra nsidThe TransactionlD returned to the client when the Readwas in itiated.hGroupThe Clie nt han dle of the grouphrMasterqualityS_OK if OPC_QUALITY_MASK for all qualitiesare OPC QUALITY GOOD, S FALSE ot
50、herwise.hrMastererrorS OK if all errors are S OK, S FALSE otherwisedwCo untThe number of items in the client handle, values,qualities, times and errors lists. This may be less tha nthe nu mber of items passed to Read. Items for whicerrors were detected and returned from Read are not included in the
51、callback.phClie ntltemsThe list of client handles for the items which were read.This is NOT guare nteed to be in any particular orderalthough it will match the values, qualities, times anderrors array.pvValuesA List of VARIANTS con tai ning the values (inRequestedDataType) for the items.pwQualitiesA List of Quality values for the itemspftTimeStampsA list of TimeStamps for the itemspErrorsA list of HRESULTS for the items. If the system is unableto return data for an item, this field allows the server toreturn additional
溫馨提示
- 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《簡(jiǎn)筆畫上色技巧》課件
- 中心投影和平行投影課件
- 《壓力管理》課件
- 《市場(chǎng)營(yíng)銷情景模擬》課件
- 單位管理制度集粹選集職工管理篇
- 單位管理制度匯編大全職員管理篇
- 單位管理制度合并選集人力資源管理篇
- 三峽復(fù)習(xí)課件
- 《精油的起源基礎(chǔ)》課件
- 單位管理制度分享合集【人事管理】
- 裝配式混凝土建筑構(gòu)件識(shí)圖-疊合板識(shí)讀(裝配式混凝土建筑)
- 會(huì)計(jì)科目涉稅風(fēng)險(xiǎn)點(diǎn)風(fēng)險(xiǎn)
- 香椿矮化密植栽培
- GB/T 4214.3-2023家用和類似用途電器噪聲測(cè)試方法洗碗機(jī)的特殊要求
- 建設(shè)工程質(zhì)量控制講義三
- YY/T 0606.7-2008組織工程醫(yī)療產(chǎn)品第7部分:殼聚糖
- 2023年遼寧軌道交通職業(yè)學(xué)院高職單招(英語(yǔ))試題庫(kù)含答案解析
- GB/T 29076-2021航天產(chǎn)品質(zhì)量問題歸零實(shí)施要求
- DL-T 5190.1-2022 電力建設(shè)施工技術(shù)規(guī)范 第1部分:土建結(jié)構(gòu)工程(附條文說(shuō)明)
- 殯葬服務(wù)人才需求調(diào)研報(bào)告
- 降低銳器盒不規(guī)腎內(nèi)科品管圈課件
評(píng)論
0/150
提交評(píng)論