Edit comments
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / climber / RunWinch.java
index 99fb0f12ab087313d8afa14e0e83ce248b609819..d6d047c98f53671e57a77ea9405c0961e0c49a65 100644 (file)
@@ -1,24 +1,36 @@
 package org.usfirst.frc.team3501.robot.commands.climber;
 
+import org.usfirst.frc.team3501.robot.Robot;
+
+import com.sun.glass.ui.Timer;
+
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
- * Runs the winch for a given time and motor value
+ * This command runs the winch for a given motor value and time in seconds
  *
+ * @param motorVal
+ *          value range is from -1 to 1
+ * @param time
+ *          in seconds
  * @author shivanighanta
  *
  */
 public class RunWinch extends Command {
+  Timer timer;
   private double time;
   private double motorVal;
 
   public RunWinch(double time, double motorVal) {
+    requires(Robot.getClimber());
     this.time = time;
     this.motorVal = motorVal;
   }
 
   @Override
   protected void initialize() {
+    timer.start();
+    Robot.getClimber().setMotorValue(motorVal);
   }
 
   @Override
@@ -28,15 +40,16 @@ public class RunWinch extends Command {
 
   @Override
   protected boolean isFinished() {
-    return false;
+    return timer.get() >= time;
   }
 
   @Override
   protected void end() {
-
+    Robot.getClimber().stop();
   }
 
   @Override
   protected void interrupted() {
+    end();
   }
 }