16Trigger Tool Usage
An automatic printing tool independent of the Designer: it listens for events (File / Timer / Serial Port / Manual / Network HTTP / Database) โ checks the condition โ loads a .iba template and prints.
16.1 Basic Concepts
A trigger = Trigger Source (when to wake) + Trigger Condition (whether to pass) + Action (what to do)
| Concept | Description |
|---|---|
| Trigger Source | When to trigger: File Monitoring, Timer, Serial Port data, Manual, Network HTTP, Database polling |
| Trigger Condition | Optional expression; the action runs only when it evaluates to true; leave empty = always run |
| Action | Print a specified .iba template (with data injection, selectable printer / copies) |
16.2 Interface Layout
- Top toolbar: Add / Delete trigger, Save / Load config, Start / Stop, Test trigger
- Left list: Trigger list (checkbox = enabled, click = edit that trigger)
- Right config: Basic info, trigger parameters, trigger condition, trigger action (template / printer), data mapping
- Bottom log: Real-time trigger / print progress
16.3 File Monitoring (most common)
- Click "๏ผ Add Trigger", select type File Monitoring
- Folder: enter or browse the folder to watch, e.g.
D:\Triggers - Filter:
*.txtwatches only txt;*.csvonly csv;*.*everything - Trigger Action: choose the
.ibatemplate, printer, print mode (GDI / ZPL), copies - Delete trigger file after successful print (optional): deletes the source file after a successful print to avoid repeated triggers / file accumulation; failed prints keep the file for retry
- Click โถ Start
- Drop a matching file into the folder โ auto print
About repeated triggers: dropping a file can raise multiple events (create + several changes). The tool has built-in deduplication (the same file triggers only once within 2 seconds), so one file prints once. If the writing program takes more than 2 seconds, it may trigger again; enable "Delete trigger file" to avoid this further.
16.4 Timer
- Select type Timer
- Interval (ms): e.g.
5000= every 5 seconds;60000= every minute - Configure the template / printer, start, and it prints automatically each interval
16.5 Manual
- Select type Manual
- Configure the template / printer, then click "Test Trigger" to run once immediately (also used for external
ManualTrigger(Id)calls)
16.6 Serial Port
- Select type Serial Port
- Port: automatically lists all serial ports (refreshable); Baud rate: e.g.
9600 - Each line of data received triggers once; data fields are described under "Trigger Condition Variables" below
16.7 Network HTTP Trigger
- Select type Network HTTP
- Port (default
8700), Path (defaulttrigger) - The config area automatically shows the callable URL (localhost loopback + LAN IP) with a sample query
- Accessing
http://IP:port/pathfrom the other system triggers printing; three content formats are supported, multiple fields become data fields automatically:- GET query parameters:
http://IP:8700/trigger?batch=LOT1&qty=500 - POST form:
Content-Type: application/x-www-form-urlencoded, bodybatch=LOT1&qty=500 - POST JSON:
Content-Type: application/json, body{"batch":"LOT1","qty":500,"detail":{"customer":"ACME"}}- Nested objects are flattened with dot notation:
detail.customer=ACME; arrays keep the raw JSON text (fieldJsonArray)
- Nested objects are flattened with dot notation:
- Built-in fields:
EventType=Network,Url,Body(raw body)
- GET query parameters:
- Token (optional): if set, the caller must provide it, otherwise
401is returned and nothing triggers- Any one of:
?token=valueparameter /X-Api-Token: valueheader /Authorization: Bearer value
- Any one of:
- Data fields = request parameter names; map them with custom field names to template variables
16.8 Network HTTP Trigger โ Testing (POSTMAN / Winsock Debugger)
Response codes: 200 OK = received and triggered; 401 = wrong Token; 404 = path does not match the configuration.
Method 1: POSTMAN (recommended, format handled automatically)
- GET: method
GET, URLhttp://127.0.0.1:8700/trigger, addorder=abc,batch=123under Params, click Send - POST form: method
POST, Body โx-www-form-urlencoded, enterorder=abc,batch=123, Send - POST JSON: Body โ
rawโ type JSON, content like{"order":"abc","batch":123}, Send - Token: for GET add
token=valuein Params; or add headerX-Api-Token: value - Use the port / path shown in the tool UI (not necessarily 8700)
Method 2: Winsock / Network Debugger (raw TCP)
The debugger is a "raw TCP" tool that only sends bytes โ you must write the HTTP format yourself:
- Target IP
127.0.0.1, port as shown in the tool, click "Connect" - Enter the following in the send box (each line ends with a line break, and leave one blank line at the end):
GET /trigger?order=abc&batch=123 HTTP/1.1
Host: 127.0.0.1:8700
Connection: close
- Key points:
- "HEX Send" must be OFF (default text mode is fine)
- The blank line after the headers is required (the server uses it to detect the end of headers); LF-only (
\n) line endings also work (the server accepts both\r\n\r\nand\n\n) - For POST, Content-Length must equal the body byte count; Chinese characters count as 3 bytes each in UTF-8 (e.g.
่ฎขๅ=ๅผ&ๆนๅท=ๅผ= 20 bytes) - Use English parameter names for testing (e.g.
order/batch), then set the matching "Source Field" in the mapping, to avoid garbled Chinese when the tool sends in GBK
- Receiving
OKand seeing the fields in the TriggerTool log means the test passed
16.9 Database Trigger (SQLite / MySQL / PostgreSQL / SQL Server / Oracle)
- Select type Database, choose the database type:
- SQLite โ pick the database file (.db / .sqlite / .db3)
- MySQL / PostgreSQL / SQL Server / Oracle โ enter server, port, database, username, password
- Default ports: MySQL
3306, PostgreSQL5432, SQL Server1433(can be left blank), Oracle1521
- Default ports: MySQL
- Click Test Connection to verify the connection settings
- Query SQL: a
SELECTreturning rows to process, e.g.SELECT * FROM print_queue - Polling interval (ms): default
5000 - Process SQL (optional): runs after each row triggers,
{column}references the row value, e.g.DELETE FROM print_queue WHERE id={id} - Each row triggers once; the row's columns become data fields (column name โ map with custom field name)
16.10 Trigger Conditions (important)
Leave empty = every trigger event runs directly. Fill it in = runs only when the expression is true.
Available variables
| Variable | Trigger source | Meaning | Example |
|---|---|---|---|
FileName | File | File name (no path) | ok.txt |
FilePath | File | Full path | D:\Triggers\ok.txt |
EventType | File | Event type | Created(new) Changed(modified) |
TriggerTime | Timer | Trigger time | 2026-08-03 12:00:00 |
Data | Serial Port | One line of received data | M6x20 |
PortName | Serial Port | Port name | COM1 |
Source | Manual | Trigger source | UI test |
Syntax
- Comparison:
==!=><>=<= - Logic:
&&(and)||(or)!(not) - String methods:
ContainsStartsWithEndsWith - String literals are wrapped in double quotes
Common examples
FileName == "ok.txt" // only ok.txt
FileName.EndsWith("_print.csv") // ends with _print.csv
EventType == "Created" // trigger only on create (ignore modify)
FileName.Contains("urgent") && EventType == "Created"
!FileName.StartsWith("temp") // exclude temp prefix
Data == "DONE" // serial port receives DONE
16.11 Data Mapping (injecting template variables)
Fill trigger data into template variables so label content changes with the data.
- Delimiter: enter a custom delimiter to split the file content into segments
- Common: comma
,, slash/, semicolon;, tab\t, CRLF\r\n - Multiple delimiters separated by
|, e.g.,|\r\n= comma or CRLF - Leave empty = whole file = 1 value
- Preset buttons: comma / slash / semicolon / Tab / newline / comma-or-newline
- Common: comma
- Trigger data field dropdown:
Field 1/Field 2โฆ โ with a file = segment 1 / 2 / โฆ; for Network / Database triggers = the 1st / 2nd / โฆ received field (in arrival order)FileContentโ whole file textFilePath/FileName/EventType/TriggerTimeโ event dataDataโ serial port data- Network / Database multi-fields can also be mapped directly by custom field name (more intuitive)
- Template variable: enter the variable name (no braces), e.g. template uses
{Batch}โ enterBatch - Click "๏ผ Add Mapping"
- On trigger,
{variable}in the template is replaced by the corresponding data
Single-field example
File content: LOT20260803; map FileContent โ batch; template {batch} = LOT20260803
Multi-field example (CSV)
File content: LOT20260803,500,PO-2026-001
- Delimiter: comma ,
- Three mappings:
Field 1 โ batch
Field 2 โ qty
Field 3 โ orderNo
- Template
{batch}/{qty}/{orderNo}=LOT20260803 / 500 / PO-2026-001
Multi-field example (one value per line)
File content:
LOT20260803
500
PO-2026-001
- Delimiter: newline
- Mappings: Field 1 โ batch, Field 2 โ qty, Field 3 โ orderNo (same as above)
16.12 Configuration Persistence
- Click "Save Config" โ writes
TriggerToolConfig.jsonnext to the program - Click "Load Config" or it loads automatically on next start
- Contents: all triggers (type / parameters / condition / action / data mapping)
16.13 Print Modes
| Mode | Applies to | Configuration needed |
|---|---|---|
| Driver print | Windows driver printers (regular laser / inkjet), consistent across printers | Printer name |
| ZPL print | Zebra-compatible barcode printers, raw ZPL via Windows driver | Printer name (driver installed) |
| Driverless ZPL | Bypasses the driver, sends ZPL straight over TCP (Zebra default 9100) | Printer IP + port (default 9100) |
- Driver print / ZPL print: the printer dropdown lists installed printers; choose
(default/auto)to use the system default. - Driverless ZPL: enter the printer IP (e.g.
192.168.1.100) and port (Zebra default9100); no driver needed.
16.14 Quick Test Guide
- Create a simple template (with a variable such as
{FileName}) - Add a File Monitoring trigger pointing to an empty folder, filter
*.txt - Click "Start"
- Create
ok.txtwith Notepad and drop it into the folder - Check the bottom log: should show "triggered โ load template โ inject variables โ print done"
- To avoid real printing, leave the printer unset and watch the log for triggering and template loading