Pragmas
A pragma is a { … } annotation that attaches metadata to a declaration without
changing its data type. logiccloud supports two kinds: the access pragma on
variable declarations and the JSON pragma on struct elements.
Access pragma
Section titled “Access pragma”The access pragma is written after a variable declaration and controls how that variable is exposed to connectors and the HMI, and how it behaves on reset.
VAR speed : REAL { IN HMI }; state : INT { OUT RESET_TO 0 }; setpoint: REAL { IN_OUT INTERNAL };END_VARKeywords
Section titled “Keywords”| Keyword | Meaning |
|---|---|
IN | Expose the variable as an input access variable. |
OUT | Expose the variable as an output access variable. |
IN_OUT | Expose as both input and output (two access variables generated). |
HMI | Make the access variable visible in the HMI. |
INTERNAL | Mark as internal use only (not used in connectors; typically HMI-only values). |
RESET_TO <const> | On program reset, reset the variable to a constant value. |
NO_RESET | Do not reset the variable on program reset. |
RESET_DEFAULT | Reset the variable to its default value on program reset (the default policy). |
A pragma names one direction (IN, OUT or IN_OUT), optionally INTERNAL
and/or HMI, and — for OUT / IN_OUT — an optional reset policy. The reset
keywords are mutually exclusive.
VAR sensor : BOOL { IN HMI }; // HMI-visible input alarm : BOOL { OUT HMI NO_RESET }; // retained across resets gain : REAL { OUT RESET_TO 1.0 }; // reset to 1.0 scratch: INT { OUT INTERNAL }; // internal, not a connectorEND_VARJSON struct-element pragma
Section titled “JSON struct-element pragma”A struct element can carry a { JSON … } pragma that controls how that element
is serialized to / deserialized from JSON.
TYPE Reading : STRUCT id : DINT; value : REAL { JSON "measurement" }; // rename the JSON field debugInfo : STRING { JSON IGNORE }; // omit from JSON entirely note : STRING { JSON OMIT_EMPTY }; // drop when empty label : STRING { JSON "tag" OMIT_EMPTY };// rename and omit when empty END_STRUCT;END_TYPEOptions
Section titled “Options”| Form | Effect |
|---|---|
{ JSON IGNORE } | The element is excluded from JSON serialization. |
{ JSON "name" } | Use "name" as the JSON field name instead of the element name. |
{ JSON OMIT_EMPTY } | Omit the element from the JSON output when it holds an empty/zero value. |
{ JSON "name" OMIT_EMPTY } | Combine a custom field name with omit-when-empty. |