asyn  4-45
testAsynPortDriver.h
Go to the documentation of this file.
1 /*
2  * testAsynPortDriver.h
3  *
4  * Asyn driver that inherits from the asynPortDriver class to demonstrate its use.
5  * It simulates a digital scope looking at a 1kHz 1000-point noisy sine wave. Controls are
6  * provided for time/division, volts/division, volt offset, trigger delay, noise amplitude, update time,
7  * and run/stop.
8  * Readbacks are provides for the waveform data, min, max and mean values.
9  *
10  * Author: Mark Rivers
11  *
12  * Created Feb. 5, 2009
13  */
14 
15 #include "asynPortDriver.h"
16 
17 #define NUM_VERT_SELECTIONS 4
18 
19 
20 /* These are the drvInfo strings that are used to identify the parameters.
21  * They are used by asyn clients, including standard asyn device support */
22 #define P_RunString "SCOPE_RUN" /* asynInt32, r/w */
23 #define P_MaxPointsString "SCOPE_MAX_POINTS" /* asynInt32, r/o */
24 #define P_TimePerDivString "SCOPE_TIME_PER_DIV" /* asynFloat64, r/w */
25 #define P_TimePerDivSelectString "SCOPE_TIME_PER_DIV_SELECT" /* asynInt32, r/w */
26 #define P_VertGainString "SCOPE_VERT_GAIN" /* asynFloat64, r/w */
27 #define P_VertGainSelectString "SCOPE_VERT_GAIN_SELECT" /* asynInt32, r/w */
28 #define P_VoltsPerDivString "SCOPE_VOLTS_PER_DIV" /* asynFloat64, r/w */
29 #define P_VoltsPerDivSelectString "SCOPE_VOLTS_PER_DIV_SELECT" /* asynInt32, r/w */
30 #define P_VoltOffsetString "SCOPE_VOLT_OFFSET" /* asynFloat64, r/w */
31 #define P_TriggerDelayString "SCOPE_TRIGGER_DELAY" /* asynFloat64, r/w */
32 #define P_NoiseAmplitudeString "SCOPE_NOISE_AMPLITUDE" /* asynFloat64, r/w */
33 #define P_UpdateTimeString "SCOPE_UPDATE_TIME" /* asynFloat64, r/w */
34 #define P_WaveformString "SCOPE_WAVEFORM" /* asynFloat64Array, r/o */
35 #define P_TimeBaseString "SCOPE_TIME_BASE" /* asynFloat64Array, r/o */
36 #define P_MinValueString "SCOPE_MIN_VALUE" /* asynFloat64, r/o */
37 #define P_MaxValueString "SCOPE_MAX_VALUE" /* asynFloat64, r/o */
38 #define P_MeanValueString "SCOPE_MEAN_VALUE" /* asynFloat64, r/o */
39 
47 public:
48  testAsynPortDriver(const char *portName, int maxArraySize);
50 
51  /* These are the methods that we override from asynPortDriver */
52  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
53  virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
54  virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
55  size_t nElements, size_t *nIn);
56  virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[],
57  size_t nElements, size_t *nIn);
58 
59  /* These are the methods that are new to this class */
60  void simTask(void);
61 
62 protected:
64  int P_Run;
81 
82 private:
83  /* Our data */
84  epicsEventId eventId_;
85  epicsThreadId threadId_;
86  bool exiting_;
87  epicsFloat64 *pData_;
88  epicsFloat64 *pTimeBase_;
89  // Actual volts per division are these values divided by vertical gain
90  char *voltsPerDivStrings_[NUM_VERT_SELECTIONS];
91  int voltsPerDivValues_[NUM_VERT_SELECTIONS];
92  int voltsPerDivSeverities_[NUM_VERT_SELECTIONS];
93  void setVertGain();
94  void setVoltsPerDiv();
95  void setTimePerDiv();
96 };
Base class for asyn port drivers; handles most of the bookkeeping for writing an asyn port driver wit...
Definition: asynPortDriver.h:98
char * portName
The name of this asyn port.
Definition: asynPortDriver.h:256
Class that demonstrates the use of the asynPortDriver base class to greatly simplify the task of writ...
Definition: testAsynPortDriver.h:46
int P_VoltsPerDiv
Definition: testAsynPortDriver.h:70
int P_VoltOffset
Definition: testAsynPortDriver.h:72
int P_VertGainSelect
Definition: testAsynPortDriver.h:69
int P_TimePerDivSelect
Definition: testAsynPortDriver.h:67
int P_MaxValue
Definition: testAsynPortDriver.h:79
virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[], size_t nElements, size_t *nIn)
Called when asyn clients call pasynEnum->read().
Definition: testAsynPortDriver.cpp:375
int P_MaxPoints
Definition: testAsynPortDriver.h:65
int P_MinValue
Definition: testAsynPortDriver.h:78
~testAsynPortDriver()
Definition: testAsynPortDriver.cpp:139
int P_Waveform
Definition: testAsynPortDriver.h:76
int P_UpdateTime
Definition: testAsynPortDriver.h:75
int P_MeanValue
Definition: testAsynPortDriver.h:80
void simTask(void)
Simulation task that runs as a separate thread.
Definition: testAsynPortDriver.cpp:175
int P_TriggerDelay
Definition: testAsynPortDriver.h:73
virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value, size_t nElements, size_t *nIn)
Called when asyn clients call pasynFloat64Array->read().
Definition: testAsynPortDriver.cpp:342
int P_VoltsPerDivSelect
Definition: testAsynPortDriver.h:71
testAsynPortDriver(const char *portName, int maxArraySize)
Constructor for the testAsynPortDriver class.
Definition: testAsynPortDriver.cpp:49
int P_Run
Values used for pasynUser->reason, and indexes into the parameter library.
Definition: testAsynPortDriver.h:64
int P_TimePerDiv
Definition: testAsynPortDriver.h:66
int P_TimeBase
Definition: testAsynPortDriver.h:77
int P_NoiseAmplitude
Definition: testAsynPortDriver.h:74
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: testAsynPortDriver.cpp:240
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: testAsynPortDriver.cpp:290
int P_VertGain
Definition: testAsynPortDriver.h:68
#define NUM_VERT_SELECTIONS
Definition: testAsynPortDriver.h:17