Tools

class pytm4srv.models.tool.Tool

Represents one tool and/or insert.

assembly_id: Mapped[int | None]

The ID of the tool assembly that this tool is part of.

calibration_date: Mapped[date | None]

When the tool was last calibrated. Mainly for durable tools.

Serialized as YYYY-MM-DD.

calibration_interval: Mapped[timedelta | None]

How often the tool needs calibration.

Serialized as a number of days.

NULL means never.

calibration_notify: Mapped[int | None]

Where to send calibration reminders.

NULL disables reminders.

created: Mapped[datetime]

When this tool was created.

day_warning_sent: Mapped[bool]

Whether a “days remaining” warning notification has been sent for this tool since the last replacement.

id: MappedColumn object at 0x7c965e161c60>]]

Unique, numeric ID for this tool/insert in OnTakt.

image: Mapped[bytes | None]

A user-provided image of this tool.

image_type: Mapped[str | None]

The MIME type of the file stored in image.

in_service_date: Mapped[date | None]

When the tool was put into service. Mainly for durable tools.

Serialized as YYYY-MM-DD.

If this is after the out_service_date (or that date is null), the tool is considered to be in service.

inventory_item_id: Mapped[int | None]

ID of the item to order to supply this tool.

is_critical: Mapped[bool]

Whether the machine should be kept from running when this tool is used beyond its expected life.

last_part_id: Mapped[int | None]

The ID of the last part that was created using this tool.

last_replaced

Get the timestamp of the last time this tool was replaced. If this tool has never been replaced, this will be None.

life_history: WriteOnlyMapped[ToolLifeRecord]

The life records created each time a life field is changed. :meta private:

location_history: WriteOnlyMapped[ToolLocationRecord]

The location records created each time this tool is moved. :meta private:

maintenance_status: Mapped[int]

The current rebuild status of this tool. Mainly for durable tools.

The following states are supported:

  1. Not set

  2. Needs rebuild

  3. Not ready for use

  4. Out for rebuild

  5. Received from rebuild

  6. Ready for use

  7. In service

monitoring_dest: Mapped[int | None]

Channel to send replacement notifications to.

NULL disables notifications.

name: Mapped[str]

User-specified name of the tool/insert.

notes: Mapped[str]

User-specified notes about the tool/insert.

offset_number: Mapped[int | None]

The offset number of this tool’s data in the control’s memory.

order_qty: Mapped[int | None]

How many of this tool are ordered at a time.

out_service_date: Mapped[date | None]

When the tool was taken out of service. Mainly for durable tools.

Serialized as YYYY-MM-DD.

If this is after the in_service_date (or that date is null), the tool is considered to be out of service.

pinned: Mapped[bool]

Whether this tool should be pinned to the top of lists, ignoring sorting.

purchase_date: Mapped[date | None]

When the tool was purchased. Mainly for durable tools.

reorder_point: Mapped[int | None]

How many of this tool remaining should trigger an order.

replace_duration: Mapped[timedelta]

How long it is expected to take to replace this tool, in minutes.

replaced_checklist: Mapped[List[str] | None]

Checklist to display to the user after replacing this tool. The user must check all items to continue.

This field can take three forms:

  1. null (default): the global tool_replaced_checklist option will be inherited

  2. Empty array: no checklist will be displayed

  3. Array of strings: each element of the array will be displayed as a checklist item

When replaced_message is also set, it will be displayed above the checklist.

replaced_message: Mapped[str]

Text to display to the user after replacing this tool.

replacement_history: WriteOnlyMapped[ToolReplacement]

The replacement objects created each time the tool is reset. :meta private:

replacement_rules_snoozed_until: Mapped[datetime | None]

If non-null, notifications will not be sent about this tool’s replacement rules until after this date and time.

slots: Mapped[int]

Number of inventory items (usually inserts) this tool uses at one time.

stick_out: Mapped[float | None]

Measured value when tool is in a machine.

stick_out_ref: Mapped[str]

Where the stick-out value is measured from.

tags: Mapped[List[str]]

Array of tags applied to this tool for searching and grouping.

Example: ["Sandvik", "cutting", "drawer 1"]

torque_spec: Mapped[float | None]

Torque to use during tool changes.

torque_spec_units: Mapped[str]

The units the torque_spec field is stored in.

Allowed values: - lb_ft for pound-feet - n_m for Newton-meters

usage_mode: Mapped[int]

How usage should be displayed for this tool.

The supported values are described in the table below:

Value

Usage mode

Usage calculation

0 (default)

Parts

part_count / part_life

1

Run time

runtime / max_runtime

2

Clock time

day_count / day_life

Note

Run time and clock time are still experimental. These two modes are not yet considered when suggesting inventory item order quantities or running tool reports.

used_corners: Mapped[int]

The number of indexed cutting positions that have been used since replacement.

warning_sent: Mapped[bool]

Whether a “parts remaining” warning notification has been sent for this tool since the last replacement.

class pytm4srv.models.tool.ToolReplacement

Represents one time a tool has been replaced.

assembly_id: Mapped[int | None]

The ID of the assembly this tool belonged to at the time of replacement.

Will be NULL if the tool was not in an assembly at the time of replacement.

condition: Mapped[int]

The specific condition of the tool prior to replacement.

This is a bitfield (of length 16), so multiple condition flags can be selected by combining their values with bitwise OR.

The following condition flags are supported:

Value

Binary

Description

0

0000 0000

(Not specified)

1

0000 0001

Snapped

2

0000 0010

Corner fracture

4

0000 0100

Side fracture

8

0000 1000

Large fracture

16

0001 0000

Normal wear

32

0010 0000

Could have run longer

day_count: Mapped[int]

The day count at the time the tool was replaced.

id: MappedColumn object at 0x7c965e161c60>]]

Unique, numeric ID for this replacement in OnTakt.

image: Mapped[bytes | None]

A user-provided image of this tool replacement.

image_type: Mapped[str | None]

The MIME type of the file stored in image.

indexed: Mapped[bool | None]

Whether the replacement was actually a tool index.

inventory_item_id: Mapped[int | None]

The ID of the inventory item that was consumed when this replacement was created.

Used for comparing performance between interchangeable inventory items and undoing replacements.

Will be NULL for replacements before this column was added, replacements of tools without an inventory item assigned, and for replacements whose inventory items have since been deleted.

inventory_point_id: Mapped[int | None]

ID of the inventory point this tool replacement came from.

Used for undoing replacements.

life_record_id: Mapped[int | None]

The ID of the latest tool life record at the time of replacement.

This can be used to show the tool’s expected life fields at the time of replacement even if they have since changed.

notes: Mapped[str]

Notes entered by the user when replacing the tool.

parts: Mapped[Dict[str, int] | None]

The part count at the time the tool was replaced, broken down by program. The keys of this object will be program IDs and the values will be how many parts of that program this tool produced.

If static_part_count is greater than the sum of this object’s values, that means programs were unassigned from this tool between production and replacement, so we don’t know what programs they came from.

process_id: Mapped[int | None]

The ID of the process this tool’s assembly belonged to at the time of replacement.

Will be NULL if the tool was not in an assembly or that assembly was not in use by a process at the time of replacement.

reason: Mapped[int]

The reason for this tool replacement.

The following values are supported:

Value

Reason

Notes

0

Unspecified

condition or notes may be used to provide more details.

1

Broken

Tool is no longer usable.

2

Preemptive

Preemptive tool replacements are not considered when calculating average tool life.

3

Scheduled

Fixed schedule to reduce the effect of normal wear on part dimensions or finish.

runtime: Mapped[timedelta]

The value of tool’s machining time counter at the time of replacement.

static_part_count: Mapped[int]

The part count at the time the tool was replaced.

Does not change when parts/programs/etc are changed.

substitute_id: Mapped[int | None]

The ID of the tool that replaced this one (for durable tools).

testing: Mapped[bool]

Whether this tool replacement was a test of a new inventory item.

testing_notes: Mapped[str | None]

Notes entered about what is being tested.

timestamp: Mapped[datetime]

When the tool was replaced.

tmac_job: Mapped[str | None]

The name of the TMAC job that was running when this tool was replaced.

tool_id: Mapped[int]

The ID of the tool that was replaced.

user_id: Mapped[int | None]

The ID of the user who replaced the tool.

class pytm4srv.models.tool.assembly.ToolAssembly

A grouping to make referencing whole tools easier.

id: MappedColumn object at 0x7c965e161c60>]]

Unique, numeric ID for this tool assembly in OnTakt.

image: Mapped[bytes | None]

A user-provided image of this tool.

image_type: Mapped[str | None]

The MIME type of the file stored in image.

location: Mapped[int | None]

User-specified location of the assembly for identification.

Usually the tool pot number in the machine.

name: Mapped[str]

User-specified name of this tool assembly.

notes: Mapped[str]

User-specified notes about the assembly.

process_id: Mapped[int | None]

The ID of the process this assembly is currently being used for.

shared: Mapped[bool]

Shared tools are associated with a machine instead of a single process.

When OnTakt detects that a machine has switched processes, it will reassign all shared tools in any process associated with that machine to the newly loaded process.