mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-05 13:03:59 -06:00
Merge pull request #4975 from Ultimaker/CURA-6011_connection_types
[4.0] Every output device should define its connection type
This commit is contained in:
commit
71e71e0a4f
15 changed files with 183 additions and 104 deletions
|
@ -7,7 +7,7 @@ from UM.i18n import i18nCatalog
|
|||
from UM.Qt.Duration import DurationFormat
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
|
||||
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType
|
||||
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
||||
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
|
||||
from cura.PrinterOutput.GenericOutputController import GenericOutputController
|
||||
|
@ -29,7 +29,7 @@ catalog = i18nCatalog("cura")
|
|||
|
||||
class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||
def __init__(self, serial_port: str, baud_rate: Optional[int] = None) -> None:
|
||||
super().__init__(serial_port)
|
||||
super().__init__(serial_port, connection_type = ConnectionType.UsbConnection)
|
||||
self.setName(catalog.i18nc("@item:inmenu", "USB printing"))
|
||||
self.setShortDescription(catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print via USB"))
|
||||
self.setDescription(catalog.i18nc("@info:tooltip", "Print via USB"))
|
||||
|
@ -179,7 +179,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
return
|
||||
CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
|
||||
self._onGlobalContainerStackChanged()
|
||||
self.setConnectionState(ConnectionState.connected)
|
||||
self.setConnectionState(ConnectionState.Connected)
|
||||
self._update_thread.start()
|
||||
|
||||
def _onGlobalContainerStackChanged(self):
|
||||
|
@ -208,7 +208,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
self._sendCommand(command)
|
||||
|
||||
def _sendCommand(self, command: Union[str, bytes]):
|
||||
if self._serial is None or self._connection_state != ConnectionState.connected:
|
||||
if self._serial is None or self._connection_state != ConnectionState.Connected:
|
||||
return
|
||||
|
||||
new_command = cast(bytes, command) if type(command) is bytes else cast(str, command).encode() # type: bytes
|
||||
|
@ -222,7 +222,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
self._command_received.set()
|
||||
|
||||
def _update(self):
|
||||
while self._connection_state == ConnectionState.connected and self._serial is not None:
|
||||
while self._connection_state == ConnectionState.Connected and self._serial is not None:
|
||||
try:
|
||||
line = self._serial.readline()
|
||||
except:
|
||||
|
|
|
@ -66,7 +66,7 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
|
|||
return
|
||||
|
||||
changed_device = self._usb_output_devices[serial_port]
|
||||
if changed_device.connectionState == ConnectionState.connected:
|
||||
if changed_device.connectionState == ConnectionState.Connected:
|
||||
self.getOutputDeviceManager().addOutputDevice(changed_device)
|
||||
else:
|
||||
self.getOutputDeviceManager().removeOutputDevice(serial_port)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue