Script Table Columns
- The step name provides dual purposes:
- Acts as a unique step identifier for jumps
- Provides the user/log with a description of the step being executed
- Step names may contain spaces and special characters
- Step names are case sensitive for jumps and swap references
- Step names can use swap variables <> and [] to reference other step returned/result values
- Comm Labels identify the device to use
Scripttells the engine to use an internal script command- Any other value is treated as a device
- Comm Labels are case sensitive: Pico != pico
- The first use of a device must include all properties
- {"label":"Pico","protocol":"serial","baud":204000,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}
- {"label":"UUT","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"sn","expect":"CR"}}
- {"label":"USBDevice","protocol":"dll","dllPath":"C:\\\\Drivers\\\\MyDevice\\\\api.dll","function":"SendCommand","callType":"stdcall","returnType":"string"}.
- Once a Comm Label has been used, later steps can reference it by label only: Pico / UUT / USBDevice
If a comm label was used with all properties and new properties are provided, the new properties are used.
Swap variables can be used for comm lenles - Script Commands are special internal commands executed by the script engine.
- Script Commands are not case sensitive; device labels/variables may be.
- Commands are delimited by commas
- When a device requires a literal comma inside an argument, use
commaor-comma-or0x2cor-0x2c-(placeholders restored to,after parsing) - Commands can be cascaded within a single cell by separating commands with | or / (spaces allowed)
- | returns all results separated by |
- / returns only the last result
- If any delimiter is /, only the last result is returned; all must be | to get all results
- Cascaded commands (script or device) can use a prior result via _index_
- DIO:0:1 | DIO:13:0 | DIO:17:_0_ will result in these three commands: DIO:0:1 | DIO:13:0 | DIO:17:1 because DIO:0:1 should return a 1 Returned will be 1:0:1
- DIO:0:1 / DIO:13:0 / DIO:17:_0_ will result in these three commands: DIO:0:1 | DIO:13:0 | DIO:17:1 because DIO:0:1 should return a 1. Returned will be 1.
- The returned value is evaluated against these limits to determine pass/fail
- Min/Max or both may be left empty
- Empty min = no lower limit; empty max = no upper limit; both empty = no limits
- If returned/min/max are numeric, numeric comparison is used; otherwise lexicographic comparison
- This column holds the result of the command(s)
- This value is used for <> swaps within commands/limits
- Compared against Min/Max to determine pass/fail
- This column holds the evaluated result of the returned value against the Min/Max limits
- This column can have only 4 values
- This column is used for [] swaps within commands/limits
- Empty: not executed yet
- pass: returned value met limits
- fail: returned value outside limits
- aborted: catastrophic failure or stop pressed
- The value in the log column controls visibility, reporting and logging.
- Log=0 : Steps execute but are hidden unless they fail (typically no limits) and are not logged for passed tests.
- Log=1 : Steps execute and log, but are hidden by default from display and reports.
- Log=2 : Steps execute, log, and display on screen and in reports.
- Log='' : Empty filter shows all; use 0 to show only 0; !0 shows everything except 0.
Tip: Any column can be filtered to show only values containing the filter string. Prefix with ! to
show rows that do not include that string.
Step Name
Tip: Step names starting with --- or with an empty Comm Label are skipped for execution/evaluation
(noop).
Comm Label
Tip: Empty Comm Label rows are skipped for execution/evaluation (noop).
Command
Tip: Script commands are delimited by commas;
best practice is no spaces around delimiters.
Script command keys (before the first delimiter) are case insensitve and may contain _ or spaces in any
portion of the command: Set Sn = Set_Sn = setsn = S__eT_S_N.
Underscored, non-underscored, spaced and cased spellings are interchangeable (float_to_hex_le = float to hex
le = float2hexle, set_line_delay = Set Line Delay= setlinedelay, report_save = report save = reportsave, etc.).
Min/Max
Returned
Result
Log
Variable Swaps
| Pattern | Description | Example |
|---|---|---|
| <Step Name> | Replaced with the Returned value of that step, variable swaps apply to Step Name, Comm Label, Min and Max Limits | <Compose DIO14>:? |
| [Step Name] | Replaced with the Result (pass/fail/aborted) of that step | ifpass,[Calc step],Jump OK,Jump fail |
| {profile.property} | Replaced with the corresponding value from the Comm Label without exposing it to the UI --use for device passwords | EX: Comm Label: UUT:{protocol:serial,port:/dev/ttyACM0,baud:115200,pw:Efos123,commandTerminator:CR,autoFind:{command:sn,expect:[sn]}} Command: sn:{{profile.pw}} replaces {{profile.pw}} with Efos123 before dispatching, so the device receives sn:Efos123. Use any property name the same way (e.g., {{profile.user}}, {{profile.token}}). If the property is missing, it substitutes an empty string. |
Cascaded Commands
| Pattern | Description | Example |
|---|---|---|
| a|b|c | Runs sequentially; returns all results joined by “|” | cmdA | cmdB | cmdC |
| a/b/c | Runs sequentially; returns only last result | cmdA / cmdB / cmdC |
| _index_ | Within a cascaded command, swaps in the result at that index | set_sn,SN123 | addAfter,_0_,:OK |
Command Quick Reference
Examples show typical usage; underscores/spaces are interchangeable where noted. Commands are case-insensitive.
| Command(s) | Example | Notes |
|---|---|---|
| if | if,1,=,1,StepOK,StepFail | Conditional jump |
| ifpass | ifpass,[SomeStep],GoNext,HandleFail | Jump if arg contains “pass” |
| math / mathint | math,5,+,3 | mathint truncates |
| get | get,model / get,Hello | Returns meta varaible (model, script, operator, job, sn, technician,testid ,workcell,workorder) or literal of arg[0] |
| delayms / delays / delaym / delayh | delayms,200 | ms / seconds / minutes / hours |
| replace / replaceall | replace,OK,GOOD,OK123 | Replaces first match / ReplaceAll replaces all matches |
| find | find,abc,bc | Returns index |
| len / upper / lower / trim | upper,hello | String helpers |
| split | split,a|b|c,|,1 | Returns indexed part |
| substring | substring,Hello,1,3 | Start,length |
| addbefore / addafter | addafter,VAL,:OK | Concatenate |
| echo | echo,Hello world | Return text |
| padleft / padright | padleft,123,0,5 | Pad to width |
| remove / removeall | removeall,abcabc,ab | Remove substring(s) |
| round / int / long | round,3.14,1 | Numeric helpers |
| hex2string / hex2float | hex2float,41200000 | Conversions |
| float2hex / float2hexle | float2hex,3.5 | Hex helpers (Big endian default/le = Little endian) |
| double2hex / double2hexle | double2hex,3.5 | Float64 (le = little endian) |
| bin2hex / bin2long | bin2hex,1111 | Binary helpers |
| long2bin / long2hex | long2hex,15 | Binary/hex helpers |
| hex2long | hex2long,F | Hex helpers |
| getdate / gettimestamp / getcurrenttimemillis | gettimestamp | Date/time |
| setlinedelay | setlinedelay,50 | Line delay ms |
| getsn / setsn | setsn,SN123 | Serial number |
| getworkcell / setworkcell | setworkcell,CellA | Workcell |
| getworkorder / setworkorder | setworkorder,WO42 | Work order |
| settestid / gettestid | settestid,TEST42 | Test ID |
| getoverallstatus / overallstatus / overallresult | getoverallstatus | Overall result |
| get_meta_sn | get_meta_sn | Serial from form/meta |
| jump / call / return | jump,Step2 | Control flow by step name; call/return support nested flows. |
| endscript | EndScript | Lock overall status; remaining steps can run for reporting/logging. |
| stripleading / striptrailing | stripleading,HelloWorld,5 | Substring helpers |
| cmd / cmd-prompt | cmd,uname,-a | Run shell command |
| runprog | runprog,notepad.exe | Launch program |
| openfile / openapp | openfile,C:\\temp\\readme.txt | Open file/app |
| messagealert | messagealert,Check wiring,/InstructionImages/Inst1.jpg,OK,Cancel | Alert (optional image) Note: Message alert returns are not evaluated, use an ifpass to evalute the result of a mesage prompt. |
| messageinstructions | messageinstructions,Follow wiring,/InstructionImages/Inst1.jpg,OK,Cancel | Instructions (optional image) Note: Message instruction returns are not evaluated, use an ifpass to evalute the result of a mesage prompt. |
| messageprompt | messageprompt,Enter tech,butto1Text,Button2Text | Prompt for user input Note: Message prompt returns are not evaluated, use an ifpass to evalute the result of a mesage prompt. |
| report / reportsave / reportprint | report,log,save,true,[Overall] | Generate report |
| ClearDevice | ClearDevice,label | Remove a device from cache, next use will require full json properties, this will force a new autofind |
| AutoFindDevice | AutoFindDevice,label | Clears cached device and forces auto-find on next use for that label. |
| Comm Label | {"label":"Pico","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}, | The first use of a device must have all its properties defined: {"label":"Pico","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}, subsequent uses can refer to it by label only. To send a no response device command, prefix the command with fire: (fire:DIO:0:1) will send the command and not wait for any response |
Math Operators (for math / mathint)
| Operator | Example | Meaning |
|---|---|---|
| + | math,5,+,3 | Add |
| - | math,5,-,3 | Subtract |
| * or x | math,5,*,3 | Multiply |
| / | math,6,/,3 | Divide |
| >, >=, <, <=, =, != | math,5,>,3 | Comparisons |
| ^ | math,2,^,8 | Power |
| sqrt | math,sqrt,9 | Square root |
| abs | math,abs,-5 | Absolute value |
| min / max | math,min,5,3 | Min/Max |
| % | math,7,%,4 | Remainder |
| << / >> | math,4,<<,1 | Bit shifts |
| & / | | math,6,&,3 | Bitwise and/or |
| && / || | math,true,&&,false | Logical and/or |
Tip: Separators (step names starting with --- or empty commLabel) are skipped for execution.
Tip: Script commands are delimited by , (comma) and may contain spaces before or after delimiters.
Operation
- Start/Pause/Stop controls the run. Stop on fail will halt on first fail.
- Run uses resolved values; table shows original commands, reports show resolved.
- Overall status locks at EndScript; post-EndScript steps still execute for reporting.
- Troubleshoot mode: double-click or Enter runs the selected row manually.
- Banner tones: double chime for pass, double buzz for fail, mid beep for aborted.
Maintenance & Editing
- Unlock Maintenance to edit, drag/drop, add/delete, duplicate, or reorder steps.
- Shortcuts (when unlocked): Add before (Ctrl+I), Add after (Ctrl+B), Duplicate (Ctrl+D), Delete (Ctrl+X), Move up/down (Ctrl+Arrow), To top/bottom (Ctrl+Home/End), Undo (Ctrl+Z), Run step (Ctrl+R).
- Table filters: default Log=2; prefix with ! to exclude.
- Save updates the current script (JSON or SQLite source).
Devices & Comm Labels
- Comm label can include device profile JSON (auto-find etc.). Examples:
{"label":"Pico","protocol":"serial","baud":19200,"commandTerminator":"CR","autoFind":{"command":"id","expect":"Pico"}}
{"label":"UUT","protocol":"serial","port":"/dev/ttyACM0","baud":115200,"pw":"Efos123","commandTerminator":"CR","autoFind":{"command":"sn","expect":"\\r"}} - Ethernet protocol supports:
get,http://host:port/path,post,http://host:port/path,payload, andraw:payload(host/port from profile).
comm Label: "EthernetGET":{"protocol":"ethernet","host":"172.165.5.189","port":9110,"timeout":3000}
Command Ex: http://172.165.5.189:9110/daq?cmd=DIO:1:?&returnType=raw
get,http://172.165.5.189:9110/daq?cmd=DIO:1:?&returnType=raw
or this wil also work because ip and port are in comm Label
get,/daq?cmd=DIO:1:?&returnType=raw
http calls prefer IPv4 (localhost resolves to 127.0.0.1) - Windows USB: if the vendor driver exposes the device as a COM port (virtual serial), it will work with the serial protocol here. If it does not create a COM port (custom USB class), a dedicated adapter module is needed.
- DLL protocol (Windows): if the vendor exposes a DLL API, set
"protocol":"dll"and provide:dllPath: absolute path to the DLLfunction: entry point namecallType: optional (e.g., stdcall)args: optional array of argument types (ffi-napi/ref types)returnType: optional return type (default string)
{"label":"USBDevice","protocol":"dll","dllPath":"C:\\\\Drivers\\\\MyDevice\\\\api.dll","function":"SendCommand","callType":"stdcall","returnType":"string"}. The script command text is split on commas and passed as arguments unless a custom arg parser is provided. Use-comma-or0x2cas placeholders for literal commas.
Tip: CommandTerminaors must be in the form CR. LF or CRLF, but for autofind commands if only a return or line feed is expected, use \\r, \\n or \\r\\n
Program Structure (Execution Flow)
- UI loop: Clicking Run triggers
runFrominpublic/app.js. It iterates steps and callsexecuteRowfor each (handles cascades, dialogs, limits, and status). - Backend entry:
executeRowPOSTs to/execute(nafcTestEngine_r0.js), which callsengine.executeStep. - Step dispatch:
engine.executeStepresolves the comm label viaregistryand dispatches:- CommLabel =
Script→modules/scriptCommands.js(logic, math, jumps, prompts, reports, etc.). - Protocol
serial→modules/serialAdapter. - Protocol
ethernet/tcp→modules/tcpAdapter(HTTP GET/POST or raw socket). - Protocol
dll→modules/dllAdapter. - Legacy TCP:
modules/TCP/genTcpServiceif available.
|or/) execute in order;_index_placeholders pull prior cascade results. - CommLabel =
- Limit evaluation:
engine.evaluateLimitschecks returned vs. Min/Max;engine.updateOveralltracks overall status. - Completion/abort: The UI loop stops on end, fail (if Stop on Fail), or abort. It locks overall
status, updates banners, and logs the run to SQLite (
modules/logStore.js)—passes log only steps with log ≥ 1; fail/abort logs all. - Reports: Report requests (
reportcommand/buttons) call/report, rendered bymodules/report.jsusing current meta and steps (log/full/fail filters).