00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef GRASPITSERVER_HXX
00031 #include <q3serversocket.h>
00032 #include <q3socket.h>
00033 #include <qstringlist.h>
00034 #include <iostream>
00035 #include <vector>
00036
00037 class Body;
00038 class Robot;
00039
00041
00071 class ClientSocket : public Q3Socket
00072 {
00073 Q_OBJECT
00074
00075 public:
00076
00082 ClientSocket( int sock, QObject *parent=0, const char *name=0 ) :
00083 Q3Socket( parent, name )
00084 {
00085 connect( this, SIGNAL(readyRead()), SLOT(readClient()) );
00086 connect( this, SIGNAL(connectionClosed()), SLOT(connectionClosed()) );
00087 setSocket( sock );
00088 }
00089
00090 ~ClientSocket();
00091
00092 private:
00093
00095 QString line;
00096
00098 QStringList lineStrList;
00099
00101 QStringList::const_iterator strPtr;
00102
00103 int readBodyIndList(std::vector<Body *> &bodyVec);
00104 int readRobotIndList(std::vector<Robot *> &robVec);
00105 void sendContacts(Body *bod,int numData);
00106 void sendAverageContacts(Body *bod);
00107 void sendBodyName(Body* bod);
00108 void computeNewVelocities(double ts);
00109 void moveDynamicBodies(double ts);
00110
00111 void sendRobotName(Robot* rob);
00112 void sendDOFVals(Robot *rob);
00113
00114 int readDOFVals();
00115 int readDOFForces(Robot *rob);
00116
00117
00118
00119
00120
00121 private slots:
00122 void readClient();
00123
00125 void connectionClosed() { delete this;}
00126
00127 };
00128
00130
00135 class GraspItServer : public Q3ServerSocket
00136 {
00137 Q_OBJECT
00138
00139
00140 public:
00141 GraspItServer(Q_UINT16 port, int backlog = 1, QObject *parent = 0,
00142 const char *name = 0);
00143
00145 ~GraspItServer() {}
00146 void newConnection(int socket);
00147 };
00148 #define GRASPITSERVER_HXX
00149 #endif