summaryrefslogtreecommitdiff
path: root/digital/io/src/top_cb.c
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-14 12:00:59 +0200
committerJérémy Dufour2008-04-14 12:00:59 +0200
commita87f059b7acdc9f00b2102249a647a51f8389de4 (patch)
treed542d1e6b560a69ffd7319375756e8d2fbb71fb1 /digital/io/src/top_cb.c
parent197fb2f8192e083df38427a1dfa4b67ddebde525 (diff)
* digital/io/src
* asserv - improve the API of the arm functions to ease usage ; - add a new function to put the arm to the position to close the input hole. * get sample FSM - keep only the needed and real events ; - correctly names the states ; - improve the function to select where to put the samples ; * general - add headers for some standard configuration defines. * trap - add another entry to the enum to know its length.
Diffstat (limited to 'digital/io/src/top_cb.c')
-rw-r--r--digital/io/src/top_cb.c79
1 files changed, 52 insertions, 27 deletions
diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c
index bb2f6c1d..ff45c290 100644
--- a/digital/io/src/top_cb.c
+++ b/digital/io/src/top_cb.c
@@ -34,15 +34,20 @@ top__BACKWARD__collector_full (void)
fsm_branch_t
top__BACKWARD__ended (void)
{
+ /* Generic get sample data */
+ struct getsamples_data_t get_sample_data;
+ get_sample_data.event = TOP_EVENT_ice_took;
+ get_sample_data.sample_bitfield = ~top_data.boxes_used; // XXX
+ get_sample_data.distributor_y = ICE_DISTRIBUTOR_Y;
if (top_data.team_color)
{
- getsamples_start ( ICE_DISTRIBUTOR_LEFT, ICE_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_ice_took);
+ get_sample_data.distributor_x = ICE_DISTRIBUTOR_LEFT;
+ getsamples_start (get_sample_data);
}
else
{
- getsamples_start ( ICE_DISTRIBUTOR_RIGHT, ICE_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_ice_took);
+ get_sample_data.distributor_x = ICE_DISTRIBUTOR_RIGHT;
+ getsamples_start (get_sample_data);
}
return top_next (BACKWARD, ended);
}
@@ -55,17 +60,21 @@ top__BACKWARD__ended (void)
fsm_branch_t
top__BACKWARD__ice_dist_empty (void)
{
+ /* Generic get sample data */
+ struct getsamples_data_t get_sample_data;
+ get_sample_data.event = TOP_EVENT_ice_took;
+ get_sample_data.sample_bitfield = ~top_data.boxes_used; // XXX
+ get_sample_data.distributor_y = ICE_DISTRIBUTOR_Y;
if (top_data.team_color)
{
- getsamples_start ( ICE_DISTRIBUTOR_RIGHT, ICE_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_ice_took);
+ get_sample_data.distributor_x = ICE_DISTRIBUTOR_LEFT;
+ getsamples_start (get_sample_data);
}
else
{
- getsamples_start ( ICE_DISTRIBUTOR_LEFT, ICE_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_ice_took);
+ get_sample_data.distributor_x = ICE_DISTRIBUTOR_RIGHT;
+ getsamples_start (get_sample_data);
}
-
return top_next (BACKWARD, ice_dist_empty);
}
@@ -93,17 +102,22 @@ top__GET_ICE__ice_took (void)
fsm_branch_t
top__START__ok (void)
{
+ /* Generic get sample data */
+ struct getsamples_data_t get_sample_data;
+ get_sample_data.event = TOP_EVENT_samples_took;
+ get_sample_data.sample_bitfield = ~top_data.boxes_used; // XXX
if (top_data.team_color == BLUE_TEAM)
{
- getsamples_start ( BLUE_DISTRIBUTOR_X, BLUE_DISTRIBUTOR_Y ,
- ~top_data.boxes_used, TOP_EVENT_samples_took);
+ get_sample_data.distributor_x = BLUE_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = BLUE_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
}
else
{
- getsamples_start ( RED_DISTRIBUTOR_X, RED_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_samples_took);
+ get_sample_data.distributor_x = RED_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = RED_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
}
-
return top_next (START, ok);
}
@@ -115,15 +129,21 @@ top__START__ok (void)
fsm_branch_t
top__GO_TO_GOAL__samples_deposed (void)
{
+ /* Generic get sample data */
+ struct getsamples_data_t get_sample_data;
+ get_sample_data.event = TOP_EVENT_samples_took;
+ get_sample_data.sample_bitfield = ~top_data.boxes_used; // XXX
if (top_data.team_color == BLUE_TEAM)
{
- getsamples_start ( BLUE_DISTRIBUTOR_X, BLUE_DISTRIBUTOR_Y ,
- ~top_data.boxes_used, TOP_EVENT_samples_took);
+ get_sample_data.distributor_x = BLUE_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = BLUE_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
}
else
{
- getsamples_start ( RED_DISTRIBUTOR_X, RED_DISTRIBUTOR_Y,
- ~top_data.boxes_used, TOP_EVENT_samples_took);
+ get_sample_data.distributor_x = RED_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = RED_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
}
return top_next (GO_TO_GOAL, samples_deposed);
}
@@ -155,17 +175,22 @@ top__GET_SAMPLES__samples_took (void)
// Call the get samples state machine.
// Blue color.
+ /* Generic get sample data */
+ struct getsamples_data_t get_sample_data;
+ get_sample_data.event = TOP_EVENT_samples_took;
+ get_sample_data.sample_bitfield = top_data.sequence; // XXX
if (top_data.team_color == BLUE_TEAM)
- {
- getsamples_start (BLUE_DISTRIBUTOR_X, BLUE_DISTRIBUTOR_Y,
- top_data.sequence, TOP_EVENT_samples_took);
- }
+ {
+ get_sample_data.distributor_x = BLUE_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = BLUE_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
+ }
else
- {
- getsamples_start (RED_DISTRIBUTOR_X, RED_DISTRIBUTOR_Y,
- top_data.sequence, TOP_EVENT_samples_took);
- }
-
+ {
+ get_sample_data.distributor_x = RED_DISTRIBUTOR_X;
+ get_sample_data.distributor_y = RED_DISTRIBUTOR_Y;
+ getsamples_start (get_sample_data);
+ }
return top_next (START, ok);
}