Machine
Model
- class pytm4srv.models.Machine
Represents one reporting machine.
- last_shift_notes_submission: ShiftNotesSubmission
The most recent shift notes submission for this machine.
- active_tool: Mapped[int | None]
The number of the last active tool reported by the machine, or NULL.
- alarm_notification_grouping: Mapped[int]
A notification will be sent when this many alarms have occurred so far in the day. The next notification will be sent after this many more alarms.
- alarms: Mapped[list[dict]]
A list of current alarms. For details, see Machine update format.
- archived: Mapped[bool]
Whether the machine is not currently in use and should be hidden.
- autocomp_support: Mapped[bool]
Whether this machine is configured for AutoComp.
- current_work_order: Mapped[str]
User-specified work order name to be applied to newly finished parts.
- custom_alarms: Mapped[dict[str, str]]
User-defined alarm messages.
- custom_properties: Mapped[Dict[str, Any]]
Custom properties for this machine.
These can be used to enable experimental behavior, change advanced settings, etc.
Only modify these under the direction of Wolfram Manufacturing Technologies.
- cycle_state_id: Mapped[BigInteger | None]
The current cycle execution state.
- description: Mapped[str]
User-specified, persistent description for this machine.
Equivalent to the
notes
field of other types, but renamed to avoid confusion with per-day shift notes.
- disabled: Mapped[bool]
Whether the machine is currently disabled and should be hidden.
Unlike archived machines, OnTakt will not attempt to connect to disabled machines.
- downtime_alarms: Mapped[List[str]]
A list of alarm messages that will automatically create downtime on this machine.
This is processed independently of
custom_alarms
, so these should be the strings as reported by the control.
- earning_rate: Mapped[float]
Average currency value of this machine’s runtime per hour.
- estopped: Mapped[bool | None]
Whether or not this machine is currently emergency stopped.
- feed_rate_override: Mapped[int | None]
The last feed rate override (percentage) reported by the machine, or NULL.
Stored as an integral percentage, for example: 100 for 100%.
- id: MappedColumn object at 0x7ec1c1979d80>]]
Unique, numeric ID for the machine in OnTakt.
- ignore_zero_part_count: Mapped[bool]
Whether to ignore the part count when it is zero.
This should be enabled for if they are reporting many ghost parts at once, because this means the control is intermittently reporting an incorrect part count of zero.
- inventory_point_id: Mapped[int | None]
This machine’s primary inventory point.
- keep_current_work_order: Mapped[bool]
Whether to continue the current work order when a process switch is detected instead of clearing it.
- last_contact: Mapped[datetime | None]
The timestamp of the last time this machine reported.
- last_part_count: Mapped[int]
The last part count the machine reported.
- last_preflight_check: Mapped[datetime | None]
The timestamp of the last time an external service ran a Preflight™ check on this machine.
- last_tmac_contact: Mapped[datetime | None]
The timestamp of the last time TMAC reported.
- last_vars: Mapped[dict[str, Any]]
The last known state of all common variables.
Note that for JSON compatibility, keys (variable numbers) will be strings.
- mute_alarms: Mapped[List[str]]
List of alarm codes to skip notifications for.
- name: Mapped[str]
User-specified name for the machine.
- nc_properties: Mapped[Dict[str, str]]
Key/value map of properties related to the selected system.
The keys are the
properties
of the selected system fromGET /api/machines/systems
.All keys and values are strings. Extra properties are ignored.
- notify_channel: Mapped[int | None]
Notification channel ID to send messages to when events occur.
- notify_cycle_completed: Mapped[bool]
Whether to send a notification when this machine completes a cycle resulting in at least one new part.
- notify_end_shift: Mapped[bool]
Whether to send a report notification at the end of the shift.
- notify_feed_hold: Mapped[bool]
Whether to send notifications when the machine enters FEED HOLD.
- notify_goal_met: Mapped[bool]
Whether to send notifications when this machine meets the part goal.
- notify_mid_shift: Mapped[bool]
Whether to send a report notification in the middle of the shift.
- notify_nc_alarms: Mapped[bool]
Whether to send notifications for machine alarms.
See also:
alarm_notification_grouping
- notify_process_changed: Mapped[bool]
Whether to send a notification when this machine changes between processes.
- notify_production_behind: Mapped[int]
Setting to a positive number will notify when the machine’s production has fallen behind the goal line by that percent. Set to 0 to disable.
- notify_production_stopped: Mapped[bool]
Whether to notify when production seems stuck/stopped.
- notify_tmac_alarms: Mapped[bool]
Whether to send notifications for TMAC alarms.
See also:
alarm_notification_grouping
- part_count_cv: Mapped[int | None]
Variable to use to count parts on this machine.
This can be overridden by individual processes.
- priority: Mapped[int]
The current priority of this machine for sorting and delegating.
Allowed values are: -
1
= low -2
= medium (default) -3
= high
- program_cv: Mapped[int | None]
If this is set and there is a program from this machine with its
load_by_var_value
equal to the value of this variable, that program will be loaded instead of the reported program name.
- program_name: Mapped[str | None]
The filename of the currently running program.
- rapid_override: Mapped[int | None]
The last rapid override (percentage) reported by the machine, or NULL.
Stored as an integral percentage, for example: 100 for 100%.
- shift_notes_notify: Mapped[bool]
Whether to notify when shift notes are submitted.
- system: Mapped[str]
The protocol to use when communicating with the control.
This is a value of the
key
field fromGET /api/machines/systems
.
- tags: Mapped[List[str]]
List of tags this machine has.
- target_utilization: Mapped[int]
The expected utilization (%) of this machine over the measurement period (usually 1 week).
- time_study: Mapped[bool]
Whether this machine is currently part of a time study.
- tmac_alarm: Mapped[dict[str, float]]
A mapping of the alarm name to the timestamp OnTakt first saw it.
- tmac_api_key: Mapped[str]
API key used to access the TMAC 3.0 API.
Configured in TMAC -> Profiles -> Application Integrations.
If the active user is not an administrator, this will be returned as a boolean indicating whether it is set instead of the actual value.
- tmac_instance_name: Mapped[str]
Instance name of the machine on the TCU.
- tmac_job: Mapped[str | None]
The name of the TMAC job last reported for this machine.
- tmac_learn: Mapped[bool | None]
The state of TMAC learn mode last reported for this machine.
- tmac_monitor_disable_limit: Mapped[timedelta | None]
How long TMAC monitoring can be disabled before a warning notification is sent.
NULL
means notifications will never be sent.
- tmac_monitor_disabled: Mapped[datetime | None]
When TMAC monitoring was last switched off.
NULL
means it is currently enabled, or we have not received a TMAC message for this machine.
- tmac_monitor_notified: Mapped[bool]
Whether we have already notified about TMAC monitoring being disabled this time.
- tmac_url: Mapped[str | None]
URL of the Caron TMAC MTConnect endpoint.
- tools_seen: Mapped[List[int]]
The tool numbers that have been reported as active since the last part was finished.
Endpoints
- GET /api/machines/(int: machine_id)
Get information about a single machine.
- Parameters:
machine_id – the ID of the machine to query
- Returns:
the machine object
- Status Codes:
404 Not Found – if the machine object does not exist
- GET /api/machines/
Get a list of all registered machines.
- Returns:
an object mapping machine IDs to machine objects
- GET /api/machines/systems
Get a list of supported Machine systems.
- Returns:
an object mapping system IDs to system objects
- PUT /api/machines/
Add a new machine with the provided name.
- Request JSON Object:
name (string) – name for the new machine
- Returns:
the new machine object
- Status Codes:
400 Bad Request – if the name is missing
500 Internal Server Error – if there is an error
201 Created – on success
- DELETE /api/machines/(int: machine_id)
Delete a machine from the database.
- Parameters:
machine_id – The numeric ID of the machine to delete.
- Status Codes:
204 No Content – on success
404 Not Found – if the machine does not exist
- GET /api/machines/(int: machine_id)/goals
Get a machine’s production goals.
- Query Parameters:
start (float) – start the chart at this UNIX timestamp. Defaults to the start of the current day in local time.
end (float) – end the chart at this UNIX timestamp. Defaults to the start of the current day in local time.
- Parameters:
machine_id – the ID of the machine to check goals for
- Returns:
an object mapping timestamps to the number of parts that should be produced by that time
- Status Codes:
404 Not Found – if the machine does not exist
- GET /api/machines/(int: machine_id)/chart
Get chart data for a machine.
Note
Goals and feed rate overrides are returned as 2D arrays to reduce data size in transit and in memory. When parsing this response in strongly-typed languages, the timestamps may be truncated to integers to make 2D array allocation easier.
Feature
Properties included in response
nc_alarms
nc_alarms
autocomp
autocomp_data
downtime
downtime
feed_rate
feed_rate_overrides
goals
goals
parts
parts
programs
processes
rapid
rapid_overrides
shifts
shifts
tmac_alarms
tmac_alarms
tools
tools
tool_replacements
upcoming_tool_replacements
utilization
utilization
- Parameters:
machine_id – The ID of the machine to get chart data for
- Query Parameters:
start (float) – start the chart at this UNIX timestamp. Defaults to the start of the current day in local time.
end (float) – end the chart at this UNIX timestamp. Defaults to the start of the current day in local time.
feature (string) – specify a feature to include Using this parameter to request specific features can decrease the request processing time. This parameter can be set multiple times to request multiple features. If it is not specified, all features will be enabled. Allowed values and the response fields they provide are described in the table above.
- Response JSON Object:
machine_id (int)
machine_name (string)
shift – contains
start
andend
timestampsgoals – array of 2-arrays, where each 2-array contains: [0] the UNIX timestamp when this number of parts should be completed (float), and [1] the number of parts that should be completed (int)
parts – maps part IDs to part objects
nc_alarms – maps NC alarm ID to Alarm object
tmac_alarms – maps TMAC alarm ID to Alarm object
tool_replacements – tool replacements indexed by tool ID
upcoming_tool_replacements – map of tool ID to predicted timestamp of next replacement due
autocomp_data – AutoComp data indexed by program
feed_rate_overrides – array of 2-arrays, where each 2-array contains: [0] the UNIX timestamp the feed rate was recorded and (float), and [1] the value recorded (int)
- Status Codes:
404 Not Found – if the machine does not exist
- PATCH /api/machines/(int: machine_id)
Save machine settings.
Note
Some settings require administrator privileges to change, while others can be changed with planner privileges. Errors will be silently ignored.
Setting
Admin
Planner
name
X
description
X
system
X
custom_alarms
X
nc_properties
X
tmac_url
X
tmac_api_key
X
tmac_instance_name
X
autocomp_support
X
time_study
X
notify_channel
X
alarm_notification_grouping
X
notify_nc_alarms
X
X
notify_tmac_alarms
X
X
notify_feed_hold
X
X
notify_end_shift
X
X
notify_production_behind
X
X
notify_goal_met
X
X
notify_production_stopped
X
X
inventory_point_id
X
X
- Parameters:
machine_id – The numeric ID of the machine to save settings for
- Returns:
the modified machine object
- Status Codes:
404 Not Found – if the machine does not exist
- GET /api/machines/(int: machine_id)/overview/(int: year)
- GET /api/machines/(int: machine_id)/overview/(int: year)/(int: month)
Get a day-level overview of a machine’s production history.
- Parameters:
machine_id – The ID of the machine to query
year – the year to get parts from
month – the month to get parts from (1..12). If omitted, the entire year will be returned.
- Returns:
a JSON object mapping dates in “YYYY-MM-DD” format to arrays with: - [0] the number of parts produced - [1] the average cycle time Days with no parts produced will not be included.
- Status Codes:
404 Not Found – if the machine does not exist
- GET /api/machines/tags
Get all known machine tags and their colors.
Tool tag colors can be customized by setting the
machine_tag_colors
option.- Returns:
an object with tags as keys and colors as values
- GET /api/machines/(int: machine_id)/oee
Get OEE history for a machine, sorted with the most recent calculations first.
- Query Parameters:
collapse – set to “day” to get only the last calculation per day or leave the default “all” to get every stored calculation
limit (int) – limit the number of results returned
offset (int) – skip past this many results
- Status Codes:
404 Not Found – if the machine does not exist
400 Bad Request – if the interval is incorrect
- POST /api/machines/(int: machine_id)/update/(src)
Manually update the machine state without involving the proxy.
This endpoint only accepts the Machine update format in the request body.
- Parameters:
machine_id – the ID of the machine to update
src – “nc” or “tmac”
- Status Codes:
404 Not Found – if the machine does not exist
412 Precondition Failed – if the data source is invalid
- GET /api/machines/(int: machine_id)/stateHistory
Get the history of a machine’s cycle state.
- Query Parameters:
start (float) – only state history records on or after this time (UNIX timestamp) will be returned
end (float) – only state history records on or before this time (UNIX timestamp) will be returned
- Status Codes:
404 Not Found – if the machine does not exist
- Returns:
an array of MachineStateRecord objects in chronological order
- GET /api/machines/(int: machine_id)/holds
Get past and/or present holds on the specified machine.
- Parameters:
machine_id – the ID of the machine to get holds for
- Query Parameters:
limit (int) – limit the number of results returned
offset (int) – skip this many entries
- Returns:
a list of MachineHold objects in chronological order by start date and time
- Status Codes:
201 Created – on success
404 Not Found – if the machine does not exist
- PUT /api/machines/(int: machine_id)/holds
Create a new hold on the specified machine.
- Parameters:
machine_id – the ID of the machine to hold
- Reqjson:
a MachineHold object
- Returns:
the new MachineHold object
- Status Codes:
201 Created – on success
404 Not Found – if the machine does not exist