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
-
class
implib.cutcmds.
HeaderExtCmd
(arg_list=None)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
class
implib.cutcmds.
CheckpointCmd
(arg_list)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
class
implib.cutcmds.
CutterCmd
(arg_list)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
class
implib.cutcmds.
PhaseCmd
(arg_list)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
class
implib.cutcmds.
SpeedCmd
(arg_list)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
class
implib.cutcmds.
AccelCmd
(arg_list)[source]¶ Bases:
implib.cutcmds.InfoCmd
-
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
-
class
implib.cutcmds.
CheckSumCmd
(arg_list=None)[source]¶ Bases:
implib.cutcmds.InfoCmd
implib.cutfile module¶
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.cutter module¶
implib.fileutils module¶
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.
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.
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.