Implement RunIndexWheel class
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheel.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.Timer;
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command runs index wheel at a given speed for given time in seconds.
10 *
11 * pre-condition: fly wheel is running at full speed to prepare for shooting
12 * fuel
13 *
14 * @author Shaina
15 */
16 public class RunIndexWheel extends Command {
17 Timer timer;
18 private double time;
19 private double motorVal;
20
21 /**
22 * See JavaDoc comment in class for details
23 *
24 * @param motorVal
25 * value range from -1 to 1
26 * @param time
27 * in seconds, amount of time to run index wheel motor
28 */
29 public RunIndexWheel(double motorVal, double time) {
30 requires(Robot.getShooter());
31
32 timer = new Timer();
33 this.motorVal = motorVal;
34 this.time = time;
35 }
36
37 // Called just before this Command runs the first time
38 @Override
39 protected void initialize() {
40 timer.start();
41 Robot.getShooter().setIndexWheelMotorVal(motorVal);
42
43 }
44
45 // Called repeatedly when this Command is scheduled to run
46 @Override
47 protected void execute() {
48 }
49
50 // Called once after isFinished returns true
51 @Override
52 protected void end() {
53 Robot.getShooter().stopIndexWheel();
54
55 }
56
57 // Called when another command which requires one or more of the same
58 // subsystems is scheduled to run
59 @Override
60 protected void interrupted() {
61 end();
62 }
63
64 @Override
65 protected boolean isFinished() {
66 return timer.get() >= time;
67 }
68
69 }