From 6bf91d2b3a2ea71c7bbf6869057ad5616280df97 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 14 Sep 2018 13:59:05 +0200 Subject: [PATCH 1/4] Fix updating temperature while preheating bed or extruder While preheating the bed/extruder with M190 or M109, the firmware keeps outputting temperature lines, but these do not contain "ok" because no new command was acknowledged. Fixes #3741 --- plugins/USBPrinting/USBPrinterOutputDevice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 4ceda52875..39b358224c 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -313,6 +313,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): while self._connection_state == ConnectionState.connected and self._serial is not None: try: line = self._serial.readline() + print(line) except: continue @@ -326,8 +327,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if self._firmware_name is None: self.sendCommand("M115") - if (b"ok " in line and b"T:" in line) or line.startswith(b"T:") or b"ok B:" in line or line.startswith(b"B:"): # Temperature message. 'T:' for extruder and 'B:' for bed - extruder_temperature_matches = re.findall(b"T(\d*): ?([\d\.]+) ?\/?([\d\.]+)?", line) + if re.search(b"[B|T\d*]: ?\d+\.?\d*", line): # Temperature message. 'T:' for extruder and 'B:' for bed + extruder_temperature_matches = re.findall(b"T(\d*): ?(\d+\.?\d*) ?\/?(\d+\.?\d*)?", line) # Update all temperature values matched_extruder_nrs = [] for match in extruder_temperature_matches: @@ -349,7 +350,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if match[2]: extruder.updateTargetHotendTemperature(float(match[2])) - bed_temperature_matches = re.findall(b"B: ?([\d\.]+) ?\/?([\d\.]+)?", line) + bed_temperature_matches = re.findall(b"B: ?(\d+\.?\d*) ?\/?(\d+\.?\d*) ?", line) if bed_temperature_matches: match = bed_temperature_matches[0] if match[0]: From 9c865e80d113438699c34cee724d0c9945f7b8db Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 14 Sep 2018 19:15:23 +0200 Subject: [PATCH 2/4] Remove debug print --- plugins/USBPrinting/USBPrinterOutputDevice.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 39b358224c..36c5321180 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -313,7 +313,6 @@ class USBPrinterOutputDevice(PrinterOutputDevice): while self._connection_state == ConnectionState.connected and self._serial is not None: try: line = self._serial.readline() - print(line) except: continue From 6db1342255493c264694074fc3dc7f423038e840 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 3 Oct 2018 10:44:20 +0200 Subject: [PATCH 3/4] Fix the layer view when there is a print job with only one layer. Contributes to CURA-5789. --- plugins/SimulationView/LayerSlider.qml | 10 ++++++++++ plugins/SimulationView/SimulationView.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/SimulationView/LayerSlider.qml b/plugins/SimulationView/LayerSlider.qml index 841472a836..1552506969 100644 --- a/plugins/SimulationView/LayerSlider.qml +++ b/plugins/SimulationView/LayerSlider.qml @@ -234,6 +234,11 @@ Item UM.SimulationView.setCurrentLayer(value) var diff = (value - sliderRoot.maximumValue) / (sliderRoot.minimumValue - sliderRoot.maximumValue) + // In case there is only one layer, the diff value results in a NaN, so this is for catching this specific case + if (isNaN(diff)) + { + diff = 0 + } var newUpperYPosition = Math.round(diff * (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize))) y = newUpperYPosition @@ -339,6 +344,11 @@ Item UM.SimulationView.setMinimumLayer(value) var diff = (value - sliderRoot.maximumValue) / (sliderRoot.minimumValue - sliderRoot.maximumValue) + // In case there is only one layer, the diff value results in a NaN, so this is for catching this specific case + if (isNaN(diff)) + { + diff = 0 + } var newLowerYPosition = Math.round((sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize) + diff * (sliderRoot.height - (2 * sliderRoot.handleSize + sliderRoot.minimumRangeHandleSize))) y = newLowerYPosition diff --git a/plugins/SimulationView/SimulationView.py b/plugins/SimulationView/SimulationView.py index 44643dbf1c..5b369c26d2 100644 --- a/plugins/SimulationView/SimulationView.py +++ b/plugins/SimulationView/SimulationView.py @@ -334,7 +334,7 @@ class SimulationView(View): self._old_max_layers = self._max_layers ## Recalculate num max layers - new_max_layers = 0 + new_max_layers = -1 for node in DepthFirstIterator(scene.getRoot()): layer_data = node.callDecoration("getLayerData") if not layer_data: @@ -369,7 +369,7 @@ class SimulationView(View): if new_max_layers < layer_count: new_max_layers = layer_count - if new_max_layers > 0 and new_max_layers != self._old_max_layers: + if new_max_layers >= 0 and new_max_layers != self._old_max_layers: self._max_layers = new_max_layers # The qt slider has a bit of weird behavior that if the maxvalue needs to be changed first From c3e7e426ffc4bbe44081f05f1289c01785540a4a Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 3 Oct 2018 11:21:03 +0200 Subject: [PATCH 4/4] Fix getDefaultVariantNode for UM2 CURA-5790 UM2 has optional variant which depends on whether Olsson Block is enabled. getDefaultVariantNode() should take that into account. --- cura/Machines/VariantManager.py | 17 ++++++++++++----- cura/Settings/CuraStackBuilder.py | 3 ++- resources/definitions/ultimaker2.def.json | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cura/Machines/VariantManager.py b/cura/Machines/VariantManager.py index 969fed670e..0d497de51e 100644 --- a/cura/Machines/VariantManager.py +++ b/cura/Machines/VariantManager.py @@ -115,17 +115,24 @@ class VariantManager: # # Gets the default variant for the given machine definition. + # If the optional GlobalStack is given, the metadata information will be fetched from the GlobalStack instead of + # the DefinitionContainer. Because for machines such as UM2, you can enable Olsson Block, which will set + # "has_variants" to True in the GlobalStack. In those cases, we need to fetch metadata from the GlobalStack or + # it may not be correct. # def getDefaultVariantNode(self, machine_definition: "DefinitionContainer", - variant_type: VariantType) -> Optional["ContainerNode"]: + variant_type: "VariantType", + global_stack: Optional["GlobalStack"] = None) -> Optional["ContainerNode"]: machine_definition_id = machine_definition.getId() + container_for_metadata_fetching = global_stack if global_stack is not None else machine_definition + preferred_variant_name = None if variant_type == VariantType.BUILD_PLATE: - if parseBool(machine_definition.getMetaDataEntry("has_variant_buildplates", False)): - preferred_variant_name = machine_definition.getMetaDataEntry("preferred_variant_buildplate_name") + if parseBool(container_for_metadata_fetching.getMetaDataEntry("has_variant_buildplates", False)): + preferred_variant_name = container_for_metadata_fetching.getMetaDataEntry("preferred_variant_buildplate_name") else: - if parseBool(machine_definition.getMetaDataEntry("has_variants", False)): - preferred_variant_name = machine_definition.getMetaDataEntry("preferred_variant_name") + if parseBool(container_for_metadata_fetching.getMetaDataEntry("has_variants", False)): + preferred_variant_name = container_for_metadata_fetching.getMetaDataEntry("preferred_variant_name") node = None if preferred_variant_name: diff --git a/cura/Settings/CuraStackBuilder.py b/cura/Settings/CuraStackBuilder.py index 6374e6056c..58109d3a8d 100644 --- a/cura/Settings/CuraStackBuilder.py +++ b/cura/Settings/CuraStackBuilder.py @@ -114,7 +114,8 @@ class CuraStackBuilder: # get variant container for extruders extruder_variant_container = application.empty_variant_container - extruder_variant_node = variant_manager.getDefaultVariantNode(global_stack.definition, VariantType.NOZZLE) + extruder_variant_node = variant_manager.getDefaultVariantNode(global_stack.definition, VariantType.NOZZLE, + global_stack = global_stack) extruder_variant_name = None if extruder_variant_node: extruder_variant_container = extruder_variant_node.getContainer() diff --git a/resources/definitions/ultimaker2.def.json b/resources/definitions/ultimaker2.def.json index aa684946c2..a91d2332b0 100644 --- a/resources/definitions/ultimaker2.def.json +++ b/resources/definitions/ultimaker2.def.json @@ -14,6 +14,7 @@ "platform_offset": [9, 0, 0], "has_materials": false, "has_machine_quality": true, + "preferred_variant_name": "0.4 mm", "exclude_materials": ["generic_hips", "generic_petg", "generic_bam", "ultimaker_bam", "generic_pva", "ultimaker_pva", "generic_tough_pla", "ultimaker_tough_pla_black", "ultimaker_tough_pla_green", "ultimaker_tough_pla_red", "ultimaker_tough_pla_white"], "first_start_actions": ["UM2UpgradeSelection"], "supported_actions":["UM2UpgradeSelection", "UpgradeFirmware"],