00001 #ifndef asynPortDriver_H
00002 #define asynPortDriver_H
00003
00004 #include <epicsTypes.h>
00005 #include <epicsMutex.h>
00006 #include <asynStandardInterfaces.h>
00007
00009 typedef struct {
00010 int param;
00011 const char *paramString;
00012 } asynParamString_t;
00013
00014 #ifdef __cplusplus
00015
00017 #define asynCommonMask 0x00000001
00018 #define asynDrvUserMask 0x00000002
00019 #define asynOptionMask 0x00000004
00020 #define asynInt32Mask 0x00000008
00021 #define asyUInt32DigitalMask 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
00031
00033 typedef enum {
00034 paramUndef,
00035 paramInt,
00036 paramDouble,
00037 paramString
00038 } paramType;
00039
00041 typedef struct
00042 {
00043 paramType type;
00045 union
00046 {
00047 double dval;
00048 int ival;
00049 char *sval;
00050 } data;
00051 } paramVal;
00052
00058 class paramList {
00059 public:
00060 paramList(int startVal, int nVals, asynStandardInterfaces *pasynInterfaces);
00061 ~paramList();
00062 asynStatus setInteger(int index, int value);
00063 asynStatus setDouble(int index, double value);
00064 asynStatus setString(int index, const char *string);
00065 asynStatus getInteger(int index, int *value);
00066 asynStatus getDouble(int index, double *value);
00067 asynStatus getString(int index, int maxChars, char *value);
00068 asynStatus callCallbacks(int addr);
00069 asynStatus callCallbacks();
00070 void report();
00071
00072 private:
00073 asynStatus setFlag(int index);
00074 asynStatus intCallback(int command, int addr, int value);
00075 asynStatus doubleCallback(int command, int addr, double value);
00076 asynStatus stringCallback(int command, int addr, char *value);
00077 int startVal;
00078 int nVals;
00079 int nFlags;
00080 asynStandardInterfaces *pasynInterfaces;
00081 int *flags;
00082 paramVal *vals;
00083 };
00084
00087 class asynPortDriver {
00088 public:
00089 asynPortDriver(const char *portName, int maxAddr, int paramTableSize, int interfaceMask, int interruptMask,
00090 int asynFlags, int autoConnect, int priority, int stackSize);
00091 virtual ~asynPortDriver();
00092 virtual asynStatus lock();
00093 virtual asynStatus unlock();
00094 virtual asynStatus getAddress(asynUser *pasynUser, const char *functionName, int *address);
00095 virtual asynStatus readInt32(asynUser *pasynUser, epicsInt32 *value);
00096 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00097 virtual asynStatus getBounds(asynUser *pasynUser, epicsInt32 *low, epicsInt32 *high);
00098 virtual asynStatus readFloat64(asynUser *pasynUser, epicsFloat64 *value);
00099 virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00100 virtual asynStatus readOctet(asynUser *pasynUser, char *value, size_t maxChars,
00101 size_t *nActual, int *eomReason);
00102 virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars,
00103 size_t *nActual);
00104 virtual asynStatus readInt8Array(asynUser *pasynUser, epicsInt8 *value,
00105 size_t nElements, size_t *nIn);
00106 virtual asynStatus writeInt8Array(asynUser *pasynUser, epicsInt8 *value,
00107 size_t nElements);
00108 virtual asynStatus doCallbacksInt8Array(epicsInt8 *value,
00109 size_t nElements, int reason, int addr);
00110 virtual asynStatus readInt16Array(asynUser *pasynUser, epicsInt16 *value,
00111 size_t nElements, size_t *nIn);
00112 virtual asynStatus writeInt16Array(asynUser *pasynUser, epicsInt16 *value,
00113 size_t nElements);
00114 virtual asynStatus doCallbacksInt16Array(epicsInt16 *value,
00115 size_t nElements, int reason, int addr);
00116 virtual asynStatus readInt32Array(asynUser *pasynUser, epicsInt32 *value,
00117 size_t nElements, size_t *nIn);
00118 virtual asynStatus writeInt32Array(asynUser *pasynUser, epicsInt32 *value,
00119 size_t nElements);
00120 virtual asynStatus doCallbacksInt32Array(epicsInt32 *value,
00121 size_t nElements, int reason, int addr);
00122 virtual asynStatus readFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00123 size_t nElements, size_t *nIn);
00124 virtual asynStatus writeFloat32Array(asynUser *pasynUser, epicsFloat32 *value,
00125 size_t nElements);
00126 virtual asynStatus doCallbacksFloat32Array(epicsFloat32 *value,
00127 size_t nElements, int reason, int addr);
00128 virtual asynStatus readFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00129 size_t nElements, size_t *nIn);
00130 virtual asynStatus writeFloat64Array(asynUser *pasynUser, epicsFloat64 *value,
00131 size_t nElements);
00132 virtual asynStatus doCallbacksFloat64Array(epicsFloat64 *value,
00133 size_t nElements, int reason, int addr);
00134 virtual asynStatus readGenericPointer(asynUser *pasynUser, void *pointer);
00135 virtual asynStatus writeGenericPointer(asynUser *pasynUser, void *pointer);
00136 virtual asynStatus doCallbacksGenericPointer(void *pointer, int reason, int addr);
00137 virtual asynStatus findParam(asynParamString_t *paramTable, int numParams, const char *paramName,
00138 int *param);
00139 virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo,
00140 const char **pptypeName, size_t *psize);
00141 virtual asynStatus drvUserCreateParam(asynUser *pasynUser, const char *drvInfo,
00142 const char **pptypeName, size_t *psize,
00143 asynParamString_t *paramTable, int numParams);
00144 virtual asynStatus drvUserGetType(asynUser *pasynUser,
00145 const char **pptypeName, size_t *psize);
00146 virtual asynStatus drvUserDestroy(asynUser *pasynUser);
00147 virtual void report(FILE *fp, int details);
00148 virtual asynStatus connect(asynUser *pasynUser);
00149 virtual asynStatus disconnect(asynUser *pasynUser);
00150
00151 virtual asynStatus setIntegerParam(int index, int value);
00152 virtual asynStatus setIntegerParam(int list, int index, int value);
00153 virtual asynStatus setDoubleParam(int index, double value);
00154 virtual asynStatus setDoubleParam(int list, int index, double value);
00155 virtual asynStatus setStringParam(int index, const char *value);
00156 virtual asynStatus setStringParam(int list, int index, const char *value);
00157 virtual asynStatus getIntegerParam(int index, int * value);
00158 virtual asynStatus getIntegerParam(int list, int index, int * value);
00159 virtual asynStatus getDoubleParam(int index, double * value);
00160 virtual asynStatus getDoubleParam(int list, int index, double * value);
00161 virtual asynStatus getStringParam(int index, int maxChars, char *value);
00162 virtual asynStatus getStringParam(int list, int index, int maxChars, char *value);
00163 virtual asynStatus callParamCallbacks();
00164 virtual asynStatus callParamCallbacks(int list, int addr);
00165 virtual void reportParams();
00166
00167 char *portName;
00169 int maxAddr;
00170 void callbackTask();
00171
00172 protected:
00173 asynUser *pasynUserSelf;
00174 asynStandardInterfaces asynStdInterfaces;
00176 private:
00177 paramList **params;
00178 epicsMutexId mutexId;
00179
00180 };
00181
00182 #endif
00183
00184 #endif