mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 17:57:55 -06:00
STAR-322: Extracting models to be able for converting themselves
This commit is contained in:
parent
163226f940
commit
b693b9d98f
20 changed files with 324 additions and 254 deletions
|
@ -0,0 +1,52 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import List
|
||||
|
||||
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
||||
from .CloudClusterPrinterConfiguration import CloudClusterPrinterConfiguration
|
||||
from .CloudClusterPrintJobConstraint import CloudClusterPrintJobConstraint
|
||||
from ...Models import BaseModel
|
||||
|
||||
|
||||
## Class representing a print job
|
||||
from plugins.UM3NetworkPrinting.src.UM3PrintJobOutputModel import UM3PrintJobOutputModel
|
||||
|
||||
|
||||
class CloudClusterPrintJob(BaseModel):
|
||||
def __init__(self, **kwargs) -> None:
|
||||
self.assigned_to = None # type: str
|
||||
self.configuration = [] # type: List[CloudClusterPrinterConfiguration]
|
||||
self.constraints = [] # type: List[CloudClusterPrintJobConstraint]
|
||||
self.created_at = None # type: str
|
||||
self.force = None # type: str
|
||||
self.last_seen = None # type: str
|
||||
self.machine_variant = None # type: str
|
||||
self.name = None # type: str
|
||||
self.network_error_count = None # type: int
|
||||
self.owner = None # type: str
|
||||
self.printer_uuid = None # type: str
|
||||
self.started = None # type: str
|
||||
self.status = None # type: str
|
||||
self.time_elapsed = None # type: str
|
||||
self.time_total = None # type: str
|
||||
self.uuid = None # type: str
|
||||
super().__init__(**kwargs)
|
||||
self.printers = [CloudClusterPrinterConfiguration(**c) if isinstance(c, dict) else c
|
||||
for c in self.configuration]
|
||||
self.printers = [CloudClusterPrintJobConstraint(**p) if isinstance(p, dict) else p
|
||||
for p in self.constraints]
|
||||
|
||||
## Creates an UM3 print job output model based on this cloud cluster print job.
|
||||
# \param printer: The output model of the printer
|
||||
def createOutputModel(self, printer: PrinterOutputModel) -> UM3PrintJobOutputModel:
|
||||
model = UM3PrintJobOutputModel(printer.getController(), self.uuid, self.name)
|
||||
model.updateAssignedPrinter(printer)
|
||||
return model
|
||||
|
||||
## Updates an UM3 print job output model based on this cloud cluster print job.
|
||||
# \param model: The model to update.
|
||||
def updateOutputModel(self, model: UM3PrintJobOutputModel) -> None:
|
||||
model.updateTimeTotal(self.time_total)
|
||||
model.updateTimeElapsed(self.time_elapsed)
|
||||
model.updateOwner(self.owner)
|
||||
model.updateState(self.status)
|
Loading…
Add table
Add a link
Reference in a new issue