Merge remote-tracking branch 'origin/master' into feature_intent

This commit is contained in:
Lipu Fei 2019-10-02 12:52:37 +02:00
commit 750632ec41
5 changed files with 25 additions and 18 deletions

View file

@ -124,11 +124,11 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
def matchesNetworkKey(self, network_key: str) -> bool:
# Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local."
# the host name should then be "ultimakersystem-aabbccdd0011"
if network_key.startswith(self.clusterData.host_name):
if network_key.startswith(str(self.clusterData.host_name or "")):
return True
# However, for manually added printers, the local IP address is used in lieu of a proper
# network key, so check for that as well
if self.clusterData.host_internal_ip is not None and network_key in self.clusterData.host_internal_ip:
# network key, so check for that as well. It is in the format "manual:10.1.10.1".
if network_key.endswith(str(self.clusterData.host_internal_ip or "")):
return True
return False

View file

@ -9,6 +9,7 @@ from UM.Logger import Logger # To log errors talking to the API.
from UM.Signal import Signal
from cura.API import Account
from cura.CuraApplication import CuraApplication
from cura.Settings.CuraStackBuilder import CuraStackBuilder
from cura.Settings.GlobalStack import GlobalStack
from .CloudApiClient import CloudApiClient
@ -140,14 +141,15 @@ class CloudOutputDeviceManager:
if not device:
return
# The newly added machine is automatically activated.
machine_manager = CuraApplication.getInstance().getMachineManager()
machine_manager.addMachine(device.printerType, device.clusterData.friendly_name)
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
if not active_machine:
# Create a new machine and activate it.
# We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it.
new_machine = CuraStackBuilder.createMachine(device.name, device.printerType)
if not new_machine:
Logger.log("e", "Failed creating a new machine")
return
active_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
self._connectToOutputDevice(device, active_machine)
new_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId())
self._connectToOutputDevice(device, new_machine)
## Callback for when the active machine was changed by the user or a new remote cluster was found.
def _connectToActiveMachine(self) -> None:

View file

@ -9,6 +9,7 @@ from UM.Signal import Signal
from UM.Version import Version
from cura.CuraApplication import CuraApplication
from cura.Settings.CuraStackBuilder import CuraStackBuilder
from cura.Settings.GlobalStack import GlobalStack
from .ZeroConfClient import ZeroConfClient
@ -203,12 +204,16 @@ class LocalClusterOutputDeviceManager:
if device is None:
return
# The newly added machine is automatically activated.
CuraApplication.getInstance().getMachineManager().addMachine(device.printerType, device.name)
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
if not active_machine:
# Create a new machine and activate it.
# We do not use use MachineManager.addMachine here because we need to set the network key before activating it.
# If we do not do this the auto-pairing with the cloud-equivalent device will not work.
new_machine = CuraStackBuilder.createMachine(device.name, device.printerType)
if not new_machine:
Logger.log("e", "Failed creating a new machine")
return
self._connectToOutputDevice(device, active_machine)
new_machine.setMetaDataEntry(self.META_NETWORK_KEY, device.key)
CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId())
self._connectToOutputDevice(device, new_machine)
self._showCloudFlowMessage(device)
## Add an address to the stored preferences.

View file

@ -54,7 +54,7 @@
},
"machine_start_gcode":
{
"default_value": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15.0 F{speed_travel} ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E3 ;extrude 3mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F{speed_travel}\nM117 Printing...\nG5"
"default_value": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15.0 F{speed_travel} ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E3 ;extrude 3mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F{speed_travel}\nG0 Y20 F{speed_travel}\nM117 Printing...\nG5"
},
"machine_end_gcode":
{

View file

@ -1440,7 +1440,7 @@
"unit": "mm",
"type": "float",
"default_value": 100.0,
"value": "0 if (z_seam_position == 'frontleft' or z_seam_position == 'left' or z_seam_position == 'backleft') else machine_width/2 if (z_seam_position == 'front' or z_seam_position == 'back') else machine_width",
"value": "(0 if (z_seam_position == 'frontleft' or z_seam_position == 'left' or z_seam_position == 'backleft') else machine_width / 2 if (z_seam_position == 'front' or z_seam_position == 'back') else machine_width) - (machine_width / 2 if z_seam_relative or machine_center_is_zero else 0)",
"enabled": "z_seam_type == 'back'",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true
@ -1452,7 +1452,7 @@
"unit": "mm",
"type": "float",
"default_value": 100.0,
"value": "0 if (z_seam_position == 'frontleft' or z_seam_position == 'front' or z_seam_position == 'frontright') else machine_depth/2 if (z_seam_position == 'left' or z_seam_position == 'right') else machine_depth",
"value": "(0 if (z_seam_position == 'frontleft' or z_seam_position == 'front' or z_seam_position == 'frontright') else machine_depth / 2 if (z_seam_position == 'left' or z_seam_position == 'right') else machine_depth) - (machine_depth / 2 if z_seam_relative or machine_center_is_zero else 0)",
"enabled": "z_seam_type == 'back'",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true