Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
ezeio2:scriptref:start [2019-09-02 21:27] – andreh | ezeio2:scriptref:start [2020-05-01 15:10] – andreh | ||
---|---|---|---|
Line 35: | Line 35: | ||
Although the user script runs in a sandboxed runtime engine, the recommended programming pattern is similar to [[https:// | Although the user script runs in a sandboxed runtime engine, the recommended programming pattern is similar to [[https:// | ||
- | This means that you should avoid long-running loops, and instead make use of blocking calls or system callbacks provided in the function library. | + | This means that you should avoid long-running loops, and instead make use of system callbacks provided in the function library. |
- | + | ||
- | The following calls are blocking and are allowed in ' | + | |
- | + | ||
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
The following system callback functions are defined: | The following system callback functions are defined: | ||
Line 61: | Line 44: | ||
| '' | | '' | ||
| '' | | '' | ||
- | | '' | ||
=== State machines === | === State machines === | ||
- | A common programming pattern in control applications is to use state machines. PAWN and the ezeio implements strong support for state machines. The following is a typical pattern: | + | A common programming pattern in control applications is to use state machines. PAWN and the ezeio implements strong support for state machines. The following is a typical pattern |
<code javascript> | <code javascript> | ||
Line 73: | Line 55: | ||
main() | main() | ||
{ | { | ||
- | SetTickInterval(500); // set tick interval to 500ms (0.5s) | + | SetTickInterval(100); // set tick interval to 100ms (0.1s) |
state WAITING; | state WAITING; | ||
} | } | ||
Line 96: | Line 78: | ||
state RUNNING; | state RUNNING; | ||
- | | + | |
- | state WAITING; | + | state WAITING; |
} | } | ||
| | ||
Line 109: | Line 91: | ||
@Tick(uptime) < | @Tick(uptime) < | ||
{ | { | ||
- | if( GetField(2) < 100 ) | + | if( GetField(2) < 100 ) // Check if the engine stopped |
- | state WAITING; | + | state WAITING; |
} | } | ||
| | ||
</ | </ | ||