Class DoubleSolenoid

java.lang.Object
org.wpilib.hardware.pneumatic.DoubleSolenoid
All Implemented Interfaces:
AutoCloseable, TelemetryLoggable

public class DoubleSolenoid extends Object implements TelemetryLoggable, AutoCloseable
DoubleSolenoid class for running 2 channels of high voltage Digital Output on the pneumatics module.

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

  • Constructor Details

    • DoubleSolenoid

      public DoubleSolenoid(CANPort busId, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
      Constructs a double solenoid for a default module of a specific module type.
      Parameters:
      busId - The bus ID
      moduleType - The module type to use.
      forwardChannel - The forward channel on the module to control.
      reverseChannel - The reverse channel on the module to control.
    • DoubleSolenoid

      public DoubleSolenoid(CANPort busId, int module, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
      Constructs a double solenoid for a specified module of a specific module type.
      Parameters:
      busId - The bus ID
      module - The module of the solenoid module to use.
      moduleType - The module type to use.
      forwardChannel - The forward channel on the module to control.
      reverseChannel - The reverse channel on the module to control.
  • 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.
    • isFwdSolenoidDisabled

      public boolean isFwdSolenoidDisabled()
      Check if the forward solenoid is Disabled. If a solenoid is shorted, it is added to the DisabledList and disabled until power cycle, or until faults are cleared.
      Returns:
      If solenoid is disabled due to short.
    • isRevSolenoidDisabled

      public boolean isRevSolenoidDisabled()
      Check if the reverse solenoid is Disabled. If a solenoid is shorted, it is added to the DisabledList and disabled until power cycle, or until faults are cleared.
      Returns:
      If solenoid is disabled due to short.
    • logTo

      public void logTo(TelemetryTable table)
      Description copied from interface: TelemetryLoggable
      Logs the object to a TelemetryTable.
      Specified by:
      logTo in interface TelemetryLoggable
      Parameters:
      table - telemetry table
    • getTelemetryType

      public String getTelemetryType()
      Description copied from interface: TelemetryLoggable
      Gets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.
      Specified by:
      getTelemetryType in interface TelemetryLoggable
      Returns:
      Table type