mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
they are purely aesthetic. I ran clang-format with google style
over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
or gtest, and the eclipse formatter over all of the Java files
using the Google eclipse formatting configuration.
Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved.
|
||||
*/
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -7,110 +8,104 @@
|
||||
#include "SolenoidBase.h"
|
||||
|
||||
// Needs to be global since the protected resource spans all Solenoid objects.
|
||||
Resource *SolenoidBase::m_allocated = NULL;
|
||||
Resource* SolenoidBase::m_allocated = NULL;
|
||||
|
||||
void* SolenoidBase::m_ports[m_maxModules][m_maxPorts];
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param moduleNumber The CAN PCM ID.
|
||||
*/
|
||||
SolenoidBase::SolenoidBase(uint8_t moduleNumber)
|
||||
: m_moduleNumber (moduleNumber)
|
||||
{
|
||||
for (uint32_t i = 0; i < kSolenoidChannels; i++)
|
||||
{
|
||||
void* port = getPortWithModule(moduleNumber, i);
|
||||
int32_t status = 0;
|
||||
SolenoidBase::m_ports[moduleNumber][i] = initializeSolenoidPort(port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
: m_moduleNumber(moduleNumber) {
|
||||
for (uint32_t i = 0; i < kSolenoidChannels; i++) {
|
||||
void* port = getPortWithModule(moduleNumber, i);
|
||||
int32_t status = 0;
|
||||
SolenoidBase::m_ports[moduleNumber][i] =
|
||||
initializeSolenoidPort(port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
SolenoidBase::~SolenoidBase()
|
||||
{
|
||||
}
|
||||
SolenoidBase::~SolenoidBase() {}
|
||||
|
||||
/**
|
||||
* Set the value of a solenoid.
|
||||
*
|
||||
*
|
||||
* @param value The value you want to set on the module.
|
||||
* @param mask The channels you want to be affected.
|
||||
*/
|
||||
void SolenoidBase::Set(uint8_t value, uint8_t mask, int module)
|
||||
{
|
||||
int32_t status = 0;
|
||||
for (int i = 0; i < m_maxPorts; i++) {
|
||||
uint8_t local_mask = 1 << i;
|
||||
if (mask & local_mask)
|
||||
setSolenoid(m_ports[module][i], value & local_mask, &status);
|
||||
}
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
void SolenoidBase::Set(uint8_t value, uint8_t mask, int module) {
|
||||
int32_t status = 0;
|
||||
for (int i = 0; i < m_maxPorts; i++) {
|
||||
uint8_t local_mask = 1 << i;
|
||||
if (mask & local_mask)
|
||||
setSolenoid(m_ports[module][i], value & local_mask, &status);
|
||||
}
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all 8 solenoids as a single byte
|
||||
*
|
||||
*
|
||||
* @return The current value of all 8 solenoids on the module.
|
||||
*/
|
||||
uint8_t SolenoidBase::GetAll(int module) const
|
||||
{
|
||||
uint8_t value = 0;
|
||||
int32_t status = 0;
|
||||
for (int i = 0; i < m_maxPorts; i++) {
|
||||
value |= getSolenoid(m_ports[module][i], &status) << i;
|
||||
}
|
||||
return value;
|
||||
uint8_t SolenoidBase::GetAll(int module) const {
|
||||
uint8_t value = 0;
|
||||
int32_t status = 0;
|
||||
for (int i = 0; i < m_maxPorts; i++) {
|
||||
value |= getSolenoid(m_ports[module][i], &status) << i;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* 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()
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidBlackList(m_ports[module][0], &status);
|
||||
uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidBlackList(m_ports[module][0], &status);
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
* @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 SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageStickyFault(m_ports[module][0], &status);
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageStickyFault(m_ports[module][0], &status);
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
* @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 SolenoidBase::GetPCMSolenoidVoltageFault(int module) const
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageFault(m_ports[module][0], &status);
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const {
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageFault(m_ports[module][0], &status);
|
||||
}
|
||||
/**
|
||||
* 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 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 SolenoidBase::ClearAllPCMStickyFaults(int module)
|
||||
{
|
||||
int32_t status = 0;
|
||||
return clearAllPCMStickyFaults_sol(m_ports[module][0], &status);
|
||||
void SolenoidBase::ClearAllPCMStickyFaults(int module) {
|
||||
int32_t status = 0;
|
||||
return clearAllPCMStickyFaults_sol(m_ports[module][0], &status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user