2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-09-14 15:22:54 -05:00
|
|
|
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05: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. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/ErrorBase.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
|
|
|
/**
|
|
|
|
|
* SolenoidBase class is the common base class for the Solenoid and
|
|
|
|
|
* DoubleSolenoid classes.
|
|
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class SolenoidBase : public ErrorBase {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Read all 8 solenoids as a single byte
|
|
|
|
|
*
|
|
|
|
|
* @param module the module to read from
|
|
|
|
|
* @return The current value of all 8 solenoids on the module.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
static int GetAll(int module);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read all 8 solenoids as a single byte
|
|
|
|
|
*
|
|
|
|
|
* @return The current value of all 8 solenoids on the module.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
int GetAll() const;
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Reads complete solenoid blacklist for all 8 solenoids as a single byte.
|
|
|
|
|
*
|
|
|
|
|
* If a solenoid is shorted, it is added to the blacklist and
|
|
|
|
|
* disabled until power cycle, or until faults are cleared.
|
|
|
|
|
* @see ClearAllPCMStickyFaults()
|
|
|
|
|
*
|
|
|
|
|
* @param module the module to read from
|
|
|
|
|
* @return The solenoid blacklist of all 8 solenoids on the module.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
static int GetPCMSolenoidBlackList(int module);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads complete solenoid blacklist for all 8 solenoids as a single byte.
|
|
|
|
|
*
|
|
|
|
|
* If a solenoid is shorted, it is added to the blacklist and
|
|
|
|
|
* disabled until power cycle, or until faults are cleared.
|
|
|
|
|
* @see ClearAllPCMStickyFaults()
|
|
|
|
|
*
|
|
|
|
|
* @return The solenoid blacklist of all 8 solenoids on the module.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
int GetPCMSolenoidBlackList() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param module the module to read from
|
|
|
|
|
* @return true if PCM sticky fault is set : The common highside solenoid
|
|
|
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
static bool GetPCMSolenoidVoltageStickyFault(int module);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return true if PCM sticky fault is set : The common highside solenoid
|
|
|
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
bool GetPCMSolenoidVoltageStickyFault() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param module the module to read from
|
|
|
|
|
* @return true if PCM is in fault state : The common highside solenoid
|
|
|
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
static bool GetPCMSolenoidVoltageFault(int module);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return true if PCM is in fault state : The common highside solenoid
|
|
|
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
bool GetPCMSolenoidVoltageFault() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
|
|
|
|
*
|
|
|
|
|
* If a sticky fault is set, then it will be persistently cleared. Compressor
|
|
|
|
|
* drive maybe momentarily disable while flags are being cleared. Care should
|
|
|
|
|
* be taken to not call this too frequently, otherwise normal compressor
|
|
|
|
|
* functionality may be prevented.
|
|
|
|
|
*
|
|
|
|
|
* If no sticky faults are set then this call will have no effect.
|
|
|
|
|
*
|
|
|
|
|
* @param module the module to read from
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
static void ClearAllPCMStickyFaults(int module);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
|
|
|
|
*
|
|
|
|
|
* If a sticky fault is set, then it will be persistently cleared. Compressor
|
|
|
|
|
* drive maybe momentarily disable while flags are being cleared. Care should
|
|
|
|
|
* be taken to not call this too frequently, otherwise normal compressor
|
|
|
|
|
* functionality may be prevented.
|
|
|
|
|
*
|
|
|
|
|
* If no sticky faults are set then this call will have no effect.
|
|
|
|
|
*/
|
2017-05-08 21:55:11 -07:00
|
|
|
void ClearAllPCMStickyFaults();
|
2015-06-19 17:23:54 -07:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
protected:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param moduleNumber The CAN PCM ID.
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
explicit SolenoidBase(int pcmID);
|
2017-11-19 19:04:28 -08:00
|
|
|
|
2018-09-24 00:08:25 -07:00
|
|
|
SolenoidBase(SolenoidBase&&) = default;
|
|
|
|
|
SolenoidBase& operator=(SolenoidBase&&) = default;
|
|
|
|
|
|
2017-11-19 19:04:28 -08:00
|
|
|
static constexpr int m_maxModules = 63;
|
|
|
|
|
static constexpr int m_maxPorts = 8;
|
|
|
|
|
|
2017-05-08 21:55:11 -07:00
|
|
|
int m_moduleNumber; // PCM module number
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|