-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRobotLifeCycle.h
95 lines (54 loc) · 1.73 KB
/
RobotLifeCycle.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#define STATUS_INVERVAL_DELAY 200
#define STATUS_INTERVAL_RANDOM_FIX 30
#define UNIT_MAX_HEALTH 100
#define UNIT_HEALING_TRIGGER 10
#define GROUP_FRIENDLY 1
#define MESSAGE_TO_ALL 0
/// admin stuff here
#define ADMIN_SET_ID 10
#define ADMIN_SET_GROUP 11
#define ADMIN_SET_HEALTH 12
#define ADMIN_SET_HIT_POINTS 13
#define ADMIN_GET_STATUS 14
#define SENDER_ADMIN 15
/// general commands
#define COMMAND_ATTACK 2
#define COMMAND_HEAL 3
#define COMMAND_FOLLOW 4
#define COMMAND_STATUS 5
#define COMMAND_STATUS_TOWER 7
#define LEDRGB_TIMOUT 250
typedef void(*CallbackOnAttack)(IRMessage);
typedef void(*CallbackOnStatus)(IRMessage);
typedef void(*CallbackOnHeal)(IRMessage);
typedef void(*CallbackOnStatusTimer)();
class RobotLifeCycle {
private:
unsigned long _lastStatusEvent;
unsigned long _rgbStatusTimer;
short _statusIntervalDelay;
IRMessage _message;
RobotModel * _robotModel;
RobotController * _robotController;
IRMessaging * _irMessaging;
LedRGBIndicator * _ledRGB;
CallbackOnStatusTimer _callbackOnStatusTimer;
CallbackOnAttack _callbackOnAttack;
CallbackOnStatus _callbackOnStatus;
CallbackOnHeal _callbackOnHeal;
void _handleTimers();
void _checkForIRMessage();
public:
void tick();
void onStatus(CallbackOnStatus callback);
void onHeal(CallbackOnHeal callback);
void onAttack(CallbackOnAttack callback);
void onStatusTimer(CallbackOnStatusTimer callback);
void setStatusTiming(short interval);
RobotLifeCycle();
void attachRobotModel(RobotModel &robotModel);
void attachRobotController(RobotController &robotController );
void attachIRMessaging(IRMessaging &irMessaging);
void attachLedRGB(LedRGBIndicator &ledRGB);
};