implib package

Submodules

implib.cutcmds module

This module is a collection of classes used to represent cut commands.

THINK uses three cut-file types: CLS, CUT, and CBF. While each file type has its own formatting rules, they can all be used to represent the same list of commands. Equivalency issues often arise when a command has multiple representations, possibly a different model for each file type. This module ensures that there is a single model for each command, and thus should prevent equivlanecy issues.

There are two main types of cut commands: MoveCmd and InfoCmd.

Notes

Default Units (unless specified otherwise):
  • distance (mm)
  • velocity (m/s)
  • acceleration (m/s/s)
Cut-file Format Spec Documents:
class implib.cutcmds.CutCmd(arg_list=None)[source]

Bases: object

General cut command.

Base-class for all cut commands – all cut commands must extend this class.

Parameters:arg_list (List, optional) – A list of argument values. Defaults to None.
is_move_cmd

bool – True if this command is a MoveCmd.

is_info_cmd

bool – True if this command is an InfoCmd.

req_chkpt_before

bool – True if this command requries a checkpoint as the previous command.

req_chkpt_after

bool – True if this command requries a checkpoint as the next command.

req_stop_before

bool – True if all movement must be stopped before this command.

req_stop_after

bool – True if all movement must be stopped at the end of this command.

Notes

  • Default tolerance for all operations is 1e-4.
get_cbf()[source]

Compile and retrieve the CBF byte-string for this commmand.

The command is compiled according to the format specified in document 300071, Rev03, Spec, Cutfile Binary Format (CBF). The returned bytearray will not include the command sequence number.

Returns:[cmd code, cmd code, # arg bytes, 0, checksum, args]
Return type:bytearray

Note

The returned bytearray will not include the command sequence number.

get_cbf_cmd_code()[source]

Get the CBF command code for this command.

The command codes are listed in document 300071, Rev03, Spec, Cutfile Binary Format (CBF).

Returns:CBF command code
Return type:int
get_cls()[source]

Compile and retrieve the CLS command for this command.

The command is compiled according to the format specified in document 300319, Rev01, CLSFCUT Interface Specification.

Returns:the CLS command (for most commands this is the CUT command with “$$CUT” prepended to it)
Return type:string
get_cut()[source]

Compile and retrieve the CUT command for this command.

The command is compiled according to the format specified in document 300072, Rev07, Spec, Cutfile ASCII Format (CUT).

Returns:the CUT command (command name + command value)
Return type:string
is_info_cmd = False
is_move_cmd = False
req_chkpt_after = False
req_chkpt_before = False
req_stop_after = False
req_stop_before = False
class implib.cutcmds.MoveCmd(arg_list=None)[source]

Bases: implib.cutcmds.CutCmd

Parent class for all Movement commands.

is_move_cmd

bool – True

Note

Default constructor will not assign any start/end points/directions.

end_dir = None

numpy 3-vec to store end direction. Default is None.

end_pt = None

numpy 3-vec to store end point. Default is None.

get_cls()[source]

Over-ride CutCmd.get_cls().

Returns:NotImplemented
Return type:error

Note

This function over-rides the get_cls() function for the CutCmd class.

is_move_cmd = True
start_dir = None

numpy 3-vec to store start direction. Default is None.

start_pt = None

numpy 3-vec to store start point. Default is None.

class implib.cutcmds.InfoCmd(arg_list=None)[source]

Bases: implib.cutcmds.CutCmd

is_info_cmd = True
class implib.cutcmds.PointCmd(arg_list)[source]

Bases: implib.cutcmds.MoveCmd

class implib.cutcmds.OrientCmd(arg_list)[source]

Bases: implib.cutcmds.MoveCmd

class implib.cutcmds.Orient5XCmd(arg_list)[source]

Bases: implib.cutcmds.MoveCmd

class implib.cutcmds.LineCmd(arg_list)[source]

Bases: implib.cutcmds.MoveCmd

class implib.cutcmds.Line5XCmd(arg_list)[source]

Bases: implib.cutcmds.MoveCmd

class implib.cutcmds.HeaderCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

get_cbf_value()[source]
class implib.cutcmds.HeaderExtCmd(arg_list=None)[source]

Bases: implib.cutcmds.InfoCmd

get_cbf_value()[source]
class implib.cutcmds.CheckpointCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

class implib.cutcmds.CutterCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

get_cls()[source]
class implib.cutcmds.PhaseCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

get_cls()[source]
set_cutter(cutter_pn)[source]
class implib.cutcmds.StartshapeCmd(arg_list)[source]

Bases: implib.cutcmds.ShapeCmd

class implib.cutcmds.EndshapeCmd(arg_list)[source]

Bases: implib.cutcmds.ShapeCmd

class implib.cutcmds.DecelOnCmd(arg_list=None)[source]

Bases: implib.cutcmds.DecelCmd

class implib.cutcmds.DecelOffCmd(arg_list=None)[source]

Bases: implib.cutcmds.DecelCmd

class implib.cutcmds.SpeedCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

get_cls()[source]
class implib.cutcmds.AccelCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

class implib.cutcmds.CutterOnCmd(arg_list=None)[source]

Bases: implib.cutcmds.CutterControlCmd

class implib.cutcmds.CutterOffCmd(arg_list=None)[source]

Bases: implib.cutcmds.CutterControlCmd

class implib.cutcmds.FCparmsCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

class implib.cutcmds.VersionCmd(arg_list=None)[source]

Bases: implib.cutcmds.InfoCmd

class implib.cutcmds.CommentCmd(arg_list)[source]

Bases: implib.cutcmds.InfoCmd

get_cls()[source]
class implib.cutcmds.CheckSumCmd(arg_list=None)[source]

Bases: implib.cutcmds.InfoCmd

exception implib.cutcmds.InvalidCutCmdError(cmd)[source]

Bases: Exception

implib.cutfile module

class implib.cutfile.CutFile(cmd_list=None, name=None, version=3)[source]

Bases: object

equals(other, hdr=True, moves=True, info=True)[source]
get_cmd_list()[source]
get_name()[source]
read(file_path)[source]
set_cmd_list(cmd_list)[source]
set_header(implant_pn)[source]
set_name(name)[source]
write(dir_path=None, file_name=None, cut=False, cbf=False, cls=False)[source]

implib.cutfileutils module

implib.cutfileutils.read_cls_cut_file(file_path)[source]

Convert a cls(f) cut file to a list of CutCmds

implib.cutfileutils.read_binary_cut_file(file_path)[source]

Convert a binary cut file to a list of CutCmds.

implib.cutfileutils.read_ascii_cut_file(file_path)[source]

Convert an ASCII cut file to a list of CutCmds.

implib.cutfileutils.read_cut_file(file_path)[source]
implib.cutfileutils.is_cmd_list(lst, raise_err=True)[source]
implib.cutfileutils.make_cbf_header(hdr_cmd, file_checksum, version, num_cmds, hdr_ext=None)[source]
implib.cutfileutils.make_goto_cmd(loc, ori, decimals=4)[source]

implib.cutter module

class implib.cutter.Cutter(pn, slv, drv, prb, length, rad, ht, shp, xy_stiff, z_stiff)[source]

Bases: object

implib.fileutils module

implib.fileutils.check_ext(file_path, ext)[source]
implib.fileutils.get_clean_ext(file_path)[source]
implib.fileutils.get_data_file_path(file_path)[source]
implib.fileutils.get_dir(file_path)[source]
implib.fileutils.get_ext(file_path)[source]
implib.fileutils.get_file_name(file_path, exclude_ext=False)[source]
implib.fileutils.has_ext(file_path)[source]
implib.fileutils.is_cbf_file_name(file_path)[source]
implib.fileutils.is_cls_file_name(file_path)[source]
implib.fileutils.is_cut_file(file_path)[source]
implib.fileutils.is_cut_file_name(file_path)[source]
implib.fileutils.is_dir(dir_path, raise_err=True)[source]
implib.fileutils.is_file(file_path, raise_err=True)[source]
implib.fileutils.make_file_name(dir_path, file_name, ext, ext_upper=False)[source]

implib.mathext module

implib.mathext.cmp_flt(f1, f2, tol)[source]

Evaluates the equality of two floats within a given tolerance.

Parameters:
  • f1 – float
  • f2 – float
  • tol – tolerance - float
Returns:

True if f1 and f2 are within tolerance of each other.

False otherwise.

implib.mathext.cmp_vec(v1, v2, tol)[source]

Evaluates the equality of two vectors within a given tolerance.

Parameters:
  • v1 – numpy array or None
  • v2 – numpy array or None
  • tol – tolerance - float
Returns:

True if both v1 and v2 are None or is each element in v1 is within

tolerance of the corresponding element in v2. False otherwise.

implib.mathext.compute_checksum(bytes_string)[source]
implib.mathext.float_to_bytes(flt)[source]
implib.mathext.float_to_cut_string(number, decimals=4)[source]

Converts a float to a rounded string for use in the CUT domain.

Parameters:
  • number – float
  • decimals – number of decimal places to round each element

in np_vec to. - integer - default = 4

Returns:Empty string if number is None or not a float. Otherwise, round

the float to decimals decimal places and convert to a string.

implib.mathext.get_reserved_bytes(num_bytes)[source]
implib.mathext.np_vec_to_bytes(vec)[source]
implib.mathext.np_vec_to_cls_vec(np_vec, decimals=4)[source]
implib.mathext.np_vec_to_cut_vec(np_vec, decimals=4)[source]

Converts a 3x1 numpy array to its representation in the CUT domain.

Parameters:
  • np_vec – numpy array or None
  • decimals – number of decimal places to round each element

in np_vec to. - integer - default = 4

Returns:Empty string if np_vec is None or len(np_vec) != 3. Otherwise,

the string ‘< x1, x2, x3 >’ where x1, x2, x3 are the elements of np_vec rounded to decimals decimal places.

implib.mathext.str_to_bytes(string, length)[source]
implib.mathext.u_int_to_bytes(num, num_bytes)[source]

Module contents