summaryrefslogtreecommitdiff
path: root/i/simulotron/src
diff options
context:
space:
mode:
authorhaller2005-12-28 21:50:58 +0000
committerhaller2005-12-28 21:50:58 +0000
commitcdecf7b590a8d6c2f6ba2e54c3a613d1f0fd67cf (patch)
tree76143bf1aa46ee65ea9abaf5ff664a2fd0da5321 /i/simulotron/src
parent6273e5acb760a2f0b3ca6d2abd3da2ddf25cb800 (diff)
* Codage de ComC en cours...
Diffstat (limited to 'i/simulotron/src')
-rw-r--r--i/simulotron/src/comc/Makefile.incl.am8
-rw-r--r--i/simulotron/src/comc/comc.hh16
-rw-r--r--i/simulotron/src/comc/comc.tcc (renamed from i/simulotron/src/comc/comc.cc)33
-rw-r--r--i/simulotron/src/comc/send.tcc40
-rw-r--r--i/simulotron/src/comc/test_comc.cc16
-rw-r--r--i/simulotron/src/comc/test_comc_struct.hh37
6 files changed, 137 insertions, 13 deletions
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.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 C>
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 <class T>
void send(const T & message, const std::string & destname);
- /// Recoie quelque chose et appelle une fonction callback
- template <class C>
- 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.cc b/i/simulotron/src/comc/comc.tcc
index 4781c33..6e7bef7 100644
--- a/i/simulotron/src/comc/comc.cc
+++ b/i/simulotron/src/comc/comc.tcc
@@ -23,17 +23,36 @@
*
* }}} */
-/// Constructeur
+#include "comc/comc.hh"
+
+#include <stdexcept>
+
+/// Constructeur général
template <class C>
ComC<C>::ComC(const std::string & address, int port, const std::string & name)
- :C(),gst_(address, port)
+ :C(),aiguillage_(address, port, name)
+{
+}
+
+/// Fonction send générale qui DOIT planter
+template <class C> template <class T>
+void
+ComC<C>::send(const T & message, const std::string & destname)
{
+ throw std::runtime_error("ComC: Utilisation de send avec une struct indéfini!!");
}
-/// Envoie un truc dans le réseau
-template <class T>
-void send(const T & message, const std::string & destname);
+
/// Recoie quelque chose et appelle une fonction callback
template <class C>
-void receive(void);
+void
+ComC<C>::receive(void)
+{
+ throw std::runtime_error("ComC: Utilisation de receive avec une class indefini!!!");
+}
+
+class TuSersARien{};
-#endif //COMC_HH
+template<>
+void
+ComC<TuSersARien>::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 <class C> template <>
+void
+ComC<C>::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 <iostream>
+
int
main (void)
{
+ try
+ {
+ ComC<TuSersARien> 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