|
24 | 24 |
|
25 | 25 | from PySide6.QtCore import QCoreApplication, Signal
|
26 | 26 | from PySide6.QtWidgets import QDockWidget
|
| 27 | +from wakepy import keep |
27 | 28 |
|
28 | 29 | from .. import utils
|
29 | 30 | from ..machine import Machine
|
@@ -172,33 +173,34 @@ def run(self, operation: Operation) -> None:
|
172 | 173 | self.config.portname = self.__read_portname()
|
173 | 174 | self.control.start(self.pattern, self.memos, self.config, operation)
|
174 | 175 |
|
175 |
| - while True: |
176 |
| - # continue operating |
177 |
| - # typically each step involves some communication with the device |
178 |
| - output = self.control.operate(operation) |
179 |
| - if output != self.control.notification: |
180 |
| - self.__feedback.handle(output) |
181 |
| - self.control.notification = output |
182 |
| - if operation == Operation.KNIT: |
183 |
| - self.__handle_status() |
184 |
| - if self.__canceled or self.control.state == State.FINISHED: |
185 |
| - break |
186 |
| - |
187 |
| - self.control.stop() |
| 176 | + with keep.presenting(on_fail="pass"): |
| 177 | + while True: |
| 178 | + # continue operating |
| 179 | + # typically each step involves some communication with the device |
| 180 | + output = self.control.operate(operation) |
| 181 | + if output != self.control.notification: |
| 182 | + self.__feedback.handle(output) |
| 183 | + self.control.notification = output |
| 184 | + if operation == Operation.KNIT: |
| 185 | + self.__handle_status() |
| 186 | + if self.__canceled or self.control.state == State.FINISHED: |
| 187 | + break |
| 188 | + |
| 189 | + self.control.stop() |
188 | 190 |
|
189 |
| - if operation == Operation.KNIT: |
190 |
| - if self.__canceled: |
191 |
| - self.emit_notification("Knitting canceled.") |
192 |
| - self.__logger.info("Knitting canceled.") |
| 191 | + if operation == Operation.KNIT: |
| 192 | + if self.__canceled: |
| 193 | + self.emit_notification("Knitting canceled.") |
| 194 | + self.__logger.info("Knitting canceled.") |
| 195 | + else: |
| 196 | + # operation == Operation.TEST: |
| 197 | + self.__logger.info("Finished knitting.") |
193 | 198 | else:
|
194 |
| - # operation == Operation.TEST: |
195 |
| - self.__logger.info("Finished knitting.") |
196 |
| - else: |
197 |
| - # TODO: provide translations for these messages |
198 |
| - self.__logger.info("Finished testing.") |
199 |
| - |
200 |
| - # send signal to finish operation |
201 |
| - self.emit_operation_finisher(operation) |
| 199 | + # TODO: provide translations for these messages |
| 200 | + self.__logger.info("Finished testing.") |
| 201 | + |
| 202 | + # send signal to finish operation |
| 203 | + self.emit_operation_finisher(operation) |
202 | 204 |
|
203 | 205 | def __handle_status(self) -> None:
|
204 | 206 | if self.status.active:
|
|
0 commit comments