Commit | Line | Data |
---|---|---|
f43a1c52 CZ |
1 | package org.usfirst.frc.team3501.robot.commands.driving; |
2 | ||
0704e870 | 3 | import org.usfirst.frc.team3501.robot.Constants.DriveTrain; |
f43a1c52 CZ |
4 | import org.usfirst.frc.team3501.robot.Robot; |
5 | ||
0704e870 | 6 | import edu.wpi.first.wpilibj.DoubleSolenoid.Value; |
f43a1c52 CZ |
7 | import edu.wpi.first.wpilibj.command.Command; |
8 | ||
9 | /** | |
0704e870 | 10 | * This command toggles the gear(low or high). |
f43a1c52 CZ |
11 | * |
12 | * post-condition: if the drivetrain is running at high gear, it will be made to | |
13 | * run at low gear, and vice versa | |
14 | */ | |
15 | public class ToggleGear extends Command { | |
16 | ||
17 | public ToggleGear() { | |
18 | requires(Robot.getDriveTrain()); | |
0704e870 | 19 | |
f43a1c52 CZ |
20 | } |
21 | ||
22 | // Called just before this Command runs the first time | |
23 | @Override | |
24 | protected void initialize() { | |
0704e870 | 25 | |
f43a1c52 CZ |
26 | } |
27 | ||
28 | // Called repeatedly when this Command is scheduled to run | |
29 | @Override | |
30 | protected void execute() { | |
0704e870 AD |
31 | Value gearPistonValue = Robot.getDriveTrain().getGearPistonValue(); |
32 | if (gearPistonValue == DriveTrain.LOW_GEAR) { | |
33 | Robot.getDriveTrain().setHighGear(); | |
34 | } else { | |
35 | Robot.getDriveTrain().setLowGear(); | |
36 | } | |
f43a1c52 CZ |
37 | } |
38 | ||
39 | // Make this return true when this Command no longer needs to run execute() | |
40 | @Override | |
41 | protected boolean isFinished() { | |
42 | return false; | |
43 | } | |
44 | ||
45 | // Called once after isFinished returns true | |
46 | @Override | |
47 | protected void end() { | |
48 | } | |
49 | ||
50 | // Called when another command which requires one or more of the same | |
51 | // subsystems is scheduled to run | |
52 | @Override | |
53 | protected void interrupted() { | |
54 | } | |
55 | } |