asyn 4-18
/home/epics/devel/asynR4-18/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 /* These are the drvInfo strings that are used to identify the parameters.
00018  * They are used by asyn clients, including standard asyn device support */
00019 #define P_RunString                "SCOPE_RUN"             /* asynInt32,    r/w */
00020 #define P_MaxPointsString          "SCOPE_MAX_POINTS"      /* asynInt32,    r/o */
00021 #define P_TimePerDivisionString    "SCOPE_TIME_PER_DIV"    /* asynFloat64,  r/w */
00022 #define P_VoltsPerDivisionString   "SCOPE_VOLTS_PER_DIV"   /* asynFloat64,  r/w */
00023 #define P_VoltOffsetString         "SCOPE_VOLT_OFFSET"     /* asynFloat64,  r/w */
00024 #define P_TriggerDelayString       "SCOPE_TRIGGER_DELAY"   /* asynFloat64,  r/w */
00025 #define P_NoiseAmplitudeString     "SCOPE_NOISE_AMPLITUDE" /* asynFloat64,  r/w */
00026 #define P_UpdateTimeString         "SCOPE_UPDATE_TIME"     /* asynFloat64,  r/w */
00027 #define P_WaveformString           "SCOPE_WAVEFORM"        /* asynFloat64Array,  r/o */
00028 #define P_TimeBaseString           "SCOPE_TIME_BASE"       /* asynFloat64Array,  r/o */
00029 #define P_MinValueString           "SCOPE_MIN_VALUE"       /* asynFloat64,  r/o */
00030 #define P_MaxValueString           "SCOPE_MAX_VALUE"       /* asynFloat64,  r/o */
00031 #define P_MeanValueString          "SCOPE_MEAN_VALUE"      /* asynFloat64,  r/o */
00032 
00039 class testAsynPortDriver : public asynPortDriver {
00040 public:
00041     testAsynPortDriver(const char *portName, int maxArraySize);
00042                  
00043     /* These are the methods that we override from asynPortDriver */
00044     virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00045     virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00046     virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00047                                         size_t nElements, size_t *nIn);
00048 
00049     /* These are the methods that are new to this class */
00050     void simTask(void);
00051 
00052 protected:
00054     int P_Run;
00055     #define FIRST_SCOPE_COMMAND P_Run
00056     int P_MaxPoints;
00057     int P_TimePerDivision;
00058     int P_VoltsPerDivision;
00059     int P_VoltOffset;
00060     int P_TriggerDelay;
00061     int P_NoiseAmplitude;
00062     int P_UpdateTime;
00063     int P_Waveform;
00064     int P_TimeBase;
00065     int P_MinValue;
00066     int P_MaxValue;
00067     int P_MeanValue;
00068     #define LAST_SCOPE_COMMAND P_MeanValue
00069  
00070 private:
00071     /* Our data */
00072     epicsEventId eventId;
00073     epicsFloat64 *pData;
00074     epicsFloat64 *pTimeBase;
00075 };
00076 
00077 
00078 #define NUM_SCOPE_PARAMS (&LAST_SCOPE_COMMAND - &FIRST_SCOPE_COMMAND + 1)
00079