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 0x7efbf5375d80>]]

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 process

  • loaded (int) – set to 1 to only include loaded programs or 0 to only include unloaded programs

  • archived (int) – set to 1 to only include archived programs or 0 to only include non-archived programs

Status Codes:
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 and machine_id are required).

Status Codes:
GET /api/programs/(int: program_id)

Get information about a single program.

Parameters:
  • program_id – the ID of the program

Status Codes:
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:
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:
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: