mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Showing print queue, works with multiple printers in cluster, Add TODO
This commit is contained in:
parent
05ca0b372a
commit
373c953dbf
2 changed files with 26 additions and 18 deletions
|
@ -18,6 +18,7 @@ from cura.CuraApplication import CuraApplication
|
||||||
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice
|
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice
|
||||||
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
|
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
|
||||||
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
||||||
|
from plugins.UM3NetworkPrinting.src.Cloud.CloudOutputController import CloudOutputController
|
||||||
from ..MeshFormatHandler import MeshFormatHandler
|
from ..MeshFormatHandler import MeshFormatHandler
|
||||||
from ..UM3PrintJobOutputModel import UM3PrintJobOutputModel
|
from ..UM3PrintJobOutputModel import UM3PrintJobOutputModel
|
||||||
from .CloudApiClient import CloudApiClient
|
from .CloudApiClient import CloudApiClient
|
||||||
|
@ -266,8 +267,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
self._printers.remove(removed_printer)
|
self._printers.remove(removed_printer)
|
||||||
|
|
||||||
for added_printer in added_printers:
|
for added_printer in added_printers:
|
||||||
controller = PrinterOutputController(self)
|
self._printers.append(added_printer.createOutputModel(CloudOutputController(self)))
|
||||||
self._printers.append(added_printer.createOutputModel(controller))
|
|
||||||
|
|
||||||
for model, printer in updated_printers:
|
for model, printer in updated_printers:
|
||||||
printer.updateOutputModel(model)
|
printer.updateOutputModel(model)
|
||||||
|
@ -276,7 +276,8 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
if not self._active_printer:
|
if not self._active_printer:
|
||||||
self.setActivePrinter(self._printers[0])
|
self.setActivePrinter(self._printers[0])
|
||||||
|
|
||||||
self._clusterPrintersChanged.emit()
|
if removed_printers or added_printers or updated_printers:
|
||||||
|
self._clusterPrintersChanged.emit()
|
||||||
|
|
||||||
def _updatePrintJobs(self, jobs: List[CloudClusterPrintJob]) -> None:
|
def _updatePrintJobs(self, jobs: List[CloudClusterPrintJob]) -> None:
|
||||||
received = {j.uuid: j for j in jobs} # type: Dict[str, CloudClusterPrintJob]
|
received = {j.uuid: j for j in jobs} # type: Dict[str, CloudClusterPrintJob]
|
||||||
|
@ -284,6 +285,9 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
removed_jobs, added_jobs, updated_jobs = findChanges(previous, received)
|
removed_jobs, added_jobs, updated_jobs = findChanges(previous, received)
|
||||||
|
|
||||||
|
# TODO: we see that not all data in the UI is correctly updated when the queue and active jobs change.
|
||||||
|
# TODO: we need to fix this here somehow by updating the correct output models.
|
||||||
|
|
||||||
for removed_job in removed_jobs:
|
for removed_job in removed_jobs:
|
||||||
self._print_jobs.remove(removed_job)
|
self._print_jobs.remove(removed_job)
|
||||||
|
|
||||||
|
@ -292,24 +296,30 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
for model, job in updated_jobs:
|
for model, job in updated_jobs:
|
||||||
job.updateOutputModel(model)
|
job.updateOutputModel(model)
|
||||||
|
self._updatePrintJobDetails(model)
|
||||||
|
|
||||||
# We only have to update when jobs are added or removed
|
# We only have to update when jobs are added or removed
|
||||||
# updated jobs push their changes via their output model
|
# updated jobs push their changes via their output model
|
||||||
if added_jobs or removed_jobs:
|
if added_jobs or removed_jobs or updated_jobs:
|
||||||
self.printJobsChanged.emit()
|
self.printJobsChanged.emit()
|
||||||
|
|
||||||
def _addPrintJob(self, job: CloudClusterPrintJob) -> None:
|
def _addPrintJob(self, job: CloudClusterPrintJob) -> None:
|
||||||
# TODO: we don't see the queued print jobs on the monitor page yet because job.printer_uuid and job.assigned_to
|
print_job = job.createOutputModel(CloudOutputController(self))
|
||||||
# are always None
|
self._updatePrintJobDetails(print_job)
|
||||||
try:
|
|
||||||
printer = next(p for p in self._printers if job.printer_uuid == p.key or job.assigned_to == p.key)
|
|
||||||
except StopIteration:
|
|
||||||
return Logger.log("w", "Missing printer %s for job %s in %s", job.printer_uuid, job.uuid,
|
|
||||||
[p.key for p in self._printers])
|
|
||||||
|
|
||||||
print_job = job.createOutputModel(printer)
|
|
||||||
self._print_jobs.append(print_job)
|
self._print_jobs.append(print_job)
|
||||||
|
|
||||||
|
def _updatePrintJobDetails(self, print_job: UM3PrintJobOutputModel):
|
||||||
|
printer = None
|
||||||
|
try:
|
||||||
|
printer = next(p for p in self._printers if print_job.assignedPrinter == p.key)
|
||||||
|
except StopIteration:
|
||||||
|
Logger.log("w", "Missing printer %s for job %s in %s", print_job.assignedPrinter, print_job.key,
|
||||||
|
[p.key for p in self._printers])
|
||||||
|
|
||||||
|
if printer:
|
||||||
|
printer.updateActivePrintJob(print_job)
|
||||||
|
print_job.updateAssignedPrinter(printer)
|
||||||
|
|
||||||
def _onPrintJobCreated(self, mesh: bytes, job_response: CloudJobResponse) -> None:
|
def _onPrintJobCreated(self, mesh: bytes, job_response: CloudJobResponse) -> None:
|
||||||
self._api.uploadMesh(job_response, mesh, self._onPrintJobUploaded, self._updateUploadProgress,
|
self._api.uploadMesh(job_response, mesh, self._onPrintJobUploaded, self._updateUploadProgress,
|
||||||
lambda _: self._onUploadError(T.UPLOAD_ERROR))
|
lambda _: self._onUploadError(T.UPLOAD_ERROR))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
from plugins.UM3NetworkPrinting.src.Cloud.CloudOutputController import CloudOutputController
|
||||||
from .CloudClusterPrinterConfiguration import CloudClusterPrinterConfiguration
|
from .CloudClusterPrinterConfiguration import CloudClusterPrinterConfiguration
|
||||||
from .CloudClusterPrintJobConstraint import CloudClusterPrintJobConstraint
|
from .CloudClusterPrintJobConstraint import CloudClusterPrintJobConstraint
|
||||||
from ...Models import BaseModel
|
from ...Models import BaseModel
|
||||||
|
@ -38,11 +38,9 @@ class CloudClusterPrintJob(BaseModel):
|
||||||
|
|
||||||
## Creates an UM3 print job output model based on this cloud cluster print job.
|
## Creates an UM3 print job output model based on this cloud cluster print job.
|
||||||
# \param printer: The output model of the printer
|
# \param printer: The output model of the printer
|
||||||
def createOutputModel(self, printer: PrinterOutputModel) -> UM3PrintJobOutputModel:
|
def createOutputModel(self, controller: CloudOutputController) -> UM3PrintJobOutputModel:
|
||||||
model = UM3PrintJobOutputModel(printer.getController(), self.uuid, self.name)
|
model = UM3PrintJobOutputModel(controller, self.uuid, self.name)
|
||||||
# TODO: implement more data as shown in ClusterUM3OutputDevice._createPrintJobModel
|
# TODO: implement more data as shown in ClusterUM3OutputDevice._createPrintJobModel
|
||||||
model.updateAssignedPrinter(printer)
|
|
||||||
printer.updateActivePrintJob(model)
|
|
||||||
return model
|
return model
|
||||||
|
|
||||||
## Updates an UM3 print job output model based on this cloud cluster print job.
|
## Updates an UM3 print job output model based on this cloud cluster print job.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue