mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 17:57:55 -06:00
Convert doxygen to rst for UM3NetworkPrinting
This commit is contained in:
parent
de82406782
commit
5eb5ffd916
38 changed files with 797 additions and 487 deletions
|
@ -15,9 +15,11 @@ from .Network.LocalClusterOutputDevice import LocalClusterOutputDevice
|
|||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
|
||||
## Machine action that allows to connect the active machine to a networked devices.
|
||||
# TODO: in the future this should be part of the new discovery workflow baked into Cura.
|
||||
class UltimakerNetworkedPrinterAction(MachineAction):
|
||||
"""Machine action that allows to connect the active machine to a networked devices.
|
||||
|
||||
TODO: in the future this should be part of the new discovery workflow baked into Cura.
|
||||
"""
|
||||
|
||||
# Signal emitted when discovered devices have changed.
|
||||
discoveredDevicesChanged = pyqtSignal()
|
||||
|
@ -27,59 +29,69 @@ class UltimakerNetworkedPrinterAction(MachineAction):
|
|||
self._qml_url = "resources/qml/DiscoverUM3Action.qml"
|
||||
self._network_plugin = None # type: Optional[UM3OutputDevicePlugin]
|
||||
|
||||
## Override the default value.
|
||||
def needsUserInteraction(self) -> bool:
|
||||
"""Override the default value."""
|
||||
|
||||
return False
|
||||
|
||||
## Start listening to network discovery events via the plugin.
|
||||
@pyqtSlot(name = "startDiscovery")
|
||||
def startDiscovery(self) -> None:
|
||||
"""Start listening to network discovery events via the plugin."""
|
||||
|
||||
self._networkPlugin.discoveredDevicesChanged.connect(self._onDeviceDiscoveryChanged)
|
||||
self.discoveredDevicesChanged.emit() # trigger at least once to populate the list
|
||||
|
||||
## Reset the discovered devices.
|
||||
@pyqtSlot(name = "reset")
|
||||
def reset(self) -> None:
|
||||
"""Reset the discovered devices."""
|
||||
|
||||
self.discoveredDevicesChanged.emit() # trigger to reset the list
|
||||
|
||||
## Reset the discovered devices.
|
||||
@pyqtSlot(name = "restartDiscovery")
|
||||
def restartDiscovery(self) -> None:
|
||||
"""Reset the discovered devices."""
|
||||
|
||||
self._networkPlugin.startDiscovery()
|
||||
self.discoveredDevicesChanged.emit() # trigger to reset the list
|
||||
|
||||
## Remove a manually added device.
|
||||
@pyqtSlot(str, str, name = "removeManualDevice")
|
||||
def removeManualDevice(self, key: str, address: str) -> None:
|
||||
"""Remove a manually added device."""
|
||||
|
||||
self._networkPlugin.removeManualDevice(key, address)
|
||||
|
||||
## Add a new manual device. Can replace an existing one by key.
|
||||
@pyqtSlot(str, str, name = "setManualDevice")
|
||||
def setManualDevice(self, key: str, address: str) -> None:
|
||||
"""Add a new manual device. Can replace an existing one by key."""
|
||||
|
||||
if key != "":
|
||||
self._networkPlugin.removeManualDevice(key)
|
||||
if address != "":
|
||||
self._networkPlugin.addManualDevice(address)
|
||||
|
||||
## Get the devices discovered in the local network sorted by name.
|
||||
@pyqtProperty("QVariantList", notify = discoveredDevicesChanged)
|
||||
def foundDevices(self):
|
||||
"""Get the devices discovered in the local network sorted by name."""
|
||||
|
||||
discovered_devices = list(self._networkPlugin.getDiscoveredDevices().values())
|
||||
discovered_devices.sort(key = lambda d: d.name)
|
||||
return discovered_devices
|
||||
|
||||
## Connect a device selected in the list with the active machine.
|
||||
@pyqtSlot(QObject, name = "associateActiveMachineWithPrinterDevice")
|
||||
def associateActiveMachineWithPrinterDevice(self, device: LocalClusterOutputDevice) -> None:
|
||||
"""Connect a device selected in the list with the active machine."""
|
||||
|
||||
self._networkPlugin.associateActiveMachineWithPrinterDevice(device)
|
||||
|
||||
## Callback for when the list of discovered devices in the plugin was changed.
|
||||
def _onDeviceDiscoveryChanged(self) -> None:
|
||||
"""Callback for when the list of discovered devices in the plugin was changed."""
|
||||
|
||||
self.discoveredDevicesChanged.emit()
|
||||
|
||||
## Get the network manager from the plugin.
|
||||
@property
|
||||
def _networkPlugin(self) -> UM3OutputDevicePlugin:
|
||||
"""Get the network manager from the plugin."""
|
||||
|
||||
if not self._network_plugin:
|
||||
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
|
||||
network_plugin = output_device_manager.getOutputDevicePlugin("UM3NetworkPrinting")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue