QXRD  0.11.16
Public Slots | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
QxrdDetectorSimulated Class Reference

#include <qxrddetectorsimulated.h>

Inheritance diagram for QxrdDetectorSimulated:
Inheritance graph
[legend]
Collaboration diagram for QxrdDetectorSimulated:
Collaboration graph
[legend]

Public Slots

void startDetector ()
 
void stopDetector ()
 
virtual void onExposureTimeChanged ()
 
void onTimerTimeout ()
 
- Public Slots inherited from QxrdDetector
bool isEnabled ()
 
bool checkDetectorEnabled ()
 
virtual void startDetector ()
 
virtual void stopDetector ()
 
virtual void onExposureTimeChanged ()
 
void openControlWindow ()
 
QxrdDetectorProcessorPtr processor ()
 
void startOrStop (bool enabled)
 
virtual void beginFrame ()
 
virtual QcepImageDataBasePtr acquireFrameIfAvailable ()
 
virtual QcepImageDataBasePtr acquireFrame ()
 
int roiCount ()
 
QxrdROICoordinatesPtr roi (int i)
 
QcepDoubleVector scalerCounts ()
 
double scalerCounts (int chan)
 
- Public Slots inherited from QcepObject
virtual void printLine (QString line)
 
virtual QString settingsScript ()
 
QString scriptValueLiteral (QVariant v)
 

Public Member Functions

 QxrdDetectorSimulated (QcepSettingsSaverWPtr saver, QxrdExperimentWPtr expt, QxrdAcquisitionWPtr acq, int detNum, QcepObject *parent)
 
virtual ~QxrdDetectorSimulated ()
 
void pushPropertiesToProxy (QxrdDetectorProxyPtr proxy)
 
void pullPropertiesfromProxy (QxrdDetectorProxyPtr proxy)
 
void beginAcquisition (double exposure)
 
void endAcquisition ()
 
void shutdownAcquisition ()
 
- Public Member Functions inherited from QxrdDetector
 QxrdDetector (QcepSettingsSaverWPtr saver, QxrdExperimentWPtr expt, QxrdAcquisitionWPtr acq, int detType, int detNum, QcepObject *parent)
 
void initialize ()
 
virtual ~QxrdDetector ()
 
QxrdExperimentWPtr experiment ()
 
QxrdAcquisitionWPtr acquisition ()
 
void printMessage (QString msg, QDateTime ts=QDateTime::currentDateTime()) const
 
void criticalMessage (QString msg, QDateTime ts=QDateTime::currentDateTime()) const
 
void statusMessage (QString msg, QDateTime ts=QDateTime::currentDateTime()) const
 
void readSettings (QSettings *settings, QString section)
 
void writeSettings (QSettings *settings, QString section)
 
void enqueueAcquiredFrame (QcepImageDataBasePtr img)
 
- Public Member Functions inherited from QcepObject
 QcepObject (QString name, QcepObject *parent)
 
virtual ~QcepObject ()
 
QString get_Name () const
 
void set_Name (QString name)
 

Static Public Member Functions

static void pushDefaultsToProxy (QxrdDetectorProxyPtr proxy)
 
- Static Public Member Functions inherited from QxrdDetector
static QScriptValue toScriptValue (QScriptEngine *engine, const QxrdDetectorPtr &det)
 
static void fromScriptValue (const QScriptValue &obj, QxrdDetectorPtr &det)
 
static void pushDefaultsToProxy (QxrdDetectorProxyPtr proxy, int detType)
 
- Static Public Member Functions inherited from QcepObject
static int allocatedObjects ()
 
static int deletedObjects ()
 
static QSet< QcepObject * > allocatedObjectsSet ()
 
static QString addSlashes (QString str)
 

Private Attributes

QTimer m_Timer
 

Additional Inherited Members

- Public Types inherited from QxrdDetector
enum  { FileIndexScaler, FilePhaseScaler, ExtraScalers }
 
- Protected Attributes inherited from QxrdDetector
QcepSettingsSaverWPtr m_Saver
 
QxrdExperimentWPtr m_Experiment
 
QxrdAcquisitionWPtr m_Acquisition
 
QxrdDetectorProcessorPtr m_Processor
 
QxrdDetectorControlWindowPtr m_DetectorControlWindow
 
- Properties inherited from QxrdDetector
int detectorNumber
 
int detectorType
 
QString detectorTypeName
 
bool enabled
 
QString detectorName
 
int nCols
 
int nRows
 
int hBinning
 
int vBinning
 
QString extension
 
- Properties inherited from QcepObject
QString name
 

Detailed Description

Definition at line 8 of file qxrddetectorsimulated.h.

Constructor & Destructor Documentation

QxrdDetectorSimulated::QxrdDetectorSimulated ( QcepSettingsSaverWPtr  saver,
QxrdExperimentWPtr  expt,
QxrdAcquisitionWPtr  acq,
int  detNum,
QcepObject parent 
)
explicit

Definition at line 10 of file qxrddetectorsimulated.cpp.

References DEBUG_CONSTRUCTORS, m_Timer, onTimerTimeout(), and qcepDebug().

14  :
15  QxrdDetector(saver, expt, acq, QxrdDetectorThread::SimulatedDetector, detNum, parent)
16 {
18  printf("QxrdDetectorSimulated::QxrdDetectorSimulated(%p)\n", this);
19  }
20 
21  connect(&m_Timer, &QTimer::timeout, this, &QxrdDetectorSimulated::onTimerTimeout);
22 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QxrdDetector(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr expt, QxrdAcquisitionWPtr acq, int detType, int detNum, QcepObject *parent)

Here is the call graph for this function:

QxrdDetectorSimulated::~QxrdDetectorSimulated ( )
virtual

Definition at line 24 of file qxrddetectorsimulated.cpp.

References DEBUG_CONSTRUCTORS, and qcepDebug().

25 {
26 #ifndef QT_NO_DEBUG
27  printf("Deleting simulated detector\n");
28 #endif
29 
31  printf("QxrdDetectorSimulated::~QxrdDetectorSimulated(%p)\n", this);
32  }
33 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26

Here is the call graph for this function:

Member Function Documentation

void QxrdDetectorSimulated::beginAcquisition ( double  exposure)
virtual

Reimplemented from QxrdDetector.

Definition at line 127 of file qxrddetectorsimulated.cpp.

References QxrdDetector::beginAcquisition(), and frameCounter.

128 {
129  if (QThread::currentThread() != thread()) {
130  QMetaObject::invokeMethod(this, "beginAcquisition", Qt::BlockingQueuedConnection, Q_ARG(double, exposure));
131  } else {
133 
134  frameCounter = 0;
135  }
136 }
static int frameCounter
virtual void beginAcquisition(double exposure)

Here is the call graph for this function:

void QxrdDetectorSimulated::endAcquisition ( )
virtual

Reimplemented from QxrdDetector.

Definition at line 138 of file qxrddetectorsimulated.cpp.

References QxrdDetector::endAcquisition().

139 {
140  if (QThread::currentThread() != thread()) {
141  QMetaObject::invokeMethod(this, "endAcquisition", Qt::BlockingQueuedConnection);
142  } else {
144  }
145 }
virtual void endAcquisition()

Here is the call graph for this function:

void QxrdDetectorSimulated::onExposureTimeChanged ( )
virtualslot

Definition at line 56 of file qxrddetectorsimulated.cpp.

References QxrdDetector::isEnabled(), QxrdDetector::m_Acquisition, QxrdDetector::m_Experiment, and m_Timer.

Referenced by startDetector().

57 {
58  if (QThread::currentThread() != thread()) {
59  QMetaObject::invokeMethod(this, "onExposureTimeChanged");
60  } else {
63 
64  if (isEnabled() && acq && expt) {
65  double newTime = acq->get_ExposureTime();
66 
67  expt->printMessage(tr("Exposure time changed to %1").arg(newTime));
68 
69  m_Timer.start(newTime*1000);
70  }
71  }
72 }
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QxrdExperimentWPtr m_Experiment
Definition: qxrddetector.h:93
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
QxrdAcquisitionWPtr m_Acquisition
Definition: qxrddetector.h:94

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdDetectorSimulated::onTimerTimeout ( )
slot

Definition at line 156 of file qxrddetectorsimulated.cpp.

References QcepAllocator::AllocateFromReserve, QxrdDetector::checkDetectorEnabled(), QxrdDetector::enqueueAcquiredFrame(), frameCounter, QxrdDetector::m_Acquisition, QxrdDetector::nCols, QcepAllocator::newInt16Image(), and QxrdDetector::nRows.

Referenced by QxrdDetectorSimulated().

157 {
159 
160  if (checkDetectorEnabled() && acq) {
161  if (acq->synchronizedAcquisition()) {
162  acq->synchronizedAcquisition()->acquiredFrameAvailable(frameCounter);
163  }
164 
165  int nRows = get_NRows();
166  int nCols = get_NCols();
167 
169  nCols, nRows, acq.data());
170  int xpmsec = (int)(acq->get_ExposureTime()*1000+0.5);
171  int frame = frameCounter % 8;
172 
173  if (image) {
174  quint16 *ptr = image->data();
175 
176  for (int j=0; j<nRows; j++) {
177  for (int i=0; i<nCols; i++) {
178  if ((i>=frame*64) && (i<(frame+1)*64) && (j < 64)) {
179  *ptr++ = frame;
180  } else {
181  *ptr++ = xpmsec;
182  }
183  }
184  }
185 
186  if ((nRows > 1024) && (nCols > 1024)) {
187  const int labelWidth = 256;
188  const int labelHeight = 64;
189 
190  QImage imageLabel(labelWidth, labelHeight, QImage::Format_RGB32);
191  QPainter painter(&imageLabel);
192 
193  painter.fillRect(0,0,labelWidth,labelHeight, Qt::black);
194  painter.setPen(Qt::white);
195  painter.setFont(QFont("Times", labelHeight, QFont::Bold, true));
196  painter.drawText(0, labelHeight, tr("%1").arg(frameCounter));
197 
198  QRgb *rgb = (QRgb*) imageLabel.bits();
199  int nFrames = nRows / labelHeight;
200  int frameN = frameCounter % nFrames;
201  int plval = qGray(*rgb);
202  int pRgb = *rgb;
203 
204  for (int j=0; j<labelHeight; j++) {
205  for (int i=0; i<labelWidth; i++) {
206  int x = nCols-labelWidth+i;
207  int y = (frameN+1)*labelHeight-j;
208  // int val = image->value(x,y);
209  int vRgb = *rgb++;
210  int lval = qGray(vRgb);
211 
212  if (lval != plval) {
213  plval = lval;
214  }
215 
216  if (vRgb != pRgb) {
217  pRgb = vRgb;
218  }
219 
220  image->setValue(x,y,lval);
221  }
222  }
223  }
224  }
225 
226  enqueueAcquiredFrame(image);
227 
228  frameCounter++;
229  }
230 }
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
QxrdAcquisitionWPtr m_Acquisition
Definition: qxrddetector.h:94
bool checkDetectorEnabled()
void enqueueAcquiredFrame(QcepImageDataBasePtr img)
static QcepInt16ImageDataPtr newInt16Image(AllocationStrategy strat, int width, int height, QcepObject *parent)
static int frameCounter
QSharedPointer< QcepInt16ImageData > QcepInt16ImageDataPtr

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdDetectorSimulated::pullPropertiesfromProxy ( QxrdDetectorProxyPtr  proxy)
virtual

Reimplemented from QxrdDetector.

Definition at line 49 of file qxrddetectorsimulated.cpp.

References QxrdDetector::pullPropertiesfromProxy().

50 {
52 
53 // printf("Need to implement QxrdDetectorSimulated::pullPropertiesfromProxy\n");
54 }
virtual void pullPropertiesfromProxy(QxrdDetectorProxyPtr proxy)

Here is the call graph for this function:

void QxrdDetectorSimulated::pushDefaultsToProxy ( QxrdDetectorProxyPtr  proxy)
static

Definition at line 35 of file qxrddetectorsimulated.cpp.

References QxrdDetector::pushDefaultsToProxy(), and QxrdDetectorThread::SimulatedDetector.

Referenced by QxrdDetectorThread::pushDefaultsToProxy().

36 {
38 
39 // printf("Need to implement QxrdDetectorSimulated::pushDefaultsToProxy\n");
40 }
static void pushDefaultsToProxy(QxrdDetectorProxyPtr proxy, int detType)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdDetectorSimulated::pushPropertiesToProxy ( QxrdDetectorProxyPtr  proxy)
virtual

Reimplemented from QxrdDetector.

Definition at line 42 of file qxrddetectorsimulated.cpp.

References QxrdDetector::pushPropertiesToProxy().

43 {
45 
46 // printf("Need to implement QxrdDetectorSimulated::pushPropertiesToProxy\n");
47 }
virtual void pushPropertiesToProxy(QxrdDetectorProxyPtr proxy)

Here is the call graph for this function:

void QxrdDetectorSimulated::shutdownAcquisition ( )
virtual

Reimplemented from QxrdDetector.

Definition at line 147 of file qxrddetectorsimulated.cpp.

References QxrdDetector::shutdownAcquisition().

148 {
149  if (QThread::currentThread() != thread()) {
150  QMetaObject::invokeMethod(this, "shutdownAcquisition", Qt::BlockingQueuedConnection);
151  } else {
153  }
154 }
virtual void shutdownAcquisition()

Here is the call graph for this function:

void QxrdDetectorSimulated::startDetector ( )
slot

Definition at line 88 of file qxrddetectorsimulated.cpp.

References QxrdDetector::checkDetectorEnabled(), QxrdDetector::m_Acquisition, onExposureTimeChanged(), QxrdDetector::printMessage(), and QxrdDetector::startDetector().

89 {
90  if (QThread::currentThread() != thread()) {
91  QMetaObject::invokeMethod(this, "startDetector", Qt::BlockingQueuedConnection);
92  } else {
94 
96 
97  if (checkDetectorEnabled() && acq) {
98  printMessage(tr("Starting simulated detector \"%1\"").arg(get_DetectorName()));
99 
100  set_NRows(2048);
101  set_NCols(2048);
102 
103  if (acq->get_ExposureTime() <= 0) {
104  acq->set_ExposureTime(0.1);
105  }
106 
108  }
109  }
110 }
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
QxrdAcquisitionWPtr m_Acquisition
Definition: qxrddetector.h:94
bool checkDetectorEnabled()
virtual void onExposureTimeChanged()
virtual void startDetector()

Here is the call graph for this function:

void QxrdDetectorSimulated::stopDetector ( )
slot

Definition at line 112 of file qxrddetectorsimulated.cpp.

References m_Timer, QxrdDetector::printMessage(), and QxrdDetector::stopDetector().

113 {
114  if (QThread::currentThread() != thread()) {
115  QMetaObject::invokeMethod(this, "startDetector", Qt::BlockingQueuedConnection);
116  } else {
117  printMessage(tr("Stopping simulated detector \"%1\"").arg(get_DetectorName()));
118 
120 
121  m_Timer.stop();
122  }
123 }
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
virtual void stopDetector()

Here is the call graph for this function:

Member Data Documentation

QTimer QxrdDetectorSimulated::m_Timer
private

The documentation for this class was generated from the following files: