oEvent Object

Back to top of page Description:
 A Processing Object that calls a Sub procedure when it's Operate property is set to 1.
 The following table lists the size and availability of the oEvent Object.
 ObjectSizeDescriptionA1A2B1B2C1
oEvent3 BytesAn Object that runs program code in response to an event.xxxxx
oEventC5 BytesAn Object that runs program code in response to an event.xxx
oEventP5 BytesAn Object that runs program code in response to an event.xxx
oEventPC7 BytesAn Object that runs program code in response to an event.xxx
Back to top of page 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 used, then the operation is modified so that this function only occurs once each time an oLogic Object transitions.

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. 

The oEvent object is non-maskable, which means that it will interrupt any oEventP object.

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

Back to top of pageProperty Options:
 The oEvent Object has 2 different property options: X and C.  
  • X specifies that the Priority property is added.
  • C specifies that a clocked version of the object is used.
 Continuous
operation
Clocked
operation
Standard:oEventoEventC
Priority property added:oEventPoEventPC
Back to top of page Properties:
 

The following table lists the properties of the oEvent Object:

Property

Description

Operate
A value that selects if the oEvent Object's Code is executed.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOff

The oEvent Object's Code is not executed.

1cvOn

The oEvent Object's Code is executed.

Priority
A value that specifies the event's priority.
Object Class: oVar4 Value Range: 0 - 15
Data Type: Numeric Default Value: 0
Process
Clock
See Clocked Objects for detail
Object Class: oClockedOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Availability: oEventC oEventPC
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Examples:
 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 oEventP
Dim Ax As New oDIO4
Dim G As New oDIO1
Dim Gw As New oWire

Dim B As New oEventP
Dim Bx As New oDIO4
Dim H As New oDIO1
Dim Hw As New oWire

Sub Main()
  ooPIC.PullUp = 1
  Ax.IOPack = 7
  Ax.Direction = cvOutput
  Bx.IOPack = 3
  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

Back to top of page Related Items:

 Sub Procedures
Back to top of page Version History and Bug List:
 Firmware Ver A1: Introduced.

Bugs: Ver 5.01 Compiler:  oEventC does not function.  Fixed in Ver 6.0


 

ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.