Moves the HAL priority_ custom types to the hal namespace (#532)

There is a shim for backwards compatibility, just like the frc namespace.
As with the frc namespace, the library compiles without the shim.
This commit is contained in:
Thad House
2017-05-11 21:25:22 -07:00
committed by Peter Johnson
parent 16e71eac43
commit efec0c5cc3
47 changed files with 250 additions and 223 deletions

View File

@@ -17,7 +17,7 @@
using namespace frc;
std::set<MotorSafetyHelper*> MotorSafetyHelper::m_helperList;
priority_recursive_mutex MotorSafetyHelper::m_listMutex;
hal::priority_recursive_mutex MotorSafetyHelper::m_listMutex;
/**
* The constructor for a MotorSafetyHelper object.
@@ -37,12 +37,12 @@ MotorSafetyHelper::MotorSafetyHelper(MotorSafety* safeObject)
m_expiration = DEFAULT_SAFETY_EXPIRATION;
m_stopTime = Timer::GetFPGATimestamp();
std::lock_guard<priority_recursive_mutex> sync(m_listMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_listMutex);
m_helperList.insert(this);
}
MotorSafetyHelper::~MotorSafetyHelper() {
std::lock_guard<priority_recursive_mutex> sync(m_listMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_listMutex);
m_helperList.erase(this);
}
@@ -51,7 +51,7 @@ MotorSafetyHelper::~MotorSafetyHelper() {
* Resets the timer on this object that is used to do the timeouts.
*/
void MotorSafetyHelper::Feed() {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
m_stopTime = Timer::GetFPGATimestamp() + m_expiration;
}
@@ -60,7 +60,7 @@ void MotorSafetyHelper::Feed() {
* @param expirationTime The timeout value in seconds.
*/
void MotorSafetyHelper::SetExpiration(double expirationTime) {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
m_expiration = expirationTime;
}
@@ -69,7 +69,7 @@ void MotorSafetyHelper::SetExpiration(double expirationTime) {
* @return the timeout value in seconds.
*/
double MotorSafetyHelper::GetExpiration() const {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
return m_expiration;
}
@@ -79,7 +79,7 @@ double MotorSafetyHelper::GetExpiration() const {
* timed out.
*/
bool MotorSafetyHelper::IsAlive() const {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
return !m_enabled || m_stopTime > Timer::GetFPGATimestamp();
}
@@ -93,7 +93,7 @@ void MotorSafetyHelper::Check() {
DriverStation& ds = DriverStation::GetInstance();
if (!m_enabled || ds.IsDisabled() || ds.IsTest()) return;
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
if (m_stopTime < Timer::GetFPGATimestamp()) {
std::ostringstream desc;
m_safeObject->GetDescription(desc);
@@ -109,7 +109,7 @@ void MotorSafetyHelper::Check() {
* @param enabled True if motor safety is enforced for this object
*/
void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
m_enabled = enabled;
}
@@ -119,7 +119,7 @@ void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
* @return True if motor safety is enforced for this device
*/
bool MotorSafetyHelper::IsSafetyEnabled() const {
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_syncMutex);
return m_enabled;
}
@@ -129,7 +129,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const {
* any that have timed out.
*/
void MotorSafetyHelper::CheckMotors() {
std::lock_guard<priority_recursive_mutex> sync(m_listMutex);
std::lock_guard<hal::priority_recursive_mutex> sync(m_listMutex);
for (auto elem : m_helperList) {
elem->Check();
}