QXRD  0.11.16
qxrdacquisitionthread.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
3 
4 #include "qxrddataprocessor.h"
5 #include "qxrdapplication.h"
6 #include "qxrdexperiment.h"
7 #include "qxrdacquisition.h"
8 #include "qcepmutexlocker.h"
9 
10 #include <QFuture>
11 #include <QVariant>
12 #include <QMetaObject>
13 
14 //static int g_DetectorType = -1;
15 
19  QcepAllocatorWPtr allocator,
20  int detectorType)
21  : QxrdThread(),
22  m_Saver(saver),
23  m_Experiment(doc),
24  m_Allocator(allocator),
25  m_Processor(proc),
26  m_DetectorType(detectorType),
28 {
30  printf("QxrdAcquisitionThread::QxrdAcquisitionThread(%p)\n", this);
31  }
32 
33  setObjectName("acquisition");
34 }
35 
37 {
38  shutdown();
39 
41  printf("QxrdAcquisitionThread::~QxrdAcquisitionThread(%p)\n", this);
42  }
43 }
44 
46 {
47  if (qcepDebug(DEBUG_THREADS)) {
48  printf("Acquisition Thread Started\n");
49  }
50 
53 
54  int rc = -1;
55 
56  if (acq) {
57  acq -> initialize();
58 
59  m_Mutex.lock();
60  m_Acquisition = acq;
61  m_Mutex.unlock();
62 
63  rc = exec();
64  }
65 
66  {
67  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
68 
70  }
71 
72  if (qcepDebug(DEBUG_THREADS)) {
73  printf("Acquisition Thread Terminated with rc %d\n", rc);
74  }
75 }
76 
78 {
79  exit();
80 
81  wait();
82 }
83 
85 {
86  QThread::msleep(msec);
87 }
88 
90 {
91  while (isRunning()) {
92  {
93  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
94 
95  if (m_Acquisition) return m_Acquisition;
96  }
97 
98  QThread::msleep(50);
99  }
100 
101  return QxrdAcquisitionPtr();
102 }
103 
105 {
106  QThread::usleep((int)(time*1e6));
107 }
QWeakPointer< QxrdDataProcessor > QxrdDataProcessorWPtr
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QxrdDataProcessorWPtr m_Processor
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
QcepAllocatorWPtr m_Allocator
QxrdAcquisitionThread(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr doc, QxrdDataProcessorWPtr proc, QcepAllocatorWPtr allocator, int detectorType)
QxrdAcquisitionPtr m_Acquisition
QcepSettingsSaverWPtr m_Saver
QWeakPointer< QcepAllocator > QcepAllocatorWPtr
QMutex m_Mutex
Definition: qcepthread.h:17
QxrdAcquisitionPtr acquisition() const
QxrdExperimentWPtr m_Experiment
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr