edu.wpi.first.wpilibj

## Class Compressor

- java.lang.Object
- - edu.wpi.first.wpilibj.SensorBase
  - - edu.wpi.first.wpilibj.Compressor

- All Implemented Interfaces:
    LiveWindowSendable, Sendable

      public class Compressor
      extends SensorBase
      implements LiveWindowSendable

  Class for operating a compressor connected to a PCM (Pneumatic Control Module). The PCM will automatically run in closed loop mode by default whenever a `Solenoid` object is created. For most cases, a Compressor object does not need to be instantiated or used in a robot program. This class is only required in cases where the robot program needs a more detailed status of the compressor or to enable/disable closed loop control.

  Note: you cannot operate the compressor directly from this class as doing so would circumvent the safety provided by using the pressure switch and closed loop control. You can only turn off closed loop control, thereby stopping the compressor from operating.

- - ### Field Summary

    - ### Fields inherited from class edu.wpi.first.wpilibj.SensorBase

      `kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecond`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Compressor()` Makes a new instance of the compressor using the default PCM ID of 0.
    `Compressor(int module)` Makes a new instance of the compressor using the provided CAN device ID.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearAllPCMStickyFaults()` Clear ALL sticky faults inside PCM that Compressor is wired to.
    `boolean` | `enabled()` Get the status of the compressor.
    `boolean` | `getClosedLoopControl()` Gets the current operating mode of the PCM.
    `double` | `getCompressorCurrent()` Get the current being used by the compressor.
    `boolean` | `getCompressorCurrentTooHighFault()` If PCM is in fault state : Compressor Drive is disabled due to compressor current being too high.
    `boolean` | `getCompressorCurrentTooHighStickyFault()` If PCM sticky fault is set : Compressor is disabled due to compressor current being too high.
    `boolean` | `getCompressorNotConnectedFault()` If PCM is in fault state : Compressor does not appear to be wired, i.e.
    `boolean` | `getCompressorNotConnectedStickyFault()` If PCM sticky fault is set : Compressor does not appear to be wired, i.e.
    `boolean` | `getCompressorShortedFault()` If PCM is in fault state : Compressor output appears to be shorted.
    `boolean` | `getCompressorShortedStickyFault()` If PCM sticky fault is set : Compressor output appears to be shorted.
    `boolean` | `getPressureSwitchValue()` Get the pressure switch value.
    `java.lang.String` | `getSmartDashboardType()` The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
    `void` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `void` | `setClosedLoopControl(boolean on)` Set the PCM in closed loop control mode.
    `void` | `start()` Start the compressor running in closed loop control mode.
    `void` | `startLiveWindowMode()` Start having this sendable object automatically respond to value changes reflect the value on the table.
    `void` | `stop()` Stop the compressor from running in closed loop control mode.
    `void` | `stopLiveWindowMode()` Stop having this sendable object automatically respond to value changes.
    `void` | `updateTable()` Update the table for this sendable object with the latest values.

    - ### Methods inherited from class edu.wpi.first.wpilibj.SensorBase

      `checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, free, getDefaultSolenoidModule, setDefaultSolenoidModule`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Compressor

          public Compressor(int module)

      Makes a new instance of the compressor using the provided CAN device ID. Use this constructor when you have more than one PCM.
      Parameters:
        `module` - The PCM CAN device ID (0 - 62 inclusive)

    - #### Compressor

          public Compressor()

      Makes a new instance of the compressor using the default PCM ID of 0.

      Additional modules can be supported by making a new instance and `specifying the CAN ID.`

  - ### Method Detail

    - #### start

          public void start()

      Start the compressor running in closed loop control mode.

      Use the method in cases where you would like to manually stop and start the compressor for applications such as conserving battery or making sure that the compressor motor doesn't start during critical operations.

    - #### stop

          public void stop()

      Stop the compressor from running in closed loop control mode.

      Use the method in cases where you would like to manually stop and start the compressor for applications such as conserving battery or making sure that the compressor motor doesn't start during critical operations.

    - #### enabled

          public boolean enabled()

      Get the status of the compressor.
      Returns:
        true if the compressor is on

    - #### getPressureSwitchValue

          public boolean getPressureSwitchValue()

      Get the pressure switch value.
      Returns:
        true if the pressure is low

    - #### getCompressorCurrent

          public double getCompressorCurrent()

      Get the current being used by the compressor.
      Returns:
        current consumed by the compressor in amps

    - #### setClosedLoopControl

          public void setClosedLoopControl(boolean on)

      Set the PCM in closed loop control mode.
      Parameters:
        `on` - if true sets the compressor to be in closed loop control mode (default)

    - #### getClosedLoopControl

          public boolean getClosedLoopControl()

      Gets the current operating mode of the PCM.
      Returns:
        true if compressor is operating on closed-loop mode

    - #### getCompressorCurrentTooHighFault

          public boolean getCompressorCurrentTooHighFault()

      If PCM is in fault state : Compressor Drive is disabled due to compressor current being too high.
      Returns:
        true if PCM is in fault state.

    - #### getCompressorCurrentTooHighStickyFault

          public boolean getCompressorCurrentTooHighStickyFault()

      If PCM sticky fault is set : Compressor is disabled due to compressor current being too high.
      Returns:
        true if PCM sticky fault is set.

    - #### getCompressorShortedStickyFault

          public boolean getCompressorShortedStickyFault()

      If PCM sticky fault is set : Compressor output appears to be shorted.
      Returns:
        true if PCM sticky fault is set.

    - #### getCompressorShortedFault

          public boolean getCompressorShortedFault()

      If PCM is in fault state : Compressor output appears to be shorted.
      Returns:
        true if PCM is in fault state.

    - #### getCompressorNotConnectedStickyFault

          public boolean getCompressorNotConnectedStickyFault()

      If PCM sticky fault is set : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.
      Returns:
        true if PCM sticky fault is set.

    - #### getCompressorNotConnectedFault

          public boolean getCompressorNotConnectedFault()

      If PCM is in fault state : Compressor does not appear to be wired, i.e. compressor is not drawing enough current.
      Returns:
        true if PCM is in fault state.

    - #### clearAllPCMStickyFaults

          public void clearAllPCMStickyFaults()

      Clear ALL sticky faults inside PCM that Compressor is wired to.

      If a sticky fault is set, then it will be persistently cleared. The compressor might momentarily disable while the flags are being cleared. Doo not call this method too frequently, otherwise normal compressor functionality may be prevented.

      If no sticky faults are set then this call will have no effect.

    - #### startLiveWindowMode

          public void startLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Start having this sendable object automatically respond to value changes reflect the value on the table.
      Specified by:
        `startLiveWindowMode` in interface `LiveWindowSendable`

    - #### stopLiveWindowMode

          public void stopLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Stop having this sendable object automatically respond to value changes.
      Specified by:
        `stopLiveWindowMode` in interface `LiveWindowSendable`

    - #### getSmartDashboardType

          public java.lang.String getSmartDashboardType()

      Description copied from interface: `Sendable`
      The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
      Specified by:
        `getSmartDashboardType` in interface `Sendable`
      Returns:
        The type of this `Sendable`.

    - #### initTable

          public void initTable(NetworkTable subtable)

      Description copied from interface: `Sendable`
      Initializes a table for this `Sendable` object.
      Specified by:
        `initTable` in interface `Sendable`
      Parameters:
        `subtable` - The table to put the values in.

    - #### updateTable

          public void updateTable()

      Description copied from interface: `LiveWindowSendable`
      Update the table for this sendable object with the latest values.
      Specified by:
        `updateTable` in interface `LiveWindowSendable`