-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
50 lines (40 loc) · 1.61 KB
/
main.cpp
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
#include "StateMachine.h"
using namespace std;
int main ()
{
StateMachine state_machine(StateMachine::state_empty);
/*
// needed to start the highest-level SM. This will call on_entry and mark the start of the SM
p.start();
// go to Open, call on_exit on Empty, then action, then on_entry on Open
p.process_event(open_close()); pstate(p);
p.process_event(open_close()); pstate(p);
// will be rejected, wrong disk type
p.process_event(
cd_detected("louie, louie",DISK_DVD)); //pstate(p);
p.process_event(
cd_detected("louie, louie",DISK_CD)); //pstate(p);
p.process_event(play());
// at this point, Play is active
p.process_event(pause()); pstate(p);
// go back to Playing
p.process_event(end_pause()); pstate(p);
p.process_event(pause()); pstate(p);
p.process_event(stop()); pstate(p);
// event leading to the same state
// no action method called as it is not present in the transition table
p.process_event(stop()); pstate(p);
//std::cout << "stop fsm" << std::endl;
p.stop();
*/
state_machine.HandleEvent(StateMachine::event_open_close);
state_machine.HandleEvent(StateMachine::event_open_close);
state_machine.HandleEvent(StateMachine::event_cd_detected);
state_machine.HandleEvent(StateMachine::event_cd_detected);
state_machine.HandleEvent(StateMachine::event_play);
state_machine.HandleEvent(StateMachine::event_pause);
state_machine.HandleEvent(StateMachine::event_pause);
state_machine.HandleEvent(StateMachine::event_stop);
state_machine.HandleEvent(StateMachine::event_stop);
return 0;
}