public Value get() { if (forwards && !reverse) { return Value.kForward; } else if (!forwards && reverse) { return Value.kReverse; } else if (forwards && reverse) { return Value.kOn; } else { return Value.kOff; } }
@Test public void test() { // pretext Assert.assertEquals(doubleSolenoide.isDefaultState(), true); // test toggle doubleSolenoide.toggle(); Assert.assertEquals(relay1, Relay.Value.kForward); Assert.assertEquals(relay2, Relay.Value.kOff); doubleSolenoide.toggle(); Assert.assertEquals(relay1, Relay.Value.kOff); Assert.assertEquals(relay2, Relay.Value.kForward); }
public void autonomousPeriodic() { if (mTimer.get() < 2) { mRelay.set(Value.kForward); } else if (mTimer.get() < 4) { mRelay.set(Value.kReverse); } else { mRelay.set(Value.kOn); } }
public void toggle() { if (isOn) { isOn = false; light.set(Value.kOff); } else { isOn = true; light.set(Value.kForward); } }
public void setVisionEnabled(boolean enabled) { if (gripVision != null) { ringLightsPower.set(enabled? Value.kOn: Value.kOff); gripVision.setVideoOutEnabled(enabled); gripVision.setEnabled(enabled); tracer.traceInfo("Vision", "Grip Vision is %s!", enabled? "enabled": "disabled"); } else if (faceDetector != null) { faceDetector.setVideoOutEnabled(enabled); faceDetector.setEnabled(enabled); tracer.traceInfo("Vision", "Face Detector is %s!", enabled? "enabled": "disabled"); } else { ringLightsPower.set(enabled? Value.kOn: Value.kOff); if (frontPixy != null) { frontPixy.setEnabled(enabled); tracer.traceInfo("Vision", "Front pixy is %s!", enabled? "enabled": "disabled"); } if (rearPixy != null) { rearPixy.setEnabled(enabled); tracer.traceInfo("Vision", "Rear pixy is %s!", enabled? "enabled": "disabled"); } } }
@Override public State state() { Value value = relay.get(); if (value == Value.kForward || value == Value.kOn) return State.ON; if (value == Value.kReverse || value == Value.kOff) return State.OFF; return State.UNKOWN; }
public void set(IOutputEnum key, Object value) { if(value instanceof Value) { relay.set((Value) value); } }
private static boolean baselinePath () { System.out.println("Current State = " + currentState); System.out.println("Encoder Val: " + Hardware.autoDrive.getAveragedEncoderValues()); // System.out.println("Delayval: " + delayBeforeAuto); // System.out.println("Timer val: " + Hardware.autoStateTimer.get()); switch (currentState) { case INIT: Hardware.leftRearMotor.set(0); Hardware.leftFrontMotor.set(0); Hardware.rightRearMotor.set(0); Hardware.rightFrontMotor.set(0); Hardware.gearIntake.stopIntakeWheels(); Hardware.autoStateTimer.reset(); Hardware.autoStateTimer.start(); initializeDriveProgram(); // Hardware.ringlightRelay.set(Value.kOn); Hardware.autoStateTimer.start(); currentState = MainState.DELAY_BEFORE_START; break; case DELAY_BEFORE_START: // stop all the motors to feed the watchdog Hardware.leftRearMotor.set(0); Hardware.leftFrontMotor.set(0); Hardware.rightRearMotor.set(0); Hardware.rightFrontMotor.set(0); Hardware.gearIntake.raiseArm(); // wait for timer to run out if (Hardware.autoStateTimer.get() >= delayBeforeAuto) { // Hardware.axisCamera.saveImagesSafely(); // currentState = MainState.ACCELERATE; currentState = MainState.DRIVE_FORWARD_TO_CENTER; Hardware.autoStateTimer.reset(); Hardware.autoStateTimer.start(); } break; case DRIVE_FORWARD_TO_CENTER: // baseline is 94 inches from wall, so drive a little bit further if (onNewDrive == false) { if (Hardware.autoDrive.driveInches(115, DRIVE_SPEED) == true) { currentState = MainState.DONE; } } else { if (Hardware.newDrive.driveStraightInches(115, DRIVE_SPEED) == true) { currentState = MainState.DONE; } } break; default: case DONE: Hardware.autoDrive.drive(0, 0, 0); Hardware.ringlightRelay.set(Value.kOff); return true; } return false; }
protected void execute() { RobotMap.lightsLightEnable.set(Value.kOn); RobotMap.lightsLightEnable.set(Value.kForward); }
protected void execute() { RobotMap.motorRelayMotorRelay1.set(Value.kOff); }
public RelayDisplay() { setPreferredSize(new Dimension(sWIDTH, sHEIGHT)); mValue = Value.kOff; }
public void updateDisplay(Value value) { mValue = value; }
@Override public void tick() { IntakeSubsystemMode mode = (IntakeSubsystemMode) this.getMode(); if(mode != null) { switch(mode) { case INTAKING: if(this.canIntake()) { System.out.println("Trying to intake, and all is good."); this.set(1.0d); } else { System.out.println("Trying to intake, but the thing is a thing and that is bad."); this.set(0.0d); } break; case OUTPUTTING: this.set(-1.0d); break; case FIRING: this.set(1.0d); break; case DISABLED: this.stopMotor(); break; case STOPPED: default: this.set(0.0d); break; } } else { this.set(0.0d); } if(this._limitSwitch.isTripped()) { this._indicatorRelay.set(Value.kOn); } else { this._indicatorRelay.set(Value.kOff); } }
public boolean get(){ return !light.get().equals(Value.kOff); }
@Override public HardwareRelay on() { relay.set(Value.kForward); return this; }
@Override public HardwareRelay off() { relay.set(Value.kOff); return this; }
public void startCompressor() { compressor.setRelayValue(Value.kForward); }
public void stopCompressor() { compressor.setRelayValue(Value.kOff); }
@Override public void setRelayValues(Value relayOne, Value relayTwo) { relay1 = relayOne; relay2 = relayTwo; }
@Override public Value intakeLiftState() { return intakeOpen ? Relay.Value.kForward : Relay.Value.kReverse; }
/** * Forcefully turns the compressor on */ public void turnCompressorOn() { compressor.setRelayValue(Value.kForward); secondaryCompressionSystem.setRelayValue(Value.kForward); }
/** * Forcefully turns the compressor off */ public void turnCompressorOff() { compressor.setRelayValue(Value.kOff); secondaryCompressionSystem.setRelayValue(Value.kOff); }