Add pre-conditions and post-conditions to comments
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / climber / RunWinch.java
1 package org.usfirst.frc.team3501.robot.commands.climber;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import com.sun.glass.ui.Timer;
6
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs the winch at a specified speed and time in seconds when the
11 * button triggering it is pressed.
12 *
13 * pre-condition: This command is run by a button in OI. The robot must be
14 * attached to the rope.
15 *
16 * post-condition: Winch motor set to a specified speed for a specified time.
17 *
18 * @param motorVal
19 * value range is from -1 to 1
20 * @param time
21 * in seconds
22 * @author shivanighanta
23 *
24 */
25 public class RunWinch extends Command {
26 Timer timer;
27 private double time;
28 private double motorVal;
29
30 public RunWinch(double time, double motorVal) {
31 requires(Robot.getClimber());
32 this.time = time;
33 this.motorVal = motorVal;
34 }
35
36 @Override
37 protected void initialize() {
38 timer.start();
39 Robot.getClimber().setMotorValue(motorVal);
40 }
41
42 @Override
43 protected void execute() {
44
45 }
46
47 @Override
48 protected boolean isFinished() {
49 return timer.get() >= time;
50 }
51
52 @Override
53 protected void end() {
54 Robot.getClimber().stop();
55 }
56
57 @Override
58 protected void interrupted() {
59 end();
60 }
61 }