|
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
|
@@ -168,33 +169,34 @@ def run(self, operation: Operation) -> None:
|
168 | 169 | self.config.portname = self.__read_portname()
|
169 | 170 | self.control.start(self.pattern, self.config, operation)
|
170 | 171 |
|
171 |
| - while True: |
172 |
| - # continue operating |
173 |
| - # typically each step involves some communication with the device |
174 |
| - output = self.control.operate(operation) |
175 |
| - if output != self.control.notification: |
176 |
| - self.__feedback.handle(output) |
177 |
| - self.control.notification = output |
178 |
| - if operation == Operation.KNIT: |
179 |
| - self.__handle_status() |
180 |
| - if self.__canceled or self.control.state == State.FINISHED: |
181 |
| - break |
182 |
| - |
183 |
| - self.control.stop() |
| 172 | + with keep.presenting(on_fail="pass"): |
| 173 | + while True: |
| 174 | + # continue operating |
| 175 | + # typically each step involves some communication with the device |
| 176 | + output = self.control.operate(operation) |
| 177 | + if output != self.control.notification: |
| 178 | + self.__feedback.handle(output) |
| 179 | + self.control.notification = output |
| 180 | + if operation == Operation.KNIT: |
| 181 | + self.__handle_status() |
| 182 | + if self.__canceled or self.control.state == State.FINISHED: |
| 183 | + break |
| 184 | + |
| 185 | + self.control.stop() |
184 | 186 |
|
185 |
| - if operation == Operation.KNIT: |
186 |
| - if self.__canceled: |
187 |
| - self.emit_notification("Knitting canceled.") |
188 |
| - self.__logger.info("Knitting canceled.") |
| 187 | + if operation == Operation.KNIT: |
| 188 | + if self.__canceled: |
| 189 | + self.emit_notification("Knitting canceled.") |
| 190 | + self.__logger.info("Knitting canceled.") |
| 191 | + else: |
| 192 | + # operation == Operation.TEST: |
| 193 | + self.__logger.info("Finished knitting.") |
189 | 194 | else:
|
190 |
| - # operation == Operation.TEST: |
191 |
| - self.__logger.info("Finished knitting.") |
192 |
| - else: |
193 |
| - # TODO: provide translations for these messages |
194 |
| - self.__logger.info("Finished testing.") |
195 |
| - |
196 |
| - # send signal to finish operation |
197 |
| - self.emit_operation_finisher(operation) |
| 195 | + # TODO: provide translations for these messages |
| 196 | + self.__logger.info("Finished testing.") |
| 197 | + |
| 198 | + # send signal to finish operation |
| 199 | + self.emit_operation_finisher(operation) |
198 | 200 |
|
199 | 201 | def __handle_status(self) -> None:
|
200 | 202 | if self.status.active:
|
|
0 commit comments