From 91233c681919a79f76206d8845b16006608803ad Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Thu, 10 Apr 2008 01:03:51 +0200 Subject: * digital/io/src: - fixed build. --- digital/io/src/Makefile | 18 ++++--- digital/io/src/fsm.h | 2 +- digital/io/src/top.c | 42 ++++++++++++++++ digital/io/src/top.fsm | 52 ++++++++++++++++++++ digital/io/src/top.h | 39 +++++++++++++++ digital/io/src/top_cb.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++ digital/io/src/topfsm.c | 43 ---------------- digital/io/src/topfsm.fsm | 52 -------------------- digital/io/src/topfsm.h | 39 --------------- 9 files changed, 267 insertions(+), 142 deletions(-) create mode 100644 digital/io/src/top.c create mode 100644 digital/io/src/top.fsm create mode 100644 digital/io/src/top.h create mode 100644 digital/io/src/top_cb.c delete mode 100644 digital/io/src/topfsm.c delete mode 100644 digital/io/src/topfsm.fsm delete mode 100644 digital/io/src/topfsm.h diff --git a/digital/io/src/Makefile b/digital/io/src/Makefile index c9666126..1898742a 100644 --- a/digital/io/src/Makefile +++ b/digital/io/src/Makefile @@ -2,9 +2,11 @@ BASE = ../../avr PROGS = io io_SOURCES = main.c asserv.c servo.avr.c eeprom.avr.c trap.c sharp.c \ simu.host.c \ - fsm.c getsamples.c getsamples_fsm.c getsamples_cb.c \ - gutter_fsm.c gutter_cb.c move_fsm.c move_cb.c move.c \ - topfsm.c + fsm.c \ + getsamples.c getsamples_fsm.c getsamples_cb.c \ + gutter_fsm.c gutter_cb.c \ + move.c move_fsm.c move_cb.c \ + top.c top_fsm.c top_cb.c MODULES = proto uart twi utils adc CONFIGFILE = avrconfig.h # atmega8, atmega8535, atmega128... @@ -42,18 +44,20 @@ EXTRA_CLEAN_FILES = getsamples_fsm.h getsamples_fsm.c getsamples_cb.h \ getsamples_cb_skel.c getsamples.png \ gutter_fsm.h gutter_fsm.c gutter_cb.h \ gutter_cb_skel.c gutter.png \ - move_fsm.h move_fsm.c move.png move_cb.h move_cb_skel.c \ - topfsm.png + move_fsm.h move_fsm.c move_cb.h move_cb_skel.c move.png \ + top_fsm.h top_fsm.c top_cb.h top_cb_skel.c top.png # Bootstrap, fsm should be generated before fsm.h is used. fsm.c: fsm.h -fsm.h: getsamples_fsm.h gutter_fsm.h move_fsm.h topfsm.h +fsm.h: getsamples_fsm.h gutter_fsm.h move_fsm.h top_fsm.h DFAGEN = python $(BASE)/../../tools/dfagen/dfagen.py %_fsm.h %_fsm.c %_cb.h %_cb_skel.c: %.fsm fsm.conf $(FSM_TEMPLATES) $(DFAGEN) -o c -d $< -c fsm.conf -p $(<:%.fsm=%) +.PRECIOUS: getsamples_cb.c gutter_cb.c move_cb.c top_cb.c + ifndef CB %_cb.c: %_cb_skel.c @echo "Please update $@" @@ -83,7 +87,7 @@ else endif -png: getsamples.png gutter.png move.png topfsm.png +png: getsamples.png gutter.png move.png top.png %.png: %.dot dot -Tpng -o $@ $< diff --git a/digital/io/src/fsm.h b/digital/io/src/fsm.h index 84bc960b..ced9fadb 100644 --- a/digital/io/src/fsm.h +++ b/digital/io/src/fsm.h @@ -88,6 +88,6 @@ fsm_handle_event (fsm_t *fsm, u8 event); #include "getsamples_fsm.h" #include "gutter_fsm.h" #include "move_fsm.h" -#include "topfsm.h" +#include "top_fsm.h" #endif /* fsm_h */ diff --git a/digital/io/src/top.c b/digital/io/src/top.c new file mode 100644 index 00000000..42ffa80b --- /dev/null +++ b/digital/io/src/top.c @@ -0,0 +1,42 @@ +/* top.c */ +/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ + * + * Copyright (C) 2008 Nélio Laranjeiro + * + * 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 "asserv.h" +#include "top.h" +#include "fsm.h" + +struct top_data_t top_data; + +/** Start a main FSM. */ +void +robot_main_start (void) +{ + /* Set parameters. */ + top_data.sequence = 0x15; + /* Start the FSM. */ + fsm_init (&top_fsm); + fsm_handle_event (&top_fsm, TOP_EVENT_ok); +} + diff --git a/digital/io/src/top.fsm b/digital/io/src/top.fsm new file mode 100644 index 00000000..1da78745 --- /dev/null +++ b/digital/io/src/top.fsm @@ -0,0 +1,52 @@ +# Top FSM. +top + +States: + START + GET_SAMPLES + GET_ICE + GO_TO_GOAL + GET_ADV_ICE + +Events: + ok + samples_took + collector_full + ice_took + samples_deposed + samples_took_ice_distributor_empty_not_enough_time + samples_took_ice_distributor_empty_enough_time + samples_deposed_ice_distributor_empty + ice_took_collector_full + not_enough_time + ice_took_collector_not_full + +START: + ok -> GET_SAMPLES + Go to take some samples. The sequence shall be adapt to take the correct number of samples. + +GET_SAMPLES: + samples_took -> GET_ICE + The samples had been took and now the ice is missing. + samples_took_ice_distributor_empty_not_enough_time -> GO_TO_GOAL + Some samples had been took and there is not enough time to get some ice. + samples_took_ice_distributor_empty_enough_time -> GET_ADV_ICE + Go to take ice in the adversary distributor because the one in our part of the table is empty. + collector_full -> GO_TO_GOAL + All the room in the robot are full. + +GET_ICE: + ice_took -> GO_TO_GOAL + The ice had been taken and the collector is full. The robot shall go to depose it into the goal. + +GO_TO_GOAL: + samples_deposed -> GET_SAMPLES + The samples had been deposed, it shall try to get more samples. This state will call the getsamples FSM and the moveFSM. + samples_deposed_ice_distributor_empty -> GET_ADV_ICE + Go to get some adversary ice because our distributor is empty. + +GET_ADV_ICE: + ice_took -> GO_TO_GOAL + The ice has been taken, now the robot shall depose it. + ice_took_collector_not_full -> GET_SAMPLES + There is enough time to get some samples and go to the goal. diff --git a/digital/io/src/top.h b/digital/io/src/top.h new file mode 100644 index 00000000..651e13f5 --- /dev/null +++ b/digital/io/src/top.h @@ -0,0 +1,39 @@ +#ifndef top_h +#define top_h +/* top.h */ +/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ + * + * Copyright (C) 2008 Nélio Laranjeiro + * + * 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. + * + * }}} */ + +struct top_data_t +{ + uint8_t sequence; +}; + +extern struct top_data_t top_data; + +/** Start a Top FSM. */ +void +top_start (void); + +#endif /* top_h */ diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c new file mode 100644 index 00000000..52a5129d --- /dev/null +++ b/digital/io/src/top_cb.c @@ -0,0 +1,122 @@ +/* + * THIS IS AN AUTOMATICALLY GENERATED FILE, DO NOT EDIT! + * + * Skeleton for top callbacks implementation. + * + * + */ +#include "common.h" +#include "fsm.h" +#include "top_cb.h" + +/* + * START =ok=> + * => GET_SAMPLES + * Go to take some samples. The sequence shall be adapt to take the correct number of samples. + */ +fsm_branch_t +top__START__ok (void) +{ + return top_next (START, ok); +} + +/* + * GET_SAMPLES =samples_took_ice_distributor_empty_not_enough_time=> + * => GO_TO_GOAL + * Some samples had been took and there is not enough time to get some ice. + */ +fsm_branch_t +top__GET_SAMPLES__samples_took_ice_distributor_empty_not_enough_time (void) +{ + return top_next (GET_SAMPLES, samples_took_ice_distributor_empty_not_enough_time); +} + +/* + * GET_SAMPLES =samples_took=> + * => GET_ICE + * The samples had been took and now the ice is missing. + */ +fsm_branch_t +top__GET_SAMPLES__samples_took (void) +{ + return top_next (GET_SAMPLES, samples_took); +} + +/* + * GET_SAMPLES =collector_full=> + * => GO_TO_GOAL + * All the room in the robot are full. + */ +fsm_branch_t +top__GET_SAMPLES__collector_full (void) +{ + return top_next (GET_SAMPLES, collector_full); +} + +/* + * GET_SAMPLES =samples_took_ice_distributor_empty_enough_time=> + * => GET_ADV_ICE + * Go to take ice in the adversary distributor because the one in our part of the table is empty. + */ +fsm_branch_t +top__GET_SAMPLES__samples_took_ice_distributor_empty_enough_time (void) +{ + return top_next (GET_SAMPLES, samples_took_ice_distributor_empty_enough_time); +} + +/* + * GO_TO_GOAL =samples_deposed_ice_distributor_empty=> + * => GET_ADV_ICE + * Go to get some adversary ice because our distributor is empty. + */ +fsm_branch_t +top__GO_TO_GOAL__samples_deposed_ice_distributor_empty (void) +{ + return top_next (GO_TO_GOAL, samples_deposed_ice_distributor_empty); +} + +/* + * GO_TO_GOAL =samples_deposed=> + * => GET_SAMPLES + * The samples had been deposed, it shall try to get more samples. This state will call the getsamples FSM and the moveFSM. + */ +fsm_branch_t +top__GO_TO_GOAL__samples_deposed (void) +{ + return top_next (GO_TO_GOAL, samples_deposed); +} + +/* + * GET_ICE =ice_took=> + * => GO_TO_GOAL + * The ice had been taken and the collector is full. The robot shall go to depose it into the goal. + */ +fsm_branch_t +top__GET_ICE__ice_took (void) +{ + return top_next (GET_ICE, ice_took); +} + +/* + * GET_ADV_ICE =ice_took_collector_not_full=> + * => GET_SAMPLES + * There is enough time to get some samples and go to the goal. + */ +fsm_branch_t +top__GET_ADV_ICE__ice_took_collector_not_full (void) +{ + return top_next (GET_ADV_ICE, ice_took_collector_not_full); +} + +/* + * GET_ADV_ICE =ice_took=> + * => GO_TO_GOAL + * The ice has been taken, now the robot shall depose it. + */ +fsm_branch_t +top__GET_ADV_ICE__ice_took (void) +{ + return top_next (GET_ADV_ICE, ice_took); +} + + diff --git a/digital/io/src/topfsm.c b/digital/io/src/topfsm.c deleted file mode 100644 index 27eef2b2..00000000 --- a/digital/io/src/topfsm.c +++ /dev/null @@ -1,43 +0,0 @@ -/* robot_main_fsm.c */ -/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ - * - * Copyright (C) 2008 Nélio Laranjeiro - * - * 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 "asserv.h" -#include "topfsm.h" -#include "fsm.h" - -struct topfsm_data_t topfsm_data; - -/** Start a main FSM. */ -void -robot_main_start (void) -{ - /* Set parameters. */ - topfsm_data.sequence = 0x15; - /* Start the FSM. */ -/* fsm_init (&robot_main_fsm); - fsm_handle_event (&robot_main_fsm, ROBOT_MAIN_EVENT_ok); - */ -} - diff --git a/digital/io/src/topfsm.fsm b/digital/io/src/topfsm.fsm deleted file mode 100644 index d0631813..00000000 --- a/digital/io/src/topfsm.fsm +++ /dev/null @@ -1,52 +0,0 @@ -# Main FSM. -topfsm - -States: - START - GET_SAMPLES - GET_ICE - GO_TO_GOAL - GET_ADV_ICE - -Events: - ok - samples_took - collector_full - ice_took - samples_deposed - samples_took_ice_distributor_empty_not_enough_time - samples_took_ice_distributor_empty_enough_time - samples_deposed_ice_distributor_empty - ice_took_collector_full - not_enough_time - ice_took_collector_not_full - -START: - ok -> GET_SAMPLES - Go to take some samples. The sequence shall be adapt to take the correct number of samples. - -GET_SAMPLES: - samples_took -> GET_ICE - The samples had been took and now the ice is missing. - samples_took_ice_distributor_empty_not_enough_time -> GO_TO_GOAL - Some samples had been took and there is not enough time to get some ice. - samples_took_ice_distributor_empty_enough_time -> GET_ADV_ICE - Go to take ice in the adversary distributor because the one in our part of the table is empty. - collector_full -> GO_TO_GOAL - All the room in the robot are full. - -GET_ICE: - ice_took -> GO_TO_GOAL - The ice had been taken and the collector is full. The robot shall go to depose it into the goal. - -GO_TO_GOAL: - samples_deposed -> GET_SAMPLES - The samples had been deposed, it shall try to get more samples. This state will call the getsamples FSM and the moveFSM. - samples_deposed_ice_distributor_empty -> GET_ADV_ICE - Go to get some adversary ice because our distributor is empty. - -GET_ADV_ICE: - ice_took -> GO_TO_GOAL - The ice has been taken, now the robot shall depose it. - ice_took_collector_not_full -> GET_SAMPLES - There is enough time to get some samples and go to the goal. diff --git a/digital/io/src/topfsm.h b/digital/io/src/topfsm.h deleted file mode 100644 index f6b1f0bf..00000000 --- a/digital/io/src/topfsm.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef topfsm_h -#define topfsm_h -/* topfsm.h */ -/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ - * - * Copyright (C) 2008 Nélio Laranjeiro - * - * 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. - * - * }}} */ - -struct topfsm_data_t -{ - uint8_t sequence; -}; - -extern struct topfsm_data_t topfsm_data; - -/** Start a main FSM. */ -void -topfsm_start (void); - -#endif /* topfsm_h */ -- cgit v1.2.3