quadEM  7-0
drvNSLS2_EM.h
Go to the documentation of this file.
1 /*
2  * drvNSLS2_EM.h
3  *
4  * Asyn driver that inherits from the drvQuadEM class to control the NSLS2 electrometer / XBPM
5  *
6  * Author: Mark Rivers, Pete Siddons
7  *
8  * Created January 18th, 2016
9  */
10 
11 #include "drvQuadEM.h"
12 
13 #define MAX_FIRMWARE_LEN 64
14 #define MAX_RANGES 5
15 #define P_DACString "QE_DAC" /* asynInt32, r/w */
16 #define P_CalibrationModeString "QE_CALIBRATION_MODE" /* asynInt32, r/w */
17 #define P_ADCOffsetString "QE_ADC_OFFSET" /* asynInt32, r/w */
18 
20 class drvNSLS2_EM : public drvQuadEM {
21 public:
22  drvNSLS2_EM(const char *portName, int moduleID, int ringBufferSize);
23  ~drvNSLS2_EM();
24 
25  /* These are the methods we implement from asynPortDriver */
26  void report(FILE *fp, int details);
27 
28  /* These are the methods that are new to this class */
29  virtual void exitHandler();
30  /* This should be private but we call it from C so it needs to be public */
31  void callbackFunc();
32  bool isAcquiring();
33 
34 protected:
35  /* These are the methods we implement from quadEM */
36  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
37  virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high);
38  virtual asynStatus setAcquire(epicsInt32 value);
39  virtual asynStatus setRange(epicsInt32 value);
40  virtual asynStatus setValuesPerRead(epicsInt32 value);
41  virtual asynStatus setAveragingTime(epicsFloat64 value);
42  virtual asynStatus setBiasVoltage(epicsFloat64 value);
43  virtual asynStatus readStatus();
44  virtual asynStatus reset();
45 
46  int P_DAC;
47  #define FIRST_NSLS2_COMMAND P_DAC
50 
51 private:
52  /* Our data */
53  double ranges_[MAX_RANGES];
54  epicsFloat64 rawData_[QE_MAX_INPUTS];
55  int readingsAveraged_;
56  int readingActive_;
57  bool calibrationMode_;
58  int ADCOffset_[QE_MAX_INPUTS];
59  char firmwareVersion_[MAX_FIRMWARE_LEN];
60  volatile unsigned int *fpgabase_; //mmap'd fpga registers
61  epicsFloat64 scaleFactor_[QE_MAX_INPUTS][MAX_RANGES];
62  int memfd_;
63  int intfd_;
64 
65  /* our functions */
66  asynStatus getFirmwareVersion();
67  asynStatus readMeter(int *adcbuf);
68  asynStatus setDAC(int channel, int value);
69  void mmap_fpga();
70  asynStatus pl_open(int *fd);
71  asynStatus setAcquireParams();
72 };
73 
int P_CalibrationMode
Definition: drvNSLS2_EM.h:48
virtual asynStatus setRange(epicsInt32 value)
Definition: drvNSLS2_EM.cpp:403
Base class to control the quad electrometer.
Definition: drvQuadEM.h:128
virtual asynStatus setValuesPerRead(epicsInt32 value)
Sets the values per read.
Definition: drvNSLS2_EM.cpp:389
#define QE_MAX_INPUTS
Definition: drvQuadEM.h:124
drvNSLS2_EM(const char *portName, int moduleID, int ringBufferSize)
Definition: drvNSLS2_EM.cpp:184
void callbackFunc()
Definition: drvNSLS2_EM.cpp:313
~drvNSLS2_EM()
Definition: drvNSLS2_EM.cpp:242
char * portName
The name of this asyn port.
Definition: asynPortDriver.h:201
virtual asynStatus setBiasVoltage(epicsFloat64 value)
Definition: drvNSLS2_EM.cpp:396
bool isAcquiring()
Definition: drvNSLS2_EM.cpp:147
virtual void exitHandler()
Definition: drvNSLS2_EM.cpp:458
int P_DAC
Definition: drvNSLS2_EM.h:46
#define MAX_RANGES
Definition: drvNSLS2_EM.h:14
#define MAX_FIRMWARE_LEN
Definition: drvNSLS2_EM.h:13
int P_ADCOffset
Definition: drvNSLS2_EM.h:49
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: drvNSLS2_EM.cpp:252
virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high)
Called when asyn clients call pasynInt32->getBounds(), returning the bounds on the asynInt32 interfac...
Definition: drvNSLS2_EM.cpp:298
virtual asynStatus reset()
Downloads all of the current EPICS settings to the electrometer.
Definition: drvNSLS2_EM.cpp:445
Class to control the NSLS Precision Integrator.
Definition: drvNSLS2_EM.h:20
void report(FILE *fp, int details)
Report status of the driver.
Definition: drvNSLS2_EM.cpp:450
virtual asynStatus setAcquire(epicsInt32 value)
Starts and stops the electrometer.
Definition: drvNSLS2_EM.cpp:341
virtual asynStatus readStatus()
Definition: drvNSLS2_EM.cpp:427
virtual asynStatus setAveragingTime(epicsFloat64 value)
Definition: drvNSLS2_EM.cpp:381