mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Moved C++ comments from source files to headers (#1111)
Also sorted functions in C++ sources to match order in related headers.
This commit is contained in:
committed by
Peter Johnson
parent
d9971a705a
commit
8c680a26f8
@@ -19,15 +19,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Relay constructor given a channel.
|
||||
*
|
||||
* This code initializes the relay and reserves all resources that need to be
|
||||
* locked. Initially the relay is set to both lines at 0v.
|
||||
*
|
||||
* @param channel The channel number (0-3).
|
||||
* @param direction The direction that the Relay object will control.
|
||||
*/
|
||||
Relay::Relay(int channel, Relay::Direction direction)
|
||||
: m_channel(channel), m_direction(direction) {
|
||||
if (!SensorUtil::CheckRelayChannel(m_channel)) {
|
||||
@@ -90,11 +81,6 @@ Relay::Relay(int channel, Relay::Direction direction)
|
||||
SetName("Relay", m_channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the resource associated with a relay.
|
||||
*
|
||||
* The relay channels are set to free and the relay output is turned off.
|
||||
*/
|
||||
Relay::~Relay() {
|
||||
int32_t status = 0;
|
||||
HAL_SetRelay(m_forwardHandle, false, &status);
|
||||
@@ -104,21 +90,6 @@ Relay::~Relay() {
|
||||
if (m_reverseHandle != HAL_kInvalidHandle) HAL_FreeRelayPort(m_reverseHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the relay state.
|
||||
*
|
||||
* Valid values depend on which directions of the relay are controlled by the
|
||||
* object.
|
||||
*
|
||||
* When set to kBothDirections, the relay can be any of the four states:
|
||||
* 0v-0v, 0v-12v, 12v-0v, 12v-12v
|
||||
*
|
||||
* When set to kForwardOnly or kReverseOnly, you can specify the constant for
|
||||
* the direction or you can simply specify kOff and kOn. Using only kOff and
|
||||
* kOn is recommended.
|
||||
*
|
||||
* @param value The state to set the relay.
|
||||
*/
|
||||
void Relay::Set(Relay::Value value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
@@ -170,16 +141,6 @@ void Relay::Set(Relay::Value value) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Relay State
|
||||
*
|
||||
* Gets the current state of the relay.
|
||||
*
|
||||
* When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not
|
||||
* kForward/kReverse (per the recommendation in Set).
|
||||
*
|
||||
* @return The current state of the relay as a Relay::Value
|
||||
*/
|
||||
Relay::Value Relay::Get() const {
|
||||
int32_t status;
|
||||
|
||||
@@ -216,54 +177,20 @@ Relay::Value Relay::Get() const {
|
||||
|
||||
int Relay::GetChannel() const { return m_channel; }
|
||||
|
||||
/**
|
||||
* Set the expiration time for the Relay object.
|
||||
*
|
||||
* @param timeout The timeout (in seconds) for this relay object
|
||||
*/
|
||||
void Relay::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the expiration time for the relay object.
|
||||
*
|
||||
* @return The expiration time value.
|
||||
*/
|
||||
double Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
|
||||
/**
|
||||
* Check if the relay object is currently alive or stopped due to a timeout.
|
||||
*
|
||||
* @return a bool value that is true if the motor has NOT timed out and should
|
||||
* still be running.
|
||||
*/
|
||||
bool Relay::IsAlive() const { return m_safetyHelper->IsAlive(); }
|
||||
|
||||
/**
|
||||
* Stop the motor associated with this PWM object.
|
||||
*
|
||||
* This is called by the MotorSafetyHelper object when it has a timeout for this
|
||||
* relay and needs to stop it from running.
|
||||
*/
|
||||
void Relay::StopMotor() { Set(kOff); }
|
||||
|
||||
/**
|
||||
* Enable/disable motor safety for this device.
|
||||
*
|
||||
* Turn on and off the motor safety option for this relay object.
|
||||
*
|
||||
* @param enabled True if motor safety is enforced for this object
|
||||
*/
|
||||
void Relay::SetSafetyEnabled(bool enabled) {
|
||||
m_safetyHelper->SetSafetyEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if motor safety is enabled for this object.
|
||||
*
|
||||
* @returns True if motor safety is enforced for this object
|
||||
*/
|
||||
bool Relay::IsSafetyEnabled() const {
|
||||
return m_safetyHelper->IsSafetyEnabled();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user