#include <Watchdog.h>
Public Member Functions | |
Watchdog () | |
virtual | ~Watchdog () |
bool | Feed () |
void | Kill () |
double | GetTimer () |
double | GetExpiration () |
void | SetExpiration (double expiration) |
bool | GetEnabled () |
void | SetEnabled (bool enabled) |
bool | IsAlive () |
bool | IsSystemActive () |
Public Member Functions inherited from SensorBase | |
SensorBase () | |
virtual | ~SensorBase () |
Public Member Functions inherited from ErrorBase | |
virtual Error & | GetError () |
Retrieve the current error. Get the current error information associated with this sensor. | |
virtual const Error & | GetError () const |
virtual void | SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set error information associated with a C library call that set an error to the "errno" global variable. More... | |
virtual void | SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated from the nivision Imaq API. More... | |
virtual void | SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | CloneError (ErrorBase *rhs) const |
virtual void | ClearError () const |
Clear the current error information associated with this sensor. | |
virtual bool | StatusIsFatal () const |
Check if the current error code represents a fatal error. More... | |
Static Public Attributes | |
static constexpr double | kDefaultWatchdogExpiration = 0.5 |
Static Public Attributes inherited from SensorBase | |
static const uint32_t | kSystemClockTicksPerMicrosecond = 40 |
static const uint32_t | kDigitalChannels = 14 |
static const uint32_t | kAnalogChannels = 8 |
static const uint32_t | kAnalogModules = 2 |
static const uint32_t | kDigitalModules = 2 |
static const uint32_t | kSolenoidChannels = 8 |
static const uint32_t | kSolenoidModules = 2 |
static const uint32_t | kPwmChannels = 10 |
static const uint32_t | kRelayChannels = 8 |
static const uint32_t | kChassisSlots = 8 |
Additional Inherited Members | |
Static Public Member Functions inherited from SensorBase | |
static void | DeleteSingletons () |
static uint32_t | GetDefaultAnalogModule () |
static uint32_t | GetDefaultDigitalModule () |
static uint32_t | GetDefaultSolenoidModule () |
static bool | CheckAnalogModule (uint8_t moduleNumber) |
static bool | CheckDigitalModule (uint8_t moduleNumber) |
static bool | CheckPWMModule (uint8_t moduleNumber) |
static bool | CheckRelayModule (uint8_t moduleNumber) |
static bool | CheckSolenoidModule (uint8_t moduleNumber) |
static bool | CheckDigitalChannel (uint32_t channel) |
static bool | CheckRelayChannel (uint32_t channel) |
static bool | CheckPWMChannel (uint32_t channel) |
static bool | CheckAnalogChannel (uint32_t channel) |
static bool | CheckSolenoidChannel (uint32_t channel) |
Static Public Member Functions inherited from ErrorBase | |
static void | SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static void | SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static Error & | GetGlobalError () |
Protected Member Functions inherited from SensorBase | |
void | AddToSingletonList () |
Protected Member Functions inherited from ErrorBase | |
ErrorBase () | |
Initialize the instance status to 0 for now. | |
Protected Attributes inherited from ErrorBase | |
Error | m_error |
Static Protected Attributes inherited from ErrorBase | |
static SEM_ID | _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE) |
static Error | _globalError |
Watchdog timer class. The watchdog timer is designed to keep the robots safe. The idea is that the robot program must constantly "feed" the watchdog otherwise it will shut down all the motor outputs. That way if a program breaks, rather than having the robot continue to operate at the last known speed, the motors will be shut down.
This is serious business. Don't just disable the watchdog. You can't afford it!
http://thedailywtf.com/Articles/_0x2f__0x2f_TODO_0x3a__Uncomment_Later.aspx
Watchdog::Watchdog | ( | ) |
The Watchdog is born.
|
virtual |
Time to bury him in the back yard.
bool Watchdog::Feed | ( | ) |
Throw the dog a bone.
When everything is going well, you feed your dog when you get home. Let's hope you don't drive your car off a bridge on the way home... Your dog won't get fed and he will starve to death.
By the way, it's not cool to ask the neighbor (some random task) to feed your dog for you. He's your responsibility!
bool Watchdog::GetEnabled | ( | ) |
Find out if the watchdog is currently enabled or disabled (mortal or immortal).
double Watchdog::GetExpiration | ( | ) |
Read what the current expiration is.
double Watchdog::GetTimer | ( | ) |
Read how long it has been since the watchdog was last fed.
bool Watchdog::IsAlive | ( | ) |
Check in on the watchdog and make sure he's still kicking.
This indicates that your watchdog is allowing the system to operate. It is still possible that the network communications is not allowing the system to run, but you can check this to make sure it's not your fault. Check IsSystemActive() for overall system status.
If the watchdog is disabled, then your watchdog is immortal.
bool Watchdog::IsSystemActive | ( | ) |
Check on the overall status of the system.
void Watchdog::Kill | ( | ) |
Put the watchdog out of its misery.
Don't wait for your dying robot to starve when there is a problem. Kill it quickly, cleanly, and humanely.
void Watchdog::SetEnabled | ( | bool | enabled | ) |
Enable or disable the watchdog timer.
When enabled, you must keep feeding the watchdog timer to keep the watchdog active, and hence the dangerous parts (motor outputs, etc.) can keep functioning. When disabled, the watchdog is immortal and will remain active even without being fed. It will also ignore any kill commands while disabled.
enabled | Enable or disable the watchdog. |
void Watchdog::SetExpiration | ( | double | expiration | ) |
Configure how many seconds your watchdog can be neglected before it starves to death.
expiration | The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). |