Lab 18 – Create Events 9-27
The Summary Tag List Tag Name pane appears similar to the following figure.
54. Click OK, then Finish.
The new MixerSummary tag now appears within the Tag Name pane of the All Event Tags
group.
Create the ExternalEvent Event Tag
For this task you will create an event tag that is triggered by an External action using Wonderware
Application Server instead of from within Historian. The trigger mechanism will be configured in a
subsequent lab.
55. Create a new Event tag called ExternalEvent using the previous steps.
56. Click Next.
57. Enter Triggered by Application Server within the Description: field.
58. Click Next.
Wonderware System Platform Course - Part 2
9-28 Module 9 – Historian Event System
The New Event Tag – Detector dialog box appears.
59. Select External from the Detection Type: drop-down list.
60. Click Next.
61. Select None for the Action Type.
62. Click Finish.
Review Event History
63. Start ActiveFactory Query
Event History is stored in the Event History table in the Runtime database. You will write a custom
query to view that data.
64. Select Custom in the Query type drop-down list.
65. Enter the following query:
SELECT Tagname, Datetime, Detectdatetime
FROM Eventhistory
Wonderware Training
Lab 18 – Create Events 9-29
66. Click the Data tab. You will see all the events generated so far in the Historian.
Notice that several HiLevelEvent records and TransferEvent records display in the query results:
Wonderware System Platform Course - Part 2
9-30 Module 9 – Historian Event System
You can also use the predefined Event History query in ActiveFactory Query to display event
history data.
67. Change the Query type to Event history values.
68. Check the Tag name, Date and time, and Detect date time checkboxes in the Columns tab.
69. Select 1 hour in the Time tab.
70. Select the HiLevelEvent in the Tag Picker.
71. Click the Data tab.
The events for the HiLevelEvent tag display:
Wonderware Training
Lab 18 – Create Events 9-31
Review Event Snapshot Values
You will now query the Snapshot values generated by the SysStatusEvent tag.
72. Select Event Snapshot from the Query Type drop-down list.
73. In the Time tab, verify 2 hours is shown in the Time drop-down field.
74. Select the SysStatusEvent tag in the Tag Picker.
75. In the Tag set tab, from the Snapshot Tags list, select the tags shown in the following figure:
76. Select the Columns tab.
77. Select the DetectDateTime checkbox.
Wonderware System Platform Course - Part 2
9-32 Module 9 – Historian Event System
78. Review and analyze the SQL Query:
79. Select the Data tab again to view the query results.
Wonderware Training
Section 3 – ActiveEvent 9-33
Section 3 – ActiveEvent
Section Objective
Explain and define Historian Event Tags and their characteristics.
This section explains and defines Historian Event Tags and their characteristics.
Introduction
ActiveEvent is an ActiveX control that allows you to notify the Historian event system when an
event has occurred in another application, such as InTouch. ActiveEvent is script-based and can
be used in any application that supports a COM-enabled scripting language to detect an event for
that application. COM-enabled scripting languages include InTouch scripting and Visual Basic.
After the ActiveEvent control is installed, it does not automatically appear in the list of available
ActiveX objects for use within WindowMaker. It must be registered on the InTouch node.
Use ActiveEvent for external event detection in cases where you want to cut processing overhead
used by the Historian Event Detector engine.
To enable external event detection for the Historian:
z Create an event tag in the Historian to store the event occurrence information. Make sure
that the detection type is set to External.
The event tag can then be defined so that the event is associated with an action that is
triggered from the Historian, such as executing a SQL script, sending an e-mail message,
or recording the values of a set of tags at the time the event occurred.
z Register (install on the host application) the ActiveEvent control so that it can be used in
the ActiveX container application (for example, in InTouch).
z Configure the DCOM security attributes for the external detector that will be used with
ActiveEvent. Security attributes must be set up on the Historian computer.
z Write a script that will notify the Historian event system of the external event.
z The system time for the ActiveEvent computer should be synchronized with the system
time for the Historian. If the ActiveEvent computer time is ahead, the event system may
generate NULL values for snapshot data.
Scripting ActiveEvent
Use ActiveEvent's methods in scripts to connect to a Historian and detect an external event. An
external detector is triggered using the Historian ActiveEvent control. The ActiveEvent control
(which resides on a client machine) interacts with the event detector (which resides on the server
machine) in order to trigger events externally. The ActiveEvent control facilitates the remote
triggering of events on the Historian system by first initializing with the Historian computer name
and event tag, and then calling the InvokeEventEx() method.
ActiveEvent can be scripted using any scripting language that supports COM. For example, an
InTouch script can trigger a Historian event if you use this control in an InTouch application. You
could also trigger an event from a Visual Basic script.
For details on ActiveEvent Properties and Methods, see the Historian ActiveX Controls Guide.
Wonderware System Platform Course - Part 2
9-34 Module 9 – Historian Event System
ActiveEvent Methods
Use ActiveEvent's methods in scripts to connect to a Historian and trigger an event. The
ActiveEvent control facilitates the remote triggering of events on the Historian system by first
initializing with the Historian computer name and event tag, and then calling the InvokeEventEx()
method.
ActiveEvent can be scripted using any scripting language that supports COM. For example, an
Application Server script can trigger a Historian event if you use this control in a Galaxy. You could
also trigger an event from a Visual Basic script.
AddEventTag()
Adds an event tag to the active event tag list.
Method AddEventTag(string EventTag)
Parameter EventTag
Name of the event tag with which the ActiveEvent event detector is associated.
ActiveEvent is used with an external type event detector.
Returns Value 0 = Success.
2 = Unable to execute method because ActiveEvent is not initialized.
7 = Remote function call failed.
InitializeEx()
Creates a connection to the Historian.
Method InitializeEx(string ComputerName)
Parameter ComputerName
Name of the computer on which the Historian is running. If you are not
connecting to the Historian over a network, use a blank string ("") for the
computer name.
Note You cannot use a Historian alias for this parameter.
Returns Value 0 = Success.
1 = Unknown failure.
3 = Unable to initialize ActiveEvent.
4 = ActiveEvent is already initialized.
7 = Remote function call failed.
8 = Unable to determine local computer name.
Remarks Once you have initialized with a Historian, use the IsConnected property to
determine if the connection was successful. Also, you only need to initialize with
the server once; you can invoke an unlimited number of events after initialization
has occurred.
If you are using the InTouch, initialization will not occur unless the ActiveEvent
ActiveX control is part of an open window. This limits the use of the
InvokeEventEx method within InTouch Application Scripts, Condition Scripts,
Data Change Scripts, and so on. When you close an InTouch window, all
ActiveX controls are automatically uninstantiated.
Wonderware Training
Section 3 – ActiveEvent 9-35
InvokeEventAtTimeEx()
Triggers the event at a specified date/time.
Method InvokeEventAtTimeEx(string TagName, string EventDateTime)
Parameter TagName
Name of the event tag with which the ActiveEvent event detector is associated.
ActiveEvent is used with an external type event detector.
EventDateTime
Date/time that you want the event triggered. This date is in local time for the Historian.
This parameter must be formatted as:
YYYY-MM-DD hh:mi:ss.mmm
Returns Value 0 = Success.
1 = Unknown failure.
2 = Unable to execute method because ActiveEvent is not initialized.
5 = Unable to perform date/time conversion due to invalid format.
6 = Date/time cannot be a future date.
7 = Remote function call failed.
Remarks You can invoke an unlimited number of events after you have initialized with a Historian.
InvokeEventEx()
Triggers the event at the time this method is called.
Method InvokeEventEx(string EventTag)
Parameter EventTag
Name of the event tag with which the ActiveEvent event detector is associated.
ActiveEvent is used with an external type event detector.
Returns Value 0 = Success.
1 = Unknown failure.
2 = Unable to execute method because ActiveEvent is not initialized.
7 = Remote function call failed.
Remarks You can invoke an unlimited number of events after you have initialized with a Historian.
IsConnected
Determines whether a connection to the Historian exists.
Method IsConnected
Returns Value 1 = Connected to the Historian.
0 = Not connected.
RemoveEventTag()
Removes an event tag from the active event tag list.
Method RemoveEventTag(string EventTag)
Parameter EventTag
Name of the event tag to remove from the list of external events for the ActiveEvent
control.
Returns Value 0 = Success.
2 = Unable to execute method because ActiveEvent is not initialized.
7 = Remote DCOM call failed.
Wonderware System Platform Course - Part 2
9-36 Module 9 – Historian Event System
– Intentionally left blank –
Wonderware Training