00001 #ifndef _REC_ROBOTINO_SERVER_SERVERTHREAD_H_
00002 #define _REC_ROBOTINO_SERVER_SERVERTHREAD_H_
00003
00004 #include "rec/robotino/server/defines.h"
00005 #include "rec/iocontrol/remotestate/SetState.h"
00006 #include "rec/iocontrol/remotestate/SensorState.h"
00007
00008 #include <QThread>
00009 #include <QByteArray>
00010 #include <QMutex>
00011 #include <QHostAddress>
00012
00013 namespace rec
00014 {
00015 namespace robotino
00016 {
00017 namespace server
00018 {
00019 class ServerImpl;
00020
00021 class ServerThread : public QThread
00022 {
00023 Q_OBJECT
00024 public:
00025 ServerThread( QObject* parent, int socketDescriptor, bool isMaster );
00026
00027 void setSensorState( const rec::iocontrol::remotestate::SensorState& sensorState );
00028
00029 bool isMaster() const { return _isMaster; }
00030
00031 void stop();
00032
00033 Q_SIGNALS:
00034 void setStateReceived( const rec::iocontrol::remotestate::SetState& );
00035
00036 void clientConnected( bool isMaster, quint32 address );
00037 void clientDisconnected( bool isMaster, quint32 address );
00038
00039 void clientImageRequest( bool enable, quint32 address, quint16 port );
00040
00041 void cameraControlReceived( unsigned int width, unsigned int height );
00042
00043 private:
00044 void run();
00045
00046 int _socketDescriptor;
00047 const bool _isMaster;
00048 int _readTimeout;
00049 volatile bool _run;
00050
00051 QMutex _mutex;
00052 ServerImpl* _impl;
00053
00054 private Q_SLOTS:
00055 void on_setStateReceived( const rec::iocontrol::remotestate::SetState& );
00056 void on_clientImageRequest( bool enable, quint32 address, quint16 port );
00057 void on_cameraControlReceived( unsigned int width, unsigned int height );
00058 };
00059 }
00060 }
00061 }
00062
00063 #endif //_REC_ROBOTINO_SERVER_SERVER_H_