Skip to content

Commit edc1fe9

Browse files
mathPidl1com
authored andcommitted
feat: keep the computer awake while knitting #698
1 parent fcab410 commit edc1fe9

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

requirements.build.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ bitarray==2.9.2
99
simpleaudio-patched==1.0.5
1010
numpy==1.26.4
1111
charset-normalizer<3.0.0
12-
semver==3.0.2
12+
semver==3.0.2
13+
wakepy==0.10.1

src/main/python/main/ayab/engine/engine.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from PySide6.QtCore import QCoreApplication, Signal
2626
from PySide6.QtWidgets import QDockWidget
27+
from wakepy import keep
2728

2829
from .. import utils
2930
from ..machine import Machine
@@ -168,33 +169,34 @@ def run(self, operation: Operation) -> None:
168169
self.config.portname = self.__read_portname()
169170
self.control.start(self.pattern, self.config, operation)
170171

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()
184186

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.")
189194
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)
198200

199201
def __handle_status(self) -> None:
200202
if self.status.active:

0 commit comments

Comments
 (0)