Process
Models
- class pytm4srv.models.Process
Represents a machine, a subset of its programs, and any assigned tool assemblies.
- archived: Mapped[bool]
Whether this process has been marked as archived.
- cv_map: Mapped[Dict[str, dict]]
A map of friendly names to common variable numbers in the format:
{ "Serial number": { "number": 5, "notifyComparison": "EQ", "notifyValue": 1 } }
- description: Mapped[str]
A long description of the process.
- display_variable: Mapped[int | None]
Number of a variable to display the value of on the machine’s card when this process is active.
- id: MappedColumn object at 0x79d314f5dd80>]]
Unique, numeric ID for this process.
- loaded
Check whether any program in this process is loaded on its machine.
- Returns:
True if a program is loaded, False if not.
- machine_id: Mapped[int]
The ID of the machine this process belongs to.
This cannot be changed once the process has been created.
- name: Mapped[str]
The process name.
- part_count_cv: Mapped[int | None]
The common variable to read instead of the reported part count.
- part_material_cost: Mapped[float]
How much the material used to make 1 part costs.
- part_sell_price: Mapped[float]
How much money 1 part is sold for.
- parts_per_cycle: Mapped[int]
How many parts one cycle of this process produces. Defaults to 1.
- setup_instructions: Mapped[str]
User-specified instructions to follow when switching to this process.
- tags: Mapped[List[str]]
A list of user-supplied tags that apply to this process.
- teardown_instructions: Mapped[str]
User-specified instructions to follow when switching away from this process.
- time_per_cycle: Mapped[timedelta | None]
How long (in minutes) it takes to run a cycle.
- unassigned_tools_used: Mapped[Dict[str, str]]
Stores tool locations that the machine has used while this process was active, but that aren’t filled by assemblies in this process.
This field is a map of tool location to the UNIX timestamp of when the machine last used it.
Endpoints
- GET /api/processes/
Get an object mapping process ID to process.
- Query Parameters:
programs (int) – set to
1
to include the programs that are in each processtools (int) – set to
1
to include the tools that are assigned to the processefficiency (int) – set to
1
to include production efficiency data (slow)
- Returns:
an object mapping process IDs to process objects
- GET /api/processes/(int: process_id)
Get an object that includes details about one process.
- Query Parameters:
programs – set to
1
include the programs that are in this processtools – set to
1
include the tools that are in each program in the processefficiency (int) – set to
1
to include production efficiency data
- Parameters:
process_id – the ID of the process to query
- Response JSON Array of Objects:
unused_tool_locations – list of tool locations that have assemblies present but that the machine has not used for the last few parts, configurable with the
check_unused_tools_parts
global setting.
- Returns:
the process object
- Status Codes:
404 Not Found – if the process doesn’t exist
- PUT /api/processes/
Create a new process.
- Reqjson:
a (partial) Process object
- Returns:
the new (full) Process object
- Status Codes:
400 Bad Request – if the process data is invalid
201 Created – on success
- PATCH /api/processes/(int: process_id)
Update a process in the database.
- Reqjson:
a (partial) process object. Omitted fields will not be changed.
- Parameters:
process_id – The numeric ID of the process to edit.
- Returns:
the updated process object
- Status Codes:
404 Not Found – if the process doesn’t exist
400 Bad Request – if the process data is invalid
- PUT /api/processes/(int: process_id)/toolRequirements
Create a new tool requirement in the given location of the given process.
- Parameters:
process_id – the ID of the process to create a tool requirement in.
- Reqjson:
a (partial) ProcessToolRequirement object.
- Return:
the new tool requirement object
- Status Codes:
201 Created – on success
400 Bad Request – if the assembly_id is missing
- GET /api/processes/(int: process_id)/toolRequirements
Get the tool requirements of a given process. :param process_id: the ID of the process to get tool requirements for. :returns: an object mapping ProcessToolRequirement ID to ProcessRequirement object :status 404: if the process ID is invalid.
- POST /api/processes/(int: process_id)/archive
Archive a process, and optionally its programs.
- Query Parameters:
programs (int) – set to
1
to also archive all programs in this process
- Parameters:
process_id – The numeric ID of the process to edit.
- Returns:
the updated process object
- Status Codes:
404 Not Found – if the process doesn’t exist
- DELETE /api/processes/(int: process_id)
Delete a process from the database.
- Parameters:
process_id – The numeric ID of the process to delete.
- Status Codes:
204 No Content – on success
404 Not Found – if the process does not exist
- GET /api/processes/(int: process_id)/overview/(int: year)
- GET /api/processes/(int: process_id)/overview/(int: year)/(int: month)
Get a day-level overview of a process’s production history.
- Parameters:
process_id – The ID of the process 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 years to objects each mapping “YYYY-MM-DD” to a number of parts produced
- Status Codes:
404 Not Found – if the process doesn’t exist
- GET /api/processes/(int: process_id)/chart
Get the data required to chart this process.
- Parameters:
process_id – The ID of the program to chart
- 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.
- Status Codes:
404 Not Found – if the process doesn’t exist
- Response JSON Object:
process – the process object
parts – maps part IDs to part objects
- GET /api/processes/(int: process_id)/tools
Get the tools assigned to a given process.
- Parameters:
process_id – The ID of the process to query
- Returns:
a JSON object of tools
- Status Codes:
404 Not Found – if the process doesn’t exist
- GET /api/processes/variables
Get a list of all program variables that have been used.
- Returns:
A JSON array of string variable names.
- POST /api/processes/averageCycleTimes
Look at the times between previous runs of programs in a process to determine the average cycle time.
Example request body[42, 43, 44, 45]
Example response body for the above example request, where process 44 has never run and 45 doesn’t exist.{"42": 18.4, "43": 26.1, "44": null}
- Reqjsonarr:
IDs of the processes to analyze. Invalid process IDs will be ignored.
- Returns:
an object mapping each process ID to a floating point number of minutes, which will be
null
for processes that have never run.
- POST /api/processes/(int: process_id)/duplicate
Duplicate an entire process onto a new machine.
This will create copies of every tool assembly assigned to the process, and every tool in each of those assemblies.
Programs that already exist on the new machine with filenames matching programs in the existing process will be assigned to the new process if they are not already in a different process, but no new programs will be created.
- Parameters:
process_id – the ID of the process to create a copy of
- Request JSON Object:
machine_id – the ID of the machine to build the new process on. Required.
name – the name for the new process. Required.
- Status Codes:
201 Created – on success
400 Bad Request – if a required field is missing
404 Not Found – if the process doesn’t exist
- Returns:
the new process object
- POST /api/processes/(int: from_id)/changeover/(int: to_id)
Confirm a process changeover.
- Parameters:
from_id – the ID of the previous process
to_id – the ID of the new process
- Query Parameters:
planned (int) – set to
1
to allow changing to an inactive process
- Status Codes:
400 Bad Request – if the provided JSON body is invalid
404 Not Found – if the processes whose IDs were specified do not both exist
409 Conflict – if the processes do not belong to the same machine
412 Precondition Failed – if the current process on the machine is not the new process indicated by
to_id
. Will be ignored if theplanned
query parameter is set.
- Request JSON Array of Objects:
remove_tool_assemblies – list of tool assembly IDs to remove from any process and leave unassigned.