The HyperPoint object contains the following events:
Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.
Called when the script engine initializes.
HyperPointObject_OnInitialize()
This event operates in the same manner as the Microsoft Visual Basic event of the same name. Use the OnInitialize event of an object or class to prepare the object or class for use, setting any references to sub-objects or assigning values to module-level variables. Note that points added to the Points object in this method will not be immediately available for use; to get data immediately, call the Points.ResolveNow or Points.UpdateNow methods first.
Example
The OnInitialize event is commonly used to initialize the Points object with points to be monitored, as in this example.
|
Sub DEMOPNT_OnInitialize() Points.AddPoint "CYGDEMO.UIS:POINT1", DEMOPNT 'some code . . . End Sub |
Called when the script engine initializes.
HyperPointObject_OnInitializeEx(This)
This event operates in the same manner as OnInitialize, but provides an additional parameter to make further scripting easier. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name.
Example
The following example shows the time that the point was intiliazed by self-referencing the point.
|
Sub CYG_HSS_DEMOPNT_OnInitializeEx(This) 'This is possible: MsgBox "Point initialized on " & This.Timestamp
'As opposed to this: 'MsgBox "Point initialized on " & CYG_HSS_DEMOPNT.Timestamp End Sub |
OnPointChange Event.
HyperPointObject_OnPointChange(This, Tag)
This event is fired when a point added through AddPoint or AddPointArray is modified. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name. The "Tag" parameter is the point tag of the point that has been changed.
Example
The following example demonstrates the OnPointChange event. When TESTPOINT is first initialized, it calls AddPoint and starts monitoring MonitoredPoint. When MonitoredPoint changes, the value of TESTPOINT is set to the current time.
|
Sub TESTPOINT_OnInitialize() Points.AddPoint "CYGDEMO.UIS:MonitoredPoint", TESTPOINT End Sub
Sub TESTPOINT_OnPointChange(This, Tag) This.VALUE = Time End Sub |
Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.
Called when the script engine terminates.
HyperPointObject_OnTerminate()
This event operates in the same manner as the Visual Basic event of the same name. The OnTerminate event is fired when the last instance of an object or class is removed from memory. Instances of an object or class are removed from memory by explicitly setting the object variable to Nothing or by the object variable going out of scope.
Called when the script engine terminates.
HyperPointObject_OnTerminateEx(This)
This event operates in the same manner as OnTerminate, but provides an additional parameter to make further scripting easier. The "This" parameter allows the scripter to self-reference the hyperpoint instead of typing out its full name.
Example
The following example tells the user which point was terminated by self-referencing the point.
|
Sub OnTerminateEx(This) MsgBox This.LongTag & " has been terminated" End Sub |
Called when a timer event occurs.
HyperPointObject_OnTimer(This)
Timer events notify a HyperPoint when the timer’s countdown period expires. Before an event handler is invoked, the HyperPoint object is refreshed with the HyperPoint’s current contents from the HSS. After the handler completes, the HyperPoint contents in the HSS are updated from the HyperPoint object.
Example
The following example sets the value of the point to the time at which this event is invoked.
|
Sub DEMOPNT_OnTimer() 'Set status of point to current time DEMOPNT.Value = Now End Sub |
Important: This event is obsolete. However, it is still available to existing points that use this event. It is unavailable to new points. This and other obsolete events appear in italics in the script editor event drop-down menu.
Called when a timer or point change event occurs.
HyperPointObject_OnUpdate(EventType)
| Parameter | Required | Description |
|---|---|---|
|
UpdateEventType |
Yes |
Defines the type of event that is occurring, which is either a timer event or a point value change event. Use the UpdateEventType table to access this value. |
OnUpdate has two UpdateEventTypes — a Point event and a Timer event. Functions are provided to notify a HyperPoint when a Point event occurs, such as Points.AddPoint. Timer events notify a HyperPoint when the timer’s countdown period expires. Before an event handler is invoked, the HyperPoint object is refreshed with the HyperPoint’s current contents from the HSS. After the handler completes, the HyperPoint contents in the HSS are updated from the HyperPoint object.
Example
The OnUpdate event is commonly used to obtain information from the Points object and perform related calculations. Also, it is good practice to use the value of a HyperPoint for its status. The following example of the OnUpdate event shows the status being updated and a UIS point receiving the value of the sum of two other UIS points — a calculation that will be executed each time OnUpdate is run. This example makes use of the global function SetPoint, explained in the "Global Functions" section.
|
Sub DEMOPNT_OnUpdate(EventType) 'Set status of current point DEMOPNT.Value = "updated"
'Get Point object(s) for points being monitored Set P1 = Points.Point("CYGDEMO.UIS:POINT1") Set P2 = Points.Point("CYGDEMO.UIS:POINT2")
'Set the sum to a new point If IsNumeric(P1) And IsNumeric(P2) Then SetPoint "CYGDEMO.UIS:POINTSUM", CStr(P1.Value + P2.Value) End If End Sub |