ezeio2:scriptref:start

This is an old revision of the document!


ezeio script programming - the PAWN language

The scripting feature in the ezeio allows the user to implement advanced custom logic and control functionality on the ezeio. For most common applications, scripting is not necessary.

The ezeio uses a powerful script language called PAWN. The syntax is very similar to JavaScript, and should be easily understood by anyone working with programming in similar languages.

The scripting feature of the ezeio is intended for those with previous experience in programming. This manual does not attempt to teach you to write programs. If you have a specific feature that you need help with, please contact eze System.

We strongly recommend reading the following documents to get introduced to the PAWN language:

Introduction to PAWN

PAWN language guide

ezeio script administration

When working with ezeio scripts, you will edit your code on the userscript screen. When clicking “Commit”, the script is compiled on the servers, and automatically downloaded into the ezeio, where it will start to run as soon as the download completes.

Only one user defined script can run at the same time, but the editor allows you to have multiple scripts saved on the servers, and easily switch between them. The currently running script is marked with a checkmark.

If a script fails to compile due to a syntax error, the script will not be sent to the ezeio. If a previous version of the script, or a different script, was running, this will continue to run.

Script resources

The user script can occupy up to 128kB code (compiled bytecode), and up to 16kB RAM.

The estimated requirements for a script is displayed when compiling.

Programming style

Although the user script runs in a sandboxed runtime engine, the recommended programming pattern is similar to cooperative multitasking.

This means that you should avoid long-running loops, and instead make use of blocking calls or system callbacks provided in the function library.

The following calls are blocking:

ModbusRead() Read a register block from a Modbus RTU device
RS485WriteRead() Write & Read to the Modbus port in 'raw' mode (not Modbus protocol)
ModbusWriteRead() Write and read Modbus commands on the RTU port
SDICmd() Send a SDI12 command and receive the response
ModbusTCP() Send & Receive Modbus commands on the Ethernet port
sleep() Suspend the script for a short time (process events immediately)
msSleep() Suspend the script for a short time (not processing events - DEPRECIATED)
MBRTU_Read() Read a register from a Modbus RTU device
MBRTU_Write() Write to a register on a Modbus RTU device
MBTCP_Read() Read a register from a Modbus TCP device
MBTCP_Write() Write to a register on a ModbusTCP device
SunSpecIP_Base() Find the base address for a SunSpec/TCP device
SunSpecIP_Ofs() Find the offset for a SunSpec/TCP device

The following system callback functions are defined:

@Tick Called at a regular interval, set by SetTickInterval()
@Timer Called when one of the four millisecond timers expire, see SetTimer()
@Action Called when an action is triggered due to an alarm event
@Key Called when a button is pressed on a connected terminal device
@Scan Called when a code is received from a scanner device
@J1939 Called when a J1939 packet is received
  • ezeio2/scriptref/start.1567457375.txt.gz
  • Last modified: 2019-09-02 20:49
  • by andreh