From a87f059b7acdc9f00b2102249a647a51f8389de4 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Mon, 14 Apr 2008 12:00:59 +0200 Subject: * 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. --- digital/io/src/top_cb.c | 79 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 27 deletions(-) (limited to 'digital/io/src/top_cb.c') 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); } -- cgit v1.2.3