qavrg 0.0.28
|
00001 #ifndef QAVRGACQUISITION_H 00002 #define QAVRGACQUISITION_H 00003 00004 #include <QTime> 00005 #include <QObject> 00006 #include <QVector> 00007 #include <QMutex> 00008 #include <QWaitCondition> 00009 #include "AcqirisD1Import.h" 00010 #include <QAtomicInt> 00011 00012 #include "qavrgacquisitionsimulated.h" 00013 00014 class QavrgAcquisitionThread; 00015 class QavrgApplication; 00016 class QavrgFitter; 00017 class QavrgSettings; 00018 00019 class QavrgAcquisition : public QavrgAcquisitionSimulated 00020 { 00021 Q_OBJECT 00022 00023 public: 00024 QavrgAcquisition(QavrgAcquisitionThread *acq, QavrgApplication *app, QObject *parent); 00025 ~QavrgAcquisition(); 00026 void initialize(); 00027 00028 public slots: 00029 void acquireData(); 00030 void acquireReference(); 00031 void acquireDark(); 00032 void acquireOnce(); 00033 void acquireScope(); 00034 void acquireCancel(); 00035 int acquireWait(double time); 00036 00037 void loadData(QString fileName); 00038 void saveData(QString fileName); 00039 00040 void newSaveFile(QString f, int n); 00041 void closeSaveFile(); 00042 void startNewScan(QcepStringVector header); 00043 void saveAcquisitionResult(QcepDoubleVector data); 00044 00045 QVector<double> readResult(int chan, int parm, int start, int nbins); 00046 QVector<double> readResult(int chan, int parm); 00047 double readResult(int chan, int parm, int bin); 00048 QString resultHeader(int chan, int parm, int bin); 00049 double readResultAverage(int chan, int parm, int start, int nbins); 00050 double readResultBunchAverage(int chan, int parm, int bunch, int norbits); 00051 00052 int orbitNumber(int n) const; 00053 int bucketNumber(int n) const; 00054 00055 void fillPatternChanged(); 00056 void timingResetDefaults(); 00057 void triggerResetDefaults(); 00058 00059 public: 00060 int resultSize(); 00061 int getAcquisitionLock(); 00062 void releaseAcquisitionLock(); 00063 00064 virtual QcepSettingsSaverWPtr saver() const; 00065 00066 signals: 00067 void noDeviceAvailable(); 00068 void acquisitionStarted(); 00069 void acquisitionCancelled(); 00070 void acquisitionProgress(double pct); 00071 void acquisitionCompleted(); 00072 00073 private: 00074 void findDevices(); 00075 void configureAverager(AcquisitionMode mode); 00076 void setupAcquisition(AcquisitionMode mode); 00077 void startAcquisition(int rep, int nrep); 00078 void waitAcquisition(int rep, int nrep); 00079 void readoutAcquisition(int rep, int nrep); 00080 bool checkStatus(int line, ViStatus status); 00081 00082 private: 00083 mutable QMutex m_AcquisitionMutex; 00084 mutable QMutex m_SaveFileMutex; 00085 mutable QMutex m_BufferMutex; 00086 00087 QavrgApplication *m_Application; 00088 QavrgAcquisitionThread *m_AcquisitionThread; 00089 ViInt32 m_NInstruments; 00090 ViSession *m_InstrumentID; 00091 ViInt32 *m_CardNChannels; 00092 long m_TotalChannels; 00093 QTime m_Time; 00094 FILE *m_SaveFile; 00095 QVector<double> m_Buffer; 00096 QMutex m_Acquiring; 00097 QWaitCondition m_StatusWaiting; 00098 }; 00099 00100 Q_DECLARE_METATYPE(QavrgAcquisition*) 00101 00102 #endif