asyn 4-25
|
00001 #ifndef asynPortClient_H 00002 #define asynPortClient_H 00003 00004 #include <stdexcept> 00005 00006 #include <epicsString.h> 00007 00008 #include <asynDriver.h> 00009 #include <asynInt32.h> 00010 #include <asynInt32SyncIO.h> 00011 #include <asynUInt32Digital.h> 00012 #include <asynUInt32DigitalSyncIO.h> 00013 #include <asynFloat64.h> 00014 #include <asynFloat64SyncIO.h> 00015 #include <asynOctet.h> 00016 #include <asynOctetSyncIO.h> 00017 #include <asynInt8Array.h> 00018 #include <asynInt8ArraySyncIO.h> 00019 #include <asynInt16Array.h> 00020 #include <asynInt16ArraySyncIO.h> 00021 #include <asynInt32Array.h> 00022 #include <asynInt32ArraySyncIO.h> 00023 #include <asynFloat32Array.h> 00024 #include <asynFloat32ArraySyncIO.h> 00025 #include <asynFloat64Array.h> 00026 #include <asynFloat64ArraySyncIO.h> 00027 #include <asynGenericPointer.h> 00028 #include <asynGenericPointerSyncIO.h> 00029 #include <asynEnum.h> 00030 #include <asynEnumSyncIO.h> 00031 #include <asynOption.h> 00032 #include <asynOptionSyncIO.h> 00033 #include <asynCommonSyncIO.h> 00034 #include <asynDrvUser.h> 00035 00036 #define DEFAULT_TIMEOUT 1.0 00037 00038 00041 class epicsShareClass asynPortClient { 00042 public: 00043 asynPortClient(const char *portName, int addr, const char* asynInterfaceType, const char *drvInfo, double timeout); 00044 virtual ~asynPortClient(); 00045 void setTimeout(double timeout) 00046 { timeout_ = timeout; }; 00047 void report(FILE *fp, int details); 00048 protected: 00049 asynUser *pasynUser_; 00050 asynUser *pasynUserSyncIO_; 00051 asynInterface *pasynInterface_; 00052 double timeout_; 00053 char *portName_; 00054 int addr_; 00055 char *asynInterfaceType_; 00056 char *drvInfo_; 00057 void *drvPvt; 00058 void *interruptPvt_; 00059 }; 00060 00061 00063 class epicsShareClass asynInt32Client : public asynPortClient { 00064 public: 00071 asynInt32Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00072 : asynPortClient(portName, addr, asynInt32Type, drvInfo, timeout) { 00073 pInterface_ = (asynInt32 *)pasynInterface_->pinterface; 00074 if (pasynInt32SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00075 throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed")); 00076 }; 00078 virtual ~asynInt32Client() { 00079 pasynInt32SyncIO->disconnect(pasynUserSyncIO_); 00080 }; 00083 virtual asynStatus read(epicsInt32 *value) { 00084 return pasynInt32SyncIO->read(pasynUserSyncIO_, value, timeout_); 00085 }; 00088 virtual asynStatus write(epicsInt32 value) { 00089 return pasynInt32SyncIO->write(pasynUserSyncIO_, value, timeout_); 00090 }; 00094 virtual asynStatus getBounds(epicsInt32 *low, epicsInt32 *high) { 00095 return pasynInt32SyncIO->getBounds(pasynUserSyncIO_, low, high); 00096 }; 00099 virtual asynStatus registerInterruptUser(interruptCallbackInt32 pCallback) { 00100 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00101 pCallback, this, &interruptPvt_); 00102 }; 00103 private: 00104 asynInt32 *pInterface_; 00105 }; 00106 00107 00109 class epicsShareClass asynUInt32DigitalClient : public asynPortClient { 00110 public: 00117 asynUInt32DigitalClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00118 : asynPortClient(portName, addr, asynUInt32DigitalType, drvInfo, timeout) { 00119 pInterface_ = (asynUInt32Digital *)pasynInterface_->pinterface; 00120 if (pasynInt32SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00121 throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed")); 00122 }; 00124 virtual ~asynUInt32DigitalClient() { 00125 pasynUInt32DigitalSyncIO->disconnect(pasynUserSyncIO_); 00126 }; 00130 virtual asynStatus read(epicsUInt32 *value, epicsUInt32 mask) { 00131 return pasynUInt32DigitalSyncIO->read(pasynUserSyncIO_, value, mask, timeout_); 00132 }; 00136 virtual asynStatus write(epicsUInt32 value, epicsUInt32 mask){ 00137 return pasynUInt32DigitalSyncIO->write(pasynUserSyncIO_, value, mask, timeout_); 00138 }; 00142 virtual asynStatus setInterrupt(epicsUInt32 mask, interruptReason reason) { 00143 return pasynUInt32DigitalSyncIO->setInterrupt(pasynUserSyncIO_, mask, reason, timeout_); 00144 }; 00147 virtual asynStatus clearInterrupt(epicsUInt32 mask) { 00148 return pasynUInt32DigitalSyncIO->clearInterrupt(pasynUserSyncIO_, mask, timeout_); 00149 }; 00153 virtual asynStatus getInterrupt(epicsUInt32 *mask, interruptReason reason) { 00154 return pasynUInt32DigitalSyncIO->getInterrupt(pasynUserSyncIO_, mask, reason, timeout_); 00155 }; 00159 virtual asynStatus registerInterruptUser(interruptCallbackUInt32Digital pCallback, epicsUInt32 mask) { 00160 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00161 pCallback, this, mask, &interruptPvt_); 00162 }; 00163 private: 00164 asynUInt32Digital *pInterface_; 00165 }; 00166 00167 00169 class epicsShareClass asynFloat64Client : public asynPortClient { 00170 public: 00177 asynFloat64Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00178 : asynPortClient(portName, addr, asynFloat64Type, drvInfo, timeout) { 00179 pInterface_ = (asynFloat64 *)pasynInterface_->pinterface; 00180 if (pasynFloat64SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00181 throw std::runtime_error(std::string("pasynFloat64SyncIO->connect failed")); 00182 }; 00184 virtual ~asynFloat64Client() { 00185 pasynFloat64SyncIO->disconnect(pasynUserSyncIO_); 00186 }; 00189 virtual asynStatus read(epicsFloat64 *value) { 00190 return pasynFloat64SyncIO->read(pasynUserSyncIO_, value, timeout_); 00191 }; 00194 virtual asynStatus write(epicsFloat64 value) { 00195 return pasynFloat64SyncIO->write(pasynUserSyncIO_, value, timeout_); 00196 }; 00199 virtual asynStatus registerInterruptUser(interruptCallbackFloat64 pCallback) { 00200 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00201 pCallback, this, &interruptPvt_); 00202 }; 00203 private: 00204 asynFloat64 *pInterface_; 00205 }; 00206 00207 00209 class epicsShareClass asynOctetClient : public asynPortClient { 00210 public: 00217 asynOctetClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00218 : asynPortClient(portName, addr, asynOctetType, drvInfo, timeout) { 00219 pInterface_ = (asynOctet *)pasynInterface_->pinterface; 00220 if (pasynOctetSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00221 throw std::runtime_error(std::string("pasynOctetSyncIO->connect failed")); 00222 }; 00224 virtual ~asynOctetClient() { 00225 pasynOctetSyncIO->disconnect(pasynUserSyncIO_); 00226 }; 00231 virtual asynStatus write(const char *buffer, size_t bufferLen, size_t *nActual) { 00232 return pasynOctetSyncIO->write(pasynUserSyncIO_, buffer, bufferLen, timeout_, nActual); 00233 }; 00239 virtual asynStatus read(char *buffer, size_t bufferLen, size_t *nActual, int *eomReason) { 00240 return pasynOctetSyncIO->read(pasynUserSyncIO_, buffer, bufferLen, timeout_, nActual, eomReason); 00241 }; 00250 virtual asynStatus writeRead(const char *writeBuffer, size_t writeBufferLen, char *readBuffer, size_t readBufferLen, 00251 size_t *nBytesOut, size_t *nBytesIn, int *eomReason) { 00252 return pasynOctetSyncIO->writeRead(pasynUserSyncIO_, writeBuffer, writeBufferLen, readBuffer, readBufferLen, 00253 timeout_, nBytesOut, nBytesIn, eomReason); 00254 }; 00256 virtual asynStatus flush() { 00257 return pasynOctetSyncIO->flush(pasynUserSyncIO_); 00258 }; 00262 virtual asynStatus setInputEos(const char *eos, int eosLen) { 00263 return pasynOctetSyncIO->setInputEos(pasynUserSyncIO_, eos, eosLen); 00264 }; 00269 virtual asynStatus getInputEos(char *eos, int eosSize, int *eosLen) { 00270 return pasynOctetSyncIO->getInputEos(pasynUserSyncIO_, eos, eosSize, eosLen); 00271 }; 00275 virtual asynStatus setOutputEos(const char *eos, int eosLen) { 00276 return pasynOctetSyncIO->setOutputEos(pasynUserSyncIO_, eos, eosLen); 00277 }; 00282 virtual asynStatus getOutputEos(char *eos, int eosSize, int *eosLen) { 00283 return pasynOctetSyncIO->getOutputEos(pasynUserSyncIO_, eos, eosSize, eosLen); 00284 }; 00287 virtual asynStatus registerInterruptUser(interruptCallbackOctet pCallback) { 00288 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00289 pCallback, this, &interruptPvt_); 00290 }; 00291 private: 00292 asynOctet *pInterface_; 00293 }; 00294 00295 00297 class epicsShareClass asynInt8ArrayClient : public asynPortClient { 00298 public: 00305 asynInt8ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00306 : asynPortClient(portName, addr, asynInt8ArrayType, drvInfo, timeout) { 00307 pInterface_ = (asynInt8Array *)pasynInterface_->pinterface; 00308 if (pasynInt8ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00309 throw std::runtime_error(std::string("pasynInt8ArraySyncIO->connect failed")); 00310 }; 00312 virtual ~asynInt8ArrayClient() { 00313 pasynInt8ArraySyncIO->disconnect(pasynUserSyncIO_); 00314 }; 00319 virtual asynStatus read(epicsInt8 *value, size_t nElements, size_t *nIn) { 00320 return pasynInt8ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_); 00321 }; 00325 virtual asynStatus write(epicsInt8 *value, size_t nElements) { 00326 return pasynInt8ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_); 00327 }; 00330 virtual asynStatus registerInterruptUser(interruptCallbackInt8Array pCallback) { 00331 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00332 pCallback, this, &interruptPvt_); 00333 }; 00334 private: 00335 asynInt8Array *pInterface_; 00336 }; 00337 00338 00340 class epicsShareClass asynInt16ArrayClient : public asynPortClient { 00341 public: 00348 asynInt16ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00349 : asynPortClient(portName, addr, asynInt16ArrayType, drvInfo, timeout) { 00350 pInterface_ = (asynInt16Array *)pasynInterface_->pinterface; 00351 if (pasynInt16ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00352 throw std::runtime_error(std::string("pasynInt16ArraySyncIO->connect failed")); 00353 }; 00355 virtual ~asynInt16ArrayClient() { 00356 pasynInt16ArraySyncIO->disconnect(pasynUserSyncIO_); 00357 }; 00362 virtual asynStatus read(epicsInt16 *value, size_t nElements, size_t *nIn) { 00363 return pasynInt16ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_); 00364 }; 00368 virtual asynStatus write(epicsInt16 *value, size_t nElements) { 00369 return pasynInt16ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_); 00370 }; 00373 virtual asynStatus registerInterruptUser(interruptCallbackInt16Array pCallback) { 00374 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00375 pCallback, this, &interruptPvt_); 00376 }; 00377 private: 00378 asynInt16Array *pInterface_; 00379 }; 00380 00381 00383 class epicsShareClass asynInt32ArrayClient : public asynPortClient { 00384 public: 00391 asynInt32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00392 : asynPortClient(portName, addr, asynInt32ArrayType, drvInfo, timeout) { 00393 pInterface_ = (asynInt32Array *)pasynInterface_->pinterface; 00394 if (pasynInt32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00395 throw std::runtime_error(std::string("pasynInt32ArraySyncIO->connect failed")); 00396 }; 00398 virtual ~asynInt32ArrayClient() { 00399 pasynInt32ArraySyncIO->disconnect(pasynUserSyncIO_); 00400 }; 00405 virtual asynStatus read(epicsInt32 *value, size_t nElements, size_t *nIn) { 00406 return pasynInt32ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_); 00407 }; 00411 virtual asynStatus write(epicsInt32 *value, size_t nElements) { 00412 return pasynInt32ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_); 00413 }; 00416 virtual asynStatus registerInterruptUser(interruptCallbackInt32Array pCallback) { 00417 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00418 pCallback, this, &interruptPvt_); 00419 }; 00420 private: 00421 asynInt32Array *pInterface_; 00422 }; 00423 00424 00426 class epicsShareClass asynFloat32ArrayClient : public asynPortClient { 00427 public: 00434 asynFloat32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00435 : asynPortClient(portName, addr, asynFloat32ArrayType, drvInfo, timeout) { 00436 pInterface_ = (asynFloat32Array *)pasynInterface_->pinterface; 00437 if (pasynFloat32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00438 throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed")); 00439 }; 00441 virtual ~asynFloat32ArrayClient() { 00442 pasynFloat32ArraySyncIO->disconnect(pasynUserSyncIO_); 00443 }; 00448 virtual asynStatus read(epicsFloat32 *value, size_t nElements, size_t *nIn) { 00449 return pasynFloat32ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_); 00450 }; 00454 virtual asynStatus write(epicsFloat32 *value, size_t nElements) { 00455 return pasynFloat32ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_); 00456 }; 00459 virtual asynStatus registerInterruptUser(interruptCallbackFloat32Array pCallback) { 00460 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00461 pCallback, this, &interruptPvt_); 00462 }; 00463 private: 00464 asynFloat32Array *pInterface_; 00465 }; 00466 00467 00469 class epicsShareClass asynFloat64ArrayClient : public asynPortClient { 00470 public: 00477 asynFloat64ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00478 : asynPortClient(portName, addr, asynFloat64ArrayType, drvInfo, timeout) { 00479 pInterface_ = (asynFloat64Array *)pasynInterface_->pinterface; 00480 if (pasynFloat64ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00481 throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed")); 00482 }; 00484 virtual ~asynFloat64ArrayClient() { 00485 pasynFloat64ArraySyncIO->disconnect(pasynUserSyncIO_); 00486 }; 00491 virtual asynStatus read(epicsFloat64 *value, size_t nElements, size_t *nIn) { 00492 return pasynFloat64ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_); 00493 }; 00497 virtual asynStatus write(epicsFloat64 *value, size_t nElements) { 00498 return pasynFloat64ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_); 00499 }; 00502 virtual asynStatus registerInterruptUser(interruptCallbackFloat64Array pCallback) { 00503 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00504 pCallback, this, &interruptPvt_); 00505 }; 00506 private: 00507 asynFloat64Array *pInterface_; 00508 }; 00509 00510 00512 class epicsShareClass asynGenericPointerClient : public asynPortClient { 00513 public: 00520 asynGenericPointerClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00521 : asynPortClient(portName, addr, asynGenericPointerType, drvInfo, timeout) { 00522 pInterface_ = (asynGenericPointer *)pasynInterface_->pinterface; 00523 if (pasynGenericPointerSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00524 throw std::runtime_error(std::string("pasynGenericPointerSyncIO->connect failed")); 00525 }; 00527 virtual ~asynGenericPointerClient() { 00528 pasynGenericPointerSyncIO->disconnect(pasynUserSyncIO_); 00529 }; 00532 virtual asynStatus read(void *pointer) { 00533 return pasynGenericPointerSyncIO->read(pasynUserSyncIO_, pointer, timeout_); 00534 }; 00537 virtual asynStatus write(void *pointer) { 00538 return pasynGenericPointerSyncIO->write(pasynUserSyncIO_, pointer, timeout_); 00539 }; 00542 virtual asynStatus registerInterruptUser(interruptCallbackGenericPointer pCallback) { 00543 return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_, 00544 pCallback, this, &interruptPvt_); 00545 }; 00546 private: 00547 asynGenericPointer *pInterface_; 00548 }; 00549 00550 00552 class epicsShareClass asynOptionClient : public asynPortClient { 00553 public: 00560 asynOptionClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00561 : asynPortClient(portName, addr, asynOptionType, drvInfo, timeout) { 00562 pInterface_ = (asynOption *)pasynInterface_->pinterface; 00563 if (pasynOptionSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00564 throw std::runtime_error(std::string("pasynOptionSyncIO->connect failed")); 00565 }; 00567 virtual ~asynOptionClient() { 00568 pasynOptionSyncIO->disconnect(pasynUserSyncIO_); 00569 }; 00574 virtual asynStatus getOption(const char *key, char *value, int maxChars) { 00575 return pasynOptionSyncIO->getOption(pasynUserSyncIO_, key, value, maxChars, timeout_); 00576 }; 00580 virtual asynStatus setOption(const char *key, const char *value) { 00581 return pasynOptionSyncIO->setOption(pasynUserSyncIO_, key, value, timeout_); 00582 }; 00583 private: 00584 asynOption *pInterface_; 00585 }; 00586 00587 00589 class epicsShareClass asynEnumClient : public asynPortClient { 00590 public: 00597 asynEnumClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00598 : asynPortClient(portName, addr, asynEnumType, drvInfo, timeout) { 00599 pInterface_ = (asynEnum *)pasynInterface_->pinterface; 00600 if (pasynEnumSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00601 throw std::runtime_error(std::string("pasynEnumSyncIO->connect failed")); 00602 }; 00604 virtual ~asynEnumClient() { 00605 pasynEnumSyncIO->disconnect(pasynUserSyncIO_); 00606 }; 00613 virtual asynStatus read(char *strings[], int values[], int severities[], size_t nElements, size_t *nIn) { 00614 return pasynEnumSyncIO->read(pasynUserSyncIO_, strings, values, severities, nElements, nIn, timeout_); 00615 }; 00621 virtual asynStatus write(char *strings[], int values[], int severities[], size_t nElements) { 00622 return pasynEnumSyncIO->write(pasynUserSyncIO_, strings, values, severities, nElements, timeout_); 00623 }; 00624 private: 00625 asynEnum *pInterface_; 00626 }; 00627 00628 00630 class epicsShareClass asynCommonClient : public asynPortClient { 00631 public: 00638 asynCommonClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT) 00639 : asynPortClient(portName, addr, asynCommonType, drvInfo, timeout) { 00640 pInterface_ = (asynCommon *)pasynInterface_->pinterface; 00641 if (pasynCommonSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo)) 00642 throw std::runtime_error(std::string("pasynCommonSyncIO->connect failed")); 00643 }; 00645 virtual ~asynCommonClient() { 00646 pasynCommonSyncIO->disconnect(pasynUserSyncIO_); 00647 }; 00651 virtual void report(FILE *fp, int details) { 00652 pasynCommonSyncIO->report(pasynUserSyncIO_, fp, details); 00653 }; 00655 virtual asynStatus connect() { 00656 return pasynCommonSyncIO->connectDevice(pasynUserSyncIO_); 00657 }; 00659 virtual asynStatus disconnect() { 00660 return pasynCommonSyncIO->disconnectDevice(pasynUserSyncIO_); 00661 }; 00662 private: 00663 asynCommon *pInterface_; 00664 }; 00665 00666 #endif