STAR-322: Improving documentation

This commit is contained in:
Daniel Schiavini 2018-12-17 14:57:57 +01:00
parent da974d9868
commit d28ac5e120
2 changed files with 11 additions and 10 deletions

View file

@ -83,7 +83,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
## Creates a new cloud output device ## Creates a new cloud output device
# \param api_client: The client that will run the API calls # \param api_client: The client that will run the API calls
# \param device_id: The ID of the device (i.e. the cluster_id for the cloud API) # \param cluster: The device response received from the cloud API.
# \param parent: The optional parent of this output device. # \param parent: The optional parent of this output device.
def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None: def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None:
super().__init__(device_id = cluster.cluster_id, address = "", properties = {}, parent = parent) super().__init__(device_id = cluster.cluster_id, address = "", properties = {}, parent = parent)
@ -118,30 +118,33 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
# A set of the user's job IDs that have finished # A set of the user's job IDs that have finished
self._finished_jobs = set() # type: Set[str] self._finished_jobs = set() # type: Set[str]
# Reference to the uploaded print job # Reference to the uploaded print job / mesh
self._mesh = None # type: Optional[bytes] self._mesh = None # type: Optional[bytes]
self._uploaded_print_job = None # type: Optional[CloudPrintJobResponse] self._uploaded_print_job = None # type: Optional[CloudPrintJobResponse]
## Connects this device.
def connect(self) -> None: def connect(self) -> None:
super().connect() super().connect()
Logger.log("i", "Connected to cluster %s", self.key) Logger.log("i", "Connected to cluster %s", self.key)
CuraApplication.getInstance().getBackend().backendStateChange.connect(self._onBackendStateChange) CuraApplication.getInstance().getBackend().backendStateChange.connect(self._onBackendStateChange)
## Disconnects the device
def disconnect(self) -> None: def disconnect(self) -> None:
super().disconnect() super().disconnect()
Logger.log("i", "Disconnected to cluster %s", self.key) Logger.log("i", "Disconnected to cluster %s", self.key)
CuraApplication.getInstance().getBackend().backendStateChange.disconnect(self._onBackendStateChange) CuraApplication.getInstance().getBackend().backendStateChange.disconnect(self._onBackendStateChange)
## Resets the print job that was uploaded to force a new upload, runs whenever the user re-slices.
def _onBackendStateChange(self, _: BackendState) -> None: def _onBackendStateChange(self, _: BackendState) -> None:
self._mesh = None self._mesh = None
self._uploaded_print_job = None self._uploaded_print_job = None
## Gets the host name of this device ## Gets the cluster response from which this device was created.
@property @property
def clusterData(self) -> CloudClusterResponse: def clusterData(self) -> CloudClusterResponse:
return self._cluster return self._cluster
## Updates the host name of the output device ## Updates the cluster data from the cloud.
@clusterData.setter @clusterData.setter
def clusterData(self, value: CloudClusterResponse) -> None: def clusterData(self, value: CloudClusterResponse) -> None:
self._cluster = value self._cluster = value
@ -166,11 +169,8 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
# Show an error message if we're already sending a job. # Show an error message if we're already sending a job.
if self._progress.visible: if self._progress.visible:
Message( message = Message(text = T.BLOCKED_UPLOADING, title = T.ERROR, lifetime = 10)
text = T.BLOCKED_UPLOADING, message.show()
title = T.ERROR,
lifetime = 10,
).show()
return return
if self._uploaded_print_job: if self._uploaded_print_job:
@ -312,7 +312,6 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
model.updateAssignedPrinter(printer) model.updateAssignedPrinter(printer)
## Uploads the mesh when the print job was registered with the cloud API. ## Uploads the mesh when the print job was registered with the cloud API.
# \param mesh: The bytes to upload.
# \param job_response: The response received from the cloud API. # \param job_response: The response received from the cloud API.
def _onPrintJobCreated(self, job_response: CloudPrintJobResponse) -> None: def _onPrintJobCreated(self, job_response: CloudPrintJobResponse) -> None:
self._progress.show() self._progress.show()

View file

@ -139,6 +139,7 @@ class CloudOutputDeviceManager:
) )
message.show() message.show()
## Starts running the cloud output device manager, thus periodically requesting cloud data.
def start(self): def start(self):
if self._running: if self._running:
return return
@ -149,6 +150,7 @@ class CloudOutputDeviceManager:
self._update_timer.timeout.connect(self._getRemoteClusters) self._update_timer.timeout.connect(self._getRemoteClusters)
self._onLoginStateChanged(is_logged_in = self._account.isLoggedIn) self._onLoginStateChanged(is_logged_in = self._account.isLoggedIn)
## Stops running the cloud output device manager.
def stop(self): def stop(self):
if not self._running: if not self._running:
return return