WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
MotorSafetyHelper.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef __MOTOR_SAFETY_HELPER__
8 #define __MOTOR_SAFETY_HELPER__
9 
10 #include "ErrorBase.h"
11 #include "Synchronized.h"
12 #include <semLib.h>
13 
14 class MotorSafety;
15 
17 {
18 public:
19  MotorSafetyHelper(MotorSafety *safeObject);
21  void Feed();
22  void SetExpiration(float expirationTime);
23  float GetExpiration();
24  bool IsAlive();
25  void Check();
26  void SetSafetyEnabled(bool enabled);
27  bool IsSafetyEnabled();
28  static void CheckMotors();
29 private:
30  double m_expiration; // the expiration time for this object
31  bool m_enabled; // true if motor safety is enabled for this motor
32  double m_stopTime; // the FPGA clock value when this motor has expired
33  ReentrantSemaphore m_syncMutex; // protect accesses to the state for this object
34  MotorSafety *m_safeObject; // the object that is using the helper
35  MotorSafetyHelper *m_nextHelper; // next object in the list of MotorSafetyHelpers
36  static MotorSafetyHelper *m_headHelper; // the head of the list of MotorSafetyHelper objects
37  static ReentrantSemaphore m_listMutex; // protect accesses to the list of helpers
38 };
39 
40 #endif
MotorSafetyHelper(MotorSafety *safeObject)
Definition: MotorSafetyHelper.cpp:28
Definition: MotorSafety.h:11
static void CheckMotors()
Definition: MotorSafetyHelper.cpp:149
float GetExpiration()
Definition: MotorSafetyHelper.cpp:83
Definition: ErrorBase.h:37
void Check()
Definition: MotorSafetyHelper.cpp:105
Definition: MotorSafetyHelper.h:16
void SetSafetyEnabled(bool enabled)
Definition: MotorSafetyHelper.cpp:127
Definition: Synchronized.h:31
bool IsSafetyEnabled()
Definition: MotorSafetyHelper.cpp:138
bool IsAlive()
Definition: MotorSafetyHelper.cpp:93