mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Replace with new exception-based error reporting, consistent with Java. This also builds stacktraces into the reporting/exceptions.
132 lines
3.9 KiB
C++
132 lines
3.9 KiB
C++
// 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.
|
|
|
|
#pragma once
|
|
|
|
namespace frc {
|
|
|
|
/**
|
|
* SolenoidBase class is the common base class for the Solenoid and
|
|
* DoubleSolenoid classes.
|
|
*/
|
|
class SolenoidBase {
|
|
public:
|
|
virtual ~SolenoidBase() = default;
|
|
|
|
/**
|
|
* Get the CAN ID of the module this solenoid is connected to.
|
|
*
|
|
* @return the module number.
|
|
*/
|
|
int GetModuleNumber() const;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
static int GetAll(int module);
|
|
|
|
/**
|
|
* Read all 8 solenoids as a single byte
|
|
*
|
|
* @return The current value of all 8 solenoids on the module.
|
|
*/
|
|
int GetAll() const;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
static int GetPCMSolenoidBlackList(int module);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
int GetPCMSolenoidBlackList() const;
|
|
|
|
/**
|
|
* @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.
|
|
*/
|
|
static bool GetPCMSolenoidVoltageStickyFault(int module);
|
|
|
|
/**
|
|
* @return true if PCM sticky fault is set : The common highside solenoid
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
*/
|
|
bool GetPCMSolenoidVoltageStickyFault() const;
|
|
|
|
/**
|
|
* @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.
|
|
*/
|
|
static bool GetPCMSolenoidVoltageFault(int module);
|
|
|
|
/**
|
|
* @return true if PCM is in fault state : The common highside solenoid
|
|
* voltage rail is too low, most likely a solenoid channel is shorted.
|
|
*/
|
|
bool GetPCMSolenoidVoltageFault() const;
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
static void ClearAllPCMStickyFaults(int module);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
void ClearAllPCMStickyFaults();
|
|
|
|
protected:
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param moduleNumber The CAN PCM ID.
|
|
*/
|
|
explicit SolenoidBase(int pcmID);
|
|
|
|
SolenoidBase(SolenoidBase&&) = default;
|
|
SolenoidBase& operator=(SolenoidBase&&) = default;
|
|
|
|
static constexpr int m_maxModules = 63;
|
|
static constexpr int m_maxPorts = 8;
|
|
|
|
int m_moduleNumber; // PCM module number
|
|
};
|
|
|
|
} // namespace frc
|