asyn  4-39
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);
49 
50  /* These are the methods that we override from asynPortDriver */
51  virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
52  virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
53  virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
54  size_t nElements, size_t *nIn);
55  virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[],
56  size_t nElements, size_t *nIn);
57 
58  /* These are the methods that are new to this class */
59  void simTask(void);
60 
61 protected:
63  int P_Run;
80 
81 private:
82  /* Our data */
83  epicsEventId eventId_;
84  epicsFloat64 *pData_;
85  epicsFloat64 *pTimeBase_;
86  // Actual volts per division are these values divided by vertical gain
87  char *voltsPerDivStrings_[NUM_VERT_SELECTIONS];
88  int voltsPerDivValues_[NUM_VERT_SELECTIONS];
89  int voltsPerDivSeverities_[NUM_VERT_SELECTIONS];
90  void setVertGain();
91  void setVoltsPerDiv();
92  void setTimePerDiv();
93 };
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: testAsynPortDriver.cpp:205
int P_MaxValue
Definition: testAsynPortDriver.h:78
Base class for asyn port drivers; handles most of the bookkeeping for writing an asyn port driver wit...
Definition: asynPortDriver.h:45
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:340
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: testAsynPortDriver.cpp:255
void simTask(void)
Simulation task that runs as a separate thread.
Definition: testAsynPortDriver.cpp:142
int P_VoltsPerDiv
Definition: testAsynPortDriver.h:69
int P_Waveform
Definition: testAsynPortDriver.h:75
int P_TimeBase
Definition: testAsynPortDriver.h:76
char * portName
The name of this asyn port.
Definition: asynPortDriver.h:201
int P_UpdateTime
Definition: testAsynPortDriver.h:74
int P_VoltOffset
Definition: testAsynPortDriver.h:71
int P_VertGain
Definition: testAsynPortDriver.h:67
virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value, size_t nElements, size_t *nIn)
Called when asyn clients call pasynFloat64Array->read().
Definition: testAsynPortDriver.cpp:307
int P_MinValue
Definition: testAsynPortDriver.h:77
int P_Run
Values used for pasynUser->reason, and indexes into the parameter library.
Definition: testAsynPortDriver.h:63
int P_MaxPoints
Definition: testAsynPortDriver.h:64
int P_VoltsPerDivSelect
Definition: testAsynPortDriver.h:70
int P_TimePerDivSelect
Definition: testAsynPortDriver.h:66
int P_TimePerDiv
Definition: testAsynPortDriver.h:65
testAsynPortDriver(const char *portName, int maxArraySize)
Constructor for the testAsynPortDriver class.
Definition: testAsynPortDriver.cpp:49
int P_MeanValue
Definition: testAsynPortDriver.h:79
#define NUM_VERT_SELECTIONS
Definition: testAsynPortDriver.h:17
int P_TriggerDelay
Definition: testAsynPortDriver.h:72
Class that demonstrates the use of the asynPortDriver base class to greatly simplify the task of writ...
Definition: testAsynPortDriver.h:46
int P_NoiseAmplitude
Definition: testAsynPortDriver.h:73
int P_VertGainSelect
Definition: testAsynPortDriver.h:68