summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/top_cb.c
blob: bf92b204fb07b7d602dfc58981ee2c3b8c6abcc3 (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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT!
 *
 * Skeleton for top callbacks implementation.
 *
 * 
 */
#include "common.h"
#include "fsm.h"
#include "top.h"
#include "top_cb.h"
#include "getsamples.h"

/*
 * START =ok=>
 *  => GET_SAMPLES
 *   Go to take some samples. The sequence shall be adapt to take the correct number of samples.
 */
fsm_branch_t
top__START__ok (void)
{
    // Call the get samples state machine.

    // Blue color.
    if (top_data.team_color == BLUE_TEAM)
    {
        getsamples_start (BLUE_DISTRIBUTOR_X, BLUE_DISTRIBUTOR_Y,
                          top_data.sequence);
    }
    else
    {
        getsamples_start (RED_DISTRIBUTOR_X, RED_DISTRIBUTOR_Y,
                          top_data.sequence);
    }

    return top_next (START, ok);
}

/*
 * GET_SAMPLES =samples_took_ice_distributor_empty_not_enough_time=>
 *  => GO_TO_GOAL
 *   Some samples had been took and there is not enough time to get some ice.
 */
fsm_branch_t
top__GET_SAMPLES__samples_took_ice_distributor_empty_not_enough_time (void)
{
    return top_next (GET_SAMPLES, samples_took_ice_distributor_empty_not_enough_time);
}

/*
 * GET_SAMPLES =samples_took=>
 *  => GET_ICE
 *   The samples had been took and now the ice is missing.
 */
fsm_branch_t
top__GET_SAMPLES__samples_took (void)
{
    return top_next (GET_SAMPLES, samples_took);
}

/*
 * GET_SAMPLES =collector_full=>
 *  => GO_TO_GOAL
 *   All the room in the robot are full.
 */
fsm_branch_t
top__GET_SAMPLES__collector_full (void)
{
    return top_next (GET_SAMPLES, collector_full);
}

/*
 * GET_SAMPLES =samples_took_ice_distributor_empty_enough_time=>
 *  => GET_ADV_ICE
 *   Go to take ice in the adversary distributor because the one in our part of the table is empty.
 */
fsm_branch_t
top__GET_SAMPLES__samples_took_ice_distributor_empty_enough_time (void)
{
    return top_next (GET_SAMPLES, samples_took_ice_distributor_empty_enough_time);
}

/*
 * GO_TO_GOAL =samples_deposed_ice_distributor_empty=>
 *  => GET_ADV_ICE
 *   Go to get some adversary ice because our distributor is empty.
 */
fsm_branch_t
top__GO_TO_GOAL__samples_deposed_ice_distributor_empty (void)
{
    return top_next (GO_TO_GOAL, samples_deposed_ice_distributor_empty);
}

/*
 * GO_TO_GOAL =samples_deposed=>
 *  => GET_SAMPLES
 *   The samples had been deposed, it shall try to get more samples. This state will call the getsamples FSM and the moveFSM.
 */
fsm_branch_t
top__GO_TO_GOAL__samples_deposed (void)
{
    return top_next (GO_TO_GOAL, samples_deposed);
}

/*
 * GET_ICE =ice_took=>
 *  => GO_TO_GOAL
 *   The ice had been taken and the collector is full. The robot shall go to depose it into the goal.
 */
fsm_branch_t
top__GET_ICE__ice_took (void)
{
    return top_next (GET_ICE, ice_took);
}

/*
 * GET_ADV_ICE =ice_took_collector_not_full=>
 *  => GET_SAMPLES
 *   There is enough time to get some samples and go to the goal.
 */
fsm_branch_t
top__GET_ADV_ICE__ice_took_collector_not_full (void)
{
    return top_next (GET_ADV_ICE, ice_took_collector_not_full);
}

/*
 * GET_ADV_ICE =ice_took=>
 *  => GO_TO_GOAL
 *   The ice has been taken, now the robot shall depose it.
 */
fsm_branch_t
top__GET_ADV_ICE__ice_took (void)
{
    return top_next (GET_ADV_ICE, ice_took);
}