mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Convert doxygen to rst for UltimakerMachineActions, USBPrinting
This commit is contained in:
parent
d96359f208
commit
de82406782
4 changed files with 37 additions and 21 deletions
|
@ -110,20 +110,22 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
application = CuraApplication.getInstance()
|
||||
application.triggerNextExitCheck()
|
||||
|
||||
## Reset USB device settings
|
||||
#
|
||||
def resetDeviceSettings(self) -> None:
|
||||
"""Reset USB device settings"""
|
||||
|
||||
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,
|
||||
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:
|
||||
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()
|
||||
|
@ -144,9 +146,11 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
|
||||
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):
|
||||
"""Start a print based on a g-code.
|
||||
|
||||
:param gcode: The g-code to print.
|
||||
"""
|
||||
self._gcode.clear()
|
||||
self._paused = False
|
||||
|
||||
|
@ -219,8 +223,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
self._update_thread = Thread(target=self._update, daemon=True, name = "USBPrinterUpdate")
|
||||
self._serial = None
|
||||
|
||||
## Send a command to printer.
|
||||
def sendCommand(self, command: Union[str, bytes]):
|
||||
"""Send a command to printer."""
|
||||
|
||||
if not self._command_received.is_set():
|
||||
self._command_queue.put(command)
|
||||
else:
|
||||
|
|
|
@ -20,9 +20,10 @@ from . import USBPrinterOutputDevice
|
|||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
|
||||
## Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer.
|
||||
@signalemitter
|
||||
class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
|
||||
"""Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer."""
|
||||
|
||||
addUSBOutputDeviceSignal = Signal()
|
||||
progressChanged = pyqtSignal()
|
||||
|
||||
|
@ -85,8 +86,9 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
|
|||
self._addRemovePorts(port_list)
|
||||
time.sleep(5)
|
||||
|
||||
## Helper to identify serial ports (and scan for them)
|
||||
def _addRemovePorts(self, serial_ports):
|
||||
"""Helper to identify serial ports (and scan for them)"""
|
||||
|
||||
# First, find and add all new or changed keys
|
||||
for serial_port in list(serial_ports):
|
||||
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:
|
||||
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):
|
||||
"""Because the model needs to be created in the same thread as the QMLEngine, we use a signal."""
|
||||
|
||||
device = USBPrinterOutputDevice.USBPrinterOutputDevice(serial_port)
|
||||
device.connectionStateChanged.connect(self._onConnectionStateChanged)
|
||||
self._usb_output_devices[serial_port] = device
|
||||
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):
|
||||
"""Create a list of serial ports on the system.
|
||||
|
||||
:param only_list_usb: If true, only usb ports are listed
|
||||
"""
|
||||
base_list = []
|
||||
for port in serial.tools.list_ports.comports():
|
||||
if not isinstance(port, tuple):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue