Difference between revisions of "MC-Basic:ONEVENT"

From SoftMC-Wiki
Jump to: navigation, search
m (1 revision)
(Fixed wiki corruption)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Languages|MC-Basic:ONEVENT}}
 
{{MC-Basic
 
{{MC-Basic
 
|SHORT FORM=
 
|SHORT FORM=
Line 4: Line 5:
  
 
|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
+
End Onevent
  
 
|AVAILABILITY=
 
|AVAILABILITY=
Line 12: Line 13:
  
 
|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 motion-bus 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 41:
  
 
|DEFAULT=
 
|DEFAULT=
''<priorit''y''>'': 1<br>
+
''<priority>'': 1<br>
 
''<scan time>'': 1
 
''<scan time>'': 1
  
Line 42: Line 48:
  
 
|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>
+
In the following example the event in triggered when SysDin.1 is equal 1:
       Move X-axis 50000<br>
+
 
 +
OnEvent EV1 SysDin.1=1
 +
  Move X_axis 50000
 +
End OnEvent
  
End OnEvent
 
  
 
|SEE ALSO=
 
|SEE ALSO=
* [[Axystems:MC-Basic:EVENTLIST|EVENTLIST]]
+
* [[MC-Basic:EVENTLIST|EVENTLIST]]
* [[Axystems:MC-Basic:EVENTOFF|EVENTOFF]]
+
* [[MC-Basic:EVENTOFF|EVENTOFF]]
* [[Axystems:MC-Basic:EVENTON|EVENTON]]
+
* [[MC-Basic:EVENTON|EVENTON]]
 
 
  
 +
[[Category:MC-Basic:Event Control|ONEVENT]]
 
}}
 
}}

Latest revision as of 11:14, 27 November 2023

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