Skip to content

Reference

The guides say why. These pages say exactly what: every built-in scope, object and function of the script language, every function you put in an XML chain, and every connection type and protocol — what to write, what it reads, what comes back, and the trap. Every example on these pages was run on engine 4.4.2.702 and its result is written beside it.

Engine 4.4.2.703 fixed the bugs these pages found (crashes in custom time formats and CODEC, hangs in ELM.eval and jsn(), the role of a pro_onreq handler, chains over 63 characters, rounding, and more). Where a function changed, its page says what it does now and, in a sentence starting "Before 4.4.2.703", what an older engine does.

Read a guide first. 03_Scripting explains where script lives and how the XML calls it; 02_Timers_and_Events why a write runs a chain. This reference assumes both.

The pages

Page What is on it
01_Language Types and literals, the global functions, Math, Number, String, Array, Object, JSON, Buffer, and the methods every value answers (toINT, toDEC, toDTM …)
02_Time_Text_and_Codecs Time, TIME, CODEC (Base64, hex, JWT), BYTES, Blob, SOAP, SYS, LOG, RES
03_Events_Documents_and_Addresses evt, xdb, element objects, new XML(..), threads, the address language and its functions (count, json(), stat() …), the special # addresses, sta and STA
04_Attribute_and_Element_Functions Chain functions: ATR, VAL, ELM, XDB, EVT, THR, SCR
05_Alarms_Conditions_and_Protocol_Chains Chain functions: ALM, IF, FILTER, CTRL, and the PRO functions every protocol shares
06_Sessions_and_Protocol_Scripts ses, exc, buffers, connection objects, req and res, every protocol hook (pro_onparse …), MQTT, TOPIC, AUTH, LDAP
07_SQL_History_Files_and_Cluster SQL, HIS, File, LIC, CLT, REP, RPC, OPC, PY
08_Engine_Modules FILE, IMG, CAM, GPIO, I2C, SPI, NET — the scopes of the engine modules beside the engine
09_Connection_and_Protocol_Types Every CON.x and PRO.x you put in a <con>'s xdb_fnc, and the con_* / pro_* fields each reads

At the end of this page every name is listed once, with a link to its entry.

Ask the engine

The engine documents itself. The reference is the long form; the engine's help is the short one, always at hand and always the version you run. The same commands answer in three places.

In the console window

Start the engine in a console (run.bat, ./run.sh, or AyXDB.exe -console <path>\db\AyXDB.xml) and press CTRL-X (CTRL-R does the same). The log keeps running and a prompt with the document's name appears:

EDU/S00> help Math
Type What happens
help or ? the commands, then every scope that documents itself, one line each
help <SCOPE> that scope's help, and the names of its extra texts (help CON ends with CON.help_tcp, CON.help_ser …)
ver version, current document, its log file, the licence
pwd / cd NAME the document the prompt evaluates in / switch to another one
log [lvl] [lines] the latest records of the current document's log
log on [lvl] / log off how much of the log the console shows
exit or CTRL-X leave the prompt; the engine runs on
quit stop the engine
anything else evaluated as script in the current document, and the value printed

The console runs as the engine: no xdb_acl applies to it, it can read and write everything. It exists only while the engine has a console of its own — an engine that AySVC runs as a service has none. For that, the shell below.

In a telnet shell

A <con xdb_fnc="[CON.tcp,PRO.telnet]"> is the same prompt over a socket, with a login. PRJEDU_telnet is a complete one (log in as admin / admin123 on 127.0.0.1:2323). It knows the same commands, plus who and history, and the arrow keys walk the history. What you type runs with your session's role, so xdb_acl applies exactly as it does to any other remote caller. The help itself is open to every role.

A session, as it comes back (trimmed):

SHL/S00> help CON
CON : General configuration fields
    con_host : address to connect to
    ...
More under CON (type the whole name):
  CON.help_sql
  CON.help_tcp
  ...
SHL/S00> CON.help_tcp
TCP connection
CON.tcp : CLIENT/CONNECT mode: makes a TCP connection to a server
CON.tcp : SERVER/LISTEN mode: works as a server taking TCP connection requests
con_host='10.40.1.51' con_port='502'
SHL/S00> Object.keys(Time)
["help","GetTimeStr","FmtTimeStr","GetTimeMs","now","ParseTimeMs","GetTimeZoneMs","GetTimeDstMs","tz","AddDurationMs","SleepMs"]

From a script

Every scope's help is a value under the key help (lower case; an engine module's scope keeps its text under a function's name, below):

evt.Log(4, Math.help);                       // the text into the log
evt.Log(4, Object.keys(Math));               // every name in the scope, as JSON text
var all = evt.AskValue("#shell", "help");    // what 'help' prints, as a string
var pro = evt.AskValue("#shell", "help PRO");

What to type for what

You want Type
every scope that has a help text help
one scope help Math or Math.help
every name in a scope, help or not Object.keys(Math) — the complete list
one connection type or protocol help CON / help PRO, then the name it lists: CON.help_tcp, PRO.help_modbus
the event object Object.XDB_EVT.help (or evt.help in a script)
the document object Object.XDB_DOC.help (or xdb.help)
the other objects Object.keys(Object) names them: XDB_ELM, XDB_THR, XDB_CON, CON_SES, CON_EXC, CON_BUF, CON_PRO, SQL_CON, SQL_RS, HTTP_MSG, HTTP_RES, LDAP_CON; then Object.CON_SES.help …
an engine module's scope FILE.help_list, IMG.help_decode, CAM.help_list, GPIO.help_chips, I2C.help_scan, SPI.help_sim; NET.help_ver once AyLIB_net is attached (by FILE.help_list, a mail or file-transfer connection, or xdb_lib="AyLIB_net")
SQL PRO.help_sql (and Object.keys(SQL))
the values of log_cfg, xdb_log, sta and the type codes the root help, a value called help: in the console or the shell type "" + help (a bare help is the command), in a script evt.Log(4, help)

Three things the list does not show, measured on 4.4.2.702:

  • SQL is not in the list — it has no help text. help SQL says SQL has no help text; its functions are described in PRO.help_sql.
  • The engine modules' scopes are not in the list (FILE, IMG, CAM, GPIO, I2C, SPI, NET), and help FILE answers no such scope. Their texts are named after a function: type FILE.help_list — that attaches the module and prints the text. Before the module is attached Object.keys(FILE) answers []. NET alone is not attached by its own name: it appears when something else attaches AyLIB_net.
  • help CON and help PRO list a module's transports and protocols only once that module is attached. PRO.help_gpio prints nothing before; type GPIO.help_chips (or use the module) and help PRO then lists PRO.help_gpio and PRO.help_reg. The same goes for AyLIB_net (FILE.help_list → PRO.help_smtp, PRO.help_ftp, PRO.help_sftp, CON.help_ssh) and AyLIB_vision (IMG.help_decode → CON.help_cam, PRO.help_cam, PRO.help_vision).

A help line is one line. Where it is too short, or a few still carry an internal change number in brackets, this reference is the long form.

How to read an entry

A script function starts with its call and what it gives back:

Math.round(v) → integer

then what it does, its arguments, what comes back on a bad argument, an example with the measured result as a comment, and the trap if there is one.

A chain function — one you write in XML, in a *_fnc attribute — starts with three facts:

In: where it goes. Reads: the attributes it takes its parameters from. Changes: what it writes.

<atr> stands for the attribute whose chain it is in. ATR.rou in a val_fnc reads val_rou; the same function in a pro_fnc reads pro_rou.

Roles are numbers: 0 Guest, 1 Customer, 2 Monitor, 3 Operator, 4 Supervisor, 5 Manager, 6 Engineer, 7 Admin, and two that are not people — 8 Document (a replication peer) and 9 System (the engine itself). The engine's own timers and chains run as System. A script started by a page, a telnet line or an MQTT command runs with that user's role, and a function that needs "Engineer or above" refuses anyone below with one ERROR line.

Types are the val_typ codes — 0x0308 a double, 0x0104 an unsigned 32-bit integer, 0x0401 a string. 01_Language lists the ones a script meets.

Every name

Language

Time, text and codecs

Events, documents and addresses

Attribute and element functions

Alarms, conditions and protocol chains

Sessions and protocol scripts

SQL, history, files and the cluster

Engine modules

Connection and protocol types