From ffa0ef335c0da785bf007f19857755661b13fd04 Mon Sep 17 00:00:00 2001 From: Nicolas Haller Date: Wed, 15 Apr 2009 00:00:40 +0200 Subject: * digital/io/src: - first version of elevator FSM --- digital/io/src/elevator_cb.c | 161 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 digital/io/src/elevator_cb.c (limited to 'digital/io/src/elevator_cb.c') diff --git a/digital/io/src/elevator_cb.c b/digital/io/src/elevator_cb.c new file mode 100644 index 00000000..7fc880c6 --- /dev/null +++ b/digital/io/src/elevator_cb.c @@ -0,0 +1,161 @@ +/* filterbridge_cb.c - filterbridge FSM callbacks. */ +/* {{{ + * + * Copyright (C) 2009 Nicolas Haller + * + * APBTeam: + * Web: http://apbteam.org/ + * Email: team AT apbteam DOT org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * }}} */ +#include "common.h" +#include "fsm.h" +#include "elevator_cb.h" + +/* + * OPEN_DOORS =doors_opened=> + * => WAIT_FOR_CLOSE_ORDER + * wait for close order + */ +fsm_branch_t +elevator__OPEN_DOORS__doors_opened (void) +{ + return elevator_next (OPEN_DOORS, doors_opened); +} + +/* + * WAIT_FOR_CLOSE_ORDER =order_received=> + * => CLOSE_DOORS + * closing doors + */ +fsm_branch_t +elevator__WAIT_FOR_CLOSE_ORDER__order_received (void) +{ + return elevator_next (WAIT_FOR_CLOSE_ORDER, order_received); +} + +/* + * CLOSE_DOORS =doors_closed=> + * => GO_TO_POS_X + * pucks are released and elevator is ready to make a new column + */ +fsm_branch_t +elevator__CLOSE_DOORS__doors_closed (void) +{ + return elevator_next (CLOSE_DOORS, doors_closed); +} + +/* + * WAIT_A_PUCK =time_up=> + * => WAIT_POS_ORDER + * no more time to wait a new puck + */ +fsm_branch_t +elevator__WAIT_A_PUCK__time_up (void) +{ + return elevator_next (WAIT_A_PUCK, time_up); +} + +/* + * WAIT_A_PUCK =new_puck=> + * => BLAH + * incrementing nb_puck var + */ +fsm_branch_t +elevator__WAIT_A_PUCK__new_puck (void) +{ + return elevator_next (WAIT_A_PUCK, new_puck); +} + +/* + * GO_TO_POX_Y =in_position=> + * => WAIT_FOR_RELEASE_ORDER + * ready to release pucks at altitude Y + */ +fsm_branch_t +elevator__GO_TO_POX_Y__in_position (void) +{ + return elevator_next (GO_TO_POX_Y, in_position); +} + +/* + * GO_TO_POS_X =in_position=> + * => WAIT_A_PUCK + * in position and ready to get a new puck + */ +fsm_branch_t +elevator__GO_TO_POS_X__in_position (void) +{ + return elevator_next (GO_TO_POS_X, in_position); +} + +/* + * WAIT_FOR_RELEASE_ORDER =order_received=> + * => OPEN_DOORS + * release pucks to the target position (I hope) + */ +fsm_branch_t +elevator__WAIT_FOR_RELEASE_ORDER__order_received (void) +{ + return elevator_next (WAIT_FOR_RELEASE_ORDER, order_received); +} + +/* + * BLAH =not_ok_for_other_pucks=> + * => WAIT_POS_ORDER + * no more puck, going next step + */ +fsm_branch_t +elevator__BLAH__not_ok_for_other_pucks (void) +{ + return elevator_next (BLAH, not_ok_for_other_pucks); +} + +/* + * BLAH =ok_for_other_pucks=> + * => GO_TO_POS_X + * update elevator position to get a new puck + */ +fsm_branch_t +elevator__BLAH__ok_for_other_pucks (void) +{ + return elevator_next (BLAH, ok_for_other_pucks); +} + +/* + * IDLE =started=> + * => GO_TO_POS_X + * match begin, we're going to be ready to get a new puck + */ +fsm_branch_t +elevator__IDLE__started (void) +{ + return elevator_next (IDLE, started); +} + +/* + * WAIT_POS_ORDER =order_received=> + * => GO_TO_POX_Y + * go to position Y + */ +fsm_branch_t +elevator__WAIT_POS_ORDER__order_received (void) +{ + return elevator_next (WAIT_POS_ORDER, order_received); +} + + -- cgit v1.2.3