Beispiel #1
0
    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)
        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")
        model.setCameraUrl(
            QUrl("http://{}:8080/?action=stream".format(self.ip_address)))

        if not model.printerConfiguration:
            # Prevent accessing printer configuration when not available.
            # This sometimes happens when a printer was just added to a group and Cura is connected to that group.
            return

        # Set the possible configurations based on whether a Material Station is present or not.
        if self.material_station and self.material_station.material_slots:
            self._updateAvailableConfigurations(model)
        if self.configuration:
            self._updateActiveConfiguration(model)
    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)
    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)
    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")
        model.setCameraUrl(QUrl("http://{}:8080/?action=stream".format(self.ip_address)))

        for configuration, extruder_output, extruder_config in \
                zip(self.configuration, model.extruders, model.printerConfiguration.extruderConfigurations):
            configuration.updateOutputModel(extruder_output)
            configuration.updateConfigurationModel(extruder_config)
Beispiel #5
0
 def _build_printer_output_model(self) -> PrinterOutputModel:
     """Returns printer Output Model for this device."""
     printer_output_model = PrinterOutputModel(
         output_controller=self._printer_output_controller,
         number_of_extruders=_NUM_EXTRUDERS)
     printer_output_model.updateKey(self._address)
     printer_output_model.updateName(self.address)
     printer_output_model.updateState('idle')
     printer_output_model.setAvailableConfigurations(
         [_build_printer_conf_model()])
     printer_output_model.updateType('Monoprice Select Mini')
     printer_output_model.updateActivePrintJob(self._print_job_model)
     return printer_output_model
Beispiel #6
0
    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"])

        if data["status"] != "unreachable":
            self._application.getDiscoveredPrintersModel(
            ).updateDiscoveredPrinter(data["ip_address"],
                                      name=data["friendly_name"],
                                      machine_type=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.updateBuildplate(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"]:
                material = self._createMaterialOutputModel(material_data)
                extruder.updateActiveMaterial(material)
Beispiel #7
0
    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")
        model.setCameraUrl(
            QUrl("http://{}:8080/?action=stream".format(self.ip_address)))

        # Set the possible configurations based on whether a Material Station is present or not.
        if self.material_station and self.material_station.material_slots:
            self._updateAvailableConfigurations(model)
        if self.configuration:
            self._updateActiveConfiguration(model)
    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"])

        if data["status"] != "unreachable":
            self._application.getDiscoveredPrintersModel().updateDiscoveredPrinter(data["ip_address"],
                                                                               name = data["friendly_name"],
                                                                               machine_type = 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.updateBuildplate(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"]:
                material = self._createMaterialOutputModel(material_data)
                extruder.updateActiveMaterial(material)