Class DoubleSolenoid

java.lang.Object
edu.wpi.first.wpilibj.SolenoidBase
edu.wpi.first.wpilibj.DoubleSolenoid
All Implemented Interfaces:
Sendable, AutoCloseable

public class DoubleSolenoid
extends SolenoidBase
implements Sendable, AutoCloseable
DoubleSolenoid class for running 2 channels of high voltage Digital Output on the PCM.

The DoubleSolenoid class is typically used for pneumatics solenoids that have two positions controlled by two separate channels.

  • Constructor Details

    • DoubleSolenoid

      public DoubleSolenoid​(int forwardChannel, int reverseChannel)
      Constructor. Uses the default PCM ID (defaults to 0).
      Parameters:
      forwardChannel - The forward channel number on the PCM (0..7).
      reverseChannel - The reverse channel number on the PCM (0..7).
    • DoubleSolenoid

      public DoubleSolenoid​(int moduleNumber, int forwardChannel, int reverseChannel)
      Constructor.
      Parameters:
      moduleNumber - The module number of the solenoid module to use.
      forwardChannel - The forward channel on the module to control (0..7).
      reverseChannel - The reverse channel on the module to control (0..7).
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • set

      public void set​(DoubleSolenoid.Value value)
      Set the value of a solenoid.
      Parameters:
      value - The value to set (Off, Forward, Reverse)
    • get

      public DoubleSolenoid.Value get()
      Read the current value of the solenoid.
      Returns:
      The current value of the solenoid.
    • toggle

      public void toggle()
      Toggle the value of the solenoid.

      If the solenoid is set to forward, it'll be set to reverse. If the solenoid is set to reverse, it'll be set to forward. If the solenoid is set to off, nothing happens.

    • getFwdChannel

      public int getFwdChannel()
      Get the forward channel.
      Returns:
      the forward channel.
    • getRevChannel

      public int getRevChannel()
      Get the reverse channel.
      Returns:
      the reverse channel.
    • isFwdSolenoidBlackListed

      public boolean isFwdSolenoidBlackListed()
      Check if the forward solenoid is blacklisted. If a solenoid is shorted, it is added to the blacklist and disabled until power cycle, or until faults are cleared.
      Returns:
      If solenoid is disabled due to short.
      See Also:
      SolenoidBase.clearAllPCMStickyFaults()
    • isRevSolenoidBlackListed

      public boolean isRevSolenoidBlackListed()
      Check if the reverse solenoid is blacklisted. If a solenoid is shorted, it is added to the blacklist and disabled until power cycle, or until faults are cleared.
      Returns:
      If solenoid is disabled due to short.
      See Also:
      SolenoidBase.clearAllPCMStickyFaults()
    • initSendable

      public void initSendable​(SendableBuilder builder)
      Description copied from interface: Sendable
      Initializes this Sendable object.
      Specified by:
      initSendable in interface Sendable
      Parameters:
      builder - sendable builder