blob: 22b5cab1010103d6bec2c4273a84e47e5bafd5c1 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
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 WATCHDOG_H
8#define WATCHDOG_H
9
10#include "ChipObject.h"
11#include "SensorBase.h"
12#include "Base.h"
13
14/**
15 * Watchdog timer class.
16 * The watchdog timer is designed to keep the robots safe. The idea is that the robot program must
17 * constantly "feed" the watchdog otherwise it will shut down all the motor outputs. That way if a
18 * program breaks, rather than having the robot continue to operate at the last known speed, the
19 * motors will be shut down.
20 *
21 * This is serious business. Don't just disable the watchdog. You can't afford it!
22 *
23 * http://thedailywtf.com/Articles/_0x2f__0x2f_TODO_0x3a__Uncomment_Later.aspx
24 */
25class Watchdog : public SensorBase
26{
27public:
28 static const double kDefaultWatchdogExpiration = 0.5;
29
30 Watchdog();
31 virtual ~Watchdog();
32 bool Feed();
33 void Kill();
34 double GetTimer();
35 double GetExpiration();
36 void SetExpiration(double expiration);
37 bool GetEnabled();
38 void SetEnabled(bool enabled);
39 bool IsAlive();
40 bool IsSystemActive();
41
42private:
43 tWatchdog *m_fpgaWatchDog;
44 DISALLOW_COPY_AND_ASSIGN(Watchdog);
45};
46
47#endif