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