asyn 4-20
/home/epics/devel/asynR4-20/asyn/asynPortDriver/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 #include "paramVal.h"
00009 
00010 class paramList;
00011 
00012 epicsShareFunc void* findAsynPortDriver(const char *portName);
00013 
00014 #ifdef __cplusplus
00015 
00017 #define asynCommonMask          0x00000001
00018 #define asynDrvUserMask         0x00000002
00019 #define asynOptionMask          0x00000004
00020 #define asynInt32Mask           0x00000008
00021 #define asynUInt32DigitalMask   0x00000010
00022 #define asynFloat64Mask         0x00000020
00023 #define asynOctetMask           0x00000040
00024 #define asynInt8ArrayMask       0x00000080
00025 #define asynInt16ArrayMask      0x00000100
00026 #define asynInt32ArrayMask      0x00000200
00027 #define asynFloat32ArrayMask    0x00000400
00028 #define asynFloat64ArrayMask    0x00000800
00029 #define asynGenericPointerMask  0x00001000
00030 #define asynEnumMask            0x00002000
00031 
00032 
00033 
00034 
00037 class epicsShareFunc asynPortDriver {
00038 public:
00039     asynPortDriver(const char *portName, int maxAddr, int paramTableSize, int interfaceMask, int interruptMask,
00040                    int asynFlags, int autoConnect, int priority, int stackSize);
00041     virtual ~asynPortDriver();
00042     virtual asynStatus lock();
00043     virtual asynStatus unlock();
00044     virtual asynStatus getAddress(asynUser *pasynUser, int *address); 
00045     virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
00046     virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00047     virtual asynStatus readUInt32Digital(asynUser *pasynUser, epicsUInt32 *value, epicsUInt32 mask);
00048     virtual asynStatus writeUInt32Digital(asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask);
00049     virtual asynStatus setInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 mask, interruptReason reason);
00050     virtual asynStatus clearInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 mask);
00051     virtual asynStatus getInterruptUInt32Digital(asynUser *pasynUser, epicsUInt32 *mask, interruptReason reason);
00052     virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high);
00053     virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
00054     virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00055     virtual asynStatus readOctet(asynUser *pasynUser, char *value, size_t maxChars,
00056                                         size_t *nActual, int *eomReason);
00057     virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
00058                                         size_t *nActual);
00059     virtual asynStatus readInt8Array(asynUser *pasynUser, epicsInt8 *value, 
00060                                         size_t nElements, size_t *nIn);
00061     virtual asynStatus writeInt8Array(asynUser *pasynUser, epicsInt8 *value,
00062                                         size_t nElements);
00063     virtual asynStatus doCallbacksInt8Array(epicsInt8 *value,
00064                                         size_t nElements, int reason, int addr);
00065     virtual asynStatus readInt16Array(asynUser *pasynUser, epicsInt16 *value,
00066                                         size_t nElements, size_t *nIn);
00067     virtual asynStatus writeInt16Array(asynUser *pasynUser, epicsInt16 *value,
00068                                         size_t nElements);
00069     virtual asynStatus doCallbacksInt16Array(epicsInt16 *value,
00070                                         size_t nElements, int reason, int addr);
00071     virtual asynStatus readInt32Array(asynUser *pasynUser, epicsInt32 *value,
00072                                         size_t nElements, size_t *nIn);
00073     virtual asynStatus writeInt32Array(asynUser *pasynUser, epicsInt32 *value,
00074                                         size_t nElements);
00075     virtual asynStatus doCallbacksInt32Array(epicsInt32 *value,
00076                                         size_t nElements, int reason, int addr);
00077     virtual asynStatus readFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00078                                         size_t nElements, size_t *nIn);
00079     virtual asynStatus writeFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00080                                         size_t nElements);
00081     virtual asynStatus doCallbacksFloat32Array(epicsFloat32 *value,
00082                                         size_t nElements, int reason, int addr);
00083     virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00084                                         size_t nElements, size_t *nIn);
00085     virtual asynStatus writeFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00086                                         size_t nElements);
00087     virtual asynStatus doCallbacksFloat64Array(epicsFloat64 *value,
00088                                         size_t nElements, int reason, int addr);
00089     virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer);
00090     virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *pointer);
00091     virtual asynStatus doCallbacksGenericPointer(void *pointer, int reason, int addr);
00092     virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[], size_t nElements, size_t *nIn);
00093     virtual asynStatus writeEnum(asynUser *pasynUser, char *strings[], int values[], int severities[], size_t nElements);
00094     virtual asynStatus doCallbacksEnum(char *strings[], int values[], int severities[], size_t nElements, int reason, int addr);
00095     virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, 
00096                                      const char **pptypeName, size_t *psize);
00097     virtual asynStatus drvUserGetType(asynUser *pasynUser,
00098                                         const char **pptypeName, size_t *psize);
00099     virtual asynStatus drvUserDestroy(asynUser *pasynUser);
00100     virtual void report(FILE *fp, int details);
00101     virtual asynStatus connect(asynUser *pasynUser);
00102     virtual asynStatus disconnect(asynUser *pasynUser);
00103    
00104     virtual asynStatus createParam(          const char *name, asynParamType type, int *index);
00105     virtual asynStatus createParam(int list, const char *name, asynParamType type, int *index);
00106     virtual asynStatus findParam(          const char *name, int *index);
00107     virtual asynStatus findParam(int list, const char *name, int *index);
00108     virtual asynStatus getParamName(          int index, const char **name);
00109     virtual asynStatus getParamName(int list, int index, const char **name);
00110     virtual asynStatus setParamStatus(          int index, asynStatus status);
00111     virtual asynStatus setParamStatus(int list, int index, asynStatus status);
00112     virtual asynStatus getParamStatus(          int index, asynStatus *status);
00113     virtual asynStatus getParamStatus(int list, int index, asynStatus *status);
00114     virtual void       reportSetParamErrors(asynStatus status, int index, int list, const char *functionName);
00115     virtual void       reportGetParamErrors(asynStatus status, int index, int list, const char *functionName);
00116     virtual asynStatus setIntegerParam(          int index, int value);
00117     virtual asynStatus setIntegerParam(int list, int index, int value);
00118     virtual asynStatus setUIntDigitalParam(          int index, epicsUInt32 value, epicsUInt32 valueMask);
00119     virtual asynStatus setUIntDigitalParam(int list, int index, epicsUInt32 value, epicsUInt32 valueMask);
00120     virtual asynStatus setUIntDigitalParam(          int index, epicsUInt32 value, epicsUInt32 valueMask, epicsUInt32 interruptMask);
00121     virtual asynStatus setUIntDigitalParam(int list, int index, epicsUInt32 value, epicsUInt32 valueMask, epicsUInt32 interruptMask);
00122     virtual asynStatus setUInt32DigitalInterrupt(          int index, epicsUInt32 mask, interruptReason reason);
00123     virtual asynStatus setUInt32DigitalInterrupt(int list, int index, epicsUInt32 mask, interruptReason reason);
00124     virtual asynStatus clearUInt32DigitalInterrupt(         int index, epicsUInt32 mask);
00125     virtual asynStatus clearUInt32DigitalInterrupt(int list, int index, epicsUInt32 mask);
00126     virtual asynStatus getUInt32DigitalInterrupt(          int index, epicsUInt32 *mask, interruptReason reason);
00127     virtual asynStatus getUInt32DigitalInterrupt(int list, int index, epicsUInt32 *mask, interruptReason reason);
00128     virtual asynStatus setDoubleParam(          int index, double value);
00129     virtual asynStatus setDoubleParam(int list, int index, double value);
00130     virtual asynStatus setStringParam(          int index, const char *value);
00131     virtual asynStatus setStringParam(int list, int index, const char *value);
00132     virtual asynStatus getIntegerParam(          int index, int * value);
00133     virtual asynStatus getIntegerParam(int list, int index, int * value);
00134     virtual asynStatus getUIntDigitalParam(          int index, epicsUInt32 *value, epicsUInt32 mask);
00135     virtual asynStatus getUIntDigitalParam(int list, int index, epicsUInt32 *value, epicsUInt32 mask);
00136     virtual asynStatus getDoubleParam(          int index, double * value);
00137     virtual asynStatus getDoubleParam(int list, int index, double * value);
00138     virtual asynStatus getStringParam(          int index, int maxChars, char *value);
00139     virtual asynStatus getStringParam(int list, int index, int maxChars, char *value);
00140     virtual asynStatus callParamCallbacks();
00141     virtual asynStatus callParamCallbacks(          int addr);
00142     virtual asynStatus callParamCallbacks(int list, int addr);
00143     virtual void reportParams(FILE *fp, int details);
00144 
00145     char *portName;         
00147     int maxAddr;            
00148     void callbackTask();
00149 
00150 protected:
00151     asynUser *pasynUserSelf;    
00152     asynStandardInterfaces asynStdInterfaces;   
00154 private:
00155     paramList **params;
00156     epicsMutexId mutexId;
00157     template <typename epicsType, typename interruptType> 
00158         asynStatus doCallbacksArray(epicsType *value, size_t nElements,
00159                                     int reason, int address, void *interruptPvt);
00160 
00161 };
00162 
00163 #endif /* cplusplus */
00164     
00165 #endif