2014-06-13 17:45:10 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
2014-06-13 17:45:10 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2014-06-13 17:45:10 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-05-25 22:40:15 -07:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2017-08-27 00:11:52 -07:00
|
|
|
#include <HAL/Types.h>
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
#include "ErrorBase.h"
|
2018-05-23 20:22:30 -07:00
|
|
|
#include "SensorUtil.h"
|
2017-12-04 23:28:33 -08:00
|
|
|
#include "SmartDashboard/SendableBase.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
2017-08-23 21:58:21 -07:00
|
|
|
* Class for operating a compressor connected to a %PCM (Pneumatic Control
|
2017-11-16 00:33:51 -08:00
|
|
|
* 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.
|
2017-08-23 21:58:21 -07:00
|
|
|
*
|
|
|
|
|
* 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.
|
2014-05-02 17:54:01 -04:00
|
|
|
*/
|
2017-12-04 23:28:33 -08:00
|
|
|
class Compressor : public ErrorBase, public SendableBase {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2015-06-24 01:06:29 -07:00
|
|
|
// Default PCM ID is 0
|
2018-05-23 20:22:30 -07:00
|
|
|
explicit Compressor(int pcmID = SensorUtil::GetDefaultSolenoidModule());
|
2017-12-04 23:28:33 -08:00
|
|
|
~Compressor() override = default;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
|
void Stop();
|
|
|
|
|
bool Enabled() const;
|
|
|
|
|
|
|
|
|
|
bool GetPressureSwitchValue() const;
|
|
|
|
|
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetCompressorCurrent() const;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
void SetClosedLoopControl(bool on);
|
|
|
|
|
bool GetClosedLoopControl() const;
|
|
|
|
|
|
|
|
|
|
bool GetCompressorCurrentTooHighFault() const;
|
|
|
|
|
bool GetCompressorCurrentTooHighStickyFault() const;
|
|
|
|
|
bool GetCompressorShortedStickyFault() const;
|
|
|
|
|
bool GetCompressorShortedFault() const;
|
|
|
|
|
bool GetCompressorNotConnectedStickyFault() const;
|
|
|
|
|
bool GetCompressorNotConnectedFault() const;
|
|
|
|
|
void ClearAllPCMStickyFaults();
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
protected:
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_CompressorHandle m_compressorHandle;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void SetCompressor(bool on);
|
2016-09-06 00:01:45 -07:00
|
|
|
int m_module;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|