forked from robotpy/robotpy-commands-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedulecommand.py
30 lines (22 loc) · 908 Bytes
/
schedulecommand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations
from .command import Command
from .commandgroup import *
class ScheduleCommand(Command):
"""
Schedules the given commands when this command is initialized. Useful for forking off from
CommandGroups. Note that if run from a composition, the composition will not know about the
status of the scheduled commands, and will treat this command as finishing instantly.
"""
def __init__(self, *commands: Command):
"""
Creates a new ScheduleCommand that schedules the given commands when initialized.
:param toSchedule: the commands to schedule"""
super().__init__()
self.toSchedule = set(commands)
def initialize(self):
for command in self.toSchedule:
command.schedule()
def isFinished(self) -> bool:
return True
def runsWhenDisabled(self) -> bool:
return True