OPC:客户端开发——应用WTclient.dll使用手册部分中文版
WinTECH軟件快速客戶端開發(fā)DLL(WTclient),提供了一種應(yīng)用API方便地將定制應(yīng)用和任何OPC Server相結(jié)合的方式。所有COM和OPC的細(xì)節(jié)均由DLL來(lái)處理,這使得一個(gè)應(yīng)用可以輕松的從服務(wù)器獲取數(shù)據(jù)點(diǎn),而不用關(guān)心接口后的實(shí)際完成過(guò)程。 這些DLL可以方便和已有的或者新的應(yīng)用相結(jié)合。其中提供了面向OPC1.0和OPC2.0數(shù)據(jù)訪問(wèn)標(biāo)準(zhǔn)所需的全部OPC接口,同時(shí)也提供了瀏覽接口和連 接到簡(jiǎn)單警報(bào)/事件服務(wù)器的支持。
這個(gè)用戶指導(dǎo)應(yīng)該被當(dāng)作一本OPC數(shù)據(jù)訪問(wèn)和OPC警報(bào)/事件規(guī)范手冊(cè)文檔使用,其中的所有資料都可在OPC主網(wǎng)站http://www.opcfoundation.org上找到。
WTclient.lib內(nèi)有DLL文件中API的出口定義,將這個(gè)文件包含到你的定制應(yīng)用的工程文件中,同時(shí)將WTclientAPI.h包 含到會(huì)調(diào)用DLL的模塊中。如果應(yīng)用Visual Basic進(jìn)行編程,需要將VBA范例中(隨demo提供)的module1.bas包含到你的工程中。
在使用WTclient.dll的之前,需要在代碼起始的時(shí)候調(diào)用一下函數(shù)Disable30MinTimer
| 函數(shù) | BOOL Disable30MinTimer (LPCSTR Authorization); |
| 說(shuō)明 | DLL里面有個(gè)計(jì)時(shí)的函數(shù),如果想正常使用dll的功能需要在開始傳遞一個(gè)字符串來(lái)調(diào)用一個(gè)禁用計(jì)時(shí)的函數(shù),否則30分鐘之后停止服務(wù)。該dll文件有的導(dǎo)出函數(shù)傳遞也是LPCSTR的,程序調(diào)用功能正常,也是采用傳遞byref?的?byte來(lái)進(jìn)行的。 至于說(shuō)這個(gè)字符串是什么,就要和Dll的廠家公司聯(lián)系了 |
?
?
?
?
?
?
?
| 函數(shù) | WTclientCoInit()、CoUninitialize() |
| 說(shuō)明 | 從WTClient.DLL2.0版本開始,初始化DCOM是客戶端應(yīng)用的責(zé)任了。2.0版本之前,WTClient.dll在DLLMain 函數(shù)中執(zhí)行DCOM和安全初始化的過(guò)程,并在dll下載時(shí)調(diào)用CoUninitialize函數(shù)。由于不同windows dll文件的加載順序,這會(huì)帶來(lái)一些問(wèn)題。 這些初始化調(diào)用被移動(dòng)到了一個(gè)新的輸出函數(shù)WTclientCoInit()中,用戶的應(yīng)用可以在主要可執(zhí)行線程啟動(dòng)的時(shí)候調(diào)用這個(gè)函數(shù)。WTclientCoInit()將DCOM初始化為多線程并使用默認(rèn)安全設(shè)定。你的應(yīng)用可以選擇自行初始化DCOM替代 這個(gè)輸出函數(shù)。任何情況下,你的應(yīng)用都必須在終止時(shí)調(diào)用CoUninitialize()函數(shù)。 |
2、獲取OPC服務(wù)器列表
| 函數(shù) | int NumberOfOPCServers (BOOL UseOPCENUM, LPCSTR MachineName); |
| 說(shuō)明 | OPCENUM是由OPC Foundation提供的一個(gè)組件,它允許預(yù)期的客戶端應(yīng)用獲取本地以及遠(yuǎn)程可用服務(wù)器列表。可惜的是,在寫這個(gè)組件的時(shí)候,OCENUM的操作并沒(méi)有很好的跨平臺(tái)一致性。 WTclient.dll允許應(yīng)用嘗試使用OPCENUM組件來(lái)獲取服務(wù)器列表,或者越過(guò)OPCENUM組件通過(guò)掃描Windows 登記的本地拷貝來(lái)獲取列表。如果使用了OPCENUM,你可以通過(guò)傳遞遠(yuǎn)程機(jī)器的名稱來(lái)獲取遠(yuǎn)程服務(wù)器列表。 |
一旦WTclietn.dll返回了服務(wù)器的數(shù)目,應(yīng)用就可以通過(guò)調(diào)用如下所示的函數(shù)來(lái)對(duì)服務(wù)器名稱列表進(jìn)行枚舉:
| 函數(shù) | BOOL GetServerName (int index, LPSTR Buffer, int BufSize); |
| 說(shuō)明 | 一個(gè)由用戶提供的字符緩沖區(qū)Buffer負(fù)責(zé)存放傳遞過(guò)來(lái)的index標(biāo)識(shí)的服務(wù)器列表中某個(gè)服務(wù)器名字。BufSize標(biāo)識(shí)用戶提供的字符緩 沖區(qū)的長(zhǎng)度,并可以防止dll載入過(guò)長(zhǎng)的名字。如果Buffer中返回了一個(gè)有效的服務(wù)器名稱,GetServerName函數(shù)返回TRUE。 |
?
還有一個(gè)補(bǔ)充函數(shù)集允許應(yīng)用獲取可用的警報(bào)/事件服務(wù)器列表。
| 函數(shù) | int NumberOfOPC_AEServers (LPCSTR MachineName); BOOL GetOPC_AEServerName (int index, char *pBuf, int BufSize); |
3、建立、斷開OPC連接
| 函數(shù) | HANDLE ConnectOPC(LPCSTR MachineName, LPCSTR ServerName, BOOL EnableDLLBuffering); HANDLE ConnectOPC1(LPCSTR MachineName, LPCSTR ServerName, BOOL EnableDLLBuffering); HANDLE ConnectOPC_AE(LPCSTR MachineName, LPCSTR ServerName); |
| 說(shuō)明 | 如果一個(gè)由計(jì)算機(jī)名稱和服務(wù)器名稱定義的和OPC服務(wù)器之間的連接可以被建立,則此函數(shù)返回一個(gè)有效的HANDLE。可以建立和不同的服務(wù)器的多個(gè)同步連接,此時(shí)返回的HANDLE標(biāo)識(shí)了可用于以后創(chuàng)建組和項(xiàng)目的連接。如果傳遞一個(gè)空字符串作為計(jì)算機(jī)名稱參數(shù),標(biāo)識(shí)的是本地計(jì)算機(jī)。 WTclient會(huì)先嘗試使用OPC2.0連接點(diǎn)接口進(jìn)行連接,如果不可用,則會(huì)轉(zhuǎn)而采用OPC1.0數(shù)據(jù)對(duì)象接口。 WTclient.dll的基本操作有兩種模式。第一種模式用于支持'C-樣式'回調(diào)函數(shù)的應(yīng)用,在這種情況下,dll中沒(méi)有緩沖區(qū)操作。由于可以從連接的OPC服務(wù)器接收到數(shù)據(jù)更改提示,回調(diào)可用于將新的信息傳送給控制應(yīng)用(此處涉及到下面會(huì)提及的EnableOPCNotification 函數(shù))。 對(duì)于使用不支持回調(diào)函數(shù)的工具設(shè)計(jì)的那些應(yīng)用(例如Visual Basic 5.0),WTclient會(huì)被配置為維護(hù)一個(gè)由應(yīng)用創(chuàng)建的全部OPC項(xiàng)目(標(biāo)簽)列表的模式。當(dāng)服務(wù)器數(shù)據(jù)改變時(shí),dll中列表里相關(guān)的標(biāo)簽值會(huì)被更 新,控制應(yīng)用可以隨時(shí)讀取標(biāo)簽的值(此處涉及到下面會(huì)提及的ReadOPCItem函數(shù))。 ConnectOPC1會(huì)總是嘗試使用OPC1.0連接。 ConnentOPC_AE會(huì)建立一個(gè)和OPC警報(bào)/事件服務(wù)器的連接,此連接由計(jì)算機(jī)名稱和服務(wù)器名稱指定。 |
斷開連接的函數(shù):
| 函數(shù) | void DisconnectOPC(HANDLE hConnect); void DisconnectOPC_AE(HANDLE hConnect); |
| 說(shuō)明 | 當(dāng)一個(gè)應(yīng)用終止的時(shí)候,它會(huì)負(fù)責(zé)從依附的服務(wù)器斷開連接。 DisconnectOPC(或Disconnect_OPCAE)函數(shù)會(huì)對(duì)hConnect定義的連接執(zhí)行一個(gè)徹底的連接關(guān)閉操作。 |
4、獲取服務(wù)器標(biāo)簽名列表
| 函數(shù) | int? NumberOfOPCItems(HANDLE hConnect); BOOL? GetOPCItemName (HANDLE hConnect, int index, char *pBuf, int BufSize); |
| 說(shuō)明 | 這兩個(gè)函數(shù)和獲取服務(wù)器名稱列表函數(shù)的調(diào)用方式類似。 NumberOfOPCItems()返回所連接OPC服務(wù)器支持的獨(dú)有標(biāo)簽總數(shù)。 依次地調(diào)用GetOPCItemName()會(huì)逐步遍歷所有可用的標(biāo)簽名,最終允許控制應(yīng)用選擇一個(gè)項(xiàng)目或者提交一個(gè)瀏覽列表給用戶。 NumberOfOPCItems()會(huì)瀏覽服務(wù)器的全部項(xiàng)目名稱列表并提供一個(gè)“FLAT”格式的列表。NumberOfOPCItems()函數(shù)相當(dāng)于在根節(jié)點(diǎn)處用OPC_FLAT方式調(diào)用BrowseItems函數(shù)。(BrowseItems函數(shù)見(jiàn)下表) |
?
| 函數(shù) | BOOL GetNameSpace (HANDLE hConnect, WORD *pNameSpace); BOOL BrowseTo (HANDLE hConnect, LPCSTR NodeName); char SetWTclientQualifier (char qualifier); int? BrowseItems (HANDLE hConnect, WORD Filter); |
| 說(shuō)明 | 為了提供較好的應(yīng)用等級(jí)體系命名空間訪問(wèn)服務(wù)器的方式,WTClient dll提供函數(shù)以便于應(yīng)用直接從服務(wù)器端瀏覽項(xiàng)目名。 GetNameSpace()函數(shù)允許應(yīng)用決定服務(wù)器的命名空間,BrowseTo()函數(shù)負(fù)責(zé)將當(dāng)前瀏覽位置移動(dòng)到指定的名稱處,BrowseItems()函數(shù)用服務(wù)器的節(jié)點(diǎn)名稱來(lái)填充內(nèi)部名稱列表。BrowseTo()函數(shù)既可以和 OPC_LEAF一起使用來(lái)讀取當(dāng)前瀏覽位置的葉片名稱,也可以和OPC_BRANCH一起使用來(lái)當(dāng)前瀏覽位置的讀取枝條名稱。這些名稱可以被 GetOPCItemName函數(shù)獲取。 WtClient動(dòng)態(tài)鏈接庫(kù)為NumberOfOPCItems()函數(shù)和BrowseItems()函數(shù)維護(hù)一個(gè)單一的名稱列表,因此應(yīng)用程序在瀏覽服務(wù)器命名空間的時(shí)候必須很小心,避免覆蓋前一次調(diào)用的值。在各個(gè)等級(jí)的樹的相互作用過(guò)程中,調(diào)用BrowseItems之后,所有的項(xiàng)目名稱必須立刻拷貝到本地存儲(chǔ)中。 SetWTclientQualifier()函數(shù)允許應(yīng)用程序改變用來(lái)解析各個(gè)等級(jí)命名空間節(jié)點(diǎn)的劃界字符。客戶端應(yīng)用一般認(rèn)為缺省的劃界符為‘.’,然而也有些服務(wù)器將‘.’字符用在了節(jié)點(diǎn)名字中。 |
| 函數(shù) | BOOL? SetBrowseFilters (HANDLE hConnect, LPCSTR UserString, VARTYPE DataType, DWORD AccessType); |
| 說(shuō)明 | 應(yīng)用程序可以設(shè)置瀏覽過(guò)濾器來(lái)影響服務(wù)器返回的OPC項(xiàng)目個(gè)數(shù)。應(yīng)用程序可以選擇僅獲取那些符合指定數(shù)據(jù)類型或者訪問(wèn)權(quán)限的項(xiàng)目。 |
5、創(chuàng)建OPC組和標(biāo)簽
| 函數(shù) | HANDLE AddOPCGroup (HANDLE hConnect, LPCSTR Name, DWORD *pRate, float *pDeadBand); void? RemoveOPCGroup (HANDLE hConnect, HANDLE hGroup); |
| 說(shuō)明 | WTclient.dll提供兩個(gè)函數(shù),允許你創(chuàng)建、移除一個(gè)OPC組。 AddOPCGroup()函數(shù)返回一個(gè)唯一指定某個(gè)組的指針,這個(gè)指針對(duì)于其他的Wtclient函數(shù)是必需的。傳送給做AddOPCGroup()參數(shù)的值由控制應(yīng)用端決定,對(duì)于每個(gè)組都是明確的。Name不會(huì)被服務(wù)器采用,可以任意選取。pRate是一個(gè)指針,指向?qū)ο鬄樗杷⑿侣?#xff08;單位為毫秒),服務(wù)器端用這個(gè)刷新率提供客戶端刷新后的返回值。 |
| 函數(shù) | BOOL? ChangeOPCGroupState (HANDLE hConnect, HANDLE hGroup, BOOL Active)); |
| 說(shuō)明 | 應(yīng)用這個(gè)函數(shù)可以將指定的OPC組設(shè)定為激活狀態(tài)(Active = TRUE)或者無(wú)效狀態(tài)(Active = FALSE)。 |
| 函數(shù) | HANDLE? AddOPCItem (HANDLE hConnect, HANDLE hGroup, LPCSTR ItemName); void? RemoveOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem); |
| 說(shuō)明 | 如果想要給指定的OPC組添加一個(gè)項(xiàng)目,只需使用組的指針以及待添加項(xiàng)目的標(biāo)簽名調(diào)用AddOPCItem函數(shù)即可,該函數(shù)會(huì)返回一個(gè)唯一標(biāo)識(shí)指定項(xiàng)目的指針。如果請(qǐng)求的項(xiàng)目不存在,則函數(shù)將會(huì)返回INVALID_HANDLE_VALUE。當(dāng)關(guān)閉一個(gè)組的時(shí)候,需要調(diào)用 RemoveOPCItem()函數(shù)來(lái)清理已分配的內(nèi)存 |
| 函數(shù) | BOOL? SetItemUpdateHandle (HANDLE hConnect,? HANDLE hGroup, HANDLE? hItem, HANDLE hUpdate); |
| 說(shuō)明 | SetItemUpdateHandle()函數(shù)允許客戶端應(yīng)用定義一個(gè)獨(dú)有的指針,供服務(wù)器在數(shù)據(jù)更新回調(diào)時(shí)使用。這個(gè)函數(shù)的提供是為了給客戶端應(yīng)用提供便利,以便于進(jìn)行更有效率的程序設(shè)計(jì),并可以對(duì)服務(wù)器提供的新數(shù)據(jù)進(jìn)行操作。 |
| 函數(shù) | BOOL GetOPCItemNameFromHandle (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, char *pBuf, int BufSize); |
| 說(shuō)明 | 這個(gè)函數(shù)允許客戶端應(yīng)用通過(guò)傳遞AddOPCItem函數(shù)返回的指針來(lái)獲取OPC項(xiàng)目名。 |
| 函數(shù) | BOOL GetOPCItemType (HANDLE hConnect, HANDLE hGroup, LPCSTR ItemName, VARTYPE *pType, DWORD *pAccessRights); |
| 說(shuō)明 | 這個(gè)函數(shù)返回了指定項(xiàng)目的本地變量類型以及訪問(wèn)權(quán)限。 |
| 函數(shù) | int? NumberOfItemProperties (HANDLE hConnect, LPCSTR ItemName); |
| 說(shuō)明 | 這個(gè)函數(shù)返回了和指定標(biāo)簽相關(guān)的OPC項(xiàng)目屬性數(shù)量 |
| 函數(shù) | BOOL? GetItemPropertyDescription (HANDLE hConnect, int PropertyIndex, DWORD *pPropertyID, VARTYPE *pVT, BYTE *pDescr, int BufSize); |
| 說(shuō)明 | 遍歷NumberOfItemProperties()函數(shù)創(chuàng)建的列表,就可以獲取每個(gè)項(xiàng)目屬性的描述 |
?
| 函數(shù) | BOOL? ReadPropertyValue (HANDLE hConnect, LPCSTR Itemname, DWORD PropertyID, VARIANT *pValue); |
| 說(shuō)明 | ReadPropertyValue()函數(shù)可以返回一個(gè)項(xiàng)目屬性的當(dāng)前值。 |
6、從服務(wù)器獲取標(biāo)簽值更新(Getting updated Tag Values from the Server)
| 函數(shù) | BOOL? EnableOPCNotification (HANDLE hConnect, NOTIFYPROC lpCallback); |
| 說(shuō)明 | 如果你的應(yīng)用支持回調(diào),當(dāng)連接的服務(wù)器發(fā)出了標(biāo)簽數(shù)據(jù)值改變的通知時(shí),WTclient會(huì)提供回調(diào)操作。回調(diào)函數(shù)的原型定義如下 |
| 函數(shù) | void CALLBACK EXPORT OPCUpdateCallback (HANDLE hGroup, HANDLE hItem, VARIANT *pVar, ???????????????????????????????????????????????????????????????????????FILETIME timestamp, DWORD quality) |
| 說(shuō)明 | 由組指針和項(xiàng)目指針確定的標(biāo)簽的值、時(shí)間戳以及OPC品質(zhì)標(biāo)簽都會(huì)在回調(diào)過(guò)程中提供給應(yīng)用。。 |
?
| 函數(shù) | BOOL? ReadOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar, ???????????????????????????????????FILETIME *pTimeStamp, DWORD *pQuality); |
| 說(shuō)明 | 如果WTclient已經(jīng)配置為維護(hù)一個(gè)內(nèi)部標(biāo)簽緩沖,控制應(yīng)用可以使用ReadOPCItem函數(shù)讀出當(dāng)前標(biāo)簽的值。如果請(qǐng)求的項(xiàng)目不可用(或者沒(méi)有選定DLL緩沖),函數(shù)會(huì)返回FALSE。 |
| 函數(shù) | HRESULT? ReadOPCItemFromDevice (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar, FILETIME *pTimeStamp, DWORD *pQuality); |
| 說(shuō)明 | 這個(gè)函數(shù)執(zhí)行了一個(gè)直接同步讀取服務(wù)器端指定項(xiàng)目的操作。 |
7、將標(biāo)簽值寫入到服務(wù)器(Writing Tag Values to the Server)
| 函數(shù) | DWORD? WriteOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar, BOOL DoAsync); |
| 說(shuō)明 | Writing new data to the connected Server is accomplished via the WriteOPCItem function.? The identifying handles for the group and item must be supplied as well as the data to be written.? The DoAsync parameter instructs the dll to perform an Asynchronous write to the Server.? For Synchronous writes, the return value indicates the hResult returned from the server and a non-zero value indicates an error.? For Asynchronous writes, the return value is a Transaction ID that defines the asynchronous callback handle and a zero value indicates an error. |
8、其他函數(shù)和回調(diào)函數(shù)(Miscellaneous Functions and callbacks)
| 函數(shù) | BOOL? GetSvrStatus (HANDLE hConnect, OPCSERVERSTATUS *pSvrStatus, int VendorInforBufSize); |
| 說(shuō)明 | The current status of the identified server is returned in the supplied buffer. |
| 函數(shù) | BOOL? SetClientName (HANDLE hConnect, LPCSTR Name); |
| 說(shuō)明 | This function allows the client to define a name to designate the connection with the server. |
| 函數(shù) | BOOL? EnableErrorNotification (ERRORPROCAPI? lpCallback); |
| 說(shuō)明 | The WTClient dll can notify the client application of errors that occur during processing of data interface calls to an OPC Server.? Error messages may be generated by the dll if unexpected situations occur during processing of a user request.? The default operation of the dll is to display a user message in a dialog box describing the condition.? In most cases, it is more appropriate for the application itself to handle the error message rather than having the dialog generated by the dll.? If Error Notification is enabled, control will be passed to the application via the following callback: |
| 函數(shù) | void CALLBACK EXPORT ErrorMsgCallback (DWORD hResult, char *pMsg); |
| 說(shuō)明 | A textual description of the error is contained in pMsg along with the resultant hResult. |
| 函數(shù) | BOOL? EnableClientEventMsgs (EVENTMSGPROC? lpCallback); |
| 說(shuō)明 | The WTClient dll can also notify the client application of various events as they occur during operation of the connection with the server.? These events are basically used for debugging and represent normal activity associated with processing individual interfaces, (such as entering and exiting a particular function).? Generally, the client application does not need to be made aware of theses events, however, if it wishes to provide a low level description of how the connection is functioning, it can receive these debugging statements as they occur by enabling Event Msgs. |
| 函數(shù) | void CALLBACK EXPORT EventMsgCallback (char *pMsg); |
| 說(shuō)明 | A textual description of the event is contained in pMsg. |
| 函數(shù) | BOOL? EnableShutdownNotification (HANDLE hConnect, SHUTDOWNPROCAPI? lpCallback); |
| 說(shuō)明 | If a connected OPC Server wishes to shutdown, it may request that any or all clients disconnect.? The Client application should enable the shutdown notification within the WTClient dll to handle this request and terminate the connection. |
| 函數(shù) | void CALLBACK EXPORT ShutdownCallback (HANDLE hConnect); |
| 說(shuō)明 | The hConnect parameter identifies the server connection that is requesting the disconnect. |
9、創(chuàng)建警報(bào)/事件訂閱機(jī)制(Creating an Alarms & Events Subscription)
| 函數(shù) | BOOL Create_AE_Subscription (HANDLE hConnect, HANDLE SubscriptionHandle,DWORD *pBufferTime, DWORD *pMaxSize); BOOL WINAPI EnableAECallback (AE_PROC lpCallback); BOOL WINAPI EnableExtendedAECallback (AE_PROC_EX lpCallback); |
| 說(shuō)明 | To begin receiving alarm and event messages from the connected server, a subscription must be in initiated and a callback procedure defined.? The application passes a SubscriptionHandle that the server uses to identify the connection to the callback.? pBufferTime and pMaxSize refer to the requested update frequency and the maximum number of events to be exchanged at one time.? (Note:? These values are for efficiency purposes only.? If the standard callback is used, the WTClient DLL will set up the connection and callback to the server.? The DLL will always issue a single callback to the application per event message, regardless of how many event messages are in the server callback to the dll.? If the extended version of the callback is used, these parameters have the effect as described in the OPC A&E Specification with respect to the ONEVENTSTRUCT.) ? |
One of two callback procedures may be defined, depending upon the complexity of the client application.? Teh standard callback procedure is prototyped as follows:
| void CALLBACK EXPORT AECallback (HANDLE SubscriptionHandle, char *pSource, |
?
| 函數(shù) | void CALLBACK EXPORT AECallback (HANDLE SubscriptionHandle, char *pSource, FILETIME timestamp, char *pMsg, DWORD severity); |
| 說(shuō)明 | The SubscriptionHandle is the same as created by the subscription,? pSource identifies the source of the event and pMsg is the description. |
If additional information regarding the alarm & event notification, the client must enable the extended version of the callback:
| 函數(shù) | void CALLBACK EXPORT ExtendedAECallback (HANDLE SubscriptionHandle, BOOL bRefresh, BOOL bLastRefresh, DWORD dwCount,??????????????????????????????????????????????????????????????????????? ONEVENTSTRUCT *pEvents) |
| 說(shuō)明 | Notice that the extended version of the A&E Callback contains the unfiltered parameter list as returned by the server OnEvent Interface, and may contain more than one event message. |
?
10、A&E服務(wù)器直接調(diào)用接口(A&E Server Direct Interface Calls)
The following functions are provided to allow the client application to call directly into the attached A&E Server.? The parameter list is passed directly to the associated Server Interface without change and the resulting returned values originate from the server itself.? The WTClient.dll does not modify these parameters in any way and their definition is described in the OPC Alarms & Events Specification available from the OPC Foundation.? Please refer to this specification for a detailed description of each of the following functions.
| BOOL? GetAESvrStatus (HANDLE hConnect, OPCEVENTSERVERSTATUS *pSvrStatus, |
The current status of the identified server is returned in the supplied buffer.??
| BOOL? Refresh_AE_Subscription (HANDLE hConnect, HANDLE hSubscription); |
This function allows the client to request a refresh of the defined A&E subscription from the server.??
| HRESULT? AckCondition (HANDLE hConnect, DWORD dwCount, LPWSTR szAcknowledgerID, |
The client uses the AckCondition method to acknowledge one or more conditions in the Event Server.? The client receives event notifications from conditions via the IOPCEventSink::OnEvent callback.? This AckCondition method specifically acknowledges the condition becoming active or transitioning into a different sub-condition (and no other state transition of the condition).? One or more conditions belong to a specific event source – the source of the event notification.? For each condition-related event notification, the corresponding Source, Condition Name, Active Time and Cookie? is received by the client as part of the OnEvent callback parameters.? (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT? EnableConditionByArea (HANDLE? hConnect, DWORD? dwNumAreas, LPWSTR *pszAreas); |
Places all conditions for all sources within the specified process areas into the enabled state.? Therefore, the server will now generate condition-related events for these conditions.?
The effect of this method is global within the scope of the event server.? Therefore, if the server is supporting multiple clients, the conditions are enabled for all clients, and they will begin receiving the associated condition-related events. (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT EnableConditionBySource (HANDLE? hConnect, DWORD? dwNumSources, LPWSTR *pszSources); |
Places all conditions for the specified event sources into the enabled state.? Therefore, the server will now generate condition-related events for these conditions.?
The effect of this method is global within the scope of the event server.? Therefore, if the server is supporting multiple clients, the conditions are enabled for all clients, and they will begin receiving the associated condition-related events. (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT DisableConditionByArea (HANDLE? hConnect, DWORD? dwNumAreas, LPWSTR? *pszAreas); |
Places all conditions for all sources within the specified process areas into the disabled state.? Therefore, the server will now cease generating condition-related events for these conditions.?
The effect of this method is global within the scope of the event server.? Therefore, if the server is supporting multiple clients, the conditions are disabled for all clients, and they will stop receiving the associated condition-related events. (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT DisableConditionBySource (HANDLE? hConnect, DWORD dwNumSources, LPWSTR? *pszSources); |
Places all conditions for the specified event sources into the disabled state.? Therefore, the server will no longer generate condition-related events for these conditions.?
The effect of this method is global within the scope of the event server.? Therefore, if the server is supporting multiple clients, the conditions are disabled for all clients, and they will stop receiving the associated condition-related events. (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT GetFilter? (HANDLE? hConnect, HANDLE? hSubscription, DWORD? *pdwEventType, |
Returns the filter currently in use for event subscriptions. (Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
| HRESULT SetFilter (HANDLE? hConnect, HANDLE hSubscription, DWORD dwEventType, |
Sets the filtering criteria to be used for the event subscription.
Events may be selected using the following criteria:
? Type of event, i.e. simple, condition, or tracking.
? Event categories
? Lowest severity, i.e. all events with a severity greater than or equal to the specified severity.
? Highest severity, i.e. all events with a severity less than or equal to the specified severity.
? Process areas
? Event Sources
A list of values for a single criterion are logically ORed together (e.g. if two event categories are specified, event notifications for both categories will be received).? If multiple criteria are specified, they will be logically ANDed together, i.e. only those events satisfying all criteria will be selected.? An example is specifying both lowest severity and highest severity will result in the selection of events with severities lying between the two values.
An OPCEventSubscription object has only one filter.
?(Refer to the OPC Alarms & Events Specification for a detailed description of the parametr list and return value.)
?
總結(jié)
以上是生活随笔為你收集整理的OPC:客户端开发——应用WTclient.dll使用手册部分中文版的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: C#读取计算机的机器码、网卡、设备码
- 下一篇: 宽带服务器维护查询,网络连接状态查询方法