MC-Basic:ONEVENT

From SoftMC-Wiki
Jump to: navigation, search
Language: English  • 中文(简体)‎

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 motion-bus 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>
End Onevent

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

In the following example the event in triggered when SysDin.1 is equal 1:

OnEvent EV1 SysDin.1=1
  Move X_axis 50000
End OnEvent

See Also