Skip to content

Commit

Permalink
Merge pull request #44 from acse-ci223/skip_object
Browse files Browse the repository at this point in the history
Start Print: Skip Objects
  • Loading branch information
mchrisgm authored Oct 18, 2024
2 parents 1a850cf + 786fa4c commit a9c563a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
32 changes: 30 additions & 2 deletions bambulabs_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def upload_file(self, file: BinaryIO, filename: str = "ftp_upload.gcode") -> str
def start_print(self, filename: str,
plate_number: int,
use_ams: bool = True,
ams_mapping: list[int] = [0]) -> bool:
ams_mapping: list[int] = [0],
skip_objects: list[int] | None = None,
) -> bool:
"""
Start printing a file.
Expand All @@ -209,6 +211,8 @@ def start_print(self, filename: str,
ams_mapping : list[int], optional
The mapping of the filament trays to the plate numbers,
by default [0].
skip_objects (list[int] | None, optional): List of gcode objects to
skip. Defaults to None.
Returns
-------
Expand All @@ -218,7 +222,8 @@ def start_print(self, filename: str,
return self.__printerMQTTClient.start_print_3mf(filename,
plate_number,
use_ams,
ams_mapping)
ams_mapping,
skip_objects)

def stop_print(self) -> bool:
"""
Expand Down Expand Up @@ -451,3 +456,26 @@ def get_current_state(self) -> PrintStatus:
The current state of the printer.
"""
return self.__printerMQTTClient.get_current_state()

def get_skipped_objects(self) -> list[int]:
"""
Get the current state of the printer.
Returns
-------
PrintStatus
The current state of the printer.
"""
return self.__printerMQTTClient.get_skipped_objects()

def skip_objects(self, obj_list: list[int]) -> bool:
"""
Skip Objects during printing.
Args:
obj_list (list[int]): object list to skip objects.
Returns:
bool: if publish command is successful
"""
return self.__printerMQTTClient.skip_objects(obj_list=obj_list)
40 changes: 39 additions & 1 deletion bambulabs_api/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ def get_light_state(self) -> str:
def start_print_3mf(self, filename: str,
plate_number: int,
use_ams: bool = True,
ams_mapping: list[int] = [0]) -> bool:
ams_mapping: list[int] = [0],
skip_objects: list[int] | None = None
) -> bool:
"""
Start the print
Expand All @@ -206,10 +208,15 @@ def start_print_3mf(self, filename: str,
plate_number (int): The plate number to print to
use_ams (bool, optional): Use the AMS system. Defaults to True.
ams_mapping (list[int], optional): The AMS mapping. Defaults to [0].
skip_objects (list[int] | None, optional): List of gcode objects to
skip. Defaults to [].
Returns:
str: print_status
"""
if skip_objects is not None and not skip_objects:
skip_objects = None

return self.__publish_command(
{
"print":
Expand All @@ -224,9 +231,40 @@ def start_print_3mf(self, filename: str,
"layer_inspect": False,
"use_ams": bool(use_ams),
"ams_mapping": list(ams_mapping),
"skip_objects": skip_objects,
}
})

def skip_objects(self, obj_list: list[int]) -> bool:
"""
Skip Objects during printing.
Args:
obj_list (list[int]): object list to skip objects.
Returns:
bool: if publish command is successful
"""
return self.__publish_command(
{
"print":
{
"command": "skip_objects",
"obj_list": obj_list,
}
})

def get_skipped_objects(self) -> list[int]:
"""
Get skipped Objects.
Args:
Returns:
bool: if publish command is successful
"""
return self.__get("s_obj", [])

def get_current_state(self) -> PrintStatus:
"""
Get the current printer state from stg_cur
Expand Down

0 comments on commit a9c563a

Please sign in to comment.