PacMaster 2.0(r200)
Controls digital PAC measurements and collects the results

PacNode.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 PACNODE_H
00022 #define PACNODE_H
00023 
00024 #include <QObject>
00025 #include <QTreeWidgetItem>
00026 #include <QTableWidgetItem>
00027 #include <QPointer>
00028 #include <QLabel>
00029 #include <QLineEdit>
00030 #include <QGroupBox>
00031 #include "PacVariantManager.h"
00032 
00033 class PacNetThread;
00034 class PacVariantManager;
00035 class QtProperty;
00036 class QPushButton;
00037 class QVBoxLayout;
00038 class QTimer;
00039 class TransmittableProperty;
00040 class TransmittablePropertyData;
00041 class WaveformProcessingInterface;
00042 class WaveformPresentationInterface;
00043 class WaveformDataInterface;
00044 class QwtPlot;
00045 class PacVoltageSpinBox;
00046 class QwtPlotCurve;
00047 class PacEnergySpectrum;
00048 class QtGroupBoxPropertyBrowser;
00049 
00055 class PacNode : public QObject
00056 {
00057     Q_OBJECT
00058   public:
00059     PacNode(unsigned int nodeid, QObject *parent = 0);
00060     ~PacNode();
00061     void deleteSetup(); 
00062     inline unsigned int nodeId() const { return nodeid; };
00063     inline QString nodeName() const { return nodename->value().toString(); };
00064     inline float getTheta() const { return theta->value().toDouble(); };
00065     inline float getPhi() const { return phi->value().toDouble(); };
00066     inline bool isConnected() const { return conn; };  
00067     inline qreal pmtVoltage() const { return pmtvoltage->value().toDouble(); };
00068     qreal fullscaleVolts() const;
00069     inline quint8 dacChannel() const { return dacchannel->value().toInt(); };
00071     inline QtProperty * toplevelProperty() const { return top; };
00073     inline QWidget * connectionControlWidget() const { return conncontrol; };
00074     inline bool nodeIsWorking() const { return nodeisworking; };
00075     QByteArray waveformTeaser() const { return wfteaser; };
00076     QMap<QString, QVariant> nodeSetup2Map() const;
00077     void map2NodeSetup(const QMap<QString, QVariant> & setup);
00078     QWidget * waveformPreviewWidget();
00079     QWidget * energySpectrumWidget() const;
00080 
00081   public slots:
00082     void connectToNode();
00083     void hostConnected();  
00084     void hostDisconnected();  
00085     void hostError(QString e);
00086     void start_recording();
00087     void stop_recording();
00088     void updateStats(qulonglong in, qulonglong drop, qulonglong datawaiting, qulonglong dataproc);
00089     void setAndSavePmtVoltage(double pmtv);
00090     void setFullscaleVolts(qreal fullscale);
00092     void updateConnectionState(int);
00093     void nodePropertyReceived(TransmittableProperty *p);
00094     void nodePropertyConfirmationReceived(TransmittablePropertyData *d);
00095     void newWaveformTeaser(QByteArray wfteaser);
00096     void recording_finished();
00097     void updateWaveformPreview();
00098     void updateEnergySpectrum();
00099     void receiveEnergySpectrum(PacEnergySpectrum *s);
00100     void enableWaveformRefresh(bool enabled);
00101     void enableEnergyRefresh(bool enabled);
00102     void showShorttermSpectrum(bool shortterm);
00103 
00104   private slots:
00105     void disconnectFromNode();
00106     void configurationChanged(QtProperty *property, const QVariant &value);
00108     void propertyDestroyed(QtProperty *property);
00109     void updatePmtVoltage();
00110     void exportSpectrum();
00111     void removeNode();
00112     void saveNodeSetup();
00113     void loadNodeSetup();
00114     void copyNodeSetup();
00115     void editNodeSetup();
00116 
00117   signals:
00118     void connected(bool b);
00119     void disconnected(bool b);
00120     void connectHost(QString address, int port);  
00121     void disconnectHost();  
00122     void updateNodeSetup(); 
00123     void anglesChanged(float theta, float phi); 
00124     void startRecording();  
00125     void stopRecording();  
00126     void waitingForOffsetSignal(unsigned int nodeid); 
00127     void foundOffsetSignal(unsigned int nodeid); 
00128     void updateDAC(quint8 channel, qreal voltage);
00129     void propertyChanged(QtProperty *property);
00130     void propertyAffirmed(QtProperty *property);
00131     void updatedNodeProperty(QByteArray newsetting);
00132     void recordingFinished();
00133     void nodeNameChanged();
00134     void requestSpectrum(bool shortterm);
00135     void removeNode(quint8);
00136     void copyNodeSetup(quint8);
00137     
00138 
00139   private:
00140     void initSettings();
00141     void createWaveformDummy();
00142     const QString createByteString(const qulonglong bytes) const;
00143     void setConnBoxTitle(const QString &info);
00144     PacNetThread *nt;
00145     unsigned int nodeid;
00146     QtVariantProperty *nodename, *theta, *phi, *address, *port, *dacchannel;
00147     QtVariantProperty *fullscaleproperty, *pmtvoltage;
00148     bool conn;
00150     int state;
00151     bool nodeisworking;
00152     QLabel *statInLabel, *statDropLabel, *statDataWaitingLabel, *statDataProcessedLabel;
00153     QLineEdit *statInField, *statDropField, *statDataWaitingField, *statDataProcessedField;
00154     PacVariantManager *setupmanager;
00155     QtVariantProperty *top;
00156     QPointer<QGroupBox> conncontrol;
00157     QPushButton *bconn , *bdisconn;
00158     QMap<QtVariantProperty*, TransmittableProperty*> qtPropertyToTransmittableProperty;
00159     QMap<quint64, TransmittableProperty*> hashToTransmittableProperty;
00160     QByteArray wfteaser;
00161 
00162     QPointer<QWidget> waveformPreview;
00163     QPointer<QWidget> waveformPreviewContainer;
00164     QPointer<QVBoxLayout> waveformPreviewContainerLayout;
00165     QTimer *waveformtimer;
00166     QList<QObject*> wfplugins;
00167     WaveformProcessingInterface *wfprocplugin;
00168     WaveformPresentationInterface *wfpresplugin;
00169     WaveformDataInterface *currentWaveform;
00170 
00171     QPointer<QGroupBox> energyspectrumwid;
00172     QPointer<QwtPlot> energyspectrum;
00173     QwtPlotCurve *spectrum;
00174     QTimer *spectrumtimer;
00175     PacEnergySpectrum *currentSpectrum;
00176     QtGroupBoxPropertyBrowser *pmtVoltageBrowser, *fullscaleBrowser;
00177     QtVariantProperty *fullscaleDummyProperty;
00178     bool shorttermspectrum;
00179 };
00180 
00181 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines