-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.h
More file actions
60 lines (43 loc) · 1.16 KB
/
Command.h
File metadata and controls
60 lines (43 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef COMMAND_H
#define COMMAND_H
#include <Arduino.h>
class Command {
friend class PausableCommand;
public:
/* Constructors */
Command();
Command(const String name);
String name;
/* Timeout related */
void setTimeout(unsigned long timeout);
virtual unsigned long getTime();
bool isTimedOut();
/* Code to execute once on first iteration
* Typically overridden by the user */
virtual void initialize() = 0;
virtual void _initialize();
/* Code to execute every iteration
* Typically overridden by the user */
virtual void execute() = 0;
virtual void _execute();
/* Code to check if the command is finished */
virtual bool isFinished() = 0;
/* Checks if the command is running */
bool isRunning();
/* Code to run once after isFinished is false */
virtual void end() = 0;
virtual void _end();
/* Execute an iteration */
virtual bool cycle();
/* Schedule the command */
void start();
/* Set if the command should run in parallel */
void setParallel(bool value);
/* Check the parallel flag */
bool isParallel();
private:
bool initialized, running, parallel;
unsigned long startTime; //In msec
unsigned long timeout; //In msec
};
#endif