Notifications
Clear all
Python
1
Posts
1
Users
0
Reactions
1,540
Views
Topic starter
2023-08-26 7:28 am
this is just one example of cron job classes in the livingrimoire auxiliary modules
class TrgEveryNMinutes(TrGEV3):
# trigger returns true every minutes interval, post start time
def __init__(self, startTime: str, minutes: int):
self._playGround: PlayGround = PlayGround()
self._minutes:int = minutes # minute interval between triggerings
self._timeStamp = startTime
self._trgTime: TrgTime = TrgTime()
self._trgTime.setTime(startTime)
def setMinutes(self, minutes: int):
if minutes > -1:
self._minutes = minutes
# override
def trigger(self) -> bool:
if self._trgTime.alarm():
self._timeStamp = self._playGround.getFutureInXMin(self._minutes)
self._trgTime.setTime(self._timeStamp)
return True
return False
# override
def reset(self):
self._timeStamp = self._playGround.getCurrentTimeStamp()
main advantage is it works cross platforms, and no need to run a pip install.
example use would be like in gatebox where the AI anticipates the user and checks up on him (see more advanced Cron class)
Team Fuki