jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame^] | 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 __SAFE_PWM__
|
| 8 | #define __SAFE_PWM__
|
| 9 |
|
| 10 | #include "MotorSafety.h"
|
| 11 | #include "PWM.h"
|
| 12 |
|
| 13 | class MotorSafetyHelper;
|
| 14 |
|
| 15 | /**
|
| 16 | * A safe version of the PWM class.
|
| 17 | * It is safe because it implements the MotorSafety interface that provides timeouts
|
| 18 | * in the event that the motor value is not updated before the expiration time.
|
| 19 | * This delegates the actual work to a MotorSafetyHelper object that is used for all
|
| 20 | * objects that implement MotorSafety.
|
| 21 | */
|
| 22 | class SafePWM: public PWM, public MotorSafety
|
| 23 | {
|
| 24 | public:
|
| 25 | explicit SafePWM(UINT32 channel);
|
| 26 | SafePWM(UINT8 moduleNumber, UINT32 channel);
|
| 27 | ~SafePWM();
|
| 28 |
|
| 29 | void SetExpiration(float timeout);
|
| 30 | float GetExpiration();
|
| 31 | bool IsAlive();
|
| 32 | void StopMotor();
|
| 33 | bool IsSafetyEnabled();
|
| 34 | void SetSafetyEnabled(bool enabled);
|
| 35 | void GetDescription(char *desc);
|
| 36 |
|
| 37 | virtual void SetSpeed(float speed);
|
| 38 | private:
|
| 39 | void InitSafePWM();
|
| 40 | MotorSafetyHelper *m_safetyHelper;
|
| 41 | };
|
| 42 |
|
| 43 | #endif
|