PacMaster 2.0(r200)
Controls digital PAC measurements and collects the results
|
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 <QMutex> 00027 #include <QTimer> 00028 #include <QSemaphore> 00029 #include "pacDataTypes.h" 00030 00031 class PacEventSorter; 00032 class PacEnergySpectrum; 00033 class PacEvent; 00034 class WaveformDataInterface; 00035 class PacEventChunk; 00036 class TransmittableProperty; 00037 class TransmittablePropertyData; 00038 00039 00045 class PacNetCom : public QObject 00046 { 00047 Q_OBJECT 00048 public: 00049 PacNetCom(QObject *parent = 0, unsigned int nodeid = 0, float theta=0.0, float phi=0.0); 00050 ~PacNetCom(); 00054 PacEventChunk * getNextEventChunk(); 00055 00056 public slots: 00057 void connectToHost(QString address, int port); 00058 void disconnectFromHost(); 00059 void sendChangedProperty(QByteArray data); 00060 void requestNodeSetup(); 00061 void startSynchronization(); 00062 void startRecording(); 00063 void stopRecording(); 00064 void sendSpectra(bool shortterm); 00065 void newAngles(float theta, float phi); 00066 void adjustSpectrumParameters(qreal emin, qreal emax, quint32 shorttermsize, quint32 channels); 00067 void adjustBufferSize(quint32 newsize); 00068 00069 private slots: 00070 void receivedData(); 00071 void socketError(); 00072 void socketConnected(); 00073 void socketDisconnected(); 00074 void update_stats(); 00075 void stateChanged(QAbstractSocket::SocketState state); 00076 void noMoreData(); 00077 00078 signals: 00079 void connected(); 00080 void disconnected(); 00081 void error(QString e); 00082 void waitingForOffsetSignal(); 00083 void foundOffsetSignal(); 00084 //void receivedSetupParameter(QString group, QString param, QString value); 00085 void spectrumData(PacEnergySpectrum *s); 00086 void waveformTeaser(QByteArray w); 00087 void updateStats(qulonglong in, qulonglong drop, qulonglong datawaiting, qulonglong dataproc); 00088 void state(int); 00089 void nodePropertyReceived(TransmittableProperty *p); 00090 void nodePropertyConfirmationReceived(TransmittablePropertyData *d); 00091 void recordingFinished(); 00092 00093 private: 00094 void processNewResults(const QByteArray data); 00095 void addToOnlineSpectra(qreal e); 00096 void sendMessage(Pac::NetMsgType type, QByteArray data = QByteArray()); 00097 QTcpSocket *socket; 00098 unsigned int nodeid; 00099 qulonglong *eSpectrum, *eShorttermSpectrum; 00100 unsigned int eSpectrumChannels, *eShorttermRingBuffer, eShorttermSpectrumSize, eStSFront, eStSBack; 00101 qreal emin, emax, *eSpectrumX; 00102 float theta; 00103 float phi; 00104 bool recording; 00105 QString lastpluginname; 00106 QTimer *stattimer; 00107 qulonglong qin, qdrop, dataproc; 00108 PacEventChunk **buffer; 00109 QSemaphore usedbufferfield, freebufferfield; 00110 qlonglong buffersize, writepos, readpos; 00111 QTimer *noMoreDataTimer; 00112 static const int noMoreDataTimeout = 20; 00113 }; 00114 00115 #endif