reworked watchdog
This commit is contained in:
@ -2,49 +2,52 @@
|
||||
#define WATCHDOG_WATCHDOG_H_
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class WatchdogTask {
|
||||
public:
|
||||
enum class States {
|
||||
NOT_STARTED,
|
||||
RUNNING,
|
||||
SUSPENDED,
|
||||
FAULTY
|
||||
};
|
||||
public:
|
||||
enum class States { NOT_STARTED, RUNNING, SUSPENDED, FAULTY };
|
||||
|
||||
enum class LoopResult {
|
||||
OK,
|
||||
SUSPEND_RQ,
|
||||
CANCEL_RQ,
|
||||
RESTART_RQ,
|
||||
TIMEOUT,
|
||||
HUNG_UP,
|
||||
FAULT
|
||||
};
|
||||
enum class LoopResult {
|
||||
OK,
|
||||
START_REQ,
|
||||
START_WITH_WATCH_REQ,
|
||||
SUSPEND_REQ,
|
||||
CANCEL_REQ,
|
||||
TIMEOUT,
|
||||
HUNG_UP,
|
||||
FAULT
|
||||
};
|
||||
|
||||
WatchdogTask();
|
||||
WatchdogTask();
|
||||
|
||||
virtual ~WatchdogTask();
|
||||
virtual ~WatchdogTask();
|
||||
|
||||
int performOperation();
|
||||
private:
|
||||
int fd = 0;
|
||||
int performOperation();
|
||||
|
||||
bool obswRunning = false;
|
||||
bool watchdogRunning = false;
|
||||
bool printNotRunningLatch = false;
|
||||
std::array<uint8_t, 64> buf;
|
||||
States state = States::NOT_STARTED;
|
||||
private:
|
||||
int fd = 0;
|
||||
|
||||
LoopResult watchdogLoop();
|
||||
LoopResult pollEvent(struct pollfd& waiter);
|
||||
LoopResult parseCommandByte(ssize_t readLen);
|
||||
bool obswRunning = false;
|
||||
bool watchingObsw = false;
|
||||
bool printNotRunningLatch = false;
|
||||
std::array<uint8_t, 64> buf;
|
||||
std::optional<std::chrono::time_point<std::chrono::system_clock>> notRunningStart;
|
||||
States state = States::NOT_STARTED;
|
||||
|
||||
int performRunningOperation();
|
||||
int performNotRunningOperation(LoopResult type);
|
||||
int performSuspendOperation();
|
||||
// Primary loop. Takes care of delaying, and reading from the communication pipe and translating
|
||||
// messages to loop results.
|
||||
LoopResult watchdogLoop();
|
||||
bool stateMachine(LoopResult result);
|
||||
LoopResult pollEvent(struct pollfd& waiter);
|
||||
LoopResult parseCommand(ssize_t readLen);
|
||||
|
||||
int performRunningOperation();
|
||||
int performNotRunningOperation(LoopResult type);
|
||||
int performSuspendOperation();
|
||||
};
|
||||
|
||||
#endif /* WATCHDOG_WATCHDOG_H_ */
|
||||
|
Reference in New Issue
Block a user