Commit | Line | Data |
---|---|---|
9738295a SG |
1 | package org.usfirst.frc.team3501.robot.commands.climber; |
2 | ||
6a363924 SG |
3 | import org.usfirst.frc.team3501.robot.Robot; |
4 | ||
5 | import com.sun.glass.ui.Timer; | |
6 | ||
9738295a SG |
7 | import edu.wpi.first.wpilibj.command.Command; |
8 | ||
9 | /** | |
e2e9a7a7 SG |
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. | |
9738295a | 17 | * |
de8c65d3 SG |
18 | * @param motorVal |
19 | * value range is from -1 to 1 | |
20 | * @param time | |
21 | * in seconds | |
9738295a SG |
22 | * @author shivanighanta |
23 | * | |
24 | */ | |
25 | public class RunWinch extends Command { | |
6a363924 | 26 | Timer timer; |
9738295a SG |
27 | private double time; |
28 | private double motorVal; | |
29 | ||
30 | public RunWinch(double time, double motorVal) { | |
6a363924 | 31 | requires(Robot.getClimber()); |
9738295a SG |
32 | this.time = time; |
33 | this.motorVal = motorVal; | |
34 | } | |
35 | ||
36 | @Override | |
37 | protected void initialize() { | |
6a363924 | 38 | timer.start(); |
cf086549 | 39 | Robot.getClimber().setMotorValue(motorVal); |
9738295a SG |
40 | } |
41 | ||
42 | @Override | |
43 | protected void execute() { | |
44 | ||
45 | } | |
46 | ||
47 | @Override | |
48 | protected boolean isFinished() { | |
6a363924 | 49 | return timer.get() >= time; |
9738295a SG |
50 | } |
51 | ||
52 | @Override | |
53 | protected void end() { | |
6a363924 | 54 | Robot.getClimber().stop(); |
9738295a SG |
55 | } |
56 | ||
57 | @Override | |
58 | protected void interrupted() { | |
6a363924 | 59 | end(); |
9738295a SG |
60 | } |
61 | } |