WPILibC++  unspecified
SafePWM.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2017 FIRST. 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 <memory>
11 
12 #include <llvm/raw_ostream.h>
13 
14 #include "MotorSafety.h"
15 #include "MotorSafetyHelper.h"
16 #include "PWM.h"
17 
18 namespace frc {
19 
27 class SafePWM : public PWM, public MotorSafety {
28  public:
29  explicit SafePWM(int channel);
30  virtual ~SafePWM() = default;
31 
32  void SetExpiration(double timeout);
33  double GetExpiration() const;
34  bool IsAlive() const;
35  void StopMotor();
36  bool IsSafetyEnabled() const;
37  void SetSafetyEnabled(bool enabled);
38  void GetDescription(llvm::raw_ostream& desc) const;
39 
40  virtual void SetSpeed(double speed);
41 
42  private:
43  std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
44 };
45 
46 } // namespace frc
virtual void SetSpeed(double speed)
Feed the MotorSafety timer when setting the speed.
Definition: SafePWM.cpp:89
Definition: Timer.cpp:18
double GetExpiration() const
Return the expiration time for the PWM object.
Definition: SafePWM.cpp:37
void SetExpiration(double timeout)
Set the expiration time for the PWM object.
Definition: SafePWM.cpp:28
void StopMotor()
Stop the motor associated with this PWM object.
Definition: SafePWM.cpp:55
Definition: MotorSafety.h:16
SafePWM(int channel)
Constructor for a SafePWM object taking a channel number.
Definition: SafePWM.cpp:18
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device.
Definition: SafePWM.cpp:64
bool IsSafetyEnabled() const
Check if motor safety is enabled for this object.
Definition: SafePWM.cpp:73
A safe version of the PWM class.
Definition: SafePWM.h:27
bool IsAlive() const
Check if the PWM object is currently alive or stopped due to a timeout.
Definition: SafePWM.cpp:47
Class implements the PWM generation in the FPGA.
Definition: PWM.h:40
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:33