areaDetector  3-13
EPICS areaDetector framework
ADLambda.h
Go to the documentation of this file.
1 
5 /* ADLambda.h
6  *
7  * This is an areaDetector driver for cameras that communicate
8  * with the X-Spectrum Lambda driver library
9  *
10  */
11 #ifndef ADLAMBDA_H
12 #define ADLAMBDA_H
13 #include <libxsp.h>
14 #include <string>
15 #include <map>
16 #include <deque>
17 #include <variant>
18 
19 
20 #include <epicsString.h>
21 #include <epicsEvent.h>
22 #include <epicsThread.h>
23 
24 #include "ADDriver.h"
25 
26 static const int ONE_BIT = 1;
27 static const int SIX_BIT = 6;
28 static const int TWELVE_BIT = 12;
29 static const int TWENTY_FOUR_BIT = 24;
30 
31 static const double ONE_BILLION = 1.E9;
32 
33 static const double SHORT_TIME = 0.000025;
34 
35 typedef std::variant<std::shared_ptr<xsp::lambda::Receiver>, std::shared_ptr<xsp::PostDecoder> > lambda_input;
36 
40 class epicsShareClass ADLambda: public ADDriver
41 {
42 public:
43  static const char *driverName;
44 
45  ADLambda(const char *portName, const char *configPath, int numModules, int fake);
46  ~ADLambda();
47 
48  virtual asynStatus disconnect();
49  virtual asynStatus connect();
50 
51  void waitAcquireThread();
52  void tryConnect();
53  void acquireThread(int receiver);
55  void exportThread();
56 
57  void report(FILE *fp, int details);
58 
59  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
60 
61 protected:
63  #define LAMBDA_FIRST_PARAM LAMBDA_ConfigFilePath
77 
78 private:
79  bool connected = false;
80  bool hasDecoder = false;
81 
82  void setSizes();
83  void incrementValue(int param);
84  void decrementValue(int param);
85  void readParameters();
86  void sendParameters();
87  void writeDepth(int depth);
88 
89  bool tryStartAcquire();
90  bool tryStopAcquire();
91 
92  int fake;
93 
94  void spawnAcquireThread(int receiver);
95  void spawnAcquireDecoderThread();
96 
97  std::unique_ptr<xsp::System> sys;
98  std::shared_ptr<xsp::lambda::Detector> det;
99 
100  std::vector< lambda_input > inputs;
101 
102  std::map<int, NDArray*> frames;
103  std::deque<NDArray*> export_queue;
104 
105  epicsEvent* startAcquireEvent;
106  epicsEvent* stopAcquireEvent;
107  epicsEvent** threadFinishEvents;
108  epicsMutex* dequeLock;
109 
110  std::string configFileName;
111  NDArray *pImage = NULL;
112 };
113 
114 typedef struct
115 {
117  int receiver;
118 } acquire_data;
119 
120 
121 #define LAMBDA_ConfigFilePathString "LAMBDA_CONFIG_FILE_PATH"
122 #define LAMBDA_DecoderDetectedString "LAMBDA_DECODER_DETECTED"
123 #define LAMBDA_EnergyThresholdString "LAMBDA_ENERGY_THRESHOLD"
124 #define LAMBDA_DualThresholdString "LAMBDA_DUAL_THRESHOLD"
125 #define LAMBDA_DecodedQueueDepthString "LAMBDA_DECODED_QUEUE_DEPTH"
126 #define LAMBDA_OperatingModeString "LAMBDA_OPERATING_MODE"
127 #define LAMBDA_DualModeString "LAMBDA_DUAL_MODE"
128 #define LAMBDA_ChargeSummingString "LAMBDA_CHARGE_SUMMING"
129 #define LAMBDA_GatingEnableString "LAMBDA_GATING_ENABLE"
130 #define LAMBDA_BadFrameCounterString "LAMBDA_BAD_FRAME_COUNTER"
131 #define LAMBDA_BadImageString "LAMBDA_BAD_IMAGE"
132 #define LAMBDA_ReadoutThreadsString "LAMBDA_NUM_READOUT_THREADS"
133 #define LAMBDA_StitchWidthString "LAMBDA_STITCHED_WIDTH"
134 #define LAMBDA_StitchHeightString "LAMBDA_STITCHED_HEIGHT"
135 
136 
137 #endif
std::variant< std::shared_ptr< xsp::lambda::Receiver >, std::shared_ptr< xsp::PostDecoder > > lambda_input
Definition: ADLambda.h:35
Class from which areaDetector drivers are directly derived.
Definition: ADDriver.h:132
virtual asynStatus connect(asynUser *pasynUser)
Connects driver to device; This method is called when the driver's pasynCommon->connect() function is...
Definition: ADDriver.cpp:63
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Sets an int32 parameter.
Definition: ADDriver.cpp:84
Class to wrap Lambda detector library provided by X-Spectrum.
Definition: ADLambda.h:41
int LAMBDA_ConfigFilePath
Definition: ADLambda.h:62
int LAMBDA_DecoderDetected
Definition: ADLambda.h:64
int LAMBDA_BadFrameCounter
Definition: ADLambda.h:72
int LAMBDA_StitchedWidth
Definition: ADLambda.h:75
int LAMBDA_DualMode
Definition: ADLambda.h:69
int LAMBDA_ReadoutThreads
Definition: ADLambda.h:74
int LAMBDA_BadImage
Definition: ADLambda.h:73
int LAMBDA_DualThreshold
Definition: ADLambda.h:66
int LAMBDA_EnergyThreshold
Definition: ADLambda.h:65
void acquireDecoderThread()
static const char * driverName
Definition: ADLambda.h:43
int LAMBDA_DecodedQueueDepth
Definition: ADLambda.h:67
int LAMBDA_ChargeSumming
Definition: ADLambda.h:70
int LAMBDA_GatingEnable
Definition: ADLambda.h:71
int LAMBDA_OperatingMode
Definition: ADLambda.h:68
int LAMBDA_StitchedHeight
Definition: ADLambda.h:76
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:99
virtual void report(FILE *fp, int details)
Report status of the driver.
Definition: asynNDArrayDriver.cpp:753
@ string
Definition: NDFileHDF5Layout.h:44
list value
Definition: makeDbAndEdl.py:234
Definition: ADLambda.h:115
int receiver
Definition: ADLambda.h:117
ADLambda * driver
Definition: ADLambda.h:116