Convert doxygen to rst for UM3NetworkPrinting

This commit is contained in:
Nino van Hooff 2020-05-15 15:05:38 +02:00
parent de82406782
commit 5eb5ffd916
38 changed files with 797 additions and 487 deletions

View file

@ -15,36 +15,9 @@ from ..BaseModel import BaseModel
from ...ClusterOutputController import ClusterOutputController
## Model for the status of a single print job in a cluster.
class ClusterPrintJobStatus(BaseModel):
"""Model for the status of a single print job in a cluster."""
## Creates a new cloud print job status model.
# \param assigned_to: The name of the printer this job is assigned to while being queued.
# \param configuration: The required print core configurations of this print job.
# \param constraints: Print job constraints object.
# \param created_at: The timestamp when the job was created in Cura Connect.
# \param force: Allow this job to be printed despite of mismatching configurations.
# \param last_seen: The number of seconds since this job was checked.
# \param machine_variant: The machine type that this job should be printed on.Coincides with the machine_type field
# of the printer object.
# \param name: The name of the print job. Usually the name of the .gcode file.
# \param network_error_count: The number of errors encountered when requesting data for this print job.
# \param owner: The name of the user who added the print job to Cura Connect.
# \param printer_uuid: UUID of the printer that the job is currently printing on or assigned to.
# \param started: Whether the job has started printing or not.
# \param status: The status of the print job.
# \param time_elapsed: The remaining printing time in seconds.
# \param time_total: The total printing time in seconds.
# \param uuid: UUID of this print job. Should be used for identification purposes.
# \param deleted_at: The time when this print job was deleted.
# \param printed_on_uuid: UUID of the printer used to print this job.
# \param configuration_changes_required: List of configuration changes the printer this job is associated with
# needs to make in order to be able to print this job
# \param build_plate: The build plate (type) this job needs to be printed on.
# \param compatible_machine_families: Family names of machines suitable for this print job
# \param impediments_to_printing: A list of reasons that prevent this job from being printed on the associated
# printer
# \param preview_url: URL to the preview image (same as wou;d've been included in the ufp).
def __init__(self, created_at: str, force: bool, machine_variant: str, name: str, started: bool, status: str,
time_total: int, uuid: str,
configuration: List[Union[Dict[str, Any], ClusterPrintCoreConfiguration]],
@ -60,6 +33,37 @@ class ClusterPrintJobStatus(BaseModel):
impediments_to_printing: List[Union[Dict[str, Any], ClusterPrintJobImpediment]] = None,
preview_url: Optional[str] = None,
**kwargs) -> None:
"""Creates a new cloud print job status model.
:param assigned_to: The name of the printer this job is assigned to while being queued.
:param configuration: The required print core configurations of this print job.
:param constraints: Print job constraints object.
:param created_at: The timestamp when the job was created in Cura Connect.
:param force: Allow this job to be printed despite of mismatching configurations.
:param last_seen: The number of seconds since this job was checked.
:param machine_variant: The machine type that this job should be printed on.Coincides with the machine_type field
of the printer object.
:param name: The name of the print job. Usually the name of the .gcode file.
:param network_error_count: The number of errors encountered when requesting data for this print job.
:param owner: The name of the user who added the print job to Cura Connect.
:param printer_uuid: UUID of the printer that the job is currently printing on or assigned to.
:param started: Whether the job has started printing or not.
:param status: The status of the print job.
:param time_elapsed: The remaining printing time in seconds.
:param time_total: The total printing time in seconds.
:param uuid: UUID of this print job. Should be used for identification purposes.
:param deleted_at: The time when this print job was deleted.
:param printed_on_uuid: UUID of the printer used to print this job.
:param configuration_changes_required: List of configuration changes the printer this job is associated with
needs to make in order to be able to print this job
:param build_plate: The build plate (type) this job needs to be printed on.
:param compatible_machine_families: Family names of machines suitable for this print job
:param impediments_to_printing: A list of reasons that prevent this job from being printed on the associated
printer
:param preview_url: URL to the preview image (same as wou;d've been included in the ufp).
"""
self.assigned_to = assigned_to
self.configuration = self.parseModels(ClusterPrintCoreConfiguration, configuration)
self.constraints = self.parseModels(ClusterPrintJobConstraints, constraints)
@ -90,24 +94,31 @@ class ClusterPrintJobStatus(BaseModel):
super().__init__(**kwargs)
## 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, controller: ClusterOutputController) -> UM3PrintJobOutputModel:
"""Creates an UM3 print job output model based on this cloud cluster print job.
:param printer: The output model of the printer
"""
model = UM3PrintJobOutputModel(controller, self.uuid, self.name)
self.updateOutputModel(model)
return model
## Creates a new configuration model
def _createConfigurationModel(self) -> PrinterConfigurationModel:
"""Creates a new configuration model"""
extruders = [extruder.createConfigurationModel() for extruder in self.configuration or ()]
configuration = PrinterConfigurationModel()
configuration.setExtruderConfigurations(extruders)
configuration.setPrinterType(self.machine_variant)
return configuration
## 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:
"""Updates an UM3 print job output model based on this cloud cluster print job.
:param model: The model to update.
"""
model.updateConfiguration(self._createConfigurationModel())
model.updateTimeTotal(self.time_total)
model.updateTimeElapsed(self.time_elapsed)