From b49d8d7fcb271f855a976125826a5a6f1459ace7 Mon Sep 17 00:00:00 2001 From: Jerome Jutteau Date: Fri, 29 Mar 2013 10:11:32 +0100 Subject: digital/io-hub/src/apbirthday: fix indentation --- digital/io-hub/src/apbirthday/candles.cc | 238 +++++++++++++++---------------- digital/io-hub/src/apbirthday/candles.hh | 36 ++--- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/digital/io-hub/src/apbirthday/candles.cc b/digital/io-hub/src/apbirthday/candles.cc index 793053aa..429d8876 100644 --- a/digital/io-hub/src/apbirthday/candles.cc +++ b/digital/io-hub/src/apbirthday/candles.cc @@ -33,131 +33,131 @@ extern "C" { Candles::Candles (int calif_mode) { - int i; - /* Init candles color. */ - for (i = 0; i < CANDLES_NB; i++) - { - color[i] = CANDLE_UNKNOWN; - state[i] = CANDLE_UNPUNCHED; - } - color[0] = CANDLE_BLUE; - color[8] = CANDLE_BLUE; - color[7] = CANDLE_RED; - color[19] = CANDLE_RED; - if (calif_mode) - { - color[12] = CANDLE_WHITE; - color[13] = CANDLE_WHITE; - color[14] = CANDLE_WHITE; - color[15] = CANDLE_WHITE; - } - actual_pos[FLOOR_NEAR] = CANDLES_NB; - actual_pos[FLOOR_FAR] = CANDLES_NB; + int i; + /* Init candles color. */ + for (i = 0; i < CANDLES_NB; i++) + { + color[i] = CANDLE_UNKNOWN; + state[i] = CANDLE_UNPUNCHED; + } + color[0] = CANDLE_BLUE; + color[8] = CANDLE_BLUE; + color[7] = CANDLE_RED; + color[19] = CANDLE_RED; + if (calif_mode) + { + color[12] = CANDLE_WHITE; + color[13] = CANDLE_WHITE; + color[14] = CANDLE_WHITE; + color[15] = CANDLE_WHITE; + } + actual_pos[FLOOR_NEAR] = CANDLES_NB; + actual_pos[FLOOR_FAR] = CANDLES_NB; } void Candles::blow (int candle) { - if (CANDLE_IS_FAR(candle)) - actual_pos[FLOOR_FAR] = candle; - else - actual_pos[FLOOR_NEAR] = candle; - deduce (); - robot->fsm_queue.post (FSM_EVENT (ai_candle_blow)); + if (CANDLE_IS_FAR(candle)) + actual_pos[FLOOR_FAR] = candle; + else + actual_pos[FLOOR_NEAR] = candle; + deduce (); + robot->fsm_queue.post (FSM_EVENT (ai_candle_blow)); } void Candles::deduce () { - int i; - /* Far. */ - for (i = 1; i < 4; i++) - if (color[i] != color[i + 3]) - { - if (color[i] == CANDLE_RED) - color[i + 3] = CANDLE_BLUE; - else if (color[i] == CANDLE_BLUE) - color[i + 3] = CANDLE_RED; - else if (color[i + 3] == CANDLE_RED) - color[i] = CANDLE_BLUE; - else if (color[i + 3] == CANDLE_BLUE) - color[i] = CANDLE_RED; - } - /* Near. */ - for (i = 9; i < 14; i++) - if (color[i] != color[i + 5]) - { - if (color[i] == CANDLE_RED) - color[i + 5] = CANDLE_BLUE; - else if (color[i] == CANDLE_BLUE) - color[i + 5] = CANDLE_RED; - else if (color[i + 5] == CANDLE_RED) - color[i] = CANDLE_BLUE; - else if (color[i + 5] == CANDLE_BLUE) - color[i] = CANDLE_RED; - } + int i; + /* Far. */ + for (i = 1; i < 4; i++) + if (color[i] != color[i + 3]) + { + if (color[i] == CANDLE_RED) + color[i + 3] = CANDLE_BLUE; + else if (color[i] == CANDLE_BLUE) + color[i + 3] = CANDLE_RED; + else if (color[i + 3] == CANDLE_RED) + color[i] = CANDLE_BLUE; + else if (color[i + 3] == CANDLE_BLUE) + color[i] = CANDLE_RED; + } + /* Near. */ + for (i = 9; i < 14; i++) + if (color[i] != color[i + 5]) + { + if (color[i] == CANDLE_RED) + color[i + 5] = CANDLE_BLUE; + else if (color[i] == CANDLE_BLUE) + color[i + 5] = CANDLE_RED; + else if (color[i + 5] == CANDLE_RED) + color[i] = CANDLE_BLUE; + else if (color[i + 5] == CANDLE_BLUE) + color[i] = CANDLE_RED; + } } /* Global candle FSM */ FSM_STATES (AI_CANDLE_SLEEPING, - AI_CANDLE_READY, - AI_CANDLE_UNDEPLOYING) + AI_CANDLE_READY, + AI_CANDLE_UNDEPLOYING) FSM_EVENTS (ai_candle_deploy, - ai_candle_undeploy, - ai_candle_blow) + ai_candle_undeploy, + ai_candle_blow) FSM_START_WITH (AI_CANDLE_SLEEPING) FSM_TRANS (AI_CANDLE_SLEEPING, ai_candle_deploy, AI_CANDLE_READY) { - /* TODO: piston arm IN */ - /* TODO: piston far OUT */ + /* TODO: piston arm IN */ + /* TODO: piston far OUT */ } FSM_TRANS (AI_CANDLE_READY, ai_candle_blow, AI_CANDLE_READY) { - int i; - for (i = 0; i < CANDLE_FLOOR_NB; i++) - { - if (robot->candles.actual_pos[i] != CANDLE_FLOOR_NB) - { - /* We can already punch if we know the color. */ - if (robot->candles.state[robot->candles.actual_pos[i]] == CANDLE_UNPUNCHED - && (robot->candles.color[robot->candles.actual_pos[i]] == (candle_color_t) team_color - || robot->candles.color[robot->candles.actual_pos[i]] == CANDLE_WHITE)) - { - if (CANDLE_IS_FAR (robot->candles.actual_pos[i])) - FSM_HANDLE (AI, ai_candle_far_punch); - else - FSM_HANDLE (AI, ai_candle_near_punch); - robot->candles.state[robot->candles.actual_pos[i]] = CANDLE_PUNCHED; - robot->candles.actual_pos[i] = CANDLE_FLOOR_NB; - } - /* We need to analyse color. */ - else if (robot->candles.color[robot->candles.actual_pos[i]] == CANDLE_UNKNOWN) - { - if (CANDLE_IS_FAR (robot->candles.actual_pos[i])) - FSM_HANDLE (AI, ai_candle_far_analyse); - else - FSM_HANDLE (AI, ai_candle_near_analyse); - } - } - } + int i; + for (i = 0; i < CANDLE_FLOOR_NB; i++) + { + if (robot->candles.actual_pos[i] != CANDLE_FLOOR_NB) + { + /* We can already punch if we know the color. */ + if (robot->candles.state[robot->candles.actual_pos[i]] == CANDLE_UNPUNCHED + && (robot->candles.color[robot->candles.actual_pos[i]] == (candle_color_t) team_color + || robot->candles.color[robot->candles.actual_pos[i]] == CANDLE_WHITE)) + { + if (CANDLE_IS_FAR (robot->candles.actual_pos[i])) + FSM_HANDLE (AI, ai_candle_far_punch); + else + FSM_HANDLE (AI, ai_candle_near_punch); + robot->candles.state[robot->candles.actual_pos[i]] = CANDLE_PUNCHED; + robot->candles.actual_pos[i] = CANDLE_FLOOR_NB; + } + /* We need to analyse color. */ + else if (robot->candles.color[robot->candles.actual_pos[i]] == CANDLE_UNKNOWN) + { + if (CANDLE_IS_FAR (robot->candles.actual_pos[i])) + FSM_HANDLE (AI, ai_candle_far_analyse); + else + FSM_HANDLE (AI, ai_candle_near_analyse); + } + } + } } FSM_TRANS (AI_CANDLE_READY, ai_candle_undeploy, AI_CANDLE_UNDEPLOYING) { - /* TODO: piston far OUT */ + /* TODO: piston far OUT */ } FSM_TRANS_TIMEOUT (AI_CANDLE_UNDEPLOYING, 10, AI_CANDLE_SLEEPING) //TODO timeout value { - /* TODO: piston far unleach */ - /* TODO: piston arm IN */ + /* TODO: piston far unleach */ + /* TODO: piston arm IN */ } /* Far puncher FSM */ FSM_STATES (AI_CANDLE_FAR_SLEEPING, - AI_CANDLE_FAR_PUNCHING) + AI_CANDLE_FAR_PUNCHING) FSM_EVENTS (ai_candle_far_punch) @@ -165,17 +165,17 @@ FSM_START_WITH (AI_CANDLE_FAR_SLEEPING) FSM_TRANS (AI_CANDLE_FAR_SLEEPING, ai_candle_far_punch, AI_CANDLE_FAR_PUNCHING) { - /* TODO: piston far OUT */ + /* TODO: piston far OUT */ } FSM_TRANS_TIMEOUT (AI_CANDLE_FAR_PUNCHING, 12, AI_CANDLE_FAR_SLEEPING) //TODO timeout value { - /* TODO: piston far OUT */ + /* TODO: piston far OUT */ } /* Near puncher FSM */ FSM_STATES (AI_CANDLE_NEAR_SLEEPING, - AI_CANDLE_NEAR_PUNCHING) + AI_CANDLE_NEAR_PUNCHING) FSM_EVENTS (ai_candle_near_punch) @@ -183,64 +183,64 @@ FSM_START_WITH (AI_CANDLE_NEAR_SLEEPING) FSM_TRANS (AI_CANDLE_NEAR_SLEEPING, ai_candle_near_punch, AI_CANDLE_NEAR_PUNCHING) { - /* TODO: piston near OUT */ + /* TODO: piston near OUT */ } FSM_TRANS_TIMEOUT (AI_CANDLE_NEAR_PUNCHING, 12, AI_CANDLE_NEAR_SLEEPING) //TODO timeout value { - /* TODO: piston near OUT */ + /* TODO: piston near OUT */ } /* Far analyse FSM */ FSM_STATES (AI_CANDLE_FAR_ANALYSE_SLEEP, - AI_CANDLE_FAR_ANALYSING) + AI_CANDLE_FAR_ANALYSING) FSM_EVENTS (ai_candle_far_analyse) FSM_START_WITH (AI_CANDLE_FAR_ANALYSE_SLEEP) FSM_TRANS (AI_CANDLE_FAR_ANALYSE_SLEEP, - ai_candle_far_analyse, - AI_CANDLE_FAR_ANALYSING) + ai_candle_far_analyse, + AI_CANDLE_FAR_ANALYSING) { - /* TODO: launch color analyse */ + /* TODO: launch color analyse */ } FSM_TRANS_TIMEOUT (AI_CANDLE_FAR_ANALYSING, 10, AI_CANDLE_FAR_ANALYSE_SLEEP) //TODO timeout value { - /* TODO Get color results and update table. */ - /* ... */ - /* Update color. */ - robot->candles.color[robot->candles.actual_pos[FLOOR_FAR]] = CANDLE_RED; // TODO = color_result - /* Update whole colors. */ - robot->candles.deduce (); - /* Send blow event. */ - FSM_HANDLE (AI, ai_candle_blow); + /* TODO Get color results and update table. */ + /* ... */ + /* Update color. */ + robot->candles.color[robot->candles.actual_pos[FLOOR_FAR]] = CANDLE_RED; // TODO = color_result + /* Update whole colors. */ + robot->candles.deduce (); + /* Send blow event. */ + FSM_HANDLE (AI, ai_candle_blow); } /* Near analyse FSM */ FSM_STATES (AI_CANDLE_NEAR_ANALYSE_SLEEP, - AI_CANDLE_NEAR_ANALYSING) + AI_CANDLE_NEAR_ANALYSING) FSM_EVENTS (ai_candle_near_analyse) FSM_START_WITH (AI_CANDLE_NEAR_ANALYSE_SLEEP) FSM_TRANS (AI_CANDLE_NEAR_ANALYSE_SLEEP, - ai_candle_near_analyse, - AI_CANDLE_NEAR_ANALYSING) + ai_candle_near_analyse, + AI_CANDLE_NEAR_ANALYSING) { - /* TODO: Launch color analyse. */ + /* TODO: Launch color analyse. */ } FSM_TRANS_TIMEOUT (AI_CANDLE_NEAR_ANALYSING, 10, AI_CANDLE_NEAR_ANALYSE_SLEEP) //TODO timeout value { - /* TODO Get color results and update table. */ - /* ... */ - /* Update color. */ - robot->candles.color[robot->candles.actual_pos[FLOOR_NEAR]] = CANDLE_RED; // TODO - /* Update whole colors. */ - robot->candles.deduce (); - /* Send blow event. */ - FSM_HANDLE (AI, ai_candle_blow); + /* TODO Get color results and update table. */ + /* ... */ + /* Update color. */ + robot->candles.color[robot->candles.actual_pos[FLOOR_NEAR]] = CANDLE_RED; // TODO + /* Update whole colors. */ + robot->candles.deduce (); + /* Send blow event. */ + FSM_HANDLE (AI, ai_candle_blow); } diff --git a/digital/io-hub/src/apbirthday/candles.hh b/digital/io-hub/src/apbirthday/candles.hh index 04345400..5aa917d9 100644 --- a/digital/io-hub/src/apbirthday/candles.hh +++ b/digital/io-hub/src/apbirthday/candles.hh @@ -43,40 +43,40 @@ - 11 16 - - 12 13 14 15 - - ______ - -*/ + */ typedef enum { - CANDLE_UNPUNCHED, - CANDLE_PUNCHED, - CANDLE_STATE_NB + CANDLE_UNPUNCHED, + CANDLE_PUNCHED, + CANDLE_STATE_NB } candle_state_t; typedef enum { - FLOOR_NEAR = 0, - FLOOR_FAR = 1, - CANDLE_FLOOR_NB + FLOOR_NEAR = 0, + FLOOR_FAR = 1, + CANDLE_FLOOR_NB } candle_floor_t; /* XXX use another common type for colors ? */ typedef enum { - CANDLE_RED = TEAM_COLOR_RIGHT, - CANDLE_BLUE = TEAM_COLOR_LEFT, - CANDLE_WHITE, - CANDLE_UNKNOWN, + CANDLE_RED = TEAM_COLOR_RIGHT, + CANDLE_BLUE = TEAM_COLOR_LEFT, + CANDLE_WHITE, + CANDLE_UNKNOWN, } candle_color_t; class Candles { - public: - candle_state_t state[CANDLES_NB]; - candle_color_t color[CANDLES_NB]; - Candles (int calif_mode); - void blow (int candle); - void deduce (); - int actual_pos[CANDLE_FLOOR_NB]; + public: + candle_state_t state[CANDLES_NB]; + candle_color_t color[CANDLES_NB]; + Candles (int calif_mode); + void blow (int candle); + void deduce (); + int actual_pos[CANDLE_FLOOR_NB]; }; #endif // candles_hh -- cgit v1.2.3