Browse Source

Starting UMOCheckup before connection was established now works correctly

CURA-1385
Jaime van Kessel 8 years ago
parent
commit
b14ae94190
1 changed files with 15 additions and 0 deletions
  1. 15 0
      plugins/UltimakerMachineActions/UMOCheckupMachineAction.py

+ 15 - 0
plugins/UltimakerMachineActions/UMOCheckupMachineAction.py

@@ -18,6 +18,11 @@ class UMOCheckupMachineAction(MachineAction):
         self._y_min_endstop_test_completed = False
         self._z_min_endstop_test_completed = False
 
+        self._check_started = False
+
+        Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged)
+
+
     onBedTestCompleted = pyqtSignal()
     onHotendTestCompleted = pyqtSignal()
 
@@ -28,6 +33,13 @@ class UMOCheckupMachineAction(MachineAction):
     bedTemperatureChanged = pyqtSignal()
     hotendTemperatureChanged = pyqtSignal()
 
+    def _onOutputDevicesChanged(self):
+        # Check if this action was started, but no output device was found the first time.
+        # If so, re-try now that an output device has been added/removed.
+        if self._output_device is None and self._check_started:
+            self.startCheck()
+
+
     def _getPrinterOutputDevices(self):
         return [printer_output_device for printer_output_device in
                 Application.getInstance().getOutputDeviceManager().getOutputDevices() if
@@ -46,6 +58,8 @@ class UMOCheckupMachineAction(MachineAction):
                 pass
         self._output_device = None
 
+        self._check_started = False
+
         # Ensure everything is reset (and right signals are emitted again)
         self._bed_test_completed = False
         self.onBedTestCompleted.emit()
@@ -121,6 +135,7 @@ class UMOCheckupMachineAction(MachineAction):
 
     @pyqtSlot()
     def startCheck(self):
+        self._check_started = True
         output_devices = self._getPrinterOutputDevices()
         if output_devices:
             self._output_device = output_devices[0]