7 #include "MotorSafetyHelper.h"
9 #include "DriverStation.h"
10 #include "MotorSafety.h"
12 #include "WPIErrors.h"
30 m_safeObject = safeObject;
32 m_expiration = DEFAULT_SAFETY_EXPIRATION;
33 m_stopTime = Timer::GetFPGATimestamp();
36 m_nextHelper = m_headHelper;
41 MotorSafetyHelper::~MotorSafetyHelper()
44 if (m_headHelper ==
this)
46 m_headHelper = m_nextHelper;
52 while (cur !=
this && cur != NULL)
53 prev = cur, cur = cur->m_nextHelper;
55 prev->m_nextHelper = cur->m_nextHelper;
63 void MotorSafetyHelper::Feed()
66 m_stopTime = Timer::GetFPGATimestamp() + m_expiration;
73 void MotorSafetyHelper::SetExpiration(
float expirationTime)
76 m_expiration = expirationTime;
96 return !m_enabled || m_stopTime > Timer::GetFPGATimestamp();
108 if (!m_enabled || ds->IsDisabled() || ds->IsTest())
return;
111 if (m_stopTime < Timer::GetFPGATimestamp())
115 m_safeObject->GetDescription(desc);
116 snprintf(buf, 128,
"%s... Output not updated often enough.", desc);
117 wpi_setWPIErrorWithContext(Timeout, buf);
118 m_safeObject->StopMotor();
152 for (
MotorSafetyHelper *msh = m_headHelper; msh != NULL; msh = msh->m_nextHelper)
MotorSafetyHelper(MotorSafety *safeObject)
void SetSafetyEnabled(bool enabled)
static DriverStation * GetInstance()
static void CheckMotors()