WinTECH软件快速客户端开发DLL

WinTECH软件快速客户端开发DLL(WTclient),提供了一种应用API方便地将定制应用和任何OPC Server相结合的方式。所有COM和OPC的细节均由DLL来处理,这使得一个应用可以轻松的从服务器获取数据点,而不用关心接口后的实际完成过程。这些DLL可以方便和已有的或者新的应用相结合。其中提供了面向OPC1.0和OPC2.0数据访问标准所需的全部OPC接口,同时也提供了浏览接口和连接到简单警报/事件服务器的支持。
  The WinTECH Software Rapid Client Development DLL, (WTclient), provides an easy to use API for integrating a custom application with data from any OPC Server.  All the details of COM and OPC are handled by the DLL, which allows an application to easily obtain data points from a Server, without having to be concerned with the actual implementation of the underlying interfaces.  The DLL may be easily integrated with existing applications, or new ones.  All required OPC Interfaces are supported for both OPC 1.0 and OPC 2.0 Data Access Standards as well as the Browse Interface and support for connecting to a simple Alarms & Events Server.
  这个用户指导应该被当作一本OPC数据访问和OPC警报/事件规范手册文档使用,其中的所有资料都可在OPC主网站http://www.opcfoundation.org上找到。
  This user’s guide should be used as a companion document to the OPC Data Access and OPC Alarms & Events Specifications available from the OPC Foundation web-site at http://www.opcfoundation.org.
应用WTclient.dll创建自定制OPC客户端
将应用和WTclient.lib连接(Link WTclient.lib with the Application)  WTclient.lib内有DLL文件中API的出口定义,将这个文件包含到你的定制应用的工程文件中,同时将WTclientAPI.h包含到会调用DLL的模块中。如果应用Visual Basic进行编程,需要将VBA范例中(随demo提供)的module1.bas包含到你的工程中。
  WTclient.lib contains the export definitions for the DLL’s API.  Include this file with the project files for the custom application and include WTclientAPI.h with those modules which will be making calls into the DLL.  If programming in Visual Basic, include the module1.bas from the VBA_example, (supplied with the demo), into your project.
DCOM初始化(DCOM Initialization)  从WTClient.DLL2.0版本开始,初始化DCOM是客户端应用的责任了。2.0版本之前,WTClient.dll在DLLMain函数中执行DCOM和安全初始化的过程,并在dll下载时调用CoUninitialize函数。由于不同windows dll文件的加载顺序,这会带来一些问题。这些初始化调用被移动到了一个新的输出函数(WTclientCoInit())中,用户的应用可以在主要可执行线程启动的时候调用这个函数。WTclientCoInit()将DCOM初始化为多线程并使用默认安全设定。你的应用可以选择自行初始化DCOM替代这个输出函数。任何情况下,你的应用都必须在终止时调用CoUninitialize()函数。
  Beginning with WTClient.DLL Version 2.0, it is now the Client Application's responsibility to properly initialize DCOM.  Prior to Version 2.0, WTClient.dll performed DCOM and Security initialization in the DLLMain function and called CoUninitialize when the dll was unloaded.  This presented some problems due to the load-order of various Windows dll’s.  These initialization calls have been moved to a new exported function, (WTclientCoInit ()), that the user application can call during the startup of the main executable thread. WTclientCoInit () initializes DCOM as multi-threaded and uses default security.  Your application may choose to perform DCOM initialization itself rather than using the exported function.  In either case, your application MUST call CoUninitialize() when terminating.
获取OPC服务器列表(Obtaining the List of OPC Servers)  WTclient.dll有两个输出函数可以允许控制应用来通过其获取可用的OPC服务器列表。
  WTclient.dll exports two functions that allow the controlling application to obtain a list of available OPC Servers.
int NumberOfOPCServers (BOOL UseOPCENUM, LPCSTR MachineName);

  OPCENUM是由OPC Foundation提供的一个组件,它允许预期的客户端应用获取本地以及远程可用服务器列表。可惜的是,在写这个组件的时候,OCENUM的操作并没有很好的跨平台一致性。WTclient.dll允许应用尝试使用OPCENUM组件来获取服务器列表,或者越过OPCENUM组件通过扫描Windows登记的本地拷贝来获取列表。如果使用了OPCENUM,你可以通过传递远程机器的名称来获取远程服务器列表。
  OPCENUM is a component supplied by the OPC Foundation to allow prospective client applications to obtain a list of available servers on the local or remote machine.  Unfortunately, at the time of this writing, the operation of OPCENUM is not consistant across all platforms.  WTclient.dll allows the application to attempt to use the OPCENUM component to obtain the list of Servers, or to bypass OPCENUM and obtain the list by scanning the local copy of the Windows Registry.  If OPCENUM is used, you can pass the name of a remote machine to obtain the remote server list.
  一旦WTclietn.dll返回了服务器的数目,应用就可以通过调用如下所示的函数来对服务器名称列表进行枚举:
  Once the number of servers has been returned from WTclient.dll, the application can iterate through the list of names by calling:
BOOL GetServerName (int index, LPSTR Buffer, int BufSize);

  一个由用户提供的字符缓冲区Buffer负责存放传递过来的index标识的服务器列表中某个服务器名字。BufSize标识用户提供的字符缓冲区的长度,并可以防止dll载入过长的名字。如果Buffer中返回了一个有效的服务器名称,GetServerName函数返回TRUE。
  A user supplied character buffer receives a name from the Server list as identified by a passed index.  BufSize identifies the length of the user supplied character buffer and prevents the dll from loading a name that's too long.  GetServerName returns TRUE if a valid Server name is returned in Buffer, otherwise the return value is FALSE.
  还有一个补充函数集允许应用获取可用的警报/事件服务器列表。
  A complementary set of functions allow the application to obtain a list of available Alarms & Events Servers.
int NumberOfOPC_AEServers (LPCSTR MachineName);
BOOL GetOPC_AEServerName (int index, char *pBuf, int BufSize);

建立OPC连接(Establishing an OPC Connection)HANDLE ConnectOPC(LPCSTR MachineName, LPCSTR ServerName, BOOL EnableDLLBuffering);
HANDLE ConnectOPC1(LPCSTR MachineName, LPCSTR ServerName, BOOL EnableDLLBuffering);
HANDLE ConnectOPC_AE(LPCSTR MachineName, LPCSTR ServerName);

  如果一个由计算机名称和服务器名称定义的和OPC服务器之间的连接可以被建立,则此函数返回一个有效的HANDLE。可以建立和不同的服务器的多个同步连接,此时返回的HANDLE标识了可用于以后创建组和项目的连接。如果传递一个空字符串作为计算机名称参数,标识的是本地计算机。WTclient会先尝试使用OPC2.0连接点接口进行连接,如果不可用,则会转而采用OPC1.0数据对象接口。
  This function returns a valid HANDLE if a connection could be established to the OPC Server defined by MachineName and ServerName.  Multiple simultaneous connections to different servers may be established, and the returned HANDLE identifies the connection for future calls to create groups and items.  Passing a Null String as the MachineName parameter identifies the local machine.  WTclient will attempt the connection using the OPC 2.0 ConnectionPoint Interface.  If not available, it will revert the the OPC 1.0 DataObject Interface.
  WTclient.dll的基本操作有两种模式。第一种模式用于支持'C-样式'回调函数的应用,在这种情况下,dll中没有缓冲区操作。由于可以从连接的OPC服务器接收到数据更改提示,回调可用于将新的信息传送给控制应用(此处涉及到下面会提及的EnableOPCNotification函数)。
  WTclient.dll operates in basically two modes.  The first is used with those applications which support 'C-Style' callback functions.  In this case, no buffering is performed inside the dll.  As data change notifications are received from the connected OPC Server, callbacks are used to pass the new information to the controlling application, (refer to EnableOPCNotification below)
  对于使用不支持回调函数的工具设计的那些应用(例如Visual Basic 5.0),WTclient会被配置为维护一个由应用创建的全部OPC项目(标签)列表的模式。当服务器数据改变时,dll中列表里相关的标签值会被更新,控制应用可以随时读取标签的值(此处涉及到下面会提及的ReadOPCItem函数)。
  For those applications designed using tools which do not support callback functions, (such as Visual Basic 5.0), WTclient may be configured to maintain a list of all OPC Items, (Tags), created by the application.  As data from the Server changes, the corresponding tag value in the dll's list will be updated.  The controlling application may read the value of a tag at any time, (refer to ReadOPCItem below).
  ConnectOPC1会总是尝试使用OPC1.0连接。
  ConnectOPC1 will always attempt an OPC 1.0 connection. 
  ConnentOPC_AE会建立一个和OPC警报/事件服务器的连接,此连接由计算机名称和服务器名称指定。
  ConnectOPC_AE will establish a connection to the OPC Alarms & Events Server specified by MachineName and ServerName.
void DisconnectOPC(HANDLE hConnect);void DisconnectOPC_AE(HANDLE hConnect);

  当一个应用终止的时候,它会负责从依附的服务器断开连接。DisconnectOPC()(或Disconnect_OPCAE())函数会对hConnect定义的连接执行一个彻底的连接关闭操作。
  When an application terminates, it is responsible for disconnecting from an attached Server.  The DisconnectOPC(), (or Disconnect_OPCAE()), function will provide a clean shutdown of the connection defined by hConnect.
获取服务器标签名列表(Obtaining a list of Server Tag Names)int  NumberOfOPCItems(HANDLE hConnect);
BOOL  GetOPCItemName (HANDLE hConnect, int index, char *pBuf, int BufSize);

  这两个函数和获取服务器名称列表函数的调用方式类似。NumberOfOPCItems()返回所连接OPC服务器支持的独有标签总数。依次地调用GetOPCItemName()会逐步遍历所有可用的标签名,最终允许控制应用选择一个项目或者提交一个浏览列表给用户。NumberOfOPCItems()会浏览服务器的全部项目名称列表并提供一个“FLAT”格式的列表。
  These two functions operate similarly to those which allow you to obtain the list of Server names.  NumberOfOPCItems() returns the total number of unique tags supported by a connected OPC Server.  Incrementally calling GetOPCItemName will step through all the available tag names to allow the controlling application to select an item or present a Browse list to the user.  NumberOfOPCItems will browse the complete list of item names from the server and present the list in a 'FLAT' format.
BOOL GetNameSpace (HANDLE hConnect, WORD *pNameSpace);
BOOL BrowseTo (HANDLE hConnect, LPCSTR NodeName);
char SetWTclientQualifier (char qualifier);
int  BrowseItems (HANDLE hConnect, WORD Filter);

  为了提供较好的应用等级体系命名空间访问服务器的方式,WTClient dll提供函数以便于应用直接从服务器端浏览项目名。GetNameSpace()函数允许应用决定服务器的命名空间。BrowseTo()函数负责将当前浏览位置移动到指定的名称处,BrowseItems()函数用服务器的节点名称来填充内部名称列表。BrowseTo()函数既可以和OPC_LEAF一起使用来读取当前浏览位置的叶片名称,也可以和OPC_BRANCH一起使用来当前浏览位置的读取枝条名称。这些名称可以被GetOPCItemName函数获取。WtClient动态链接库为NumberOfOPCItems()函数和BrowseItems()函数维护一个单一的名称列表,因此应用程序在浏览服务器命名空间的时候必须很小心,避免覆盖前一次调用的值。在各个等级的树的相互作用过程中,调用BrowseItems之后,所有的项目名称必须立刻拷贝到本地存储中。
  To provide better access to a server with a hierarchical name space, the WTClient dll provides functions to allow the application to browse item names directly from the server.  GetNameSpace allows the application to determine the namespace of the server.  BrowseTo moves the current browse position to the name specified, and BrowseItems fills the internal name array with node names from the server.  BrowseTo may be used with either OPC_LEAF to read the leaf names or OPC_BRANCH to read the branch names immediately below the current browse position.  The names may then be retrieved using the GetOPCItemName function.  The WtClient DLL maintains a single name array for use by NumberOfOPCItems and BrowseItems so the application must be careful when browsing the server namespace, not to overwrite values from a previous call.   During iteraction of the hierarchical tree, the all item names must be copied into local storage immediately after calling BrowseItems.
  NumberOfOPCItems()函数相当于在根节点处用OPC_FLAT方式调用BrowseItems()函数。
  Calling BrowseItems from the Root position using OPC_FLAT behaves identically to NumberOfOPCItems().
  SetWTclientQualifier()函数允许应用程序改变用来解析各个等级命名空间节点的划界字符。客户端应用一般认为缺省的划界符为‘.’,然而也有些服务器将‘.’字符用在了节点名字中。
  SetWTclientQualifier allows the application to change the delimiting character used to parse the nodes of a hierarchical namespace.  The default delimiter expected by the client dll is ‘.’, however, some servers use the ‘.’ character as part of the node name.
BOOL  SetBrowseFilters (HANDLE hConnect, LPCSTR UserString, VARTYPE DataType, DWORD AccessType);

  应用程序可以设置浏览过滤器来影响服务器返回的OPC项目个数。应用程序可以选择仅获取那些符合指定数据类型或者访问权限的项目。
  Browse filters may be set by the application to effect the number of OPC Items returned from the server.The application may choose to retrieve only those items of a certain data type or access rights.
创建OPC组和标签(Creating OPC Groups and Tags)HANDLE  AddOPCGroup (HANDLE hConnect, LPCSTR Name, DWORD *pRate, float *pDeadBand);
void  RemoveOPCGroup (HANDLE hConnect, HANDLE hGroup);

  WTclient.dll提供两个函数,允许你创建、移除一个OPC组。AddOPCGroup()函数返回一个唯一指定某个组的指针,这个指针对于其他的Wtclient函数是必需的。传送给做AddOPCGroup()参数的值由控制应用端决定,对于每个组都是明确的。Name不会被服务器采用,可以任意选取。pRate是一个指针,指向对象为所需刷新率(单位为毫秒),服务器端用这个刷新率提供客户端刷新后的返回值。
  WTclient.dll exports two functions which allow you to create and remove an OPC Group.  The AddOPCGroup() function returns a handle to uniquely identify the group, and must be supplied to other Wtclient functions to reference tags, etc.  The values passed to AddOPCGroup as parameters are determined by the controlling application and are specific to each Group.  The name is arbitrary and not used by the Server.  pRate is a pointer to  the desired refresh rate, (in milliseconds), that the server uses to provide updates back to the client.  The actual rate is returned from the server in pRate.
BOOL  ChangeOPCGroupState (HANDLE hConnect, HANDLE hGroup, BOOL Active));

  应用这个函数可以将指定的OPC组设定为激活状态(Active = TRUE)或者无效状态(Active = FALSE)。
  The defined OPC Group may be activated, (Active = TRUE), or deactivated, (Active = FALSE), using this function.
HANDLE  AddOPCItem (HANDLE hConnect, HANDLE hGroup, LPCSTR ItemName);
void  RemoveOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem);

  如果想要给指定的OPC组添加一个项目,只需使用组的指针以及待添加项目的标签名调用AddOPCItem函数即可,该函数会返回一个唯一标识指定项目的指针。如果请求的项目不存在,则函数将会返回INVALID_HANDLE_VALUE。当关闭一个组的时候,需要调用RemoveOPCItem()函数来清理已分配的内存。
  To add an item to a defined OPC Group, simply call the AddOPCItem function with the group's handle and the tag name of the desired item.  A handle value will be returned to uniquely define the item, INVALID_HANDLE_VALUE will be returned if the requested item does not exist).  Call RemoveOPCItem to clean-up allocated memory when closing a group.
BOOL  SetItemUpdateHandle (HANDLE hConnect,  HANDLE hGroup, HANDLE  hItem, HANDLE hUpdate);

  SetItemUpdateHandle()函数允许客户端应用定义一个独有的指针,供服务器在数据更新回调时使用。这个函数的提供是为了给客户端应用提供便利,以便于进行更有效率的程序设计,并可以对服务器提供的新数据进行操作。
  SetUpdateHandle allows the client application to specify a unique handle to be used by the server during Data Update Callbacks.  This function is provided as a convenience to the client application for more efficient design or handing new data presented by the server.
BOOL  GetOPCItemNameFromHandle (HANDLE hConnect,  HANDLE hGroup, HANDLE hItem,
                                                            char *pBuf, int BufSize);
 

  这个函数允许客户端应用通过传递AddOPCItem()函数返回的指针来获取OPC项目名。
  This function allows the client application to retrieve the OPC Item name by passing the handle returned from AddOPCItem.
BOOL  GetOPCItemType (HANDLE hConnect, HANDLE hGroup, LPCSTR ItemName, VARTYPE *pType,
                                        DWORD *pAccessRights);
 

  这个函数返回了指定项目的本地变量类型以及访问权限。
  This function returns the native variant type and access rights for the specified item.
int  NumberOfItemProperties (HANDLE hConnect, LPCSTR ItemName);
 

  这个函数返回了和指定标签相关的OPC项目属性数量。
  This function returns the number of OPC Item properties associated with the specified tag.
BOOL  GetItemPropertyDescription (HANDLE hConnect, int PropertyIndex, DWORD *pPropertyID,
                                                         VARTYPE *pVT, BYTE *pDescr, int BufSize);

  遍历NumberOfItemProperties()函数创建的列表,就可以获取每个项目属性的描述。
  A description of each item property may be obtained by iterating through the list created by NumberOfOPCItemProperties.
BOOL  ReadPropertyValue (HANDLE hConnect, LPCSTR Itemname, DWORD PropertyID, VARIANT *pValue);

  ReadPropertyValue()函数可以返回一个项目属性的当前值。
  The current value of an Item Property is returned by ReadItemProperty.
从服务器获取标签值更新(Getting updated Tag Values from the Server)BOOL  EnableOPCNotification (HANDLE hConnect, NOTIFYPROC lpCallback);

  如果你的应用支持回调,当连接的服务器发出了标签数据值改变的通知时,WTclient会提供回调操作。回调函数的原型定义如下:
  If your application supports callbacks, WTclient will issue the callback when notification from a connected Server indicates a change in the value of a Tag's data.  The prototype for the callback is defined as follows:
void CALLBACK EXPORT OPCUpdateCallback (HANDLE hGroup, HANDLE hItem, VARIANT *pVar,
                                                                       FILETIME timestamp, DWORD quality)

  由组指针和项目指针确定的标签的值、时间戳以及OPC品质标签都会在回调过程中提供给应用。
  The current value for a tag, timestamp and OPC Quality flags will be supplied to the application via the callback.  The Tag is identified by the associated handles identifying the group and item.
BOOL  ReadOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar,
                                   FILETIME *pTimeStamp, DWORD *pQuality);

  如果WTclient已经配置为维护一个内部标签缓冲,控制应用可以使用ReadOPCItem函数读出当前标签的值。如果请求的项目不可用(或者没有选定DLL缓冲),函数会返回FALSE。
  If WTclient has been configured to maintain an internal buffer of tags, the controlling application may read the current value of a tag by using the ReadOPCItem function.  If the requested item is not available, (or if DLLBuffering has not been selected), the function will return FALSE.
HRESULT  ReadOPCItemFromDevice (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar,
                                                          FILETIME *pTimeStamp, DWORD *pQuality);

  这个函数执行了一个直接同步读取服务器端指定项目的操作。
  This function performs a synchronous read directly from the server for the specified item.
将标签值写入到服务器(Writing Tag Values to the Server)DWORD  WriteOPCItem (HANDLE hConnect, HANDLE hGroup, HANDLE hItem, VARIANT *pVar, BOOL DoAsync);

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.
其他函数和回调函数(Miscellaneous Functions and callbacks)BOOL  GetSvrStatus (HANDLE hConnect, OPCSERVERSTATUS *pSvrStatus, int VendorInforBufSize);

The current status of the identified server is returned in the supplied buffer.
BOOL  SetClientName (HANDLE hConnect, LPCSTR Name);This function allows the client to define a name to designate the connection with the server.
BOOL  EnableErrorNotification (ERRORPROCAPI  lpCallback);
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:
void CALLBACK EXPORT ErrorMsgCallback (DWORD hResult, char *pMsg);
A textual description of the error is contained in pMsg along with the resultant hResult.
BOOL  EnableClientEventMsgs (EVENTMSGPROC  lpCallback);

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.
void CALLBACK EXPORT EventMsgCallback (char *pMsg);
A textual description of the event is contained in pMsg.
BOOL  EnableShutdownNotification (HANDLE hConnect, SHUTDOWNPROCAPI  lpCallback);

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.
void CALLBACK EXPORT ShutdownCallback (HANDLE hConnect);

The hConnect parameter identifies the server connection that is requesting the disconnect.
创建警报/事件订阅机制(Creating an Alarms & Events Subscription)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);

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,
                                                         FILETIME timestamp, char *pMsg, DWORD severity);

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:
void CALLBACK EXPORT ExtendedAECallback (HANDLE SubscriptionHandle, BOOL bRefresh,
                                                                        BOOL bLastRefresh, DWORD dwCount,
                                                                        ONEVENTSTRUCT *pEvents);

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.
A&E服务器直接调用接口(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,
                                      int VendorInforBufSize);

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,
                                       LPWSTR szComment, LPWSTR *pszSource, LPWSTR *pszConditionName,
                                       FILETIME *pftActiveTime, DWORD *pdwCookie, HRESULT **ppErrors);

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,
                               DWORD  *pdwNumCategories, DWORD  **ppdwEventCategories,
                               DWORD  *pdwLowSeverity, DWORD  *pdwHighSeverity, DWORD  *pdwNumAreas,
                               LPWSTR  **ppszAreaList, DWORD  *pdwNumSources, LPWSTR  **ppszSourceList);

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,
                              DWORD dwNumCategories, DWORD *pdwEventCategories, DWORD dwLowSeverity,
                              DWORD dwHighSeverity, DWORD dwNumAreas, LPWSTR *pszAreaList,
                              DWORD dwNumSources, LPWSTR *pszSourceList);

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.)
MFC范例ClientTstThe clientTst application was designed to demonstrate how an OPC Client application may be assembled using the WTclient dll.  clientTst was built using MSDEV Version 6.0.  All project and resource files are contained in the distribution file ClientTst.zip.
This simple application uses the standard MFC framework, (Application/Document/View), architecture generated by the Microsoft development platform for a multiple-document interface.  In this example,
only one Server connection is allowed at a time.  Menu options allow you to select a server using the local Windows Registry.  Adding an OPC Group will generate a new Document which will enable additional menu items for creating and viewing tags from the server.
MFC范例ClientTst2The ClientTst2 MFC application was designed to demonstrate a different technique for browsing the server namespace.  It was also designed using MSDEV 6.0 and the MFC framework.  ClientTst2 displays event messages from the WTClient.DLL as well s the current value for each subscribed tag.
MFC范例AEClientThe AEClient MFC application was designed to demonstrate a simple Alarms & Events logger.  It establishes a connection to a specified server and displays alarm and event messages as they occur.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值