Restarting machine check properly re-enables endstop check

CURA-1385
This commit is contained in:
Jaime van Kessel 2016-07-07 13:43:45 +02:00
parent 2ba2599d6b
commit 3d1bbeca38
2 changed files with 8 additions and 5 deletions

View file

@ -37,9 +37,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._connect_thread = threading.Thread(target = self._connect) self._connect_thread = threading.Thread(target = self._connect)
self._connect_thread.daemon = True self._connect_thread.daemon = True
self._end_stop_thread = threading.Thread(target = self._pollEndStop) self._end_stop_thread = None
self._end_stop_thread.daemon = True self._poll_endstop = False
self._poll_endstop = -1
# The baud checking is done by sending a number of m105 commands to the printer and waiting for a readable # The baud checking is done by sending a number of m105 commands to the printer and waiting for a readable
# response. If the baudrate is correct, this should make sense, else we get giberish. # response. If the baudrate is correct, this should make sense, else we get giberish.
@ -221,13 +220,17 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
@pyqtSlot() @pyqtSlot()
def startPollEndstop(self): def startPollEndstop(self):
if self._poll_endstop == -1: if not self._poll_endstop:
self._poll_endstop = True self._poll_endstop = True
if self._end_stop_thread is None:
self._end_stop_thread = threading.Thread(target=self._pollEndStop)
self._end_stop_thread.daemon = True
self._end_stop_thread.start() self._end_stop_thread.start()
@pyqtSlot() @pyqtSlot()
def stopPollEndstop(self): def stopPollEndstop(self):
self._poll_endstop = False self._poll_endstop = False
self._end_stop_thread = None
def _pollEndStop(self): def _pollEndStop(self):
while self._connection_state == ConnectionState.connected and self._poll_endstop: while self._connection_state == ConnectionState.connected and self._poll_endstop:

View file

@ -157,7 +157,7 @@ class UMOCheckupMachineAction(MachineAction):
self._output_device.bedTemperatureChanged.connect(self._onBedTemperatureChanged) self._output_device.bedTemperatureChanged.connect(self._onBedTemperatureChanged)
self._output_device.hotendTemperaturesChanged.connect(self._onHotendTemperatureChanged) self._output_device.hotendTemperaturesChanged.connect(self._onHotendTemperatureChanged)
self._output_device.endstopStateChanged.connect(self._onEndstopStateChanged) self._output_device.endstopStateChanged.connect(self._onEndstopStateChanged)
except AttributeError: # Connection is probably not a USB connection. Something went pretty wrong if this happens. except AttributeError as e: # Connection is probably not a USB connection. Something went pretty wrong if this happens.
pass pass
@pyqtSlot() @pyqtSlot()