Convert doxygen to rst for UltimakerMachineActions, USBPrinting

This commit is contained in:
Nino van Hooff 2020-05-15 14:00:44 +02:00
parent d96359f208
commit de82406782
4 changed files with 37 additions and 21 deletions

View File

@ -110,20 +110,22 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
application = CuraApplication.getInstance() application = CuraApplication.getInstance()
application.triggerNextExitCheck() application.triggerNextExitCheck()
## Reset USB device settings
#
def resetDeviceSettings(self) -> None: def resetDeviceSettings(self) -> None:
"""Reset USB device settings"""
self._firmware_name = None self._firmware_name = None
## Request the current scene to be sent to a USB-connected printer.
#
# \param nodes A collection of scene nodes to send. This is ignored.
# \param file_name A suggestion for a file name to write.
# \param filter_by_machine Whether to filter MIME types by machine. This
# is ignored.
# \param kwargs Keyword arguments.
def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False, def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None: file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
"""Request the current scene to be sent to a USB-connected printer.
:param nodes: A collection of scene nodes to send. This is ignored.
:param file_name: A suggestion for a file name to write.
:param filter_by_machine: Whether to filter MIME types by machine. This
is ignored.
:param kwargs: Keyword arguments.
"""
if self._is_printing: if self._is_printing:
message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress")) message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress"))
message.show() message.show()
@ -144,9 +146,11 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._printGCode(gcode_textio.getvalue()) self._printGCode(gcode_textio.getvalue())
## Start a print based on a g-code.
# \param gcode The g-code to print.
def _printGCode(self, gcode: str): def _printGCode(self, gcode: str):
"""Start a print based on a g-code.
:param gcode: The g-code to print.
"""
self._gcode.clear() self._gcode.clear()
self._paused = False self._paused = False
@ -219,8 +223,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._update_thread = Thread(target=self._update, daemon=True, name = "USBPrinterUpdate") self._update_thread = Thread(target=self._update, daemon=True, name = "USBPrinterUpdate")
self._serial = None self._serial = None
## Send a command to printer.
def sendCommand(self, command: Union[str, bytes]): def sendCommand(self, command: Union[str, bytes]):
"""Send a command to printer."""
if not self._command_received.is_set(): if not self._command_received.is_set():
self._command_queue.put(command) self._command_queue.put(command)
else: else:

View File

@ -20,9 +20,10 @@ from . import USBPrinterOutputDevice
i18n_catalog = i18nCatalog("cura") i18n_catalog = i18nCatalog("cura")
## Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer.
@signalemitter @signalemitter
class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin): class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
"""Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer."""
addUSBOutputDeviceSignal = Signal() addUSBOutputDeviceSignal = Signal()
progressChanged = pyqtSignal() progressChanged = pyqtSignal()
@ -85,8 +86,9 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
self._addRemovePorts(port_list) self._addRemovePorts(port_list)
time.sleep(5) time.sleep(5)
## Helper to identify serial ports (and scan for them)
def _addRemovePorts(self, serial_ports): def _addRemovePorts(self, serial_ports):
"""Helper to identify serial ports (and scan for them)"""
# First, find and add all new or changed keys # First, find and add all new or changed keys
for serial_port in list(serial_ports): for serial_port in list(serial_ports):
if serial_port not in self._serial_port_list: if serial_port not in self._serial_port_list:
@ -98,16 +100,19 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
if port not in self._serial_port_list: if port not in self._serial_port_list:
device.close() device.close()
## Because the model needs to be created in the same thread as the QMLEngine, we use a signal.
def addOutputDevice(self, serial_port): def addOutputDevice(self, serial_port):
"""Because the model needs to be created in the same thread as the QMLEngine, we use a signal."""
device = USBPrinterOutputDevice.USBPrinterOutputDevice(serial_port) device = USBPrinterOutputDevice.USBPrinterOutputDevice(serial_port)
device.connectionStateChanged.connect(self._onConnectionStateChanged) device.connectionStateChanged.connect(self._onConnectionStateChanged)
self._usb_output_devices[serial_port] = device self._usb_output_devices[serial_port] = device
device.connect() device.connect()
## Create a list of serial ports on the system.
# \param only_list_usb If true, only usb ports are listed
def getSerialPortList(self, only_list_usb = False): def getSerialPortList(self, only_list_usb = False):
"""Create a list of serial ports on the system.
:param only_list_usb: If true, only usb ports are listed
"""
base_list = [] base_list = []
for port in serial.tools.list_ports.comports(): for port in serial.tools.list_ports.comports():
if not isinstance(port, tuple): if not isinstance(port, tuple):

View File

@ -14,9 +14,12 @@ from UM.Logger import Logger
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
## A simple action to handle manual bed leveling procedure for printers that don't have it on the firmware.
# This is currently only used by the Ultimaker Original+
class BedLevelMachineAction(MachineAction): class BedLevelMachineAction(MachineAction):
"""A simple action to handle manual bed leveling procedure for printers that don't have it on the firmware.
This is currently only used by the Ultimaker Original+
"""
def __init__(self): def __init__(self):
super().__init__("BedLevel", catalog.i18nc("@action", "Level build plate")) super().__init__("BedLevel", catalog.i18nc("@action", "Level build plate"))
self._qml_url = "BedLevelMachineAction.qml" self._qml_url = "BedLevelMachineAction.qml"

View File

@ -11,9 +11,12 @@ catalog = i18nCatalog("cura")
from cura.Settings.CuraStackBuilder import CuraStackBuilder from cura.Settings.CuraStackBuilder import CuraStackBuilder
## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added
# as a variant.
class UMOUpgradeSelection(MachineAction): class UMOUpgradeSelection(MachineAction):
"""The Ultimaker Original can have a few revisions & upgrades.
This action helps with selecting them, so they are added as a variant.
"""
def __init__(self): def __init__(self):
super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades")) super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
self._qml_url = "UMOUpgradeSelectionMachineAction.qml" self._qml_url = "UMOUpgradeSelectionMachineAction.qml"