From cdecf7b590a8d6c2f6ba2e54c3a613d1f0fd67cf Mon Sep 17 00:00:00 2001 From: haller Date: Wed, 28 Dec 2005 21:50:58 +0000 Subject: * Codage de ComC en cours... --- i/simulotron/src/comc/Makefile.incl.am | 8 +++-- i/simulotron/src/comc/comc.cc | 39 --------------------- i/simulotron/src/comc/comc.hh | 16 ++++++--- i/simulotron/src/comc/comc.tcc | 58 +++++++++++++++++++++++++++++++ i/simulotron/src/comc/send.tcc | 40 +++++++++++++++++++++ i/simulotron/src/comc/test_comc.cc | 16 +++++++++ i/simulotron/src/comc/test_comc_struct.hh | 37 ++++++++++++++++++++ 7 files changed, 169 insertions(+), 45 deletions(-) delete mode 100644 i/simulotron/src/comc/comc.cc create mode 100644 i/simulotron/src/comc/comc.tcc create mode 100644 i/simulotron/src/comc/send.tcc create mode 100644 i/simulotron/src/comc/test_comc_struct.hh (limited to 'i/simulotron') diff --git a/i/simulotron/src/comc/Makefile.incl.am b/i/simulotron/src/comc/Makefile.incl.am index 7f3212f..93bf1ee 100644 --- a/i/simulotron/src/comc/Makefile.incl.am +++ b/i/simulotron/src/comc/Makefile.incl.am @@ -1,5 +1,9 @@ -comc_S = comc/comc.cc comc/comc.hh +comc_S = comc/comc.tcc comc/comc.hh check_PROGRAMS += test_comc test_comc_SOURCES = comc/test_comc.cc \ - $(comc_S) + $(comc_S) \ + $(socket_S) \ + $(aiguillage_S) \ + $(gs_message_S) \ + $(gs_transmitter_S) diff --git a/i/simulotron/src/comc/comc.cc b/i/simulotron/src/comc/comc.cc deleted file mode 100644 index 4781c33..0000000 --- a/i/simulotron/src/comc/comc.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* comc.cc - Classe la plus haute dans la transmission par socket */ -/* Simulotron - Programme de simulation de robot {{{ - * - * Copyright (C) 2005 Nicolas Haller - * - * Robot APB Team/Efrei 2006. - * 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. - * - * }}} */ - -/// Constructeur -template -ComC::ComC(const std::string & address, int port, const std::string & name) - :C(),gst_(address, port) -{ -} -/// Envoie un truc dans le réseau -template -void send(const T & message, const std::string & destname); -/// Recoie quelque chose et appelle une fonction callback -template -void receive(void); - -#endif //COMC_HH diff --git a/i/simulotron/src/comc/comc.hh b/i/simulotron/src/comc/comc.hh index 9d2477e..3edd2c1 100644 --- a/i/simulotron/src/comc/comc.hh +++ b/i/simulotron/src/comc/comc.hh @@ -25,20 +25,28 @@ * * }}} */ +#include "aiguillage/aiguillage.hh" + template class ComC : public C { private: - GSTransmitter gst_; + Aiguillage aiguillage_; public: /// Constructeur ComC(const std::string & address, int port, const std::string & name); + /// Initialise la communication avec le hub + void InitHub(void); /// Envoie un truc dans le réseau template void send(const T & message, const std::string & destname); - /// Recoie quelque chose et appelle une fonction callback - template - void receive(void); + // Recoie quelque chose et appelle une fonction callback + // void receive(void); }; +/// Contient les fonction de base de la classe +#include "comc/comc.tcc" +/// Contient les fonctions send spécialisé. +#include "comc/send.tcc" + #endif //COMC_HH diff --git a/i/simulotron/src/comc/comc.tcc b/i/simulotron/src/comc/comc.tcc new file mode 100644 index 0000000..6e7bef7 --- /dev/null +++ b/i/simulotron/src/comc/comc.tcc @@ -0,0 +1,58 @@ +/* comc.cc - Classe la plus haute dans la transmission par socket */ +/* Simulotron - Programme de simulation de robot {{{ + * + * Copyright (C) 2005 Nicolas Haller + * + * Robot APB Team/Efrei 2006. + * 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 "comc/comc.hh" + +#include + +/// Constructeur général +template +ComC::ComC(const std::string & address, int port, const std::string & name) + :C(),aiguillage_(address, port, name) +{ +} + +/// Fonction send générale qui DOIT planter +template template +void +ComC::send(const T & message, const std::string & destname) +{ + throw std::runtime_error("ComC: Utilisation de send avec une struct indéfini!!"); +} + +/// Recoie quelque chose et appelle une fonction callback +template +void +ComC::receive(void) +{ + throw std::runtime_error("ComC: Utilisation de receive avec une class indefini!!!"); +} + +class TuSersARien{}; + +template<> +void +ComC::receive(void) +{} diff --git a/i/simulotron/src/comc/send.tcc b/i/simulotron/src/comc/send.tcc new file mode 100644 index 0000000..6c5554a --- /dev/null +++ b/i/simulotron/src/comc/send.tcc @@ -0,0 +1,40 @@ +/* send.tcc - Contient toute les fcts send pour les structures gs */ +/* Simulotron - Programme de simulation de robot {{{ + * + * Copyright (C) 2005 Nicolas Haller + * + * Robot APB Team/Efrei 2006. + * 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. + * + * }}} */ + +// Structure 0 - Structure de test +// int, double, string(8),short, string, long +template template <> +void +ComC::send(const msg0 & message, const std::string & destname) +{ + GSMessage gsm; + gsm appendGS(&i, sizeof(int)); + gsm appendGS(&j, sizeof(double)); + gsm appendGS(&dfsdf, sizeof(int)); + gsm appendGS(&i, sizeof(int)); + gsm appendGS(&i, sizeof(int)); + gsm appendGS(&i, sizeof(int)); +} + diff --git a/i/simulotron/src/comc/test_comc.cc b/i/simulotron/src/comc/test_comc.cc index ae38e71..3e8a86f 100644 --- a/i/simulotron/src/comc/test_comc.cc +++ b/i/simulotron/src/comc/test_comc.cc @@ -22,8 +22,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * }}} */ + +#include "comc/comc.hh" + +#include + int main (void) { + try + { + ComC ccTSAR("127.0.0.1", 4080, "chier"); + ccTSAR.receive(); + } + catch (std::runtime_error & chier) + { + std::cout << chier.what() << std::endl; + exit(1); + } + return 0; } diff --git a/i/simulotron/src/comc/test_comc_struct.hh b/i/simulotron/src/comc/test_comc_struct.hh new file mode 100644 index 0000000..fa1fc63 --- /dev/null +++ b/i/simulotron/src/comc/test_comc_struct.hh @@ -0,0 +1,37 @@ +#ifndef TCS_HH +#define TCS_HH +/* test_comc_struct.hh - message de test 0 */ +/* Simulotron - Programme de simulation de robot {{{ + * + * Copyright (C) 2006 Nicolas Haller + * + * Robot APB Team/Efrei 2006. + * 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. + * + * }}} */ + +struct msg0 +{ + int i; + double j; + std::string str1; // Limité à 8 octets + short s; + std::string str2; // string infini + long l; +} +#endif //TCS_HH -- cgit v1.2.3