Call moveHead and moveBed on the printer model

Instead of on the output device. This function was moved, which caused Cura to crash when the bed levelling procedure was called.

Contributes to issue CURA-5061.
This commit is contained in:
Ghostkeeper 2018-03-08 15:29:48 +01:00
parent 676f9b8474
commit b4cf25cb7f
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -32,14 +32,16 @@ class BedLevelMachineAction(MachineAction):
@pyqtSlot() @pyqtSlot()
def startBedLeveling(self): def startBedLeveling(self):
self._bed_level_position = 0 self._bed_level_position = 0
printer_output_devices = self._getPrinterOutputDevices() printer_output_devices = self._getPrinterOutputDevices()
if not printer_output_devices: if not printer_output_devices:
Logger.log("e", "Can't start bed levelling. The printer connection seems to have been lost.") Logger.log("e", "Can't start bed levelling. The printer connection seems to have been lost.")
return return
printer = printer_output_devices[0].activePrinter
printer_output_devices[0].homeBed() printer.homeBed()
printer_output_devices[0].moveHead(0, 0, 3) printer.moveHead(0, 0, 3)
printer_output_devices[0].homeHead() printer.homeHead()
def _getPrinterOutputDevices(self) -> List[PrinterOutputDevice]: def _getPrinterOutputDevices(self) -> List[PrinterOutputDevice]:
return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)] return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)]
@ -50,26 +52,25 @@ class BedLevelMachineAction(MachineAction):
if not output_devices: #No output devices. Can't move. if not output_devices: #No output devices. Can't move.
Logger.log("e", "Can't move to the next position. The printer connection seems to have been lost.") Logger.log("e", "Can't move to the next position. The printer connection seems to have been lost.")
return return
printer = output_devices[0].activePrinter
output_device = output_devices[0]
if self._bed_level_position == 0: if self._bed_level_position == 0:
output_device.moveHead(0, 0, 3) printer.moveHead(0, 0, 3)
output_device.homeHead() printer.homeHead()
output_device.moveHead(0, 0, 3) printer.moveHead(0, 0, 3)
output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") - 10, 0, 0) printer.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") - 10, 0, 0)
output_device.moveHead(0, 0, -3) printer.moveHead(0, 0, -3)
self._bed_level_position += 1 self._bed_level_position += 1
elif self._bed_level_position == 1: elif self._bed_level_position == 1:
output_device.moveHead(0, 0, 3) printer.moveHead(0, 0, 3)
output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value" ) / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") - 10, 0) printer.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value" ) / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") - 10, 0)
output_device.moveHead(0, 0, -3) printer.moveHead(0, 0, -3)
self._bed_level_position += 1 self._bed_level_position += 1
elif self._bed_level_position == 2: elif self._bed_level_position == 2:
output_device.moveHead(0, 0, 3) printer.moveHead(0, 0, 3)
output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") + 10), 0) printer.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") + 10), 0)
output_device.moveHead(0, 0, -3) printer.moveHead(0, 0, -3)
self._bed_level_position += 1 self._bed_level_position += 1
elif self._bed_level_position >= 3: elif self._bed_level_position >= 3:
output_device.sendCommand("M18") # Turn off all motors so the user can move the axes output_devices[0].sendCommand("M18") # Turn off all motors so the user can move the axes
self.setFinished() self.setFinished()