Add piston getters in Shooter
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
index 391eeafce1e1a3806c2ee1e5ad3aa1a910101688..cce6a7d62d01d8cb18ba35a6c7316671f5600a80 100644 (file)
@@ -6,6 +6,8 @@ import org.usfirst.frc.team3501.robot.utils.HallEffectSensor;
 
 import com.ctre.CANTalon;
 
+import edu.wpi.first.wpilibj.DoubleSolenoid;
+import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 import edu.wpi.first.wpilibj.command.Subsystem;
 
 public class Shooter extends Subsystem {
@@ -14,11 +16,11 @@ public class Shooter extends Subsystem {
   private static HallEffectSensor hallEffect;
   private final CANTalon flyWheel1, flyWheel2, indexWheel;
 
-  public static final double DEFAULT_INDEXING_SPEED = -0.75;
-  public static final double DEFAULT_SHOOTING_SPEED = 2700; // rpm
-  private static double CURRENT_SHOOTING_SPEED = DEFAULT_SHOOTING_SPEED;
+  private static final double DEFAULT_INDEXING_SPEED = -0.75;
+  private static final double DEFAULT_SHOOTING_SPEED = 2800; // rpm
+  private static final double SHOOTING_SPEED_INCREMENT = 25;
 
-  public static final double SHOOTING_SPEED_INCREMENT = 25;
+  private double currentShootingSpeed = DEFAULT_SHOOTING_SPEED;
 
   private Shooter() {
     flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);
@@ -28,10 +30,6 @@ public class Shooter extends Subsystem {
     hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1);
   }
 
-  public static HallEffectSensor getHallEffectSensor() {
-    return hallEffect;
-  }
-
   /**
    * Returns shooter object
    *
@@ -82,20 +80,56 @@ public class Shooter extends Subsystem {
     indexWheel.set(0);
   }
 
-  public double getCurrentShootingSpeed() {
-    return CURRENT_SHOOTING_SPEED;
+  @Override
+  protected void initDefaultCommand() {
+
+  }
+
+  public double getShooterRPM() {
+    return hallEffect.getRPM();
   }
 
   public void setCurrentShootingSpeed(double Value) {
-    CURRENT_SHOOTING_SPEED = Value;
+    currentShootingSpeed = Value;
   }
 
-  @Override
-  protected void initDefaultCommand() {
+  public void decrementCurrentShootingSpeed() {
+    this.currentShootingSpeed -= this.SHOOTING_SPEED_INCREMENT;
+  }
 
+  public void incrementCurrentShootingSpeed() {
+    this.currentShootingSpeed += this.SHOOTING_SPEED_INCREMENT;
   }
 
-  public double getShooterRPM() {
-    return hallEffect.getRPM();
+  public void resetCurrentShootingSpeed() {
+    this.currentShootingSpeed = this.DEFAULT_SHOOTING_SPEED;
+  }
+
+  public double getCurrentShootingSpeed() {
+    return currentShootingSpeed;
+  }
+
+  public void reverseIndexWheel() {
+    this.setIndexWheelMotorVal(-DEFAULT_INDEXING_SPEED);
+  }
+
+  public void runIndexWheel() {
+    this.setIndexWheelMotorVal(DEFAULT_INDEXING_SPEED);
+  }
+
+  public Value getPistonValue() {
+    return piston.get();
+  }
+
+  public void setHighGear() {
+    changeGear(Constants.Shooter.HIGH_GEAR);
+  }
+
+  public void setLowGear() {
+    changeGear(Constants.Shooter.LOW_GEAR);
+  }
+
+  private void changeGear(DoubleSolenoid.Value gear) {
+    piston.set(gear);
   }
 }