Machine states
Models
- class pytm4srv.models.MachineStateDef
Represents a user-defined machine state.
- color: Mapped[str]
User-specified color (#RRGGBB) of the state.
- id: MappedColumn object at 0x7c965e161c60>]]
Unique, numeric ID for the state.
- is_active: Mapped[bool]
Whether this state should be treated as an active state.
- is_feed_hold: Mapped[bool]
Whether this state should be treated as a feed hold state.
- is_optional_stop: Mapped[bool]
Whether this state should be treated as an optional stop state.
- is_utilized: Mapped[bool]
Whether this state should count towards utilization.
- machine_states: Mapped[List[str]]
Which machine-reported states should trigger this defined state.
- name: Mapped[str]
User-specified name of the state.
- class pytm4srv.models.MachineStateRecord
An execution state on a single machine for a range of time.
- end: Mapped[datetime]
The timestamp of when this state ended.
- id: Mapped[int]
Unique, numeric ID of this machine state record.
- machine_id: Mapped[int]
The ID of the machine this record belongs to.
- start: Mapped[datetime]
The timestamp of when this state started.
- state: Mapped[str]
The state string that was reported by the machine.
- state_def_id: Mapped[int]
The ID of the state definition that was found for the state reported by the machine.
Endpoints
- GET /api/machines/states/
Get all state definitions.
- Returns:
an object mapping state definition ID to state definition object
- PUT /api/machines/states/
Create a new state definition.
- Reqjson:
a (partial) state definition, with at least
name
set- Status Codes:
201 Created – on success
400 Bad Request – if the new state definition is invalid
403 Forbidden – if the new state definition contains a machine state that is already mapped
- Returns:
the new MachineStateDef object
- PATCH /api/machines/states/(int: state_def_id)
Edit an existing state definition.
- Parameters:
state_def_id – the ID of the state definition to edit
- Status Codes:
404 Not Found – if the state definition does not exist
403 Forbidden – if the new
machine_states
array contains a machine state that is already mapped
- Reqjson:
a (partial) MachineStateDef object
- Returns:
the modified MachineStateDef object
- DELETE /api/machines/states/(int: state_def_id)
Delete an existing machine state definition.
- Parameters:
state_def_id – the ID of the state definition to delete
- Status Codes:
404 Not Found – if the state definition does not exist
204 No Content – on success
- POST /api/machines/states/(int: source_state_def_id)/merge/(int: target_state_def_id)
Merge an existing machine state definition into another one.
This will transfer all machine states from the source state definition into the target state definition and then delete the source state definition. Any state history blocks using the source definition will be reassigned to the target definition.
- Parameters:
source_state_def_id – the ID of the state definition to merge and delete
target_state_def_id – the ID of the state definition to merge the source into
- Status Codes:
404 Not Found – if either of the source or target state definition IDs is invalid
- Returns:
the new state of the target state definition object