From cf6e8293144792ff142d18b8b6a6a78804bb9b8a Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Thu, 17 Apr 2008 23:53:47 +0200 Subject: Replaced the END state and the START state by a single state IDLE. --- digital/io/src/move.c | 2 +- digital/io/src/move.fsm | 11 +++++------ digital/io/src/move_cb.c | 6 +++--- digital/io/src/test/move/main.c | 6 +++--- 4 files changed, 12 insertions(+), 13 deletions(-) (limited to 'digital/io') diff --git a/digital/io/src/move.c b/digital/io/src/move.c index b4155589..1f8addfc 100644 --- a/digital/io/src/move.c +++ b/digital/io/src/move.c @@ -46,7 +46,7 @@ move_start (uint32_t position_x, uint32_t position_y) move_data.position_y = position_y; /* Start the FSM. */ fsm_init (&move_fsm); - fsm_handle_event (&move_fsm, MOVE_EVENT_ok); + fsm_handle_event (&move_fsm, MOVE_EVENT_start); } /** Verify if the position desired is in the table use when the robot tries to diff --git a/digital/io/src/move.fsm b/digital/io/src/move.fsm index cbe38ba9..d7e175a4 100644 --- a/digital/io/src/move.fsm +++ b/digital/io/src/move.fsm @@ -2,24 +2,23 @@ move States: - START - END + IDLE DESIRED_POSITION MOVE_ON_LEFT MOVE_ON_RIGHT Events: - ok + start reached failed_or_blocked_or_near_border failed_or_blocked -START: - ok -> DESIRED_POSITION +IDLE: + start -> DESIRED_POSITION Tries to reach a position provided by the user. If the position desired can not be reached, it all try to move on the right or the left. DESIRED_POSITION: - reached -> END + reached -> IDLE The position provided by the user has been reached, the FSM can stop. failed_or_blocked: near_right_border -> MOVE_ON_LEFT The robot has failed to reach the position. It shall try another position before trying to reach this one again. It shall go to the on the left only if the left border is the farest one. diff --git a/digital/io/src/move_cb.c b/digital/io/src/move_cb.c index 7a055e10..65ec02ea 100644 --- a/digital/io/src/move_cb.c +++ b/digital/io/src/move_cb.c @@ -16,15 +16,15 @@ /* - * START =ok=> + * IDLE =start=> * => DESIRED_POSITION * Tries to reach a position provided by the user. If the position desired can not be reached, it all try to move on the right or the left. */ fsm_branch_t -move__START__ok (void) +move__IDLE__start (void) { asserv_goto (move_data.position_x, move_data.position_y); - return move_next (START, ok); + return move_next (IDLE, start); } /* diff --git a/digital/io/src/test/move/main.c b/digital/io/src/test/move/main.c index ea6eb4e4..e981b7f0 100644 --- a/digital/io/src/test/move/main.c +++ b/digital/io/src/test/move/main.c @@ -57,8 +57,8 @@ move_print_test (fsm_t *move) switch (move->state_current) { - case MOVE_STATE_END: - printf ("END"); + case MOVE_STATE_IDLE: + printf ("IDLE"); break; case MOVE_STATE_DESIRED_POSITION: printf ("DESIRED POSITION"); @@ -83,7 +83,7 @@ main (void) fsm_init (&move_fsm); - fsm_handle_event (&move_fsm, MOVE_EVENT_ok); + fsm_handle_event (&move_fsm, MOVE_EVENT_start); move_print_test (&move_fsm); -- cgit v1.2.3