File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 1
- from wpilib .command import InstantCommand
1
+ from wpilib .command import Command
2
2
3
- class CancelCommand (InstantCommand ):
3
+
4
+ def checkIfCanceled (self ):
5
+ if self .forceCancel :
6
+ self .forceCancel = False
7
+ return True
8
+
9
+ return self ._isFinished ()
10
+
11
+
12
+ class CancelCommand (Command ):
4
13
'''
5
14
When this command is run, it cancels the command it was passed, even if that
6
15
command is part of a :class:`wpilib.CommandGroup`.
@@ -14,7 +23,18 @@ def __init__(self, command):
14
23
super ().__init__ ('Cancel %s' % command )
15
24
16
25
self .command = command
26
+ if hasattr (self .command , '_isFinished' ):
27
+ return
28
+
29
+ self .command ._isFinished = self .command .isFinished
30
+ self .command .isFinished = checkIfCanceled .__get__ (self .command )
31
+ self .command .forceCancel = False
17
32
18
33
19
34
def initialize (self ):
20
- self .command ._cancel ()
35
+ if self .command .isRunning ():
36
+ self .command .forceCancel = True
37
+
38
+
39
+ def isFinished (self ):
40
+ return not self .command .isRunning ()
You can’t perform that action at this time.
0 commit comments