summaryrefslogtreecommitdiff
path: root/tools/dfagen/examples/ex2_robot.c
blob: 93281f1ab1da8bf6f9c72f00da5c9bc4d7192337 (plain)
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
/* Example 2 extra code. */
#include "ex2_robot.h"

#include <stdio.h>

int
main (void)
{
    robot_t robot;
    ex2_init (&robot);
    robot.bottle = 3;
    puts ("A glass:");
    robot.ice = 1;
    ex2_handle_event (&robot, EX2_EVENT_command);
    ex2_handle_event (&robot, EX2_EVENT_ice_dropped);
    ex2_handle_event (&robot, EX2_EVENT_glass_filled);
    puts ("Another glass:");
    robot.ice = 0;
    ex2_handle_event (&robot, EX2_EVENT_command);
    ex2_handle_event (&robot, EX2_EVENT_glass_filled);
    puts ("Yet another glass:");
    robot.ice = 0;
    ex2_handle_event (&robot, EX2_EVENT_command);
    ex2_handle_event (&robot, EX2_EVENT_glass_filled);
    puts ("There is no more liquid:");
    robot.ice = 0;
    ex2_handle_event (&robot, EX2_EVENT_command);
    puts ("Replace bootle:");
    ex2_handle_event (&robot, EX2_EVENT_replace_bottle);
    puts ("Another glass:");
    robot.ice = 1;
    ex2_handle_event (&robot, EX2_EVENT_command);
    puts ("Commands are ignore while the robot is fonctionning:");
    ex2_handle_event (&robot, EX2_EVENT_command);
    ex2_handle_event (&robot, EX2_EVENT_ice_dropped);
    ex2_handle_event (&robot, EX2_EVENT_command);
    ex2_handle_event (&robot, EX2_EVENT_glass_filled);
    return 0;
}