WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SafePWM.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 "MotorSafety.h"
11 #include "PWM.h"
12 #include "MotorSafetyHelper.h"
13 #include <memory>
14 #include <sstream>
15 
25 class SafePWM : public PWM, public MotorSafety {
26  public:
27  explicit SafePWM(uint32_t channel);
28  virtual ~SafePWM() = default;
29 
30  void SetExpiration(float timeout);
31  float GetExpiration() const;
32  bool IsAlive() const;
33  void StopMotor();
34  bool IsSafetyEnabled() const;
35  void SetSafetyEnabled(bool enabled);
36  void GetDescription(std::ostringstream& desc) const;
37 
38  virtual void SetSpeed(float speed);
39 
40  private:
41  std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
42 };
SafePWM(uint32_t channel)
Constructor for a SafePWM object taking a channel number.
Definition: SafePWM.cpp:15
bool IsSafetyEnabled() const
Check if motor safety is enabled for this object.
Definition: SafePWM.cpp:63
Definition: MotorSafety.h:14
Class implements the PWM generation in the FPGA.
Definition: PWM.h:34
A safe version of the PWM class.
Definition: SafePWM.h:25
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device Turn on and off the motor safety option for this PWM obje...
Definition: SafePWM.cpp:55
void SetExpiration(float timeout)
Set the expiration time for the PWM object.
Definition: SafePWM.cpp:24
virtual void SetSpeed(float speed)
Feed the MotorSafety timer when setting the speed.
Definition: SafePWM.cpp:78
bool IsAlive() const
Check if the PWM object is currently alive or stopped due to a timeout.
Definition: SafePWM.cpp:40
void StopMotor()
Stop the motor associated with this PWM object.
Definition: SafePWM.cpp:48
float GetExpiration() const
Return the expiration time for the PWM object.
Definition: SafePWM.cpp:32