From d6dd6bfa014012c4c9ef322a2a4c3e0157ef9eeb Mon Sep 17 00:00:00 2001 From: haller Date: Sun, 21 May 2006 22:01:50 +0000 Subject: * Destruction du vieux test_proto * Codage des fonctions présentes dans le main.c de la carte es dans Es --- i/marvin/src/es/es.cc | 72 ++++++++++++++++++++ i/marvin/src/es/es.hh | 26 +++++++- i/marvin/src/proto/test_proto.cc.old | 124 ----------------------------------- 3 files changed, 97 insertions(+), 125 deletions(-) delete mode 100644 i/marvin/src/proto/test_proto.cc.old (limited to 'i') diff --git a/i/marvin/src/es/es.cc b/i/marvin/src/es/es.cc index 0e93d0f..8454ac5 100644 --- a/i/marvin/src/es/es.cc +++ b/i/marvin/src/es/es.cc @@ -59,10 +59,82 @@ void Es::loadConfig(const Config & config) tty_ = config.get("es.tty"); } +// Envoie de la config des sensors RVB +void Es::setRVBSensorsConfig(int false_ic, int max_ov) +{ + proto_.send('p',"bw", false_ic, max_ov); +} + +// Envoie de la config des sniff RVB +void Es::setRVBSniffConfig(int ref_ratio) +{ + proto_.send('x', "b", ref_ratio); +} void Es::receive(char command, const Proto::Frame & frame) { } +// Règle les stats des sensors RVB +void Es::setRVBSensorsStat(int mask_captor, int freq) +{ + proto_.send('S', "wb", mask_captor, freq); +} + +// règle la couleur actuelle comme référente +void Es::setRefColor(int mask_captor, int mode) +{ + proto_.send('r', "wb", mask_captor, mode); +} + +/// Règle les stats si le "sensors is seen" +// XXX Faudra lui filer un vrai nom quand même +void Es::setRVBSeenStat(int mask_captor, int freq) +{ + proto_.send('A', "wb", mask_captor, freq); +} + +// Discute avec les servo... +void Es::setServoPos(int servoNb, int servoPos) +{ + proto_.send('m', "bb", servoNb, servoPos); +} + +// Règle la vitesse des turbines +void Es::setTurbineSpeed(int turbNb, int speed) +{ + proto_.send('v', "bw", turbNb, speed); +} + +// Règle le sens de rotation du barillet +void Es::setTheMeaningOfRotationOfBarillet(int answer) +{ + proto_.send('w', "b", answer); +} + +// Init n°2 of barillet +void Es::init2Barillet(void) +{ + proto_.send('g'); +} + +// Dépose une balle du barillet +void Es::deposeBalle(void) +{ + proto_.send('d'); +} + +/// Extrait une balle +void Es::extraitBalle(void) +{ + proto_.send('e'); +} + +/// Rotation du barillet +void Es::rotationBarillet(int posFinal) +{ + proto_.send('t', "b", posFinal); +} + bool Es::sync(void) { return proto_.sync(); diff --git a/i/marvin/src/es/es.hh b/i/marvin/src/es/es.hh index b4bf5b3..deb9771 100644 --- a/i/marvin/src/es/es.hh +++ b/i/marvin/src/es/es.hh @@ -58,6 +58,30 @@ class Es : public Proto::Receiver private: /// Charge les paramètre du fichier de config void loadConfig(const Config & config); + /// Envoie de la config des sensors RVB + void setRVBSensorsConfig(int false_ic, int max_ov); + /// Envoie de la config des sniff RVB + void setRVBSniffConfig(int ref_ratio); + /// Règle les stats des sensors RVB + void setRVBSensorsStat(int mask_captor, int freq); + /// règle la couleur actuelle comme référente + void setRefColor(int mask_captor, int mode); + /// Règle les stats si le "sensors is seen" + // XXX Faudra lui filer un vrai nom quand même + void setRVBSeenStat(int mask_captor, int freq); + /// Discute avec les servo... + void setServoPos(int servoNb, int servoPos); + /// Règle la vitesse des turbines + void setTurbineSpeed(int turbNb, int speed); + /// Règle le sens de rotation du barillet + void setTheMeaningOfRotationOfBarillet(int answer); + /// Init n°2 of barillet + void init2Barillet(void); + /// Dépose une balle du barillet + void deposeBalle(void); + /// Extrait une balle + void extraitBalle(void); + /// Rotation du barillet + void rotationBarillet(int posFinal); }; - #endif // es_hh diff --git a/i/marvin/src/proto/test_proto.cc.old b/i/marvin/src/proto/test_proto.cc.old deleted file mode 100644 index 9ec119d..0000000 --- a/i/marvin/src/proto/test_proto.cc.old +++ /dev/null @@ -1,124 +0,0 @@ -// test_proto.cc -// robert - programme du robot 2005. {{{ -// -// Copyright (C) 2005 Nicolas Haller -// -// Robot APB Team/Efrei 2005. -// Web: http://assos.efrei.fr/robot/ -// Email: robot AT efrei DOT fr -// -// 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 "proto.hh" -#include "timer/timer.hh" - -#include -#include - -/// Classe de test pour proto. -class TestProto : public Proto::Receiver -{ - void receive (char command, const Proto::Frame &frame) - { - std::cout << "received " << frame << std::endl; - } -}; - -/// Affiche un memo de suntaxe. -void -syntax (void) -{ - std::cout << "test_proto - test la classe de protocol série.\n" - "Syntaxe : test_proto <...>\n" - " s envois une commande\n" - " w attend pendant un nombre de millisecondes\n" - " ? affiche cet écran d'aide\n" - << std::endl; -} - -int -main (int argc, char **argv) -{ - try - { - int i; - if (argc < 2) - { - syntax (); - return 1; - } - TestProto testProto; - Proto proto (testProto); - proto.open (argv[1]); - i = 2; - while (i < argc) - { - bool reliable = true; - switch (argv[i][0]) - { - case 'S': - reliable = false; - // no break; - case 's': - { - if (i + 2 >= argc) - throw std::runtime_error ("syntax error"); - unsigned a; - int arg[4]; - char c = argv[++i][0]; - const char *format = argv[++i]; - if (i + static_cast (strlen (format)) >= argc) - throw std::runtime_error ("syntax error"); - for (a = 0; a < 4 && a < strlen (format); a++) - arg[a] = atoi (argv[++i]); - proto.send (c, format, arg[0], arg[1], arg[2], arg[3], - reliable); - while (!proto.wait (-1)) - ; - } - break; - case 'w': - { - int stop, t; - if (i + 1 >= argc) - throw std::runtime_error ("syntax error"); - stop = atoi (argv[++i]) + Timer::getProgramTime (); - t = Timer::getProgramTime (); - while (t < stop) - { - proto.wait (stop - t); - t = Timer::getProgramTime (); - } - break; - } - case '?': - proto.close (); - syntax (); - return 0; - default: - throw std::runtime_error ("syntax error"); - } - i++; - } - } - catch (const std::exception &e) - { - std::cerr << e.what () << std::endl; - syntax (); - return 1; - } - return 0; -} -- cgit v1.2.3