Group related process data into reusable STRUCT records, define named state lists with ENUM, and index collections with single- or multi-dimensional ARRAY variables.
STRUCT or ENUM in the Machine Editormain.machine and select the Datatypes tab.STRUCT: Click + Add Field to add named fields, select each field's data type (primitive type, ARRAY[n] OF Type, or nested custom type), and set an optional initial value and comment.ENUM: Click + Add Value to add named enumerators (for example, IDLE, RUNNING, FAULT).| Datatype Kind | Purpose | Member Access Syntax |
|---|---|---|
STRUCT |
Composite record containing multiple named and typed fields | station.speed, recipe.target_temp |
ENUM |
Ordered set of named symbolic constants | Mode.AUTO, State.IDLE |
main.machine (or use the Variables sidebar panel).STRUCT or ENUM name.ARRAY[n] OF Type or ARRAY[low..high] OF Type (for example, ARRAY[10] OF INT, ARRAY[1..8] OF BOOL, or ARRAY[4] OF StationData).ARRAY[1..3, 1..4] OF REAL).In the Sequence Editor, Smart Completion automatically suggests struct fields, enum values, and array indices:
recipe. to autocomplete fields such as recipe.clamp_pressure or recipe.dwell_time.machine_mode == Mode.AUTO in transition conditions or MOVE Mode.HOMING into machine_mode.buffer[0], pallet_grid[row, col], or stations[idx].is_ready.main.machine -> Datatypes, create an ENUM named PartType with values NONE, PLASTIC, and METAL.STRUCT named StationRecipe with fields part_type (PartType), press_time_ms (INT), and force_limit (REAL).main.machine -> Variables, declare active_recipe of type StationRecipe and part_queue of type ARRAY[10] OF PartType.from automation_machine import Machine, Struct, Enum, Array, INT, REAL
PartType = Enum("PartType", ["NONE", "PLASTIC", "METAL"])
StationRecipe = Struct("StationRecipe", {
"part_type": PartType,
"press_time_ms": INT,
"force_limit": REAL,
})
class SortingMachine(Machine):
def setup(self):
self.add_datatype(PartType)
self.add_datatype(StationRecipe)
self.add_variable("active_recipe", StationRecipe)
self.add_variable("part_queue", Array(PartType, 10))
SortingMachine()
M016–M018, S060–S062)