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

PacMaster.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 PACMASTER_H
00022 #define PACMASTER_H
00023 
00024 #define PACMASTERABOUT "\
00025 <p><b>PacMaster</b></p><p>is the control Application for digital PAC measurements</p>\
00026 <p>This application receives data from hosts running PacMan, processes it and writes it \
00027 to disk using the .pacevents format (see PaceventsWriter's doxygen documentation for details \
00028 of the binary format).</p>"
00029 
00030 #include <QtGui>
00031 #include <QSettings>
00032 #include "ui_PacMainWindow.h"
00033 #include "pacDataTypes.h"
00034 
00035 class PacNode;
00036 class PacMsg;
00037 class PacEventSorter;
00038 class PacCorrelator;
00039 class PacEventSaver;
00040 class PacUSBThread;
00041 class PacVariantManager;
00042 class QtVariantProperty;
00043 class PacCallExternalTool;
00044 class PacWaitDialog;
00045 class PacCountingSignalTransition;
00046 class PacState;
00047 class QFinalState;
00048 
00057 class PacMaster : public QMainWindow, private Ui::PacMainWindow
00058 {
00059       Q_OBJECT
00060 
00061   public:
00062     PacMaster(QWidget *parent = 0);
00063     ~PacMaster();
00064     static const QList<quint8> nodeIds();
00065     static const QString nodeIdToName(const unsigned int id);
00066     static float nodeIdToTheta(const unsigned int id);
00067     static float nodeIdToPhi(const unsigned int id);
00068     static PacEventSorter *sorter;
00069     static PacCorrelator *correlator;
00070     static PacEventSaver *eventsaver;
00071     void addNodeStatWidgets(QLabel *statInLabel, QLineEdit *statInField,
00072                             QLabel *statDropLabel, QLineEdit *statDropField,
00073                             QLabel *statDataWaitingLabel, QLineEdit *statDataWaitingField,
00074                             QLabel *statDataProcessedLabel, QLineEdit *statDataProcessedField);
00075     void removeNodeStatWidgets(const unsigned int nodeid);
00076     QMap<QString, QString> setupTreeSnapshot() const;
00077 
00078   public slots:
00079     void copyNodeSetup(quint8 nodeid);
00080     void removeNode(quint8 nodeid);
00081     void showMessageFromOtherInstance(const QString& msg);
00082 
00083   private slots:
00084     void about();
00085     void addNode();
00086     void prepare_recording();
00087     void add_comment();
00088     void tabChanged(int index);
00089     void saveSpectrum();
00090     void updateEventPath();
00091     void updateEventFilename(QString fn);
00092     void updateChunkSize(int cs);
00093     void updateCompressionLevel(int level);
00094     void showFilenamePrefixHelp();
00095     void saveUncorrelated(bool b);
00096     void updateStatistics();
00097     void connect_all_nodes();
00098     void interruptWaveformUpdate(bool hold);
00099     void highlightChangedSetupItems(QtProperty *property);
00100     void confirmSetupChange(QtProperty *property);
00101     void updateLocalProperty(QtProperty *property, const QVariant &value);
00102     void createWaveformSingleView(bool checked);
00103     void createWaveformSideBySideView(bool checked);
00104     void createWaveformStackedView(bool checked);
00105     void createWaveformTiledView(bool checked);
00106     void createEnergySingleView(bool checked);
00107     void createEnergySideBySideView(bool checked);
00108     void createEnergyStackedView(bool checked);
00109     void createEnergyTiledView(bool checked);
00110     void saveEnergySetup();
00111     void loadEnergySetup();
00112     void editEnergySetup();
00113     void updateHighVoltageTooltip(bool on);
00114     void startSpectraPac(const QString &filename);
00115     void recordingFinished();
00116 
00117   signals:
00118     void startSynchronization();  
00119     void startRecording();  
00120     void stopRecording();  
00121     void sendSyncSignal(); 
00122     void updateDAC(quint8, qreal);
00123     void highVoltageOn(bool on = true); 
00124     void highVoltageOff();
00125     void energySpectrumParameters(qreal emin, qreal emax, quint32 shorttermsize, quint32 channels);
00126     void networkBufferSize(quint32 size);
00127     void updateWaveformPreviews();
00128     void updateEnergySpectra();
00129     void enableWaveformRefresh(bool);
00130     void enableEnergyRefresh(bool);
00131     void showShorttermSpectrum(bool);
00132 
00133     void nodeConnected();
00134     void nodeDisconnected();
00135     void addedNode();
00136     void removedNode();
00137     void warmupTimeChanged(int wutime);
00138     void hostWaitingForSyncSignal();
00139     void hostFoundOffsetSignal();
00140     void recordingFailed();
00141     void quitStateMachine();
00142 
00143   private:
00144     void loadNodes(); 
00145     void loadNodeList(QListWidget *list);
00146     void initSettings();
00147     void updatePathLabels();
00148 
00149     void setupStateTimeout(QState *state, const QString &text, int timeout);
00150     PacCountingSignalTransition *createNodeCountingTransition(QState *source, QState *target, QObject *sender, const QByteArray &signal);
00151 
00157     void setupTreeSnapshot(QMap<QString, QString> *snapshot, const QtVariantProperty *top, const QString &path) const;
00158 
00159     void closeEvent(QCloseEvent * event);
00160 
00161     static QHash<quint8, PacNode*> nodes; 
00162     PacMsg *pacmsg; 
00163     QTimer *stattimer;
00164     QDirModel *eventPathDir;
00165     QGroupBox *statNodeBox;
00166     QGridLayout *statNodeGridLayout;
00167     PacUSBThread *usbthread;
00168     PacVariantManager *setupmanager;
00169     QtVariantProperty *nodePropertyTop;
00170     QVBoxLayout *nodeConnectionWidgetLayout;
00171     QtVariantProperty *autostartspectrapac, *spectrapaccommandline, *warmuptime,
00172                       *externalcommands, *switchsyncmodecmd, *switchrecmodecmd, *syncpulsecmd,
00173                       *emin, *emax, *shorttermsize,
00174                       *echannels, *maxcorrlength, *netbuffer, *corrbuffer, *saverbuffer,
00175                       *chunksize;
00176     QDateTime warmUpAndStartTime; 
00177     PacCallExternalTool *exttoolcaller;
00178     PacWaitDialog *waitdialog;
00179 
00180     QStateMachine *statemachine;
00181     PacState *idle;
00182     PacState *partiallyDisconnected;
00183     PacState *allConnected;
00184     PacState *working;
00185     PacState *warmUpPMTs;
00186     PacState *switchToSyncMode;
00187     PacState *switchNodesToSyncMode;
00188     PacState *generateSyncPulse;
00189     PacState *waitForSync;
00190     PacState *switchToRecMode;
00191     PacState *recording;
00192     QFinalState *exitPacMaster;
00193 
00194     QSignalMapper *waitdialogtext, *waitdialogtime, *exttoolmapper, *timeoutmapper;
00195     QTimer *externalTimeoutTimer;
00196     PacCountingSignalTransition *working2allConnected;
00197 };
00198 
00199 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines