Kit Server: Alarms and Events test nodes in Data Access
NODE STRUCTURE
In OPC Data Access address space, a simple tracking event is represented by an event branch. A condition state is represented by a condition state branch.
All event branches contain:
Node type | Name | Canonical data type | Access rights | Description |
---|---|---|---|---|
leaf | QualifiedSourceName | VT_BSTR | readable | The source of event notification. |
leaf | Time | VT_DATE | readable/writeable | Time of the event occurrence. |
leaf | Message | VT_BSTR | readable/writeable | Event notification message describing the event. |
leaf | Type | VT_UI4 | readable | Event type. 1 (OPC_SIMPLE_EVENT) for simple event, 2 (OPC_TRACKING_EVENT) for tracking event. |
leaf | CategoryId | VT_UI4 | readable | Event category ID. |
leaf | Severity | VT_UI4 | readable/writeable | Event severity (1..1000). |
branch | AttributeValues | Holds vendor-specific event attributes. | ||
leaf | AttributeValues.eaid | attribute type | readable/writeable | One leaf for each event attribute, where eaid is the attribute Id in decimal. |
Event branches for simple events contain in addition to the base:
Node type | Name | Canonical data type | Access rights | Description |
---|---|---|---|---|
method | Generate | Generates an event. |
Event branches for tracking events contain in addition to the base:
Node type | Name | Canonical data type | Access rights | Description |
---|---|---|---|---|
leaf | ActorId | VT_BSTR | readable/writeable | Actor ID. |
method | Generate | Generates an event. |
Wherever a “method” node type is listed, it is a shortcut for a following set of nodes:
Node type | Name | Canonical data type | Access rights | Description |
---|---|---|---|---|
leaf | MethodName | VT_BOOL | readable/writeable | Same as MethodName.Invoke. |
branch | MethodName | Holds detail nodes of the method. | ||
leaf | MethodName.Invoke | VT_BOOL | readable/writeable | Writing “true” to this leaf executes the method. The read value remains always “false”. |
branch | MethodName.ArgumentValues | Unused. It is meant to contain read/writeable leaves, one for each argument of the method. Currently none of
our methods has any arguments. |
For simple and tracking events, the OPC-DA client uses the writeable leaves to specify the variable parameters of the event, and then invokes the Generate method (by writing “true” to a corresponding leaf) to generate the OPC-A&E event.
A condition state branch contains:
Node type | Name | Canonical data type | Access rights | Description |
---|---|---|---|---|
leaf Locked VT_BOOL readable Gives “true” iff the internal lock count is non-zero. See the Lock, Unlock methods. | ||||
leaf ConditionName VT_BSTR readable The name of the condition. | ||||
leaf Enabled VT_BOOL readable/writeable Determines whether the condition is enabled. | ||||
leaf Active VT_BOOL readable Determines whether the condition is active. | ||||
leaf Acknowledged VT_BOOL readable Determines whether the condition is acknowledged. | ||||
leaf Quality VT_UI2 readable/writeable Quality associated with the condition | ||||
leaf ActiveTime VT_DATE readable Time of the most recent transition into the condition. There may be transitions among the sub-conditions which are more recent. | ||||
leaf SubconditionActiveTime VT_DATE readable Time of the most recent transition into active subcondition. This is the time value which must be specified when acknowledging the condition. | ||||
leaf InactiveTime VT_DATE readable Time of the most recent transition out of this condition. | ||||
leaf AcknowledgeTime VT_DATE readable The time of the most recent acknowledgment of this condition (of any sub-condition). | ||||
leaf AcknowledgerId VT_BSTR readable This is the ID of the client who last acknowledged this condition. | ||||
leaf Comment VT_BSTR readable The comment string passed in by the client who last acknowledged this condition. | ||||
leaf ActiveSubcondition VT_BSTR readable Same as ActiveSubcondition.Name. | ||||
branch ActiveSubcondition Holds detail nodes for the active subcondition. | ||||
leaf ActiveSubcondition.Name VT_BSTR readable The name of the current sub-condition, for multi-state conditions. For a single-state condition, this contains the condition name. | ||||
leaf ActiveSubcondition.Definition BSTR readable An expression which defines the sub-state represented by the sub-condition. | ||||
leaf ActiveSubcondition.Severity VT_UI4 readable The severity of any event notifications generated on behalf of this sub-condition. | ||||
leaf ActiveSubcondition.Description BSTR readable The text string to be included in any event notification generated on behalf of this sub-condition. | ||||
branch AttributeValues Holds vendor-specific event attributes. | ||||
leaf AttributeValues.eaid attribute type readable/writeable One leaf for each event attribute, where eaid is the attribute Id in decimal. | ||||
method Acknowledge Acknowledges the event condition. | ||||
method Activate Activate the event condition. | ||||
method Disacknowledge Disacknowledges the event condition (reverses the effect of acknowledge). | ||||
method Inactivate Inactivate the event condition. | ||||
method Lock Increments an internal lock count. When the lock count is non-zero, changes to condition state do not generate an event. | ||||
method Unlock Decrements an internal lock count. When the lock reaches zero, an event is generated if a condition state has changed since the count became non-zero. |
For condition events, the OPC-DA client uses the writeable leaves to specify the variable parameters of the condition state, and invokes appropriate methods to change the condition state. When this is done in an unlocked state, each such change may generate an OPC A&E event. If the client wants to prevent it, it invokes the Lock method, makes the changes, and then it invokes the Unlock method to generate the OPC-A&E event.
Note that there is an issue with converting between DATE (suitable for use in VARIANTs), and FILETIME (used in OPC method calls); a precise roundtrip conversion is not guaranteed. Special precautions need to be made.
EXAMPLES
Set some events to active state
Rem $Header: $ Rem Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Rem+++ Rem This example shows how to for a refresh for all active conditions and inactive, unacknowledged conditions. Option Explicit Dim EasyDAClient: Set EasyDAClient = CreateObject("OPCLabs.EasyDAClient.5.2") Dim EasyAEClient: Set EasyAEClient = CreateObject("OPCLabs.EasyAEClient.5.2") WScript.ConnectObject EasyAEClient, "EasyAEClient_" WScript.Echo "Processing event notifications..." Dim SubscriptionFilter: Set SubscriptionFilter = EasyAEClient.CreateSubscriptionFilter SubscriptionFilter.Sources = Array("Simulation.ConditionState1", "Simulation.ConditionState2", "Simulation.ConditionState3") Dim handle: handle = EasyAEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, Nothing, SubscriptionFilter) Rem The component will perform auto-refresh at this point, give it time to happen WScript.Echo "Waiting for 10 seconds..." WScript.Sleep 10*1000 Rem Set some events to active state, which will cause them to appear in refresh WScript.Echo "Activating conditions and waiting for 10 seconds..." EasyDAClient.WriteItemValue "", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", True EasyDAClient.WriteItemValue "", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState2.Activate", True WScript.Sleep 10*1000 WScript.Echo "Refreshing subscription and waiting for 10 seconds..." EasyAEClient.RefreshEventSubscription handle WScript.Sleep 10*1000 EasyAEClient.UnsubscribeEvents handle Rem Notification event handler Sub EasyAEClient_Notification(Sender, e) WScript.Echo WScript.Echo "Refresh: " & e.Refresh WScript.Echo "RefreshComplete: " & e.RefreshComplete If Not (e.Event Is Nothing) Then With e.Event WScript.Echo "Event.QualifiedSourceName: " & .QualifiedSourceName WScript.Echo "Event.Message: " & .Message WScript.Echo "Event.Active: " & .Active WScript.Echo "Event.Acknowledged: " & .Acknowledged End With End If End Sub Rem---