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