Variables¶
Read and write PLC variables by symbol path. Requires feature flag Variables enabled.
Read Variable¶
Requires role >= viewer and scope |
curl http://localhost:5000/api/plcs/Line1/variables/MAIN.nCounter
{
"data": { "symbol": "MAIN.nCounter", "value": 42, "typeName": "UDINT" },
"error": null
}
Batch Read¶
Reads multiple variables in one request. Maximum 100 symbols per request. |
Each symbol is read independently: one unreadable symbol does not fail the whole request. The response is always 200, and each entry under values carries either its value/typeName on success, or a non-null error describing why that one symbol failed — the other symbols in the same batch are unaffected.
curl "http://localhost:5000/api/plcs/Line1/variables?paths=MAIN.a&paths=MAIN.b&paths=MAIN.typo"
{
"data": {
"values": {
"MAIN.a": { "symbol": "MAIN.a", "value": 1, "typeName": "UDINT" },
"MAIN.b": { "symbol": "MAIN.b", "value": 2, "typeName": "UDINT" },
"MAIN.typo": { "symbol": "MAIN.typo", "value": null, "typeName": null, "error": "Symbol 'MAIN.typo' not found." }
}
},
"error": null
}
Write Variable¶
Requires role >= operator and scope |
curl -X PUT http://localhost:5000/api/plcs/Line1/variables/MAIN.nCounter \
-H "Content-Type: application/json" \
-d '{"value": 100}'
Batch Write¶
Maximum 100 symbols per request. |
curl -X PUT http://localhost:5000/api/plcs/Line1/variables \
-H "Content-Type: application/json" \
-d '{"values": {"MAIN.a": 1, "MAIN.b": 2}}'
Value Constraints¶
Returns the configured validation constraints for a symbol, including |
curl http://localhost:5000/api/plcs/Line1/constraints/MAIN.nSpeed
{
"data": { "symbol": "MAIN.nSpeed", "min": 0, "max": 100, "enum": null, "pattern": null, "readOnly": false },
"error": null
}
Writes are validated against these constraints. A write that violates a constraint returns 400 with error code VALUE_OUT_OF_RANGE.
Symbol Access Control¶
Write operations are checked against the symbol access guard configured per PLC (see Configuration). If a symbol is denied by the allowlist/denylist rules, the API returns 403 with error code SYMBOL_WRITE_DENIED.