oEvent Object
An Object that runs program code in response to an event.
Description:
 

A Processing Object that calls a Sub procedure when it's Operate property is set to 1.

Operation:
 

In normal operation, when an oEvent Object's Operate property transitions from 0 to 1 the program flow is interrupted with a call to a Sub procedure specified by the oEvent Object's name. While the Sub procedure is executing the oEvent Object ignores the Operate property and waits for the program flow to return from the Sub procedure. When the program flow returns from the Sub procedure the oEvent Object resumes watching for the Operate property to transition from 0 to 1.

The name of the Sub procedure that the oEvent object expects to call is the name of the oEvent object followed by "_CODE." That is to say,  An oEvent object named "A" will call a Sub procedure named "A_CODE"

If a second oEvent Object interrupts one that is in progress, the program flow will branch to the second oEvent Object's code.  After the second oEvent Object is finished, the program flow will return to the first oEvent Object's code at the point it was interrupted where the program flow resumes.

If the property option "C" is specified, then the operation is modified so that this event only occurs once each time the Flag-property to which the ClockIn property points transitions in the manner specified by the InvertC property.  In this case the Operate property is used to activate the monitoring of the ClockIn property. When Operate is 1, an active transition on ClockIn will cause the event to be called, and when Operate is 0, any active transitions will be ignored.

If the Property Option "X" is specified, then a Priority property is added that allows the events to be prioritized.  The lower numbered priorities will interrupt the higher numbered priorities, but higher numbered priorities will wait until lower numbered priorities are finished.  For example, a priority 1 event, will interrupt a priority 2 event to run its code, but a priority 3 event will wait until the priority 2 event is finished before running its code. 

Note: The oEvent Object has the highest priority and will always interrupt other oEvent Objects and oEventX objects with any priority.

Property Options:
 The oEvent Object has 2 different property options: X and C.  
  • X specifies that the Priority property is added.
  • C specifies that the ClockIn and InvertC properties are added.
 Continuous
operation
Clocked
operation
Standard:oEventoEventC
Priority property added:oEventXoEventXC
Storage size & Availability:
 The following table lists the size and availability of the oEvent Object and its variations:
ObjectSizeVersion
oEvent3 BytesA.1.0 and greater
oEventX5 BytesB.1.0
oEventC
oEventXC7 Bytes
Properties:
 

The following table lists the Properties of the oEvent Object:
PropertyDescription
Address

Returns a pointer to the address of the oEvent Object instance.

Data-Type: Number-Pointer, Read-Only

Data-Range: 0 - 127

ClockInA pointer to an Object's flag that will be used to determine when the Object performs its function.

Data-Type: Flag-Pointer

Data-Range: 0 - 127

Availability: oEventC oEventXC

InvertCA value that specifies the active transition state of the flag property pointed to by ClockIn.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Availability: oEventC oEventXC

ValueConstantOperation is performed when then flag-property pointed to by Clockin transitions
0 From 0 to 1 
1 From 1 to 0
Operate

A value that specifies whether or not the event is acknowledged.

Data-Type: Bit, Flag, Default

Data-Range: 0 - 1

The following table lists the values of the Operate Property:
OperateConstantDescription
0cvFalse

The oEvent Object's Code is not executed.

1cvTrue

The oEvent Object's Code is executed.

Priority

A value that specifies the priority of the event.

Data-Type: Nibble

Data-Range: 0 - 15

Example:
 In the following examples, an oEvent Object is used
'This program creates a Virtual 
'Circuit that will sound a tone 
'when a button is pressed.

Dim A As New oEvent
Dim D As New oDio1
Dim W As New oWire
Dim T As New oTone

Sub Main()
  oopic.node = 5
  oopic.pullup = 1
  D.IOLine = 8
  D.Direction = cvInput
  W.Input.Link(D)
  W.Output.Link(A.Operate)
  W.InvertIn = cvTrue
  W.Operate = cvTrue
End Sub

Sub A_Code()
  T.IOLine = 24
  T.Value = 120
  T.Operate = 1
  OOPic.Delay = 20
  T.Operate = 0
End Sub
'This program creates two Virtual 
'Circuits that will increment a
'oDio4 when an event is activated.
'The two events are set up with 
'different priority levels so 
'that one gets priority over 
'the other.

Dim A As New oEventX
Dim Ax As New oDio4
Dim G As New oDio1
Dim Gw As New oWire

Dim B As New oEventX
Dim Bx As New oDio4
Dim H As New oDio1
Dim Hw As New oWire

Sub Main()
  OOPic.Pullup = 1
  Ax.IOGroup = 3
  Ax.Nibble = 1
  Ax.Direction = cvOutput
  Bx.IOGroup = 3
  Bx.Nibble = 0
  Bx.Direction  = cvOutput
  G.IOline = 8
  Gw.Input.Link(G)
  Gw.Output.Link(A.Operate)
  Gw.InvertIn = 1
  Gw.Operate = 1
  H.IOLine = 10
  Hw.Input.Link(H)
  Hw.Output.Link(B.Operate)
  Hw.InvertIn = 1
  Hw.Operate = 1
  A.Priority = 5
  B.Priority = 6
End Sub

Sub A_Code()
  for Ax = 1 to 14
  OOPic.Delay = 10
  Next Ax
End Sub

Sub B_Code()
  For Bx = 1 to 14
  OOPic.Delay = 10
  Next Bx
End Sub
See Also: