Go to the documentation of this file.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
00026 #ifndef DAEMONLINK_H
00027 #define DAEMONLINK_H
00028
00029 #include <QtNetwork>
00030
00031 #include <QGpCoreTools.h>
00032
00033 class Station;
00034
00035 class DaemonLink: public QObject
00036 {
00037 Q_OBJECT
00038 public:
00039 DaemonLink(Station * station);
00040 ~DaemonLink();
00041
00042 unsigned int port() const {return _port;}
00043 void setPort(unsigned int p) {_port=p;}
00044
00045 bool isAvailable();
00046
00047 void send(const char * msg);
00048 void send(const char * buf, unsigned int len);
00049 protected:
00050 Station * station() {return _station;}
00051 const Station * station() const {return _station;}
00052
00053 virtual int bytesAvailable(const char * buffer, int bytesCount)=0;
00054 bool match(const char * buffer, int& bytesRead, int bytesCount, const char * string);
00055 int findMatch(const char * buffer, int& bytesRead, int bytesCount, const char * string);
00056 QByteArray readString(const char * buffer, int& bytesRead, int bytesCount, bool& ok);
00057 int readInteger(const char * buffer, int& bytesRead, int bytesCount, bool& ok);
00058 long int readLongInteger(const char * buffer, int& bytesRead, int bytesCount, bool& ok);
00059 double readDouble(const char * buffer, int& bytesRead, int bytesCount, bool& ok);
00060 protected slots:
00061 virtual void connected();
00062 private slots:
00063 void bytesAvailable();
00064 void hungUp();
00065 void connect();
00066 signals:
00067 void stateChanged();
00068 private:
00069 Station * _station;
00070 unsigned int _port;
00071
00072 QTcpSocket _socket;
00073 QGpCoreTools::DynamicBuffer _buffer;
00074 QTimer _connectionTimer;
00075 };
00076
00077 #endif // DAEMONLINK_H