def updateOutputModel(self, model: PrinterOutputModel) -> None: model.updateKey(self.uuid) model.updateName(self.friendly_name) model.updateType(self.machine_variant) model.updateState(self.status if self.enabled else "disabled") for configuration, extruder_output, extruder_config in \ zip(self.configuration, model.extruders, model.printerConfiguration.extruderConfigurations): configuration.updateOutputModel(extruder_output) configuration.updateConfigurationModel(extruder_config)
def _updatePrinter(self, printer: PrinterOutputModel, data: Dict[str, Any]) -> None: # For some unknown reason the cluster wants UUID for everything, except for sending a job directly to a printer. # Then we suddenly need the unique name. So in order to not have to mess up all the other code, we save a mapping. self._printer_uuid_to_unique_name_mapping[data["uuid"]] = data["unique_name"] definitions = ContainerRegistry.getInstance().findDefinitionContainers(name = data["machine_variant"]) if not definitions: Logger.log("w", "Unable to find definition for machine variant %s", data["machine_variant"]) return machine_definition = definitions[0] printer.updateName(data["friendly_name"]) printer.updateKey(data["uuid"]) printer.updateType(data["machine_variant"]) # Do not store the build plate information that comes from connect if the current printer has not build plate information if "build_plate" in data and machine_definition.getMetaDataEntry("has_variant_buildplates", False): printer.updateBuildplateName(data["build_plate"]["type"]) if not data["enabled"]: printer.updateState("disabled") else: printer.updateState(data["status"]) for index in range(0, self._number_of_extruders): extruder = printer.extruders[index] try: extruder_data = data["configuration"][index] except IndexError: break extruder.updateHotendID(extruder_data.get("print_core_id", "")) material_data = extruder_data["material"] if extruder.activeMaterial is None or extruder.activeMaterial.guid != material_data["guid"]: containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"]) if containers: color = containers[0].getMetaDataEntry("color_code") brand = containers[0].getMetaDataEntry("brand") material_type = containers[0].getMetaDataEntry("material") name = containers[0].getName() else: Logger.log("w", "Unable to find material with guid {guid}. Using data as provided by cluster".format( guid=material_data["guid"])) color = material_data["color"] brand = material_data["brand"] material_type = material_data["material"] name = "Empty" if material_data["material"] == "empty" else "Unknown" material = MaterialOutputModel(guid=material_data["guid"], type=material_type, brand=brand, color=color, name=name) extruder.updateActiveMaterial(material)
def _updatePrinter(self, printer: PrinterOutputModel, data: Dict) -> None: # For some unknown reason the cluster wants UUID for everything, except for sending a job directly to a printer. # Then we suddenly need the unique name. So in order to not have to mess up all the other code, we save a mapping. self._printer_uuid_to_unique_name_mapping[data["uuid"]] = data["unique_name"] definitions = ContainerRegistry.getInstance().findDefinitionContainers(name = data["machine_variant"]) if not definitions: Logger.log("w", "Unable to find definition for machine variant %s", data["machine_variant"]) return machine_definition = definitions[0] printer.updateName(data["friendly_name"]) printer.updateKey(data["uuid"]) printer.updateType(data["machine_variant"]) # Do not store the buildplate information that comes from connect if the current printer has not buildplate information if "build_plate" in data and machine_definition.getMetaDataEntry("has_variant_buildplates", False): printer.updateBuildplateName(data["build_plate"]["type"]) if not data["enabled"]: printer.updateState("disabled") else: printer.updateState(data["status"]) for index in range(0, self._number_of_extruders): extruder = printer.extruders[index] try: extruder_data = data["configuration"][index] except IndexError: break extruder.updateHotendID(extruder_data.get("print_core_id", "")) material_data = extruder_data["material"] if extruder.activeMaterial is None or extruder.activeMaterial.guid != material_data["guid"]: containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"]) if containers: color = containers[0].getMetaDataEntry("color_code") brand = containers[0].getMetaDataEntry("brand") material_type = containers[0].getMetaDataEntry("material") name = containers[0].getName() else: Logger.log("w", "Unable to find material with guid {guid}. Using data as provided by cluster".format( guid=material_data["guid"])) color = material_data["color"] brand = material_data["brand"] material_type = material_data["material"] name = "Empty" if material_data["material"] == "empty" else "Unknown" material = MaterialOutputModel(guid=material_data["guid"], type=material_type, brand=brand, color=color, name=name) extruder.updateActiveMaterial(material)
def updateOutputModel(self, model: PrinterOutputModel) -> None: model.updateKey(self.uuid) model.updateName(self.friendly_name) model.updateType(self.machine_variant) model.updateState(self.status if self.enabled else "disabled") model.updateBuildplate(self.build_plate.type if self.build_plate else "glass") for configuration, extruder_output, extruder_config in \ zip(self.configuration, model.extruders, model.printerConfiguration.extruderConfigurations): configuration.updateOutputModel(extruder_output) configuration.updateConfigurationModel(extruder_config)