WPILib 2012
WPILibRoboticsLibraryforFRC
MotorSafetyHelper.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __MOTOR_SAFETY_HELPER__
00008 #define __MOTOR_SAFETY_HELPER__
00009 
00010 #include "ErrorBase.h"
00011 #include <semLib.h>
00012 
00013 class MotorSafety;
00014 
00015 class MotorSafetyHelper : public ErrorBase
00016 {
00017 public:
00018         MotorSafetyHelper(MotorSafety *safeObject);
00019         ~MotorSafetyHelper();
00020         void Feed();
00021         void SetExpiration(float expirationTime);
00022         float GetExpiration();
00023         bool IsAlive();
00024         void Check();
00025         void SetSafetyEnabled(bool enabled);
00026         bool IsSafetyEnabled();
00027         static void CheckMotors();
00028 private:
00029         double m_expiration;                    // the expiration time for this object
00030         bool m_enabled;                                 // true if motor safety is enabled for this motor
00031         double m_stopTime;                              // the FPGA clock value when this motor has expired
00032         MotorSafety *m_safeObject;              // the object that is using the helper
00033         MotorSafetyHelper *m_nextHelper; // next object in the list of MotorSafetyHelpers
00034         static MotorSafetyHelper *m_headHelper; // the head of the list of MotorSafetyHelper objects
00035         static SEM_ID m_listMutex;              // protect accesses to the list of helpers
00036 };
00037 
00038 #endif
 All Classes Functions Variables