WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
MotorSafetyHelper.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "ErrorBase.h"
11 #include "HAL/cpp/priority_mutex.h"
12 
13 #include <set>
14 
15 class MotorSafety;
16 
17 class MotorSafetyHelper : public ErrorBase {
18  public:
19  MotorSafetyHelper(MotorSafety *safeObject);
21  void Feed();
22  void SetExpiration(float expirationTime);
23  float GetExpiration() const;
24  bool IsAlive() const;
25  void Check();
26  void SetSafetyEnabled(bool enabled);
27  bool IsSafetyEnabled() const;
28  static void CheckMotors();
29 
30  private:
31  double m_expiration; // the expiration time for this object
32  bool m_enabled; // true if motor safety is enabled for this motor
33  double m_stopTime; // the FPGA clock value when this motor has expired
35  m_syncMutex; // protect accesses to the state for this object
36  MotorSafety *m_safeObject; // the object that is using the helper
37  // List of all existing MotorSafetyHelper objects.
38  static std::set<MotorSafetyHelper*> m_helperList;
40  m_listMutex; // protect accesses to the list of helpers
41 };
MotorSafetyHelper(MotorSafety *safeObject)
The constructor for a MotorSafetyHelper object.
Definition: MotorSafetyHelper.cpp:34
Definition: MotorSafety.h:14
void Feed()
Feed the motor safety object.
Definition: MotorSafetyHelper.cpp:53
static void CheckMotors()
Check the motors to see if any have timed out.
Definition: MotorSafetyHelper.cpp:134
bool IsSafetyEnabled() const
Return the state of the motor safety enabled flag Return if the motor safety is currently enabled for...
Definition: MotorSafetyHelper.cpp:123
Definition: priority_mutex.h:22
bool IsAlive() const
Determine if the motor is still operating or has timed out.
Definition: MotorSafetyHelper.cpp:81
Base class for most objects.
Definition: ErrorBase.h:66
void Check()
Check if this motor has exceeded its timeout.
Definition: MotorSafetyHelper.cpp:94
float GetExpiration() const
Retrieve the timeout value for the corresponding motor safety object.
Definition: MotorSafetyHelper.cpp:71
Definition: MotorSafetyHelper.h:17
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device Turn on and off the motor safety option for this PWM obje...
Definition: MotorSafetyHelper.cpp:113
void SetExpiration(float expirationTime)
Set the expiration time for the corresponding motor safety object.
Definition: MotorSafetyHelper.cpp:62