-
Notifications
You must be signed in to change notification settings - Fork 41
/
CentrifugeTest.h
64 lines (54 loc) · 2.03 KB
/
CentrifugeTest.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
#ifndef _CENTRIFUGE_TEST_H
#define _CENTRIFUGE_TEST_H
#include "SelfTest.h"
// @brief CentrifugeTest shows StateMachine features including state machine
// inheritance, state function override, and guard/entry/exit actions. SelfTest
// provides common states shared with CentrifugeTest.
class CentrifugeTest : public SelfTest
{
public:
CentrifugeTest();
virtual void Start();
void Poll();
BOOL IsPollActive() { return m_pollActive; }
private:
BOOL m_pollActive;
INT m_speed;
void StartPoll() { m_pollActive = TRUE; }
void StopPoll() { m_pollActive = FALSE; }
// State enumeration order must match the order of state method entries
// in the state map.
enum States
{
// Continue state numbering using the last SelfTest::States enum value
ST_START_TEST = SelfTest::ST_MAX_STATES,
ST_ACCELERATION,
ST_WAIT_FOR_ACCELERATION,
ST_DECELERATION,
ST_WAIT_FOR_DECELERATION,
ST_MAX_STATES
};
// Define the state machine state functions with event data type
STATE_DECLARE(CentrifugeTest, Idle, NoEventData)
STATE_DECLARE(CentrifugeTest, StartTest, NoEventData)
GUARD_DECLARE(CentrifugeTest, GuardStartTest, NoEventData)
STATE_DECLARE(CentrifugeTest, Acceleration, NoEventData)
STATE_DECLARE(CentrifugeTest, WaitForAcceleration, NoEventData)
EXIT_DECLARE(CentrifugeTest, ExitWaitForAcceleration)
STATE_DECLARE(CentrifugeTest, Deceleration, NoEventData)
STATE_DECLARE(CentrifugeTest, WaitForDeceleration, NoEventData)
EXIT_DECLARE(CentrifugeTest, ExitWaitForDeceleration)
// State map to define state object order. Each state map entry defines a
// state object.
BEGIN_STATE_MAP_EX
STATE_MAP_ENTRY_ALL_EX(&Idle, 0, &EntryIdle, 0)
STATE_MAP_ENTRY_EX(&Completed)
STATE_MAP_ENTRY_EX(&Failed)
STATE_MAP_ENTRY_ALL_EX(&StartTest, &GuardStartTest, 0, 0)
STATE_MAP_ENTRY_EX(&Acceleration)
STATE_MAP_ENTRY_ALL_EX(&WaitForAcceleration, 0, 0, &ExitWaitForAcceleration)
STATE_MAP_ENTRY_EX(&Deceleration)
STATE_MAP_ENTRY_ALL_EX(&WaitForDeceleration, 0, 0, &ExitWaitForDeceleration)
END_STATE_MAP_EX
};
#endif