PacMan 2.0(r200)
Runs on digital PAC measurement computers

PacDigitizerDev.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 PACDIGITIZERDEV_H
00022 #define PACDIGITIZERDEV_H
00023 
00024 #include <QObject>
00025 #include <QtDebug>
00026 #include <QSettings>
00027 #include "PropertyBranch.h"
00028 #include "TransmittableProperty.h"
00029 #include "PacTriggerSetupBranch.h"
00030 
00031 #ifdef ENABLE_AGILENT
00032 #include <AcqirisImport.h>
00033 #include <AcqirisD1Import.h>
00034 #else
00035 typedef signed long ViInt32;
00036 typedef unsigned long ViUInt32;
00037 typedef char ViChar;
00038 typedef ViInt32 ViStatus;
00039 typedef ViUInt32 ViSession;
00040 #endif
00041 
00042 #ifdef Q_OS_WIN32
00043 #include <Windows.h>
00044 #endif
00045 
00046 class WaveformDataInterface;
00047 
00053 class PacDigitizerDev : public QObject, public PropertyBranch
00054 {
00055     Q_OBJECT
00056   public:
00057     PacDigitizerDev(PropertyBranchInterface *parentbranch = 0);
00058     ~PacDigitizerDev();
00059     enum Coupling {
00060       InvalidInput = 0,
00061       Dc1MInput    = 1,
00062       Ac1MInput    = 2,
00063       Dc50Input    = 3,
00064       Ac50Input    = 4
00065     };
00066     enum TriggerCoupling {
00067       DcTrigger        = 0,
00068       AcTrigger        = 1,
00069       HfRejectTrigger  = 2,
00070       Dc50Trigger      = 3,
00071       Ac50Trigger      = 4
00072     };
00073     enum TriggerMode {
00074       PositiveEdge    = 0,
00075       NegativeEdge    = 1,
00076       OutOfWindow     = 2,
00077       IntoWindow      = 3,
00078       HfDivide        = 4,
00079       SpikeStretcher  = 5
00080     };
00081     enum TriggerInput {
00082       TrigOnSignal    = 0,
00083       ExtTriggerIn    = 1
00084     };
00085     enum InputFrontEnd {
00086       Channel1        = 0,
00087       Channel2        = 1
00088     };
00089     enum FullScale {
00090       FS50mV  = 0,
00091       FS100mV = 1,
00092       FS200mV = 2,
00093       FS500mV = 3,
00094       FS1V    = 4,
00095       FS2V    = 5,
00096       FS5V    = 6
00097     };
00098     static quint32 chunkSize() { return chunksize; };
00099     virtual void childPropertyChanged(TransmittableProperty *p);
00100 
00101   public slots:
00102     void startSynchronization();
00103     void startRecording();
00104     void stopRecording();
00105     void numAnalyzerThreads(unsigned int newnum); 
00106 
00107   private slots:
00108     void sendEventsPerSecond();
00109     void send_waveform_teaser();
00110 
00111   signals:
00112     void threadReady(QString s);
00113     void eventsPerSecond(long recevents);
00114     void lastRecordedEventsSeqNum(qlonglong l);
00115     void sendWaveformTeaser(WaveformDataInterface *w);
00116     void errorStopRecording();
00117     void waitingForOffsetSignal();
00118     void foundOffsetSignal();
00119 
00120   private:
00121     void propertyChanged(TransmittableProperty *p);
00122     void loadSettings(); 
00123     void configBasicSettings(); 
00124     void configForSyncing(); 
00125     void configForRecording(); 
00126     void closeDevice(); 
00127     void digitizerFatalError(const ViStatus status, const QString errormsgprefix); 
00128     void startDataAcquisition(); 
00129     bool waitForDigitizer(); 
00130     ViSession instrumentID; 
00131     #ifdef ENABLE_AGILENT
00132     AqReadParameters *AqReadParams; 
00133     #endif
00134     bool busy;  
00135     bool synced;  
00136     bool newsettingswaiting; 
00137     bool continueRecording; 
00138     long numevents; 
00139 
00140     // Transmittable properties
00141     TransmittableProperty p_chunksize, p_numsegments, p_numbanks,
00142                           p_samplespersegment, p_samplesbeforetrigger,
00143                           p_samplerate, p_extclockfreq, p_useexternalclock,
00144                           p_inputfrontend,
00145                           p_inputmaxamplitude, p_inputpolarity,
00146                           p_inputcoupling, p_triggercoupling,
00147                           p_triggermode, p_synctriggercoupling,
00148                           p_synctriggersource, p_synctriggermode;
00149     PropertyBranch        b_sampling, b_input, b_trigger, b_synctrigger;
00150     PacTriggerSetupBranch b_triggermode, b_synctriggermode;
00151     // configurable parameters
00152     static quint32 chunksize;
00153     qint32 numsegments, numbanks;
00154     quint32 samplespersegment;
00155     qint32 samplesbeforetrigger;
00156     qreal samplerate, extclockfreq;
00157     bool useexternalclock;
00158     InputFrontEnd inputfrontend;
00159     int inputchannelnumber;
00160     int inputchannelpattern;
00161     qreal inputmaxamplitude, inputpolarity;
00162     Coupling inputcoupling;
00163     TriggerCoupling triggercoupling;
00164     TriggerMode triggermode;
00165     TriggerCoupling synctriggercoupling;
00166     TriggerInput synctriggersource;
00167     TriggerMode synctriggermode;
00168     qreal triggerlevel1, triggerlevel2, synctriggerlevel1, synctriggerlevel2;
00169 
00170     qreal realtriggerlevel1, realtriggerlevel2;
00171     long long seqnum; 
00172     unsigned int numanalyzerthreads; 
00173     bool sendTeaser;
00174     qulonglong timeoffset;
00175 };
00176 
00177 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends