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 | /** | |
de8c65d3 | 10 | * This command runs the winch for a given motor value and time in seconds |
9738295a | 11 | * |
de8c65d3 SG |
12 | * @param motorVal |
13 | * value range is from -1 to 1 | |
14 | * @param time | |
15 | * in seconds | |
9738295a SG |
16 | * @author shivanighanta |
17 | * | |
18 | */ | |
19 | public class RunWinch extends Command { | |
6a363924 | 20 | Timer timer; |
9738295a SG |
21 | private double time; |
22 | private double motorVal; | |
23 | ||
24 | public RunWinch(double time, double motorVal) { | |
6a363924 | 25 | requires(Robot.getClimber()); |
9738295a SG |
26 | this.time = time; |
27 | this.motorVal = motorVal; | |
28 | } | |
29 | ||
30 | @Override | |
31 | protected void initialize() { | |
6a363924 | 32 | timer.start(); |
cf086549 | 33 | Robot.getClimber().setMotorValue(motorVal); |
9738295a SG |
34 | } |
35 | ||
36 | @Override | |
37 | protected void execute() { | |
38 | ||
39 | } | |
40 | ||
41 | @Override | |
42 | protected boolean isFinished() { | |
6a363924 | 43 | return timer.get() >= time; |
9738295a SG |
44 | } |
45 | ||
46 | @Override | |
47 | protected void end() { | |
6a363924 | 48 | Robot.getClimber().stop(); |
9738295a SG |
49 | } |
50 | ||
51 | @Override | |
52 | protected void interrupted() { | |
6a363924 | 53 | end(); |
9738295a SG |
54 | } |
55 | } |