2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
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
|
|
|
|
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.
|
|
|
|
|
*/
|
2021-04-18 20:35:29 -07:00
|
|
|
class SolenoidBase {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2021-04-18 20:35:29 -07:00
|
|
|
virtual ~SolenoidBase() = default;
|
|
|
|
|
|
2021-02-17 04:03:57 +02:00
|
|
|
/**
|
|
|
|
|
* Get the CAN ID of the module this solenoid is connected to.
|
|
|
|
|
*
|
|
|
|
|
* @return the module number.
|
|
|
|
|
*/
|
|
|
|
|
int GetModuleNumber() const;
|
|
|
|
|
|
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
|