asyn 4-18
/home/epics/devel/asynR4-18/asyn/miscellaneous/asynPortDriver.h
Go to the documentation of this file.
00001 #ifndef asynPortDriver_H
00002 #define asynPortDriver_H
00003 
00004 #include <epicsTypes.h>
00005 #include <epicsMutex.h>
00006 
00007 #include <asynStandardInterfaces.h>
00008 
00009 epicsShareFunc void* findAsynPortDriver(const char *portName);
00010 
00011 #ifdef __cplusplus
00012 
00014 #define asynCommonMask          0x00000001
00015 #define asynDrvUserMask         0x00000002
00016 #define asynOptionMask          0x00000004
00017 #define asynInt32Mask           0x00000008
00018 #define asynUInt32DigitalMask   0x00000010
00019 #define asynFloat64Mask         0x00000020
00020 #define asynOctetMask           0x00000040
00021 #define asynInt8ArrayMask       0x00000080
00022 #define asynInt16ArrayMask      0x00000100
00023 #define asynInt32ArrayMask      0x00000200
00024 #define asynFloat32ArrayMask    0x00000400
00025 #define asynFloat64ArrayMask    0x00000800
00026 #define asynGenericPointerMask  0x00001000
00027 
00028 
00030 typedef enum { 
00031     asynParamUndefined,     
00032     asynParamInt32, 
00033     asynParamUInt32Digital,
00034     asynParamFloat64,
00035     asynParamOctet,
00036     asynParamInt8Array,
00037     asynParamInt16Array,
00038     asynParamInt32Array,
00039     asynParamFloat32Array,
00040     asynParamFloat64Array,
00041     asynParamGenericPointer
00042 } asynParamType;
00043 
00045 typedef struct
00046 {
00047     asynParamType type; 
00048     char *name;         
00049     bool valueDefined;
00050     epicsUInt32 uInt32RisingMask;
00051     epicsUInt32 uInt32FallingMask;
00052     epicsUInt32 uInt32CallbackMask;
00054     union
00055     {
00056         epicsInt32   ival;
00057         epicsUInt32  uival;
00058         epicsFloat64 dval;
00059         char         *sval;
00060         epicsInt8     *pi8;
00061         epicsInt16    *pi16;
00062         epicsInt32    *pi32;
00063         epicsFloat32  *pf32;
00064         epicsFloat64  *pf64;
00065         void         *pgp;
00066     } data;
00067 } paramVal;
00068 
00069 
00070 /* Synonyms for some unused asyn error codes for use by parameter library */
00071 #define asynParamAlreadyExists  asynTimeout
00072 #define asynParamNotFound       asynOverflow
00073 #define asynParamWrongType      asynDisconnected
00074 #define asynParamBadIndex       asynDisabled
00075 #define asynParamUndefined      asynError
00076 
00082 class paramList {
00083 public:
00084     paramList(int nVals, asynStandardInterfaces *pasynInterfaces);
00085     ~paramList();
00086     asynStatus createParam(const char *name, asynParamType type, int *index);
00087     asynStatus findParam(const char *name, int *index);
00088     asynStatus getName(int index, const char **name);
00089     asynStatus setInteger(int index, int value);
00090     asynStatus setUInt32(int index, epicsUInt32 value, epicsUInt32 valueMask, epicsUInt32 interruptMask);
00091     asynStatus setDouble(int index, double value);
00092     asynStatus setString(int index, const char *string);
00093     asynStatus getInteger(int index, int *value);
00094     asynStatus getUInt32(int index, epicsUInt32 *value, epicsUInt32 mask);
00095     asynStatus getDouble(int index, double *value);
00096     asynStatus getString(int index, int maxChars, char *value);
00097     asynStatus setUInt32Interrupt(int index, epicsUInt32 mask, interruptReason reason);
00098     asynStatus clearUInt32Interrupt(int index, epicsUInt32 mask);
00099     asynStatus getUInt32Interrupt(int index, epicsUInt32 *mask, interruptReason reason);
00100     asynStatus callCallbacks(int addr);
00101     asynStatus callCallbacks();
00102     void report(FILE *fp, int details);
00103 
00104 private:    
00105     asynStatus setFlag(int index);
00106     asynStatus int32Callback(int command, int addr, epicsInt32 value);
00107     asynStatus uint32Callback(int command, int addr, epicsUInt32 value, epicsUInt32 interruptMask);
00108     asynStatus float64Callback(int command, int addr, epicsFloat64 value);
00109     asynStatus octetCallback(int command, int addr, char *value);
00110     int nextParam;
00111     int nVals;
00112     int nFlags;
00113     asynStandardInterfaces *pasynInterfaces;
00114     int *flags;
00115     paramVal *vals;
00116 };
00117 
00120 class epicsShareFunc asynPortDriver {
00121 public:
00122     asynPortDriver(const char *portName, int maxAddr, int paramTableSize, int interfaceMask, int interruptMask,
00123                    int asynFlags, int autoConnect, int priority, int stackSize);
00124     virtual ~asynPortDriver();
00125     virtual asynStatus lock();
00126     virtual asynStatus unlock();
00127     virtual asynStatus getAddress(asynUser *pasynUser, int *address); 
00128     virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
00129     virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00130     virtual asynStatus readUInt32Digital(asynUser *pasynUser, epicsUInt32 *value, epicsUInt32 mask);
00131     virtual asynStatus writeUInt32Digital(asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask);
00132     virtual asynStatus setInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 mask, interruptReason reason);
00133     virtual asynStatus clearInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 mask);
00134     virtual asynStatus getInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 *mask, interruptReason reason);
00135     virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high);
00136     virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
00137     virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00138     virtual asynStatus readOctet(asynUser *pasynUser, char *value, size_t maxChars,
00139                                         size_t *nActual, int *eomReason);
00140     virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
00141                                         size_t *nActual);
00142     virtual asynStatus readInt8Array(asynUser *pasynUser, epicsInt8 *value, 
00143                                         size_t nElements, size_t *nIn);
00144     virtual asynStatus writeInt8Array(asynUser *pasynUser, epicsInt8 *value,
00145                                         size_t nElements);
00146     virtual asynStatus doCallbacksInt8Array(epicsInt8 *value,
00147                                         size_t nElements, int reason, int addr);
00148     virtual asynStatus readInt16Array(asynUser *pasynUser, epicsInt16 *value,
00149                                         size_t nElements, size_t *nIn);
00150     virtual asynStatus writeInt16Array(asynUser *pasynUser, epicsInt16 *value,
00151                                         size_t nElements);
00152     virtual asynStatus doCallbacksInt16Array(epicsInt16 *value,
00153                                         size_t nElements, int reason, int addr);
00154     virtual asynStatus readInt32Array(asynUser *pasynUser, epicsInt32 *value,
00155                                         size_t nElements, size_t *nIn);
00156     virtual asynStatus writeInt32Array(asynUser *pasynUser, epicsInt32 *value,
00157                                         size_t nElements);
00158     virtual asynStatus doCallbacksInt32Array(epicsInt32 *value,
00159                                         size_t nElements, int reason, int addr);
00160     virtual asynStatus readFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00161                                         size_t nElements, size_t *nIn);
00162     virtual asynStatus writeFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00163                                         size_t nElements);
00164     virtual asynStatus doCallbacksFloat32Array(epicsFloat32 *value,
00165                                         size_t nElements, int reason, int addr);
00166     virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00167                                         size_t nElements, size_t *nIn);
00168     virtual asynStatus writeFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00169                                         size_t nElements);
00170     virtual asynStatus doCallbacksFloat64Array(epicsFloat64 *value,
00171                                         size_t nElements, int reason, int addr);
00172     virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer);
00173     virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *pointer);
00174     virtual asynStatus doCallbacksGenericPointer(void *pointer, int reason, int addr);
00175     virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, 
00176                                      const char **pptypeName, size_t *psize);
00177     virtual asynStatus drvUserGetType(asynUser *pasynUser,
00178                                         const char **pptypeName, size_t *psize);
00179     virtual asynStatus drvUserDestroy(asynUser *pasynUser);
00180     virtual void report(FILE *fp, int details);
00181     virtual asynStatus connect(asynUser *pasynUser);
00182     virtual asynStatus disconnect(asynUser *pasynUser);
00183    
00184     virtual asynStatus createParam(          const char *name, asynParamType type, int *index);
00185     virtual asynStatus createParam(int list, const char *name, asynParamType type, int *index);
00186     virtual asynStatus findParam(          const char *name, int *index);
00187     virtual asynStatus findParam(int list, const char *name, int *index);
00188     virtual asynStatus getParamName(          int index, const char **name);
00189     virtual asynStatus getParamName(int list, int index, const char **name);
00190     virtual void       reportSetParamErrors(asynStatus status, int index, int list, const char *functionName);
00191     virtual void       reportGetParamErrors(asynStatus status, int index, int list, const char *functionName);
00192     virtual asynStatus setIntegerParam(          int index, int value);
00193     virtual asynStatus setIntegerParam(int list, int index, int value);
00194     virtual asynStatus setUIntDigitalParam(          int index, epicsUInt32 value, epicsUInt32 valueMask);
00195     virtual asynStatus setUIntDigitalParam(int list, int index, epicsUInt32 value, epicsUInt32 valueMask);
00196     virtual asynStatus setUIntDigitalParam(          int index, epicsUInt32 value, epicsUInt32 valueMask, epicsUInt32 interruptMask);
00197     virtual asynStatus setUIntDigitalParam(int list, int index, epicsUInt32 value, epicsUInt32 valueMask, epicsUInt32 interruptMask);
00198     virtual asynStatus setUInt32DigitalInterrupt(          int index, epicsUInt32 mask, interruptReason reason);
00199     virtual asynStatus setUInt32DigitalInterrupt(int list, int index, epicsUInt32 mask, interruptReason reason);
00200     virtual asynStatus clearUInt32DigitalInterrupt(         int index, epicsUInt32 mask);
00201     virtual asynStatus clearUInt32DigitalInterrupt(int list, int index, epicsUInt32 mask);
00202     virtual asynStatus getUInt32DigitalInterrupt(          int index, epicsUInt32 *mask, interruptReason reason);
00203     virtual asynStatus getUInt32DigitalInterrupt(int list, int index, epicsUInt32 *mask, interruptReason reason);
00204     virtual asynStatus setDoubleParam(          int index, double value);
00205     virtual asynStatus setDoubleParam(int list, int index, double value);
00206     virtual asynStatus setStringParam(          int index, const char *value);
00207     virtual asynStatus setStringParam(int list, int index, const char *value);
00208     virtual asynStatus getIntegerParam(          int index, int * value);
00209     virtual asynStatus getIntegerParam(int list, int index, int * value);
00210     virtual asynStatus getUIntDigitalParam(          int index, epicsUInt32 *value, epicsUInt32 mask);
00211     virtual asynStatus getUIntDigitalParam(int list, int index, epicsUInt32 *value, epicsUInt32 mask);
00212     virtual asynStatus getDoubleParam(          int index, double * value);
00213     virtual asynStatus getDoubleParam(int list, int index, double * value);
00214     virtual asynStatus getStringParam(          int index, int maxChars, char *value);
00215     virtual asynStatus getStringParam(int list, int index, int maxChars, char *value);
00216     virtual asynStatus callParamCallbacks();
00217     virtual asynStatus callParamCallbacks(          int addr);
00218     virtual asynStatus callParamCallbacks(int list, int addr);
00219     virtual void reportParams(FILE *fp, int details);
00220 
00221     char *portName;         
00223     int maxAddr;            
00224     void callbackTask();
00225 
00226 protected:
00227     asynUser *pasynUserSelf;    
00228     asynStandardInterfaces asynStdInterfaces;   
00230 private:
00231     paramList **params;
00232     epicsMutexId mutexId;
00233 
00234 };
00235 
00236 #endif /* cplusplus */
00237     
00238 #endif