CAM: added command line arguments for finish label, (#21881)
output machine name, and post operation. With tests.
This commit is contained in:
@@ -882,6 +882,52 @@ G54
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00145(self) -> None:
|
||||
"""Test the finish label argument."""
|
||||
# test the default finish label
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--comments",
|
||||
)
|
||||
|
||||
# test a changed finish label
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(End operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(End operation)
|
||||
(Begin operation)
|
||||
(End operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--finish_label='End' --comments",
|
||||
)
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00150(self):
|
||||
"""Test output with an empty path.
|
||||
|
||||
@@ -1178,6 +1224,9 @@ G0 Z8.000
|
||||
--feed-precision FEED_PRECISION
|
||||
Number of digits of precision for feed rate, default
|
||||
is 3
|
||||
--finish_label FINISH_LABEL
|
||||
The characters to use in the 'Finish operation'
|
||||
comment, default is "Finish"
|
||||
--header Output headers (default)
|
||||
--no-header Suppress header output
|
||||
--line_number_increment LINE_NUMBER_INCREMENT
|
||||
@@ -1198,6 +1247,16 @@ G0 Z8.000
|
||||
Output all of the available arguments
|
||||
--no-output_all_arguments
|
||||
Don't output all of the available arguments (default)
|
||||
--output_machine_name
|
||||
Output the machine name in the pre-operation
|
||||
information
|
||||
--no-output_machine_name
|
||||
Don't output the machine name in the pre-operation
|
||||
information (default)
|
||||
--output_path_labels Output Path labels at the beginning of each Path
|
||||
--no-output_path_labels
|
||||
Don't output Path labels at the beginning of each Path
|
||||
(default)
|
||||
--output_visible_arguments
|
||||
Output all of the visible arguments
|
||||
--no-output_visible_arguments
|
||||
@@ -1205,6 +1264,9 @@ G0 Z8.000
|
||||
--postamble POSTAMBLE
|
||||
Set commands to be issued after the last command,
|
||||
default is ""
|
||||
--post_operation POST_OPERATION
|
||||
Set commands to be issued after every operation,
|
||||
default is ""
|
||||
--preamble PREAMBLE Set commands to be issued before the first command,
|
||||
default is ""
|
||||
--precision PRECISION
|
||||
@@ -1293,6 +1355,146 @@ G0 X2.000
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00205(self) -> None:
|
||||
"""Test output_machine_name argument."""
|
||||
# test the default behavior
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--comments",
|
||||
)
|
||||
|
||||
# test outputting the machine name
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
(Machine: test, mm/min)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Machine: test, mm/min)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Machine: test, mm/min)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--output_machine_name --comments",
|
||||
)
|
||||
|
||||
# test not outputting the machine name
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--no-output_machine_name --comments",
|
||||
)
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00206(self) -> None:
|
||||
"""Test output_path_labels argument."""
|
||||
# test the default behavior
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--comments",
|
||||
)
|
||||
|
||||
# test outputting the path labels
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
(Path: Fixture)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Path: TC: Default Tool)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Path: Profile)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--output_path_labels --comments",
|
||||
)
|
||||
|
||||
# test not outputting the path labels
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--no-output_path_labels --comments",
|
||||
)
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00210(self):
|
||||
"""Test Post-amble."""
|
||||
nl = "\n"
|
||||
@@ -1307,6 +1509,36 @@ G0 X2.000
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00215(self) -> None:
|
||||
"""Test the post_operation argument."""
|
||||
self.multi_compare(
|
||||
[],
|
||||
"""(Begin preamble)
|
||||
G90
|
||||
G21
|
||||
(Begin operation)
|
||||
G54
|
||||
(Finish operation)
|
||||
G90 G80
|
||||
G40 G49
|
||||
(Begin operation)
|
||||
(TC: Default Tool)
|
||||
(Begin toolchange)
|
||||
(M6 T1)
|
||||
(Finish operation)
|
||||
G90 G80
|
||||
G40 G49
|
||||
(Begin operation)
|
||||
(Finish operation)
|
||||
G90 G80
|
||||
G40 G49
|
||||
(Begin postamble)
|
||||
""",
|
||||
"--comments --post_operation='G90 G80\nG40 G49'",
|
||||
)
|
||||
|
||||
#############################################################################
|
||||
|
||||
def test00220(self):
|
||||
"""Test Pre-amble."""
|
||||
nl = "\n"
|
||||
|
||||
@@ -82,6 +82,8 @@ def init_argument_defaults(argument_defaults: Dict[str, bool]) -> None:
|
||||
argument_defaults["metric_inches"] = True
|
||||
argument_defaults["modal"] = False
|
||||
argument_defaults["output_all_arguments"] = False
|
||||
argument_defaults["output_machine_name"] = False
|
||||
argument_defaults["output_path_labels"] = False
|
||||
argument_defaults["output_visible_arguments"] = False
|
||||
argument_defaults["show-editor"] = True
|
||||
argument_defaults["tlo"] = True
|
||||
@@ -102,6 +104,7 @@ def init_arguments_visible(arguments_visible: Dict[str, bool]) -> None:
|
||||
arguments_visible["enable_machine_specific_commands"] = False
|
||||
arguments_visible["end_of_line_characters"] = False
|
||||
arguments_visible["feed-precision"] = True
|
||||
arguments_visible["finish_label"] = False
|
||||
arguments_visible["header"] = True
|
||||
arguments_visible["line_number_increment"] = False
|
||||
arguments_visible["line_number_start"] = False
|
||||
@@ -110,8 +113,11 @@ def init_arguments_visible(arguments_visible: Dict[str, bool]) -> None:
|
||||
arguments_visible["metric_inches"] = True
|
||||
arguments_visible["modal"] = True
|
||||
arguments_visible["output_all_arguments"] = True
|
||||
arguments_visible["output_machine_name"] = False
|
||||
arguments_visible["output_path_labels"] = False
|
||||
arguments_visible["output_visible_arguments"] = True
|
||||
arguments_visible["postamble"] = True
|
||||
arguments_visible["post_operation"] = False
|
||||
arguments_visible["preamble"] = True
|
||||
arguments_visible["precision"] = True
|
||||
arguments_visible["return-to"] = False
|
||||
@@ -263,6 +269,17 @@ def init_shared_arguments(
|
||||
type=int,
|
||||
help=help_message,
|
||||
)
|
||||
if arguments_visible["finish_label"]:
|
||||
help_message = (
|
||||
"The characters to use in the 'Finish operation' comment, "
|
||||
f'default is "{values["FINISH_LABEL"]}"'
|
||||
)
|
||||
else:
|
||||
help_message = argparse.SUPPRESS
|
||||
shared.add_argument(
|
||||
"--finish_label",
|
||||
help=help_message,
|
||||
)
|
||||
add_flag_type_arguments(
|
||||
shared,
|
||||
argument_defaults["header"],
|
||||
@@ -332,6 +349,24 @@ def init_shared_arguments(
|
||||
"Don't output all of the available arguments",
|
||||
arguments_visible["output_all_arguments"],
|
||||
)
|
||||
add_flag_type_arguments(
|
||||
shared,
|
||||
argument_defaults["output_machine_name"],
|
||||
"--output_machine_name",
|
||||
"--no-output_machine_name",
|
||||
"Output the machine name in the pre-operation information",
|
||||
"Don't output the machine name in the pre-operation information",
|
||||
arguments_visible["output_machine_name"],
|
||||
)
|
||||
add_flag_type_arguments(
|
||||
shared,
|
||||
argument_defaults["output_path_labels"],
|
||||
"--output_path_labels",
|
||||
"--no-output_path_labels",
|
||||
"Output Path labels at the beginning of each Path",
|
||||
"Don't output Path labels at the beginning of each Path",
|
||||
arguments_visible["output_path_labels"],
|
||||
)
|
||||
add_flag_type_arguments(
|
||||
shared,
|
||||
argument_defaults["output_visible_arguments"],
|
||||
@@ -349,6 +384,14 @@ def init_shared_arguments(
|
||||
else:
|
||||
help_message = argparse.SUPPRESS
|
||||
shared.add_argument("--postamble", help=help_message)
|
||||
if arguments_visible["post_operation"]:
|
||||
help_message = (
|
||||
f"Set commands to be issued after every operation, "
|
||||
f'default is "{values["POST_OPERATION"]}"'
|
||||
)
|
||||
else:
|
||||
help_message = argparse.SUPPRESS
|
||||
shared.add_argument("--post_operation", help=help_message)
|
||||
if arguments_visible["preamble"]:
|
||||
help_message = (
|
||||
f"Set commands to be issued before the first command, "
|
||||
@@ -817,6 +860,8 @@ def process_shared_arguments(
|
||||
values["END_OF_LINE_CHARACTERS"] = "\r\n"
|
||||
else:
|
||||
print("invalid end_of_line_characters, ignoring")
|
||||
if args.finish_label:
|
||||
values["FINISH_LABEL"] = args.finish_label
|
||||
if args.header:
|
||||
values["OUTPUT_HEADER"] = True
|
||||
if args.no_header:
|
||||
@@ -837,8 +882,18 @@ def process_shared_arguments(
|
||||
values["MODAL"] = True
|
||||
if args.no_modal:
|
||||
values["MODAL"] = False
|
||||
if args.output_machine_name:
|
||||
values["OUTPUT_MACHINE_NAME"] = True
|
||||
if args.no_output_machine_name:
|
||||
values["OUTPUT_MACHINE_NAME"] = False
|
||||
if args.output_path_labels:
|
||||
values["OUTPUT_PATH_LABELS"] = True
|
||||
if args.no_output_path_labels:
|
||||
values["OUTPUT_PATH_LABELS"] = False
|
||||
if args.postamble is not None:
|
||||
values["POSTAMBLE"] = args.postamble.replace("\\n", "\n")
|
||||
if args.post_operation is not None:
|
||||
values["POST_OPERATION"] = args.post_operation.replace("\\n", "\n")
|
||||
if args.preamble is not None:
|
||||
values["PREAMBLE"] = args.preamble.replace("\\n", "\n")
|
||||
if args.return_to != "":
|
||||
|
||||
Reference in New Issue
Block a user