Difference between revisions of "MC-Basic:ONEVENT"

From SoftMC-Wiki
Jump to: navigation, search
m (1 revision)
m (adjusted layout)
Line 4: Line 4:
  
 
|SYNTAX=
 
|SYNTAX=
OnEvent ''<event> ''{''<condition>''}{Priority=''<priority>''} {ScanTime=''<time>''}<br>
+
OnEvent ''<event>'' {''<condition>''} {Priority=''<priority>''} {ScanTime=''<time>''}<br>
 
           ''<command block that defines the action>''<br>
 
           ''<command block that defines the action>''<br>
 
EndOnevent
 
EndOnevent
Line 12: Line 12:
  
 
|DESCRIPTION=
 
|DESCRIPTION=
The ONEVENT command defines a synchronous task that periodically checks the occurrence of the event condition once the event has been enabled (using EVENTON). When the condition is met, the event action block is executed. Event conditions may be any conditional expression.
+
The ONEVENT command defines a synchronous task that periodically checks the occurrence of the event condition once the event has been enabled (using EVENTON).
 +
When the condition is met, the event action block is executed.
 +
Event conditions may be any conditional expression.
  
The event action code runs as an interrupt to the task in which it is defined. Multiple events in the same task may interrupt each other, but they are not multitasked among themselves. Events defined in different tasks are multitasked.
+
The event action code runs as an interrupt to the task in which it is defined.
 +
Multiple events in the same task may interrupt each other, but they are not multitasked among themselves. Events defined in different tasks are multitasked.
  
Priority is the priority level at which the action code is executed. It may be assigned any value from 1 to 16. Event priority must be higher than the priority of the task in which it is defined.
+
Priority is the priority level at which the action code is executed.
 +
It may be assigned any value from 1 to 16. Event priority must be higher than the priority of the task in which it is defined.
  
ScanTime is given as a number of SERCOS time cycles. A value of 1 causes the condition to be checked every cycle.
+
ScanTime is given as a number of SERCOS time cycles.
 +
A value of 1 causes the condition to be checked every cycle.
  
If  Event is defined without any condition ( Versions 4.0.10 and higher ),  event action is executed every scan time, thus allowing periodic execution of application code
+
If an event is defined '''without any condition''' ( Versions 4.0.10 and higher ), the event action is executed every scan time, thus allowing periodic execution of application code.
  
 
|TYPE=
 
|TYPE=
 
''<event>'': Alphanumeric string<br>
 
''<event>'': Alphanumeric string<br>
''<condi''tion>: an expression<br>
+
''<condition>'': an expression<br>
''<priorit''y''>'': Long<br>
+
''<priority>'': Long<br>
 
''<scan time>'': Long
 
''<scan time>'': Long
  
 
|RANGE=
 
|RANGE=
''<priorit''y''>'': 1 to 16
+
''<priority>'': 1 to 16
  
 
|UNITS=
 
|UNITS=
Line 35: Line 40:
  
 
|DEFAULT=
 
|DEFAULT=
''<priorit''y''>'': 1<br>
+
''<priority>'': 1<br>
 
''<scan time>'': 1
 
''<scan time>'': 1
  
Line 42: Line 47:
  
 
|LIMITATIONS=
 
|LIMITATIONS=
An event must be enabled (using EVENTON) in order to be processed. An event cannot kill its parent task (the task in which it is defined). Event conditions do not consist of variables or properties that cannot be delivered at the same cycle (IDNs that are transferred over the SERCOS Service channel). SYSTEM.ALOAD cannot be in the event condition. Do not declare events in a subroutine or user function. OnEvent cannot be defined from IF, WHILE, or other loops.
+
An event must be enabled (using EVENTON) in order to be processed.  
 +
An event cannot kill its parent task (the task in which it is defined).  
 +
Event conditions do not consist of variables or properties that cannot be delivered at the same cycle (IDNs that are transferred over the SERCOS Service channel).
 +
SYSTEM.ALOAD cannot be in the event condition. Do not declare events in a subroutine or user function.
 +
OnEvent cannot be defined from IF, WHILE, or other loops.
  
 
|EXAMPLE=
 
|EXAMPLE=
OnEvent EV1 SysDin.1=1                           ‘Trigger event when input 1 is 1<br>
+
<pre>
       Move X-axis 50000<br>
+
OnEvent EV1 SysDin.1=1      'Trigger event when input 1 is 1
 
+
  Move X-axis 50000
 
End OnEvent
 
End OnEvent
 +
</pre>
  
 
|SEE ALSO=
 
|SEE ALSO=

Revision as of 08:36, 21 December 2011

The ONEVENT command defines a synchronous task that periodically checks the occurrence of the event condition once the event has been enabled (using EVENTON). When the condition is met, the event action block is executed. Event conditions may be any conditional expression.

The event action code runs as an interrupt to the task in which it is defined. Multiple events in the same task may interrupt each other, but they are not multitasked among themselves. Events defined in different tasks are multitasked.

Priority is the priority level at which the action code is executed. It may be assigned any value from 1 to 16. Event priority must be higher than the priority of the task in which it is defined.

ScanTime is given as a number of SERCOS time cycles. A value of 1 causes the condition to be checked every cycle.

If an event is defined without any condition ( Versions 4.0.10 and higher ), the event action is executed every scan time, thus allowing periodic execution of application code.

Syntax

OnEvent <event> {<condition>} {Priority=<priority>} {ScanTime=}
           <command block that defines the action>
EndOnevent

Availability

All versions

Type

<event>: Alphanumeric string
<condition>: an expression
<priority>: Long
<scan time>: Long

Range

<priority>: 1 to 16

Default

<priority>: 1
<scan time>: 1

Scope

Task

Limitations

An event must be enabled (using EVENTON) in order to be processed. An event cannot kill its parent task (the task in which it is defined). Event conditions do not consist of variables or properties that cannot be delivered at the same cycle (IDNs that are transferred over the SERCOS Service channel). SYSTEM.ALOAD cannot be in the event condition. Do not declare events in a subroutine or user function. OnEvent cannot be defined from IF, WHILE, or other loops.

Examples

OnEvent EV1 SysDin.1=1      'Trigger event when input 1 is 1
  Move X-axis 50000
End OnEvent

See Also