Total Complexity | 7 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | |||
9 | public class CyborgCommandDriveDirect extends Command { |
||
10 | |||
11 | public static final long TIME_WAIT = 1000; |
||
12 | public final double percent; |
||
13 | private long time; |
||
14 | private boolean inRange; |
||
15 | |||
16 | public CyborgCommandDriveDirect(double percent) { |
||
17 | this.percent = percent; |
||
18 | requires(Robot.SUB_DRIVE); |
||
19 | } |
||
20 | |||
21 | protected void initialize() { |
||
22 | DriverStation.reportWarning("DRIVING BY POWER", false); |
||
23 | Robot.SUB_DRIVE.reset(); |
||
24 | time = System.currentTimeMillis() + TIME_WAIT; |
||
25 | } |
||
26 | |||
27 | protected void execute() { |
||
28 | inRange = Robot.SUB_DRIVE.driveDistance(percent, percent); |
||
29 | } |
||
30 | |||
31 | protected boolean isFinished() { |
||
32 | if(!inRange) { |
||
33 | time = System.currentTimeMillis() + TIME_WAIT; |
||
34 | } |
||
35 | return time < System.currentTimeMillis(); |
||
36 | } |
||
37 | |||
38 | protected void end() { |
||
39 | Robot.SUB_DRIVE.driveDirect(0, 0); |
||
40 | } |
||
41 | |||
42 | protected void interrupted() { |
||
43 | end(); |
||
44 | } |
||
45 | } |