SimuPac 2.0(r200)
Simulates several PacMan nodes

PacNetCom.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Nagl                              *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef PACNETCOM_H
00022 #define PACNETCOM_H
00023 
00024 #include <QObject>
00025 #include <QTcpSocket>
00026 #include <QTimer>
00027 #include "pacDataTypes.h"
00028 #include "PropertyBranch.h"
00029 #include "TransmittableProperty.h"
00030 
00031 class WaveformDataInterface;
00032 class QTcpServer;
00033 class WaveformDataInterface;
00034 class PacPropertyBranch;
00035 class PacEvent;
00036 class PacSimulatedNode;
00037 
00043 class PacNetCom : public QObject
00044 {
00045     Q_OBJECT
00046   public:
00047     PacNetCom(int port, PacSimulatedNode *node);
00048     ~PacNetCom();
00049 
00050   public slots:
00051     void updateState();  
00052     void sendMessage(Pac::NetMsgType type, QByteArray data = QByteArray());
00053     void sendWaveformTeaser(WaveformDataInterface *w);
00054     void sendProperty(QByteArray data);
00055     void sendPropertyConfirmation(QByteArray data);
00056 
00057   private slots:
00058     void newConnection();
00059     void update_state(QAbstractSocket::SocketState socketState);
00060     void receivedData();
00061     void updateStats();
00062     void foundOffsetSignal();
00063     void sendEventChunk();
00064 
00065   signals:
00066     void startRecording();
00067     void stopRecording();
00068     void recordingFinished();
00069     void threadReady(QString s);
00070     void connectionState(QString s);
00071     void connectionStats(qulonglong bytes);
00072     void requestSetup();
00073     void propertyChanged(QByteArray data);
00074 
00075   private:
00076     QTcpServer *server;
00077     QTcpSocket *socket;
00078     QString state;
00079     bool recording;
00080     qulonglong sentbytes;
00081     QTimer *stattimer, *sendtimer;
00082     TransmittableProperty p_port;
00083     QList<PacEvent*> waitingchunk;
00084     quint64 newesttimestamp;
00085     PacSimulatedNode *node;
00086 };
00087 
00088 #endif
 All Classes Namespaces Files Functions Variables Enumerations Properties Friends Defines