diff --git a/subsystems/SolenoidSubsystem.java b/subsystems/SolenoidSubsystem.java index 382bdf08..54266e35 100644 --- a/subsystems/SolenoidSubsystem.java +++ b/subsystems/SolenoidSubsystem.java @@ -84,7 +84,8 @@ public SolenoidSubsystem(DoubleSolenoid... solenoids) { } /** - * DoubleSolenoid.Value simplified to three simple states + * DoubleSolenoid.Value simplified to three simple states. Never use the state + * OFF */ public enum SolenoidState { OFF(DoubleSolenoid.Value.kOff), EXTEND(DoubleSolenoid.Value.kForward), RETRACT(DoubleSolenoid.Value.kReverse); diff --git a/subsystems/chassis/SolenoidShifters.java b/subsystems/chassis/SolenoidShifters.java index ca479446..62c26ab3 100644 --- a/subsystems/chassis/SolenoidShifters.java +++ b/subsystems/chassis/SolenoidShifters.java @@ -1,18 +1,15 @@ package org.usfirst.frc4904.standard.subsystems.chassis; +import org.usfirst.frc4904.standard.subsystems.SolenoidSubsystem; + import edu.wpi.first.wpilibj.DoubleSolenoid; -import edu.wpi.first.wpilibj2.command.SubsystemBase; /** * A class that wraps multiple DoubleSolenoid objects with subsystem * functionality. Allows for easy inversion and setting of default state of * solenoids */ -public class SolenoidShifters extends SubsystemBase { // TODO: make solenoidshifters extend solenoidsubsystem - protected DoubleSolenoid[] solenoids; - protected SolenoidState state; - protected SolenoidState defaultState; - protected boolean isInverted; +public class SolenoidShifters extends SolenoidSubsystem { /** * A class that wraps multiple DoubleSolenoid objects with subsystem @@ -24,12 +21,9 @@ public class SolenoidShifters extends SubsystemBase { // TODO: make solenoidshif * @param defaultState Set the default state of the SolenoidSystem * @param solenoids Double solenoids of the system */ + public SolenoidShifters(String name, boolean isInverted, SolenoidState defaultState, DoubleSolenoid... solenoids) { - setName(name); - this.solenoids = solenoids; - this.isInverted = isInverted; - this.defaultState = defaultState; - this.state = defaultState; + super(name, isInverted, defaultState, solenoids); } /** @@ -105,61 +99,6 @@ public SolenoidShifters(DoubleSolenoid... solenoids) { this("SolenoidShifters", solenoids); } - /** - * DoubleSolenoid.Value simplified to three simple states - */ - public enum SolenoidState { - EXTEND(DoubleSolenoid.Value.kForward), RETRACT(DoubleSolenoid.Value.kReverse); - - public final DoubleSolenoid.Value value; - - private SolenoidState(DoubleSolenoid.Value value) { - this.value = value; - } - } - - /** - * @param state Returns the current state of the system - */ - public SolenoidState getState() { - return state; - } - - /** - * Inverts the state given - * - * @param state SolenoidState to be inverted - * @return SolenoidState Inverted state - * - */ - public SolenoidState invertState(SolenoidState state) { - switch (state) { - case EXTEND: - return SolenoidState.RETRACT; - case RETRACT: - return SolenoidState.EXTEND; - } - return state; - } - - /** - * Sets the state of the system Only sets if current state is not equal to state - * to be set - * - * @param state State to set system - */ - public void set(SolenoidState state) { - if (isInverted) { - state = invertState(state); - } - this.state = state; - if (this.state != state) { - for (DoubleSolenoid solenoid : solenoids) { - solenoid.set(state.value); - } - } - } - /** * Sets the state of the system Only sets if current state is not equal to state * to be set @@ -176,35 +115,4 @@ public void set() { // TODO: consider OFF case set(SolenoidState.RETRACT); } } - - /** - * Sets the state of the system regardless of current state - * - * @param state State to set - */ - public void setOverride(SolenoidState state) { - if (isInverted) { - state = invertState(state); - } - this.state = state; - for (DoubleSolenoid solenoid : solenoids) { - solenoid.set(state.value); - } - } - - /** - * @return solenoids DoubleSolenoid objects of the system - */ - public DoubleSolenoid[] getSolenoids() { - return solenoids; - } - - /** - * Returns whether the solenoid is extended. - * - * @return extended - */ - public boolean isExtended() { - return solenoids[0].get() == SolenoidState.EXTEND.value; - } }