Program
Model
- class pytm4srv.models.Program
Represents one program on one machine.
- archived: Mapped[bool]
Whether this program has been marked as archived.
- custom_name: Mapped[str]
A user-specified name for the program.
Displayed instead of the filename if set.
- description: Mapped[str]
A user-specified longer description for the program.
- filename: Mapped[str]
The program file name on the control.
- id: MappedColumn object at 0x7ec1c1979d80>]]
Unique (across all machines), numeric ID for this program in OnTakt.
- last_cycle: Mapped[datetime | None]
The timestamp of the last time this cycle finished.
- load_by_var_value: Mapped[int | None]
This program will be loaded when the machine’s
program_cv
equals this value regardless of the program name reported by the machine.
- machine_id: Mapped[int]
The ID of the machine this program was loaded on. If the same program file is loaded on multiple machines, then there will be a program record for each machine.
- process_id: Mapped[int | None]
The ID of the process this program belongs to, or null if not set yet.
Endpoints
- GET /api/programs/
Get all (or a subset of) registered programs.
Note
Combining query parameters is an AND operation, so a program must match ALL parameters passed to be returned.
- Query Parameters:
machine (int) – set to a machine ID to only include programs on that machine
process (int) – set to the ID of a process to only include programs in that process or
0
to get only programs that are not assigned to a processloaded (int) – set to
1
to only include loaded programs or0
to only include unloaded programsarchived (int) – set to
1
to only include archived programs or0
to only include non-archived programs
- Status Codes:
424 Failed Dependency – if the provided
process
does not exist.
- Returns:
a JSON object mapping program IDs to programs
- PUT /api/programs/
Manually create a program.
The request body should be a (partial) program object (
filename
andmachine_id
are required).- Status Codes:
400 Bad Request – if the filename and/or machine_id fields are missing
201 Created – on success
- GET /api/programs/(int: program_id)
Get information about a single program.
- Parameters:
program_id – the ID of the program
- Status Codes:
404 Not Found – if the program does not exist
- Returns:
the program object
- PATCH /api/programs/(int: program_id)
Update a program in the database.
- Status Codes:
404 Not Found – if the program does not exist
409 Conflict – if the program is being added to a process of a machine other than the machine the program belongs to
424 Failed Dependency – if the program is being added to a process that does not exist
- Parameters:
program_id – The numeric ID of the program to edit.
- Returns:
the updated program object
- DELETE /api/programs/(int: program_id)
Delete a program from the database.
- Parameters:
program_id – The numeric ID of the program to delete.
- Status Codes:
204 No Content – on success
404 Not Found – if the program does not exist
- GET /api/programs/(int: program_id)/overview/(int: year)
- GET /api/programs/(int: program_id)/overview/(int: year)/(int: month)
Get a day-level overview of a program’s production history.
- Parameters:
program_id – The program 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.
- Status Codes:
404 Not Found – if the program doesn’t exist
- Returns:
a JSON object mapping years to objects each mapping “YYYY-MM-DD” to a number of parts produced
- GET /api/programs/(int: program_id)/chart
Get the data required to chart this program.
- Parameters:
program_id – The ID of the program to chart
- Response JSON Object:
program – the program object
parts – maps part IDs to part objects
- 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 program doesn’t exist