mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -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
|
@ -18,45 +18,56 @@ class BaseModel:
|
|||
def validate(self) -> None:
|
||||
pass
|
||||
|
||||
## Checks whether the two models are equal.
|
||||
# \param other: The other model.
|
||||
# \return True if they are equal, False if they are different.
|
||||
def __eq__(self, other):
|
||||
"""Checks whether the two models are equal.
|
||||
|
||||
:param other: The other model.
|
||||
:return: True if they are equal, False if they are different.
|
||||
"""
|
||||
return type(self) == type(other) and self.toDict() == other.toDict()
|
||||
|
||||
## Checks whether the two models are different.
|
||||
# \param other: The other model.
|
||||
# \return True if they are different, False if they are the same.
|
||||
def __ne__(self, other) -> bool:
|
||||
"""Checks whether the two models are different.
|
||||
|
||||
:param other: The other model.
|
||||
:return: True if they are different, False if they are the same.
|
||||
"""
|
||||
return type(self) != type(other) or self.toDict() != other.toDict()
|
||||
|
||||
## Converts the model into a serializable dictionary
|
||||
def toDict(self) -> Dict[str, Any]:
|
||||
"""Converts the model into a serializable dictionary"""
|
||||
|
||||
return self.__dict__
|
||||
|
||||
## Parses a single model.
|
||||
# \param model_class: The model class.
|
||||
# \param values: The value of the model, which is usually a dictionary, but may also be already parsed.
|
||||
# \return An instance of the model_class given.
|
||||
@staticmethod
|
||||
def parseModel(model_class: Type[T], values: Union[T, Dict[str, Any]]) -> T:
|
||||
"""Parses a single model.
|
||||
|
||||
:param model_class: The model class.
|
||||
:param values: The value of the model, which is usually a dictionary, but may also be already parsed.
|
||||
:return: An instance of the model_class given.
|
||||
"""
|
||||
if isinstance(values, dict):
|
||||
return model_class(**values)
|
||||
return values
|
||||
|
||||
## Parses a list of models.
|
||||
# \param model_class: The model class.
|
||||
# \param values: The value of the list. Each value is usually a dictionary, but may also be already parsed.
|
||||
# \return A list of instances of the model_class given.
|
||||
@classmethod
|
||||
def parseModels(cls, model_class: Type[T], values: List[Union[T, Dict[str, Any]]]) -> List[T]:
|
||||
"""Parses a list of models.
|
||||
|
||||
:param model_class: The model class.
|
||||
:param values: The value of the list. Each value is usually a dictionary, but may also be already parsed.
|
||||
:return: A list of instances of the model_class given.
|
||||
"""
|
||||
return [cls.parseModel(model_class, value) for value in values]
|
||||
|
||||
## Parses the given date string.
|
||||
# \param date: The date to parse.
|
||||
# \return The parsed date.
|
||||
@staticmethod
|
||||
def parseDate(date: Union[str, datetime]) -> datetime:
|
||||
"""Parses the given date string.
|
||||
|
||||
:param date: The date to parse.
|
||||
:return: The parsed date.
|
||||
"""
|
||||
if isinstance(date, datetime):
|
||||
return date
|
||||
return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
|
||||
|
|
|
@ -5,22 +5,26 @@ from typing import Optional
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cloud connected cluster.
|
||||
class CloudClusterResponse(BaseModel):
|
||||
"""Class representing a cloud connected cluster."""
|
||||
|
||||
|
||||
## Creates a new cluster response object.
|
||||
# \param cluster_id: The secret unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
# \param host_guid: The unique identifier of the print cluster host, e.g. 'e90ae0ac-1257-4403-91ee-a44c9b7e8050'.
|
||||
# \param host_name: The name of the printer as configured during the Wi-Fi setup. Used as identifier for end users.
|
||||
# \param is_online: Whether this cluster is currently connected to the cloud.
|
||||
# \param status: The status of the cluster authentication (active or inactive).
|
||||
# \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on.
|
||||
# \param host_internal_ip: The internal IP address of the host printer.
|
||||
# \param friendly_name: The human readable name of the host printer.
|
||||
# \param printer_type: The machine type of the host printer.
|
||||
def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str,
|
||||
host_internal_ip: Optional[str] = None, host_version: Optional[str] = None,
|
||||
friendly_name: Optional[str] = None, printer_type: str = "ultimaker3", **kwargs) -> None:
|
||||
"""Creates a new cluster response object.
|
||||
|
||||
:param cluster_id: The secret unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
:param host_guid: The unique identifier of the print cluster host, e.g. 'e90ae0ac-1257-4403-91ee-a44c9b7e8050'.
|
||||
:param host_name: The name of the printer as configured during the Wi-Fi setup. Used as identifier for end users.
|
||||
:param is_online: Whether this cluster is currently connected to the cloud.
|
||||
:param status: The status of the cluster authentication (active or inactive).
|
||||
:param host_version: The firmware version of the cluster host. This is where the Stardust client is running on.
|
||||
:param host_internal_ip: The internal IP address of the host printer.
|
||||
:param friendly_name: The human readable name of the host printer.
|
||||
:param printer_type: The machine type of the host printer.
|
||||
"""
|
||||
|
||||
self.cluster_id = cluster_id
|
||||
self.host_guid = host_guid
|
||||
self.host_name = host_name
|
||||
|
|
|
@ -11,15 +11,17 @@ from .ClusterPrintJobStatus import ClusterPrintJobStatus
|
|||
# Model that represents the status of the cluster for the cloud
|
||||
class CloudClusterStatus(BaseModel):
|
||||
|
||||
## Creates a new cluster status model object.
|
||||
# \param printers: The latest status of each printer in the cluster.
|
||||
# \param print_jobs: The latest status of each print job in the cluster.
|
||||
# \param generated_time: The datetime when the object was generated on the server-side.
|
||||
def __init__(self,
|
||||
printers: List[Union[ClusterPrinterStatus, Dict[str, Any]]],
|
||||
def __init__(self, printers: List[Union[ClusterPrinterStatus, Dict[str, Any]]],
|
||||
print_jobs: List[Union[ClusterPrintJobStatus, Dict[str, Any]]],
|
||||
generated_time: Union[str, datetime],
|
||||
**kwargs) -> None:
|
||||
"""Creates a new cluster status model object.
|
||||
|
||||
:param printers: The latest status of each printer in the cluster.
|
||||
:param print_jobs: The latest status of each print job in the cluster.
|
||||
:param generated_time: The datetime when the object was generated on the server-side.
|
||||
"""
|
||||
|
||||
self.generated_time = self.parseDate(generated_time)
|
||||
self.printers = self.parseModels(ClusterPrinterStatus, printers)
|
||||
self.print_jobs = self.parseModels(ClusterPrintJobStatus, print_jobs)
|
||||
|
|
|
@ -5,20 +5,23 @@ from typing import Dict, Optional, Any
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing errors generated by the cloud servers, according to the JSON-API standard.
|
||||
class CloudError(BaseModel):
|
||||
"""Class representing errors generated by the cloud servers, according to the JSON-API standard."""
|
||||
|
||||
## Creates a new error object.
|
||||
# \param id: Unique identifier for this particular occurrence of the problem.
|
||||
# \param title: A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence
|
||||
# of the problem, except for purposes of localization.
|
||||
# \param code: An application-specific error code, expressed as a string value.
|
||||
# \param detail: A human-readable explanation specific to this occurrence of the problem. Like title, this field's
|
||||
# value can be localized.
|
||||
# \param http_status: The HTTP status code applicable to this problem, converted to string.
|
||||
# \param meta: Non-standard meta-information about the error, depending on the error code.
|
||||
def __init__(self, id: str, code: str, title: str, http_status: str, detail: Optional[str] = None,
|
||||
meta: Optional[Dict[str, Any]] = None, **kwargs) -> None:
|
||||
"""Creates a new error object.
|
||||
|
||||
:param id: Unique identifier for this particular occurrence of the problem.
|
||||
:param title: A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence
|
||||
of the problem, except for purposes of localization.
|
||||
:param code: An application-specific error code, expressed as a string value.
|
||||
:param detail: A human-readable explanation specific to this occurrence of the problem. Like title, this field's
|
||||
value can be localized.
|
||||
:param http_status: The HTTP status code applicable to this problem, converted to string.
|
||||
:param meta: Non-standard meta-information about the error, depending on the error code.
|
||||
"""
|
||||
|
||||
self.id = id
|
||||
self.code = code
|
||||
self.http_status = http_status
|
||||
|
|
|
@ -8,19 +8,22 @@ from ..BaseModel import BaseModel
|
|||
# Model that represents the response received from the cloud after requesting to upload a print job
|
||||
class CloudPrintJobResponse(BaseModel):
|
||||
|
||||
## Creates a new print job response model.
|
||||
# \param job_id: The job unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
# \param status: The status of the print job.
|
||||
# \param status_description: Contains more details about the status, e.g. the cause of failures.
|
||||
# \param download_url: A signed URL to download the resulting status. Only available when the job is finished.
|
||||
# \param job_name: The name of the print job.
|
||||
# \param slicing_details: Model for slice information.
|
||||
# \param upload_url: The one-time use URL where the toolpath must be uploaded to (only if status is uploading).
|
||||
# \param content_type: The content type of the print job (e.g. text/plain or application/gzip)
|
||||
# \param generated_time: The datetime when the object was generated on the server-side.
|
||||
def __init__(self, job_id: str, status: str, download_url: Optional[str] = None, job_name: Optional[str] = None,
|
||||
upload_url: Optional[str] = None, content_type: Optional[str] = None,
|
||||
status_description: Optional[str] = None, slicing_details: Optional[dict] = None, **kwargs) -> None:
|
||||
"""Creates a new print job response model.
|
||||
|
||||
:param job_id: The job unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
:param status: The status of the print job.
|
||||
:param status_description: Contains more details about the status, e.g. the cause of failures.
|
||||
:param download_url: A signed URL to download the resulting status. Only available when the job is finished.
|
||||
:param job_name: The name of the print job.
|
||||
:param slicing_details: Model for slice information.
|
||||
:param upload_url: The one-time use URL where the toolpath must be uploaded to (only if status is uploading).
|
||||
:param content_type: The content type of the print job (e.g. text/plain or application/gzip)
|
||||
:param generated_time: The datetime when the object was generated on the server-side.
|
||||
"""
|
||||
|
||||
self.job_id = job_id
|
||||
self.status = status
|
||||
self.download_url = download_url
|
||||
|
|
|
@ -6,11 +6,14 @@ from ..BaseModel import BaseModel
|
|||
# Model that represents the request to upload a print job to the cloud
|
||||
class CloudPrintJobUploadRequest(BaseModel):
|
||||
|
||||
## Creates a new print job upload request.
|
||||
# \param job_name: The name of the print job.
|
||||
# \param file_size: The size of the file in bytes.
|
||||
# \param content_type: The content type of the print job (e.g. text/plain or application/gzip)
|
||||
def __init__(self, job_name: str, file_size: int, content_type: str, **kwargs) -> None:
|
||||
"""Creates a new print job upload request.
|
||||
|
||||
:param job_name: The name of the print job.
|
||||
:param file_size: The size of the file in bytes.
|
||||
:param content_type: The content type of the print job (e.g. text/plain or application/gzip)
|
||||
"""
|
||||
|
||||
self.job_name = job_name
|
||||
self.file_size = file_size
|
||||
self.content_type = content_type
|
||||
|
|
|
@ -9,13 +9,16 @@ from ..BaseModel import BaseModel
|
|||
# Model that represents the responses received from the cloud after requesting a job to be printed.
|
||||
class CloudPrintResponse(BaseModel):
|
||||
|
||||
## Creates a new print response object.
|
||||
# \param job_id: The unique ID of a print job inside of the cluster. This ID is generated by Cura Connect.
|
||||
# \param status: The status of the print request (queued or failed).
|
||||
# \param generated_time: The datetime when the object was generated on the server-side.
|
||||
# \param cluster_job_id: The unique ID of a print job inside of the cluster. This ID is generated by Cura Connect.
|
||||
def __init__(self, job_id: str, status: str, generated_time: Union[str, datetime],
|
||||
cluster_job_id: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print response object.
|
||||
|
||||
:param job_id: The unique ID of a print job inside of the cluster. This ID is generated by Cura Connect.
|
||||
:param status: The status of the print request (queued or failed).
|
||||
:param generated_time: The datetime when the object was generated on the server-side.
|
||||
:param cluster_job_id: The unique ID of a print job inside of the cluster. This ID is generated by Cura Connect.
|
||||
"""
|
||||
|
||||
self.job_id = job_id
|
||||
self.status = status
|
||||
self.cluster_job_id = cluster_job_id
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cluster printer
|
||||
class ClusterBuildPlate(BaseModel):
|
||||
"""Class representing a cluster printer"""
|
||||
|
||||
## Create a new build plate
|
||||
# \param type: The type of build plate glass or aluminium
|
||||
def __init__(self, type: str = "glass", **kwargs) -> None:
|
||||
"""Create a new build plate
|
||||
|
||||
:param type: The type of build plate glass or aluminium
|
||||
"""
|
||||
self.type = type
|
||||
super().__init__(**kwargs)
|
||||
|
|
|
@ -9,26 +9,33 @@ from .ClusterPrinterConfigurationMaterial import ClusterPrinterConfigurationMate
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cloud cluster printer configuration
|
||||
# Also used for representing slots in a Material Station (as from Cura's perspective these are the same).
|
||||
class ClusterPrintCoreConfiguration(BaseModel):
|
||||
"""Class representing a cloud cluster printer configuration
|
||||
|
||||
Also used for representing slots in a Material Station (as from Cura's perspective these are the same).
|
||||
"""
|
||||
|
||||
def __init__(self, extruder_index: int, material: Union[None, Dict[str, Any],
|
||||
ClusterPrinterConfigurationMaterial] = None, print_core_id: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new cloud cluster printer configuration object
|
||||
|
||||
:param extruder_index: The position of the extruder on the machine as list index. Numbered from left to right.
|
||||
:param material: The material of a configuration object in a cluster printer. May be in a dict or an object.
|
||||
:param nozzle_diameter: The diameter of the print core at this position in millimeters, e.g. '0.4'.
|
||||
:param print_core_id: The type of print core inserted at this position, e.g. 'AA 0.4'.
|
||||
"""
|
||||
|
||||
## Creates a new cloud cluster printer configuration object
|
||||
# \param extruder_index: The position of the extruder on the machine as list index. Numbered from left to right.
|
||||
# \param material: The material of a configuration object in a cluster printer. May be in a dict or an object.
|
||||
# \param nozzle_diameter: The diameter of the print core at this position in millimeters, e.g. '0.4'.
|
||||
# \param print_core_id: The type of print core inserted at this position, e.g. 'AA 0.4'.
|
||||
def __init__(self, extruder_index: int,
|
||||
material: Union[None, Dict[str, Any], ClusterPrinterConfigurationMaterial] = None,
|
||||
print_core_id: Optional[str] = None, **kwargs) -> None:
|
||||
self.extruder_index = extruder_index
|
||||
self.material = self.parseModel(ClusterPrinterConfigurationMaterial, material) if material else None
|
||||
self.print_core_id = print_core_id
|
||||
super().__init__(**kwargs)
|
||||
|
||||
## Updates the given output model.
|
||||
# \param model - The output model to update.
|
||||
def updateOutputModel(self, model: ExtruderOutputModel) -> None:
|
||||
"""Updates the given output model.
|
||||
|
||||
:param model: The output model to update.
|
||||
"""
|
||||
|
||||
if self.print_core_id is not None:
|
||||
model.updateHotendID(self.print_core_id)
|
||||
|
||||
|
@ -40,14 +47,16 @@ class ClusterPrintCoreConfiguration(BaseModel):
|
|||
else:
|
||||
model.updateActiveMaterial(None)
|
||||
|
||||
## Creates a configuration model
|
||||
def createConfigurationModel(self) -> ExtruderConfigurationModel:
|
||||
"""Creates a configuration model"""
|
||||
|
||||
model = ExtruderConfigurationModel(position = self.extruder_index)
|
||||
self.updateConfigurationModel(model)
|
||||
return model
|
||||
|
||||
## Creates a configuration model
|
||||
def updateConfigurationModel(self, model: ExtruderConfigurationModel) -> ExtruderConfigurationModel:
|
||||
"""Creates a configuration model"""
|
||||
|
||||
model.setHotendID(self.print_core_id)
|
||||
if self.material:
|
||||
model.setMaterial(self.material.createOutputModel())
|
||||
|
|
|
@ -5,19 +5,22 @@ from typing import Optional
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Model for the types of changes that are needed before a print job can start
|
||||
class ClusterPrintJobConfigurationChange(BaseModel):
|
||||
"""Model for the types of changes that are needed before a print job can start"""
|
||||
|
||||
|
||||
def __init__(self, type_of_change: str, target_id: str, origin_id: str, index: Optional[int] = None,
|
||||
target_name: Optional[str] = None, origin_name: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
:param type_of_change: The type of configuration change, one of: "material", "print_core_change"
|
||||
:param index: The hotend slot or extruder index to change
|
||||
:param target_id: Target material guid or hotend id
|
||||
:param origin_id: Original/current material guid or hotend id
|
||||
:param target_name: Target material name or hotend id
|
||||
:param origin_name: Original/current material name or hotend id
|
||||
"""
|
||||
|
||||
## Creates a new print job constraint.
|
||||
# \param type_of_change: The type of configuration change, one of: "material", "print_core_change"
|
||||
# \param index: The hotend slot or extruder index to change
|
||||
# \param target_id: Target material guid or hotend id
|
||||
# \param origin_id: Original/current material guid or hotend id
|
||||
# \param target_name: Target material name or hotend id
|
||||
# \param origin_name: Original/current material name or hotend id
|
||||
def __init__(self, type_of_change: str, target_id: str, origin_id: str,
|
||||
index: Optional[int] = None, target_name: Optional[str] = None, origin_name: Optional[str] = None,
|
||||
**kwargs) -> None:
|
||||
self.type_of_change = type_of_change
|
||||
self.index = index
|
||||
self.target_id = target_id
|
||||
|
|
|
@ -5,12 +5,14 @@ from typing import Optional
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cloud cluster print job constraint
|
||||
class ClusterPrintJobConstraints(BaseModel):
|
||||
"""Class representing a cloud cluster print job constraint"""
|
||||
|
||||
## Creates a new print job constraint.
|
||||
# \param require_printer_name: Unique name of the printer that this job should be printed on.
|
||||
# Should be one of the unique_name field values in the cluster, e.g. 'ultimakersystem-ccbdd30044ec'
|
||||
def __init__(self, require_printer_name: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
:param require_printer_name: Unique name of the printer that this job should be printed on.
|
||||
Should be one of the unique_name field values in the cluster, e.g. 'ultimakersystem-ccbdd30044ec'
|
||||
"""
|
||||
self.require_printer_name = require_printer_name
|
||||
super().__init__(**kwargs)
|
||||
|
|
|
@ -3,14 +3,17 @@
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing the reasons that prevent this job from being printed on the associated printer
|
||||
class ClusterPrintJobImpediment(BaseModel):
|
||||
"""Class representing the reasons that prevent this job from being printed on the associated printer"""
|
||||
|
||||
## Creates a new print job constraint.
|
||||
# \param translation_key: A string indicating a reason the print cannot be printed,
|
||||
# such as 'does_not_fit_in_build_volume'
|
||||
# \param severity: A number indicating the severity of the problem, with higher being more severe
|
||||
def __init__(self, translation_key: str, severity: int, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
:param translation_key: A string indicating a reason the print cannot be printed,
|
||||
such as 'does_not_fit_in_build_volume'
|
||||
:param severity: A number indicating the severity of the problem, with higher being more severe
|
||||
"""
|
||||
|
||||
self.translation_key = translation_key
|
||||
self.severity = severity
|
||||
super().__init__(**kwargs)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -9,29 +9,35 @@ from cura.PrinterOutput.Models.MaterialOutputModel import MaterialOutputModel
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cloud cluster printer configuration
|
||||
class ClusterPrinterConfigurationMaterial(BaseModel):
|
||||
"""Class representing a cloud cluster printer configuration"""
|
||||
|
||||
## Creates a new material configuration model.
|
||||
# \param brand: The brand of material in this print core, e.g. 'Ultimaker'.
|
||||
# \param color: The color of material in this print core, e.g. 'Blue'.
|
||||
# \param guid: he GUID of the material in this print core, e.g. '506c9f0d-e3aa-4bd4-b2d2-23e2425b1aa9'.
|
||||
# \param material: The type of material in this print core, e.g. 'PLA'.
|
||||
def __init__(self, brand: Optional[str] = None, color: Optional[str] = None, guid: Optional[str] = None,
|
||||
material: Optional[str] = None, **kwargs) -> None:
|
||||
|
||||
"""Creates a new material configuration model.
|
||||
|
||||
:param brand: The brand of material in this print core, e.g. 'Ultimaker'.
|
||||
:param color: The color of material in this print core, e.g. 'Blue'.
|
||||
:param guid: he GUID of the material in this print core, e.g. '506c9f0d-e3aa-4bd4-b2d2-23e2425b1aa9'.
|
||||
:param material: The type of material in this print core, e.g. 'PLA'.
|
||||
"""
|
||||
|
||||
self.guid = guid
|
||||
self.brand = brand
|
||||
self.color = color
|
||||
self.material = material
|
||||
super().__init__(**kwargs)
|
||||
|
||||
## Creates a material output model based on this cloud printer material.
|
||||
#
|
||||
# A material is chosen that matches the current GUID. If multiple such
|
||||
# materials are available, read-only materials are preferred and the
|
||||
# material with the earliest alphabetical name will be selected.
|
||||
# \return A material output model that matches the current GUID.
|
||||
def createOutputModel(self) -> MaterialOutputModel:
|
||||
"""Creates a material output model based on this cloud printer material.
|
||||
|
||||
A material is chosen that matches the current GUID. If multiple such
|
||||
materials are available, read-only materials are preferred and the
|
||||
material with the earliest alphabetical name will be selected.
|
||||
:return: A material output model that matches the current GUID.
|
||||
"""
|
||||
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
same_guid = container_registry.findInstanceContainersMetadata(GUID = self.guid)
|
||||
if same_guid:
|
||||
|
|
|
@ -6,16 +6,19 @@ from ..BaseModel import BaseModel
|
|||
from .ClusterPrinterMaterialStationSlot import ClusterPrinterMaterialStationSlot
|
||||
|
||||
|
||||
## Class representing the data of a Material Station in the cluster.
|
||||
class ClusterPrinterMaterialStation(BaseModel):
|
||||
"""Class representing the data of a Material Station in the cluster."""
|
||||
|
||||
## Creates a new Material Station status.
|
||||
# \param status: The status of the material station.
|
||||
# \param: supported: Whether the material station is supported on this machine or not.
|
||||
# \param material_slots: The active slots configurations of this material station.
|
||||
def __init__(self, status: str, supported: bool = False,
|
||||
material_slots: List[Union[ClusterPrinterMaterialStationSlot, Dict[str, Any]]] = None,
|
||||
**kwargs) -> None:
|
||||
"""Creates a new Material Station status.
|
||||
|
||||
:param status: The status of the material station.
|
||||
:param: supported: Whether the material station is supported on this machine or not.
|
||||
:param material_slots: The active slots configurations of this material station.
|
||||
"""
|
||||
|
||||
self.status = status
|
||||
self.supported = supported
|
||||
self.material_slots = self.parseModels(ClusterPrinterMaterialStationSlot, material_slots)\
|
||||
|
|
|
@ -5,16 +5,19 @@ from typing import Optional
|
|||
from .ClusterPrintCoreConfiguration import ClusterPrintCoreConfiguration
|
||||
|
||||
|
||||
## Class representing the data of a single slot in the material station.
|
||||
class ClusterPrinterMaterialStationSlot(ClusterPrintCoreConfiguration):
|
||||
|
||||
## Create a new material station slot object.
|
||||
# \param slot_index: The index of the slot in the material station (ranging 0 to 5).
|
||||
# \param compatible: Whether the configuration is compatible with the print core.
|
||||
# \param material_remaining: How much material is remaining on the spool (between 0 and 1, or -1 for missing data).
|
||||
# \param material_empty: Whether the material spool is too empty to be used.
|
||||
"""Class representing the data of a single slot in the material station."""
|
||||
|
||||
def __init__(self, slot_index: int, compatible: bool, material_remaining: float,
|
||||
material_empty: Optional[bool] = False, **kwargs) -> None:
|
||||
"""Create a new material station slot object.
|
||||
|
||||
:param slot_index: The index of the slot in the material station (ranging 0 to 5).
|
||||
:param compatible: Whether the configuration is compatible with the print core.
|
||||
:param material_remaining: How much material is remaining on the spool (between 0 and 1, or -1 for missing data).
|
||||
:param material_empty: Whether the material spool is too empty to be used.
|
||||
"""
|
||||
|
||||
self.slot_index = slot_index
|
||||
self.compatible = compatible
|
||||
self.material_remaining = material_remaining
|
||||
|
|
|
@ -17,26 +17,10 @@ from .ClusterPrinterConfigurationMaterial import ClusterPrinterConfigurationMate
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing a cluster printer
|
||||
class ClusterPrinterStatus(BaseModel):
|
||||
"""Class representing a cluster printer"""
|
||||
|
||||
|
||||
## Creates a new cluster printer status
|
||||
# \param enabled: A printer can be disabled if it should not receive new jobs. By default every printer is enabled.
|
||||
# \param firmware_version: Firmware version installed on the printer. Can differ for each printer in a cluster.
|
||||
# \param friendly_name: Human readable name of the printer. Can be used for identification purposes.
|
||||
# \param ip_address: The IP address of the printer in the local network.
|
||||
# \param machine_variant: The type of printer. Can be 'Ultimaker 3' or 'Ultimaker 3ext'.
|
||||
# \param status: The status of the printer.
|
||||
# \param unique_name: The unique name of the printer in the network.
|
||||
# \param uuid: The unique ID of the printer, also known as GUID.
|
||||
# \param configuration: The active print core configurations of this printer.
|
||||
# \param reserved_by: A printer can be claimed by a specific print job.
|
||||
# \param maintenance_required: Indicates if maintenance is necessary.
|
||||
# \param firmware_update_status: Whether the printer's firmware is up-to-date, value is one of: "up_to_date",
|
||||
# "pending_update", "update_available", "update_in_progress", "update_failed", "update_impossible".
|
||||
# \param latest_available_firmware: The version of the latest firmware that is available.
|
||||
# \param build_plate: The build plate that is on the printer.
|
||||
# \param material_station: The material station that is on the printer.
|
||||
def __init__(self, enabled: bool, firmware_version: str, friendly_name: str, ip_address: str, machine_variant: str,
|
||||
status: str, unique_name: str, uuid: str,
|
||||
configuration: List[Union[Dict[str, Any], ClusterPrintCoreConfiguration]],
|
||||
|
@ -44,6 +28,25 @@ class ClusterPrinterStatus(BaseModel):
|
|||
firmware_update_status: Optional[str] = None, latest_available_firmware: Optional[str] = None,
|
||||
build_plate: Union[Dict[str, Any], ClusterBuildPlate] = None,
|
||||
material_station: Union[Dict[str, Any], ClusterPrinterMaterialStation] = None, **kwargs) -> None:
|
||||
"""Creates a new cluster printer status
|
||||
|
||||
:param enabled: A printer can be disabled if it should not receive new jobs. By default every printer is enabled.
|
||||
:param firmware_version: Firmware version installed on the printer. Can differ for each printer in a cluster.
|
||||
:param friendly_name: Human readable name of the printer. Can be used for identification purposes.
|
||||
:param ip_address: The IP address of the printer in the local network.
|
||||
:param machine_variant: The type of printer. Can be 'Ultimaker 3' or 'Ultimaker 3ext'.
|
||||
:param status: The status of the printer.
|
||||
:param unique_name: The unique name of the printer in the network.
|
||||
:param uuid: The unique ID of the printer, also known as GUID.
|
||||
:param configuration: The active print core configurations of this printer.
|
||||
:param reserved_by: A printer can be claimed by a specific print job.
|
||||
:param maintenance_required: Indicates if maintenance is necessary.
|
||||
:param firmware_update_status: Whether the printer's firmware is up-to-date, value is one of: "up_to_date",
|
||||
"pending_update", "update_available", "update_in_progress", "update_failed", "update_impossible".
|
||||
:param latest_available_firmware: The version of the latest firmware that is available.
|
||||
:param build_plate: The build plate that is on the printer.
|
||||
:param material_station: The material station that is on the printer.
|
||||
"""
|
||||
|
||||
self.configuration = self.parseModels(ClusterPrintCoreConfiguration, configuration)
|
||||
self.enabled = enabled
|
||||
|
@ -63,9 +66,12 @@ class ClusterPrinterStatus(BaseModel):
|
|||
material_station) if material_station else None
|
||||
super().__init__(**kwargs)
|
||||
|
||||
## Creates a new output model.
|
||||
# \param controller - The controller of the model.
|
||||
def createOutputModel(self, controller: PrinterOutputController) -> PrinterOutputModel:
|
||||
"""Creates a new output model.
|
||||
|
||||
:param controller: - The controller of the model.
|
||||
"""
|
||||
|
||||
# FIXME
|
||||
# Note that we're using '2' here as extruder count. We have hardcoded this for now to prevent issues where the
|
||||
# amount of extruders coming back from the API is actually lower (which it can be if a printer was just added
|
||||
|
@ -74,9 +80,12 @@ class ClusterPrinterStatus(BaseModel):
|
|||
self.updateOutputModel(model)
|
||||
return model
|
||||
|
||||
## Updates the given output model.
|
||||
# \param model - The output model to update.
|
||||
def updateOutputModel(self, model: PrinterOutputModel) -> None:
|
||||
"""Updates the given output model.
|
||||
|
||||
:param model: - The output model to update.
|
||||
"""
|
||||
|
||||
model.updateKey(self.uuid)
|
||||
model.updateName(self.friendly_name)
|
||||
model.updateUniqueName(self.unique_name)
|
||||
|
@ -110,9 +119,12 @@ class ClusterPrinterStatus(BaseModel):
|
|||
) for left_slot, right_slot in product(self._getSlotsForExtruder(0), self._getSlotsForExtruder(1))]
|
||||
model.setAvailableConfigurations(available_configurations)
|
||||
|
||||
## Create a list of Material Station slots for the given extruder index.
|
||||
# Returns a list with a single empty material slot if none are found to ensure we don't miss configurations.
|
||||
def _getSlotsForExtruder(self, extruder_index: int) -> List[ClusterPrinterMaterialStationSlot]:
|
||||
"""Create a list of Material Station slots for the given extruder index.
|
||||
|
||||
Returns a list with a single empty material slot if none are found to ensure we don't miss configurations.
|
||||
"""
|
||||
|
||||
if not self.material_station: # typing guard
|
||||
return []
|
||||
slots = [slot for slot in self.material_station.material_slots if self._isSupportedConfiguration(
|
||||
|
@ -121,15 +133,19 @@ class ClusterPrinterStatus(BaseModel):
|
|||
)]
|
||||
return slots or [self._createEmptyMaterialSlot(extruder_index)]
|
||||
|
||||
## Check if a configuration is supported in order to make it selectable by the user.
|
||||
# We filter out any slot that is not supported by the extruder index, print core type or if the material is empty.
|
||||
@staticmethod
|
||||
def _isSupportedConfiguration(slot: ClusterPrinterMaterialStationSlot, extruder_index: int) -> bool:
|
||||
"""Check if a configuration is supported in order to make it selectable by the user.
|
||||
|
||||
We filter out any slot that is not supported by the extruder index, print core type or if the material is empty.
|
||||
"""
|
||||
|
||||
return slot.extruder_index == extruder_index and slot.compatible and not slot.material_empty
|
||||
|
||||
## Create an empty material slot with a fake empty material.
|
||||
@staticmethod
|
||||
def _createEmptyMaterialSlot(extruder_index: int) -> ClusterPrinterMaterialStationSlot:
|
||||
"""Create an empty material slot with a fake empty material."""
|
||||
|
||||
empty_material = ClusterPrinterConfigurationMaterial(guid = "", material = "empty", brand = "", color = "")
|
||||
return ClusterPrinterMaterialStationSlot(slot_index = 0, extruder_index = extruder_index,
|
||||
compatible = True, material_remaining = 0, material = empty_material)
|
||||
|
|
|
@ -5,12 +5,11 @@ from typing import Dict, Any
|
|||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
## Class representing the system status of a printer.
|
||||
class PrinterSystemStatus(BaseModel):
|
||||
"""Class representing the system status of a printer."""
|
||||
|
||||
def __init__(self, guid: str, firmware: str, hostname: str, name: str, platform: str, variant: str,
|
||||
hardware: Dict[str, Any], **kwargs
|
||||
) -> None:
|
||||
hardware: Dict[str, Any], **kwargs) -> None:
|
||||
self.guid = guid
|
||||
self.firmware = firmware
|
||||
self.hostname = hostname
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue