asyn 4-25
/home/epics/devel/asynR4-25/testAsynPortDriverApp/src/testAsynPortDriver.h
Go to the documentation of this file.
00001 /*
00002  * testAsynPortDriver.h
00003  * 
00004  * Asyn driver that inherits from the asynPortDriver class to demonstrate its use.
00005  * It simulates a digital scope looking at a 1kHz 1000-point noisy sine wave.  Controls are
00006  * provided for time/division, volts/division, volt offset, trigger delay, noise amplitude, update time,
00007  * and run/stop.
00008  * Readbacks are provides for the waveform data, min, max and mean values.
00009  *
00010  * Author: Mark Rivers
00011  *
00012  * Created Feb. 5, 2009
00013  */
00014 
00015 #include "asynPortDriver.h"
00016 
00017 #define NUM_VERT_SELECTIONS 4
00018 
00019 
00020 /* These are the drvInfo strings that are used to identify the parameters.
00021  * They are used by asyn clients, including standard asyn device support */
00022 #define P_RunString                "SCOPE_RUN"                  /* asynInt32,    r/w */
00023 #define P_MaxPointsString          "SCOPE_MAX_POINTS"           /* asynInt32,    r/o */
00024 #define P_TimePerDivString         "SCOPE_TIME_PER_DIV"         /* asynFloat64,  r/w */
00025 #define P_TimePerDivSelectString   "SCOPE_TIME_PER_DIV_SELECT"  /* asynInt32,    r/w */
00026 #define P_VertGainString           "SCOPE_VERT_GAIN"            /* asynFloat64,  r/w */
00027 #define P_VertGainSelectString     "SCOPE_VERT_GAIN_SELECT"     /* asynInt32,    r/w */
00028 #define P_VoltsPerDivString        "SCOPE_VOLTS_PER_DIV"        /* asynFloat64,  r/w */
00029 #define P_VoltsPerDivSelectString  "SCOPE_VOLTS_PER_DIV_SELECT" /* asynInt32,    r/w */
00030 #define P_VoltOffsetString         "SCOPE_VOLT_OFFSET"          /* asynFloat64,  r/w */
00031 #define P_TriggerDelayString       "SCOPE_TRIGGER_DELAY"        /* asynFloat64,  r/w */
00032 #define P_NoiseAmplitudeString     "SCOPE_NOISE_AMPLITUDE"      /* asynFloat64,  r/w */
00033 #define P_UpdateTimeString         "SCOPE_UPDATE_TIME"          /* asynFloat64,  r/w */
00034 #define P_WaveformString           "SCOPE_WAVEFORM"             /* asynFloat64Array,  r/o */
00035 #define P_TimeBaseString           "SCOPE_TIME_BASE"            /* asynFloat64Array,  r/o */
00036 #define P_MinValueString           "SCOPE_MIN_VALUE"            /* asynFloat64,  r/o */
00037 #define P_MaxValueString           "SCOPE_MAX_VALUE"            /* asynFloat64,  r/o */
00038 #define P_MeanValueString          "SCOPE_MEAN_VALUE"           /* asynFloat64,  r/o */
00039 
00046 class testAsynPortDriver : public asynPortDriver {
00047 public:
00048     testAsynPortDriver(const char *portName, int maxArraySize);
00049                  
00050     /* These are the methods that we override from asynPortDriver */
00051     virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00052     virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00053     virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00054                                         size_t nElements, size_t *nIn);
00055     virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[],
00056                                 size_t nElements, size_t *nIn);
00057 
00058     /* These are the methods that are new to this class */
00059     void simTask(void);
00060 
00061 protected:
00063     int P_Run;
00064     #define FIRST_SCOPE_COMMAND P_Run
00065     int P_MaxPoints;
00066     int P_TimePerDiv;
00067     int P_TimePerDivSelect;
00068     int P_VertGain;
00069     int P_VertGainSelect;
00070     int P_VoltsPerDiv;
00071     int P_VoltsPerDivSelect;
00072     int P_VoltOffset;
00073     int P_TriggerDelay;
00074     int P_NoiseAmplitude;
00075     int P_UpdateTime;
00076     int P_Waveform;
00077     int P_TimeBase;
00078     int P_MinValue;
00079     int P_MaxValue;
00080     int P_MeanValue;
00081     #define LAST_SCOPE_COMMAND P_MeanValue
00082  
00083 private:
00084     /* Our data */
00085     epicsEventId eventId_;
00086     epicsFloat64 *pData_;
00087     epicsFloat64 *pTimeBase_;
00088     // Actual volts per division are these values divided by vertical gain
00089     char *voltsPerDivStrings_[NUM_VERT_SELECTIONS];
00090     int voltsPerDivValues_[NUM_VERT_SELECTIONS];
00091     int voltsPerDivSeverities_[NUM_VERT_SELECTIONS];
00092     void setVertGain();
00093     void setVoltsPerDiv();
00094     void setTimePerDiv();
00095 };
00096 
00097 
00098 #define NUM_SCOPE_PARAMS (&LAST_SCOPE_COMMAND - &FIRST_SCOPE_COMMAND + 1)
00099