quadEM  7-0
drvNSLS2_IC.h
Go to the documentation of this file.
1 /*
2  * drvNSLS2_IC.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 May 20th, 2019
9  */
10 
11 #include "drvQuadEM.h"
12 
13 #define MAX_FIRMWARE_LEN 64
14 #define MAX_RANGES 8
15 #define P_DACString "QE_DAC" /* asynInt32, r/w */
16 #define P_DACDoubleString "QE_DAC_DOUBLE" /* asynFloat64 r/w */
17 #define P_CalibrationModeString "QE_CALIBRATION_MODE" /* asynInt32, r/w */
18 #define P_ADCOffsetString "QE_ADC_OFFSET" /* asynInt32, r/w */
19 #define P_FullScaleString "QE_FULL_SCALE" /* asynFloat64 r/w */
20 
21 class drvNSLS2_IC : public drvQuadEM {
22 public:
23  drvNSLS2_IC(const char *portName, int ringBufferSize);
24  ~drvNSLS2_IC();
25 
26  /* These are the methods we implement from asynPortDriver */
27  void report(FILE *fp, int details);
28 
29  /* These are the methods that are new to this class */
30  virtual void exitHandler();
31  /* This should be private but we call it from C so it needs to be public */
32  void callbackFunc();
33  bool isAcquiring();
34 
35 protected:
36  /* These are the methods we implement from quadEM */
37  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
38  /* Ivan So: add writeFloat64 so we may write to the DAC thru asynPort with QE_DOUBLE_DATA */
39  virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
40  virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high);
41  virtual asynStatus setAcquire(epicsInt32 value);
42  virtual asynStatus setRange(epicsInt32 value);
43  virtual asynStatus setValuesPerRead(epicsInt32 value);
44  virtual asynStatus setAveragingTime(epicsFloat64 value);
45  virtual asynStatus setBiasVoltage(epicsFloat64 value);
46  virtual asynStatus readStatus();
47  virtual asynStatus reset();
48 
49  int P_DAC;
50  #define FIRST_NSLS2_COMMAND P_DAC
55 private:
56  /* Our data */
57  double ranges_[MAX_RANGES];
58  epicsFloat64 rawData_[QE_MAX_INPUTS];
59  int readingsAveraged_;
60  int readingActive_;
61  bool calibrationMode_;
62  int ADCOffset_[QE_MAX_INPUTS];
63  char firmwareVersion_[MAX_FIRMWARE_LEN];
64  volatile unsigned int *fpgabase_; //mmap'd fpga registers
65  epicsFloat64 scaleFactor_[MAX_RANGES];
66  int memfd_;
67  int intfd_;
68 
69  /* our functions */
70  asynStatus getFirmwareVersion();
71  asynStatus readMeter(int *adcbuf);
72  asynStatus computeScaleFactor();
73  asynStatus OpenDacs();
74  asynStatus EnableIntRef(int dev);
75  asynStatus setDAC(int channel, int value);
76  void mmap_fpga();
77  asynStatus pl_open(int *fd);
78  asynStatus setIntegrationTime(epicsFloat64 value);
79  asynStatus setAcquireParams();
80 };
81 
int P_ADCOffset
Definition: drvNSLS2_IC.h:53
~drvNSLS2_IC()
Definition: drvNSLS2_IC.cpp:294
virtual asynStatus setBiasVoltage(epicsFloat64 value)
Definition: drvNSLS2_IC.cpp:537
int P_CalibrationMode
Definition: drvNSLS2_IC.h:52
Base class to control the quad electrometer.
Definition: drvQuadEM.h:128
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: drvNSLS2_IC.cpp:304
#define QE_MAX_INPUTS
Definition: drvQuadEM.h:124
virtual asynStatus reset()
Downloads all of the current EPICS settings to the electrometer.
Definition: drvNSLS2_IC.cpp:584
#define MAX_FIRMWARE_LEN
Definition: drvNSLS2_IC.h:13
int P_DAC
Definition: drvNSLS2_IC.h:49
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_IC.cpp:393
char * portName
The name of this asyn port.
Definition: asynPortDriver.h:201
int P_FullScale
Definition: drvNSLS2_IC.h:54
#define MAX_RANGES
Definition: drvNSLS2_IC.h:14
Class to control the NSLS Precision Integrator.
Definition: drvNSLS2_IC.h:21
int P_DACDouble
Definition: drvNSLS2_IC.h:51
bool isAcquiring()
Definition: drvNSLS2_IC.cpp:183
virtual asynStatus setRange(epicsInt32 value)
Definition: drvNSLS2_IC.cpp:553
virtual void exitHandler()
Definition: drvNSLS2_IC.cpp:597
void callbackFunc()
Definition: drvNSLS2_IC.cpp:408
void report(FILE *fp, int details)
Report status of the driver.
Definition: drvNSLS2_IC.cpp:589
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: drvNSLS2_IC.cpp:352
drvNSLS2_IC(const char *portName, int ringBufferSize)
Definition: drvNSLS2_IC.cpp:241
virtual asynStatus setAcquire(epicsInt32 value)
Starts and stops the electrometer.
Definition: drvNSLS2_IC.cpp:463
virtual asynStatus readStatus()
Definition: drvNSLS2_IC.cpp:562
virtual asynStatus setAveragingTime(epicsFloat64 value)
Definition: drvNSLS2_IC.cpp:522
virtual asynStatus setValuesPerRead(epicsInt32 value)
Sets the values per read.
Definition: drvNSLS2_IC.cpp:530