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