asyn  4-35
asynPortClient.h
Go to the documentation of this file.
1 #ifndef asynPortClient_H
2 #define asynPortClient_H
3 
4 #include <stdexcept>
5 #include <string>
6 #include <map>
7 #include <string.h>
8 
9 #include <epicsString.h>
10 
11 #include <asynDriver.h>
12 #include <asynInt32.h>
13 #include <asynInt32SyncIO.h>
14 #include <asynUInt32Digital.h>
15 #include <asynUInt32DigitalSyncIO.h>
16 #include <asynFloat64.h>
17 #include <asynFloat64SyncIO.h>
18 #include <asynOctet.h>
19 #include <asynOctetSyncIO.h>
20 #include <asynInt8Array.h>
21 #include <asynInt8ArraySyncIO.h>
22 #include <asynInt16Array.h>
23 #include <asynInt16ArraySyncIO.h>
24 #include <asynInt32Array.h>
25 #include <asynInt32ArraySyncIO.h>
26 #include <asynFloat32Array.h>
27 #include <asynFloat32ArraySyncIO.h>
28 #include <asynFloat64Array.h>
29 #include <asynFloat64ArraySyncIO.h>
30 #include <asynGenericPointer.h>
31 #include <asynGenericPointerSyncIO.h>
32 #include <asynEnum.h>
33 #include <asynEnumSyncIO.h>
34 #include <asynOption.h>
35 #include <asynOptionSyncIO.h>
36 #include <asynCommonSyncIO.h>
37 #include <asynDrvUser.h>
38 #include <asynPortDriver.h>
39 
40 #define DEFAULT_TIMEOUT 1.0
41 
42 
45 class epicsShareClass asynParamClient {
46 public:
47  asynParamClient(const char *portName, int addr, const char* asynInterfaceType, const char *drvInfo, double timeout);
48  virtual ~asynParamClient();
49  void setTimeout(double timeout)
50  { timeout_ = timeout; };
51  void report(FILE *fp, int details);
52  char *getPortName() {
53  return portName_;
54  }
56  {
57  return asynInterfaceType_;
58  }
59 protected:
60  asynUser *pasynUser_;
61  asynUser *pasynUserSyncIO_;
62  asynInterface *pasynInterface_;
63  double timeout_;
64  char *portName_;
65  int addr_;
67  char *drvInfo_;
68  void *drvPvt;
70 };
71 
72 
74 class epicsShareClass asynInt32Client : public asynParamClient {
75 public:
82  asynInt32Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
83  : asynParamClient(portName, addr, asynInt32Type, drvInfo, timeout) {
84  pInterface_ = (asynInt32 *)pasynInterface_->pinterface;
85  if (pasynInt32SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
86  throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed"));
87  };
88  asynInt32Client(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
89  : asynParamClient(portName, addr, asynInt32Type, drvInfo, timeout) {
90  pInterface_ = (asynInt32 *)pasynInterface_->pinterface;
91  if (pasynInt32SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
92  throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed"));
93  };
95  virtual ~asynInt32Client() {
96  if (pInterface_ && interruptPvt_)
97  pInterface_->cancelInterruptUser(pasynInterface_->drvPvt, pasynUser_, interruptPvt_);
98  pasynInt32SyncIO->disconnect(pasynUserSyncIO_);
99  };
102  virtual asynStatus read(epicsInt32 *value) {
103  return pasynInt32SyncIO->read(pasynUserSyncIO_, value, timeout_);
104  };
107  virtual asynStatus write(epicsInt32 value) {
108  return pasynInt32SyncIO->write(pasynUserSyncIO_, value, timeout_);
109  };
113  virtual asynStatus getBounds(epicsInt32 *low, epicsInt32 *high) {
114  return pasynInt32SyncIO->getBounds(pasynUserSyncIO_, low, high);
115  };
119  virtual asynStatus registerInterruptUser(interruptCallbackInt32 pCallback, void *userPvt=0) {
120  if(interruptPvt_!=NULL) return asynError;
121  if (!userPvt) userPvt=this;
122  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
123  pCallback, userPvt, &interruptPvt_);
124  };
125 private:
126  asynInt32 *pInterface_;
127 };
128 
129 
131 class epicsShareClass asynUInt32DigitalClient : public asynParamClient {
132 public:
139  asynUInt32DigitalClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
140  : asynParamClient(portName, addr, asynUInt32DigitalType, drvInfo, timeout) {
141  pInterface_ = (asynUInt32Digital *)pasynInterface_->pinterface;
142  if (pasynUInt32DigitalSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
143  throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed"));
144  };
145  asynUInt32DigitalClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
146  : asynParamClient(portName, addr, asynUInt32DigitalType, drvInfo, timeout) {
147  pInterface_ = (asynUInt32Digital *)pasynInterface_->pinterface;
148  if (pasynUInt32DigitalSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
149  throw std::runtime_error(std::string("pasynInt32SyncIO->connect failed"));
150  };
153  pasynUInt32DigitalSyncIO->disconnect(pasynUserSyncIO_);
154  };
158  virtual asynStatus read(epicsUInt32 *value, epicsUInt32 mask) {
159  return pasynUInt32DigitalSyncIO->read(pasynUserSyncIO_, value, mask, timeout_);
160  };
164  virtual asynStatus write(epicsUInt32 value, epicsUInt32 mask){
165  return pasynUInt32DigitalSyncIO->write(pasynUserSyncIO_, value, mask, timeout_);
166  };
170  virtual asynStatus setInterrupt(epicsUInt32 mask, interruptReason reason) {
171  return pasynUInt32DigitalSyncIO->setInterrupt(pasynUserSyncIO_, mask, reason, timeout_);
172  };
175  virtual asynStatus clearInterrupt(epicsUInt32 mask) {
176  return pasynUInt32DigitalSyncIO->clearInterrupt(pasynUserSyncIO_, mask, timeout_);
177  };
181  virtual asynStatus getInterrupt(epicsUInt32 *mask, interruptReason reason) {
182  return pasynUInt32DigitalSyncIO->getInterrupt(pasynUserSyncIO_, mask, reason, timeout_);
183  };
188  virtual asynStatus registerInterruptUser(interruptCallbackUInt32Digital pCallback, epicsUInt32 mask, void* userPvt=0) {
189  if (!userPvt) userPvt=this;
190  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
191  pCallback, this, mask, &interruptPvt_);
192  };
193 private:
194  asynUInt32Digital *pInterface_;
195 };
196 
197 
199 class epicsShareClass asynFloat64Client : public asynParamClient {
200 public:
207  asynFloat64Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
208  : asynParamClient(portName, addr, asynFloat64Type, drvInfo, timeout) {
209  pInterface_ = (asynFloat64 *)pasynInterface_->pinterface;
210  if (pasynFloat64SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
211  throw std::runtime_error(std::string("pasynFloat64SyncIO->connect failed"));
212  };
213  asynFloat64Client(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
214  : asynParamClient(portName, addr, asynFloat64Type, drvInfo, timeout) {
215  pInterface_ = (asynFloat64 *)pasynInterface_->pinterface;
216  if (pasynFloat64SyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
217  throw std::runtime_error(std::string("pasynFloat64SyncIO->connect failed"));
218  };
220  virtual ~asynFloat64Client() {
221  pasynFloat64SyncIO->disconnect(pasynUserSyncIO_);
222  };
225  virtual asynStatus read(epicsFloat64 *value) {
226  return pasynFloat64SyncIO->read(pasynUserSyncIO_, value, timeout_);
227  };
230  virtual asynStatus write(epicsFloat64 value) {
231  return pasynFloat64SyncIO->write(pasynUserSyncIO_, value, timeout_);
232  };
236  virtual asynStatus registerInterruptUser(interruptCallbackFloat64 pCallback, void *userPvt=0) {
237  if (!userPvt) userPvt=this;
238  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
239  pCallback, userPvt, &interruptPvt_);
240  };
241 private:
242  asynFloat64 *pInterface_;
243 };
244 
245 
247 class epicsShareClass asynOctetClient : public asynParamClient {
248 public:
255  asynOctetClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
256  : asynParamClient(portName, addr, asynOctetType, drvInfo, timeout) {
257  pInterface_ = (asynOctet *)pasynInterface_->pinterface;
258  if (pasynOctetSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
259  throw std::runtime_error(std::string("pasynOctetSyncIO->connect failed"));
260  };
261  asynOctetClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
262  : asynParamClient(portName, addr, asynOctetType, drvInfo, timeout) {
263  pInterface_ = (asynOctet *)pasynInterface_->pinterface;
264  if (pasynOctetSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
265  throw std::runtime_error(std::string("pasynOctetSyncIO->connect failed"));
266  };
268  virtual ~asynOctetClient() {
269  pasynOctetSyncIO->disconnect(pasynUserSyncIO_);
270  };
275  virtual asynStatus write(const char *buffer, size_t bufferLen, size_t *nActual) {
276  return pasynOctetSyncIO->write(pasynUserSyncIO_, buffer, bufferLen, timeout_, nActual);
277  };
280  virtual asynStatus write(const char *buffer) {
281  size_t bufferLen = strlen(buffer);
282  size_t nActual;
283  return pasynOctetSyncIO->write(pasynUserSyncIO_, buffer, bufferLen, timeout_, &nActual);
284  };
290  virtual asynStatus read(char *buffer, size_t bufferLen, size_t *nActual, int *eomReason) {
291  return pasynOctetSyncIO->read(pasynUserSyncIO_, buffer, bufferLen, timeout_, nActual, eomReason);
292  };
301  virtual asynStatus writeRead(const char *writeBuffer, size_t writeBufferLen, char *readBuffer, size_t readBufferLen,
302  size_t *nBytesOut, size_t *nBytesIn, int *eomReason) {
303  return pasynOctetSyncIO->writeRead(pasynUserSyncIO_, writeBuffer, writeBufferLen, readBuffer, readBufferLen,
304  timeout_, nBytesOut, nBytesIn, eomReason);
305  };
307  virtual asynStatus flush() {
308  return pasynOctetSyncIO->flush(pasynUserSyncIO_);
309  };
313  virtual asynStatus setInputEos(const char *eos, int eosLen) {
314  return pasynOctetSyncIO->setInputEos(pasynUserSyncIO_, eos, eosLen);
315  };
320  virtual asynStatus getInputEos(char *eos, int eosSize, int *eosLen) {
321  return pasynOctetSyncIO->getInputEos(pasynUserSyncIO_, eos, eosSize, eosLen);
322  };
326  virtual asynStatus setOutputEos(const char *eos, int eosLen) {
327  return pasynOctetSyncIO->setOutputEos(pasynUserSyncIO_, eos, eosLen);
328  };
333  virtual asynStatus getOutputEos(char *eos, int eosSize, int *eosLen) {
334  return pasynOctetSyncIO->getOutputEos(pasynUserSyncIO_, eos, eosSize, eosLen);
335  };
339  virtual asynStatus registerInterruptUser(interruptCallbackOctet pCallback, void *userPvt=0) {
340  if (!userPvt) userPvt=this;
341  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
342  pCallback, userPvt, &interruptPvt_);
343  };
344 private:
345  asynOctet *pInterface_;
346 };
347 
348 
350 class epicsShareClass asynInt8ArrayClient : public asynParamClient {
351 public:
358  asynInt8ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
359  : asynParamClient(portName, addr, asynInt8ArrayType, drvInfo, timeout) {
360  pInterface_ = (asynInt8Array *)pasynInterface_->pinterface;
361  if (pasynInt8ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
362  throw std::runtime_error(std::string("pasynInt8ArraySyncIO->connect failed"));
363  };
364  asynInt8ArrayClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
365  : asynParamClient(portName, addr, asynInt8ArrayType, drvInfo, timeout) {
366  pInterface_ = (asynInt8Array *)pasynInterface_->pinterface;
367  if (pasynInt8ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
368  throw std::runtime_error(std::string("pasynInt8ArraySyncIO->connect failed"));
369  };
372  pasynInt8ArraySyncIO->disconnect(pasynUserSyncIO_);
373  };
378  virtual asynStatus read(epicsInt8 *value, size_t nElements, size_t *nIn) {
379  return pasynInt8ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_);
380  };
384  virtual asynStatus write(epicsInt8 *value, size_t nElements) {
385  return pasynInt8ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_);
386  };
390  virtual asynStatus registerInterruptUser(interruptCallbackInt8Array pCallback, void *userPvt=0) {
391  if (!userPvt) userPvt=this;
392  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
393  pCallback, userPvt, &interruptPvt_);
394  };
395 private:
396  asynInt8Array *pInterface_;
397 };
398 
399 
401 class epicsShareClass asynInt16ArrayClient : public asynParamClient {
402 public:
409  asynInt16ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
410  : asynParamClient(portName, addr, asynInt16ArrayType, drvInfo, timeout) {
411  pInterface_ = (asynInt16Array *)pasynInterface_->pinterface;
412  if (pasynInt16ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
413  throw std::runtime_error(std::string("pasynInt16ArraySyncIO->connect failed"));
414  };
415  asynInt16ArrayClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
416  : asynParamClient(portName, addr, asynInt16ArrayType, drvInfo, timeout) {
417  pInterface_ = (asynInt16Array *)pasynInterface_->pinterface;
418  if (pasynInt16ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
419  throw std::runtime_error(std::string("pasynInt16ArraySyncIO->connect failed"));
420  };
423  pasynInt16ArraySyncIO->disconnect(pasynUserSyncIO_);
424  };
429  virtual asynStatus read(epicsInt16 *value, size_t nElements, size_t *nIn) {
430  return pasynInt16ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_);
431  };
435  virtual asynStatus write(epicsInt16 *value, size_t nElements) {
436  return pasynInt16ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_);
437  };
441  virtual asynStatus registerInterruptUser(interruptCallbackInt16Array pCallback, void *userPvt=0) {
442  if (!userPvt) userPvt=this;
443  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
444  pCallback, userPvt, &interruptPvt_);
445  };
446 private:
447  asynInt16Array *pInterface_;
448 };
449 
450 
452 class epicsShareClass asynInt32ArrayClient : public asynParamClient {
453 public:
460  asynInt32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
461  : asynParamClient(portName, addr, asynInt32ArrayType, drvInfo, timeout) {
462  pInterface_ = (asynInt32Array *)pasynInterface_->pinterface;
463  if (pasynInt32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
464  throw std::runtime_error(std::string("pasynInt32ArraySyncIO->connect failed"));
465  };
466  asynInt32ArrayClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
467  : asynParamClient(portName, addr, asynInt32ArrayType, drvInfo, timeout) {
468  pInterface_ = (asynInt32Array *)pasynInterface_->pinterface;
469  if (pasynInt32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
470  throw std::runtime_error(std::string("pasynInt32ArraySyncIO->connect failed"));
471  };
474  pasynInt32ArraySyncIO->disconnect(pasynUserSyncIO_);
475  };
480  virtual asynStatus read(epicsInt32 *value, size_t nElements, size_t *nIn) {
481  return pasynInt32ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_);
482  };
486  virtual asynStatus write(epicsInt32 *value, size_t nElements) {
487  return pasynInt32ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_);
488  };
492  virtual asynStatus registerInterruptUser(interruptCallbackInt32Array pCallback, void *userPvt=0) {
493  if (!userPvt) userPvt=this;
494  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
495  pCallback, userPvt, &interruptPvt_);
496  };
497 private:
498  asynInt32Array *pInterface_;
499 };
500 
501 
503 class epicsShareClass asynFloat32ArrayClient : public asynParamClient {
504 public:
511  asynFloat32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
512  : asynParamClient(portName, addr, asynFloat32ArrayType, drvInfo, timeout) {
513  pInterface_ = (asynFloat32Array *)pasynInterface_->pinterface;
514  if (pasynFloat32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
515  throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed"));
516  };
517  asynFloat32ArrayClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
518  : asynParamClient(portName, addr, asynFloat32ArrayType, drvInfo, timeout) {
519  pInterface_ = (asynFloat32Array *)pasynInterface_->pinterface;
520  if (pasynFloat32ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
521  throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed"));
522  };
525  pasynFloat32ArraySyncIO->disconnect(pasynUserSyncIO_);
526  };
531  virtual asynStatus read(epicsFloat32 *value, size_t nElements, size_t *nIn) {
532  return pasynFloat32ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_);
533  };
537  virtual asynStatus write(epicsFloat32 *value, size_t nElements) {
538  return pasynFloat32ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_);
539  };
543  virtual asynStatus registerInterruptUser(interruptCallbackFloat32Array pCallback, void *userPvt=0) {
544  if (!userPvt) userPvt=this;
545  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
546  pCallback, userPvt, &interruptPvt_);
547  };
548 private:
549  asynFloat32Array *pInterface_;
550 };
551 
552 
554 class epicsShareClass asynFloat64ArrayClient : public asynParamClient {
555 public:
562  asynFloat64ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
563  : asynParamClient(portName, addr, asynFloat64ArrayType, drvInfo, timeout) {
564  pInterface_ = (asynFloat64Array *)pasynInterface_->pinterface;
565  if (pasynFloat64ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
566  throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed"));
567  };
568  asynFloat64ArrayClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
569  : asynParamClient(portName, addr, asynFloat64ArrayType, drvInfo, timeout) {
570  pInterface_ = (asynFloat64Array *)pasynInterface_->pinterface;
571  if (pasynFloat64ArraySyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
572  throw std::runtime_error(std::string("pasynFloat64ArraySyncIO->connect failed"));
573  };
576  pasynFloat64ArraySyncIO->disconnect(pasynUserSyncIO_);
577  };
582  virtual asynStatus read(epicsFloat64 *value, size_t nElements, size_t *nIn) {
583  return pasynFloat64ArraySyncIO->read(pasynUserSyncIO_, value, nElements, nIn, timeout_);
584  };
588  virtual asynStatus write(epicsFloat64 *value, size_t nElements) {
589  return pasynFloat64ArraySyncIO->write(pasynUserSyncIO_, value, nElements, timeout_);
590  };
594  virtual asynStatus registerInterruptUser(interruptCallbackFloat64Array pCallback, void *userPvt=0) {
595  if (!userPvt) userPvt=this;
596  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
597  pCallback, userPvt, &interruptPvt_);
598  };
599 private:
600  asynFloat64Array *pInterface_;
601 };
602 
603 
605 class epicsShareClass asynGenericPointerClient : public asynParamClient {
606 public:
613  asynGenericPointerClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
614  : asynParamClient(portName, addr, asynGenericPointerType, drvInfo, timeout) {
615  pInterface_ = (asynGenericPointer *)pasynInterface_->pinterface;
616  if (pasynGenericPointerSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
617  throw std::runtime_error(std::string("pasynGenericPointerSyncIO->connect failed"));
618  };
619  asynGenericPointerClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
620  : asynParamClient(portName, addr, asynGenericPointerType, drvInfo, timeout) {
621  pInterface_ = (asynGenericPointer *)pasynInterface_->pinterface;
622  if (pasynGenericPointerSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
623  throw std::runtime_error(std::string("pasynGenericPointerSyncIO->connect failed"));
624  };
627  pasynGenericPointerSyncIO->disconnect(pasynUserSyncIO_);
628  };
631  virtual asynStatus read(void *pointer) {
632  return pasynGenericPointerSyncIO->read(pasynUserSyncIO_, pointer, timeout_);
633  };
636  virtual asynStatus write(void *pointer) {
637  return pasynGenericPointerSyncIO->write(pasynUserSyncIO_, pointer, timeout_);
638  };
642  virtual asynStatus registerInterruptUser(interruptCallbackGenericPointer pCallback, void *userPvt=0) {
643  if (!userPvt) userPvt=this;
644  return pInterface_->registerInterruptUser(pasynInterface_->drvPvt, pasynUser_,
645  pCallback, userPvt, &interruptPvt_);
646  };
647 private:
648  asynGenericPointer *pInterface_;
649 };
650 
651 
653 class epicsShareClass asynOptionClient : public asynParamClient {
654 public:
661  asynOptionClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
662  : asynParamClient(portName, addr, asynOptionType, drvInfo, timeout) {
663  pInterface_ = (asynOption *)pasynInterface_->pinterface;
664  if (pasynOptionSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
665  throw std::runtime_error(std::string("pasynOptionSyncIO->connect failed"));
666  };
667  asynOptionClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
668  : asynParamClient(portName, addr, asynOptionType, drvInfo, timeout) {
669  pInterface_ = (asynOption *)pasynInterface_->pinterface;
670  if (pasynOptionSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
671  throw std::runtime_error(std::string("pasynOptionSyncIO->connect failed"));
672  };
674  virtual ~asynOptionClient() {
675  pasynOptionSyncIO->disconnect(pasynUserSyncIO_);
676  };
681  virtual asynStatus getOption(const char *key, char *value, int maxChars) {
682  return pasynOptionSyncIO->getOption(pasynUserSyncIO_, key, value, maxChars, timeout_);
683  };
687  virtual asynStatus setOption(const char *key, const char *value) {
688  return pasynOptionSyncIO->setOption(pasynUserSyncIO_, key, value, timeout_);
689  };
690 private:
691  asynOption *pInterface_;
692 };
693 
694 
696 class epicsShareClass asynEnumClient : public asynParamClient {
697 public:
704  asynEnumClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
705  : asynParamClient(portName, addr, asynEnumType, drvInfo, timeout) {
706  pInterface_ = (asynEnum *)pasynInterface_->pinterface;
707  if (pasynEnumSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
708  throw std::runtime_error(std::string("pasynEnumSyncIO->connect failed"));
709  };
710  asynEnumClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
711  : asynParamClient(portName, addr, asynEnumType, drvInfo, timeout) {
712  pInterface_ = (asynEnum *)pasynInterface_->pinterface;
713  if (pasynEnumSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
714  throw std::runtime_error(std::string("pasynEnumSyncIO->connect failed"));
715  };
717  virtual ~asynEnumClient() {
718  pasynEnumSyncIO->disconnect(pasynUserSyncIO_);
719  };
726  virtual asynStatus read(char *strings[], int values[], int severities[], size_t nElements, size_t *nIn) {
727  return pasynEnumSyncIO->read(pasynUserSyncIO_, strings, values, severities, nElements, nIn, timeout_);
728  };
734  virtual asynStatus write(char *strings[], int values[], int severities[], size_t nElements) {
735  return pasynEnumSyncIO->write(pasynUserSyncIO_, strings, values, severities, nElements, timeout_);
736  };
737 private:
738  asynEnum *pInterface_;
739 };
740 
741 
743 class epicsShareClass asynCommonClient : public asynParamClient {
744 public:
751  asynCommonClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
752  : asynParamClient(portName, addr, asynCommonType, drvInfo, timeout) {
753  pInterface_ = (asynCommon *)pasynInterface_->pinterface;
754  if (pasynCommonSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
755  throw std::runtime_error(std::string("pasynCommonSyncIO->connect failed"));
756  };
757  asynCommonClient(const char *portName, const char* drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
758  : asynParamClient(portName, addr, asynCommonType, drvInfo, timeout) {
759  pInterface_ = (asynCommon *)pasynInterface_->pinterface;
760  if (pasynCommonSyncIO->connect(portName, addr, &pasynUserSyncIO_, drvInfo))
761  throw std::runtime_error(std::string("pasynCommonSyncIO->connect failed"));
762  };
764  virtual ~asynCommonClient() {
765  pasynCommonSyncIO->disconnect(pasynUserSyncIO_);
766  };
770  virtual void report(FILE *fp, int details) {
771  pasynCommonSyncIO->report(pasynUserSyncIO_, fp, details);
772  };
774  virtual asynStatus connect() {
775  return pasynCommonSyncIO->connectDevice(pasynUserSyncIO_);
776  };
778  virtual asynStatus disconnect() {
779  return pasynCommonSyncIO->disconnectDevice(pasynUserSyncIO_);
780  };
781 private:
782  asynCommon *pInterface_;
783 };
784 
785 typedef std::map<std::string, asynParamClient*> paramMap_t;
786 
787 class epicsShareClass asynPortClient {
788 public:
789  asynPortClient(const char *portName, double timeout=1.0);
790  virtual ~asynPortClient();
791  void report(FILE *fp, int details);
792  asynStatus write(std::string paramName, epicsInt32 value, int addr=0);
793  asynStatus read(std::string paramName, epicsInt32 *value, int addr=0);
794  asynStatus write(std::string paramName, epicsFloat64 value, int addr=0);
795  asynStatus read(std::string paramName, epicsFloat64 *value, int addr=0);
796  asynStatus write(std::string paramName, const char *value, int addr=0);
797  asynStatus read(std::string paramName, char *value, size_t bufferLen, int addr=0);
798 
799  asynParamClient* getParamClient(std::string paramName, int addr=0);
800 
801 private:
802  asynPortDriver *pPort_;
803  paramMap_t** paramMaps_;
804 };
805 
806 #endif
Class for asyn port clients to communicate on the asynCommon interface.
Definition: asynPortClient.h:743
virtual asynStatus getOption(const char *key, char *value, int maxChars)
Get an option from the port driver.
Definition: asynPortClient.h:681
asynUInt32DigitalClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynUInt32DigitalClient class.
Definition: asynPortClient.h:139
virtual asynStatus read(epicsFloat32 *value, size_t nElements, size_t *nIn)
Reads an epicsFloat32 array from the port driver.
Definition: asynPortClient.h:531
char * getAsynInterfaceType()
Definition: asynPortClient.h:55
char * getPortName()
Definition: asynPortClient.h:52
Class for asyn port clients to communicate on the asynInt32 interface.
Definition: asynPortClient.h:74
virtual asynStatus registerInterruptUser(interruptCallbackFloat64Array pCallback, void *userPvt=0)
Registers an interruptCallbackFloat64Array function that the driver will call when there is a new val...
Definition: asynPortClient.h:594
virtual asynStatus write(epicsInt32 *value, size_t nElements)
Writes an epicsInt32 array to the port driver.
Definition: asynPortClient.h:486
Class for asyn port clients to communicate on the asynInt16Array interface.
Definition: asynPortClient.h:401
void setTimeout(double timeout)
Definition: asynPortClient.h:49
Base class for asyn port drivers; handles most of the bookkeeping for writing an asyn port driver wit...
Definition: asynPortDriver.h:41
virtual asynStatus read(epicsFloat64 *value, size_t nElements, size_t *nIn)
Reads an epicsFloat64 array from the port driver.
Definition: asynPortClient.h:582
virtual asynStatus read(epicsInt16 *value, size_t nElements, size_t *nIn)
Reads an epicsInt16 array from the port driver.
Definition: asynPortClient.h:429
double timeout_
Definition: asynPortClient.h:63
virtual asynStatus write(const char *buffer)
Writes a char buffer to the port driver.
Definition: asynPortClient.h:280
virtual asynStatus write(epicsFloat64 *value, size_t nElements)
Writes an epicsFloat64 array to the port driver.
Definition: asynPortClient.h:588
Base class for asyn port clients; handles most of the bookkeeping for writing an asyn port client wit...
Definition: asynPortClient.h:45
virtual asynStatus getInterrupt(epicsUInt32 *mask, interruptReason reason)
Gets the current interrupt mask for the specified reason from the driver.
Definition: asynPortClient.h:181
virtual asynStatus disconnect()
Calls the disconnect method in the driver disconnects from the port device.
Definition: asynPortClient.h:778
virtual ~asynInt32ArrayClient()
Destructor for asynInt32Array class.
Definition: asynPortClient.h:473
virtual ~asynGenericPointerClient()
Destructor for asynGenericPointer class.
Definition: asynPortClient.h:626
virtual ~asynInt32Client()
Destructor for asynInt32Client class.
Definition: asynPortClient.h:95
virtual asynStatus write(epicsInt16 *value, size_t nElements)
Writes an epicsInt16 array to the port driver.
Definition: asynPortClient.h:435
Class for asyn port clients to communicate on the asynInt8Array interface.
Definition: asynPortClient.h:350
asynEnumClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:710
virtual asynStatus registerInterruptUser(interruptCallbackInt32 pCallback, void *userPvt=0)
Registers an interruptCallbackInt32 function that the driver will call when there is a new value...
Definition: asynPortClient.h:119
asynUser * pasynUserSyncIO_
Definition: asynPortClient.h:61
void * drvPvt
Definition: asynPortClient.h:68
Class for asyn port clients to communicate on the asynFloat32Array interface.
Definition: asynPortClient.h:503
Class for asyn port clients to communicate on the asynInt32Array interface.
Definition: asynPortClient.h:452
char * asynInterfaceType_
Definition: asynPortClient.h:66
void * interruptPvt_
Definition: asynPortClient.h:69
virtual void report(FILE *fp, int details)
Calls the report method in the driver.
Definition: asynPortClient.h:770
virtual asynStatus registerInterruptUser(interruptCallbackInt16Array pCallback, void *userPvt=0)
Registers an interruptCallbackInt16Array function that the driver will call when there is a new value...
Definition: asynPortClient.h:441
virtual asynStatus getOutputEos(char *eos, int eosSize, int *eosLen)
Gets the output end-of-string terminator from the driver.
Definition: asynPortClient.h:333
asynFloat32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynFloat32Array class.
Definition: asynPortClient.h:511
virtual ~asynUInt32DigitalClient()
Destructor for asynInt32Client class.
Definition: asynPortClient.h:152
virtual asynStatus read(epicsFloat64 *value)
Reads an epicsFloat64 value from the port driver.
Definition: asynPortClient.h:225
asynInt8ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynInt8Array class.
Definition: asynPortClient.h:358
virtual ~asynEnumClient()
Destructor for asynEnum class.
Definition: asynPortClient.h:717
virtual asynStatus write(epicsUInt32 value, epicsUInt32 mask)
Writes an epicsUInt32 value to the port driver.
Definition: asynPortClient.h:164
virtual asynStatus registerInterruptUser(interruptCallbackFloat64 pCallback, void *userPvt=0)
Registers an interruptCallbackFloat64 function that the driver will call when there is a new value...
Definition: asynPortClient.h:236
Class for asyn port clients to communicate on the asynEnum interface.
Definition: asynPortClient.h:696
Class for asyn port clients to communicate on the asynFloat64Array interface.
Definition: asynPortClient.h:554
Class for asyn port clients to communicate on the asynGenericPointer interface.
Definition: asynPortClient.h:605
virtual asynStatus read(epicsInt32 *value)
Reads an epicsInt32 value from the port driver.
Definition: asynPortClient.h:102
asynInterface * pasynInterface_
Definition: asynPortClient.h:62
virtual asynStatus read(epicsUInt32 *value, epicsUInt32 mask)
Reads an epicsUInt32 value from the port driver.
Definition: asynPortClient.h:158
virtual asynStatus connect()
Calls the connect method in the driver which attempts to connect to the port device.
Definition: asynPortClient.h:774
virtual asynStatus write(void *pointer)
Writes a generic pointer to the port driver.
Definition: asynPortClient.h:636
virtual asynStatus read(epicsInt32 *value, size_t nElements, size_t *nIn)
Reads an epicsInt32 array from the port driver.
Definition: asynPortClient.h:480
virtual ~asynOctetClient()
Destructor for asynOctetClient class.
Definition: asynPortClient.h:268
virtual asynStatus setOption(const char *key, const char *value)
Sets an option in the port driver.
Definition: asynPortClient.h:687
std::map< std::string, asynParamClient * > paramMap_t
Definition: asynPortClient.h:785
asynCommonClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:757
asynInt32Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynInt32Client class.
Definition: asynPortClient.h:82
virtual asynStatus registerInterruptUser(interruptCallbackInt8Array pCallback, void *userPvt=0)
Registers an interruptCallbackInt8Array function that the driver will call when there is a new value...
Definition: asynPortClient.h:390
virtual ~asynFloat64ArrayClient()
Destructor for asynFloat64Array class.
Definition: asynPortClient.h:575
asynOctetClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:261
virtual ~asynOptionClient()
Destructor for asynOption class.
Definition: asynPortClient.h:674
asynEnumClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynEnum class.
Definition: asynPortClient.h:704
virtual asynStatus registerInterruptUser(interruptCallbackFloat32Array pCallback, void *userPvt=0)
Registers an interruptCallbackFloat32Array function that the driver will call when there is a new val...
Definition: asynPortClient.h:543
virtual ~asynFloat32ArrayClient()
Destructor for asynFloat32Array class.
Definition: asynPortClient.h:524
asynGenericPointerClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:619
virtual ~asynInt16ArrayClient()
Destructor for asynInt16Array class.
Definition: asynPortClient.h:422
Definition: asynPortClient.h:787
Class for asyn port clients to communicate on the asynFloat64 interface.
Definition: asynPortClient.h:199
asynUInt32DigitalClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:145
asynFloat64ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynFloat64Array class.
Definition: asynPortClient.h:562
asynFloat64Client(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:213
Class for asyn port clients to communicate on the asynUInt32Digital interface.
Definition: asynPortClient.h:131
virtual asynStatus registerInterruptUser(interruptCallbackOctet pCallback, void *userPvt=0)
Registers an interruptCallbackOctet function that the driver will call when there is a new value...
Definition: asynPortClient.h:339
virtual asynStatus writeRead(const char *writeBuffer, size_t writeBufferLen, char *readBuffer, size_t readBufferLen, size_t *nBytesOut, size_t *nBytesIn, int *eomReason)
Writes a char buffer to the port driver and reads the response as an atomic operation.
Definition: asynPortClient.h:301
virtual asynStatus write(epicsInt32 value)
Writes an epicsInt32 value to the port driver.
Definition: asynPortClient.h:107
char * portName_
Definition: asynPortClient.h:64
asynInt32ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynInt32Array class.
Definition: asynPortClient.h:460
virtual asynStatus read(epicsInt8 *value, size_t nElements, size_t *nIn)
Reads an epicsInt8 array from the port driver.
Definition: asynPortClient.h:378
asynGenericPointerClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynGenericPointer class.
Definition: asynPortClient.h:613
virtual asynStatus write(const char *buffer, size_t bufferLen, size_t *nActual)
Writes a char buffer to the port driver.
Definition: asynPortClient.h:275
virtual ~asynCommonClient()
Destructor for asynCommon class.
Definition: asynPortClient.h:764
asynInt32ArrayClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:466
virtual asynStatus getInputEos(char *eos, int eosSize, int *eosLen)
Gets the input end-of-string terminator from the driver.
Definition: asynPortClient.h:320
char * drvInfo_
Definition: asynPortClient.h:67
asynInt16ArrayClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:415
asynOptionClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:667
asynUser * pasynUser_
Definition: asynPortClient.h:60
virtual ~asynInt8ArrayClient()
Destructor for asynInt8Array class.
Definition: asynPortClient.h:371
asynFloat64ArrayClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:568
asynOptionClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynOption class.
Definition: asynPortClient.h:661
virtual asynStatus write(char *strings[], int values[], int severities[], size_t nElements)
Writes enum strings, values, and severities to the port driver.
Definition: asynPortClient.h:734
int addr_
Definition: asynPortClient.h:65
virtual asynStatus setInputEos(const char *eos, int eosLen)
Sets the input end-of-string terminator in the driver.
Definition: asynPortClient.h:313
virtual asynStatus write(epicsFloat32 *value, size_t nElements)
Writes an epicsFloat32 array to the port driver.
Definition: asynPortClient.h:537
virtual asynStatus read(void *pointer)
Reads an generic pointer from the port driver.
Definition: asynPortClient.h:631
asynOctetClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynOctetClient class.
Definition: asynPortClient.h:255
virtual asynStatus registerInterruptUser(interruptCallbackInt32Array pCallback, void *userPvt=0)
Registers an interruptCallbackInt32Array function that the driver will call when there is a new value...
Definition: asynPortClient.h:492
asynCommonClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynCommon class.
Definition: asynPortClient.h:751
virtual asynStatus write(epicsFloat64 value)
Writes an epicsFloat64 value to the port driver.
Definition: asynPortClient.h:230
virtual ~asynFloat64Client()
Destructor for asynFloat64Client class.
Definition: asynPortClient.h:220
#define DEFAULT_TIMEOUT
Definition: asynPortClient.h:40
asynInt8ArrayClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:364
asynInt16ArrayClient(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynInt16Array class.
Definition: asynPortClient.h:409
virtual asynStatus setInterrupt(epicsUInt32 mask, interruptReason reason)
Sets the interrupt mask for the specified interrupt reason in the driver.
Definition: asynPortClient.h:170
virtual asynStatus flush()
Flushes the input buffer in the port driver.
Definition: asynPortClient.h:307
virtual asynStatus read(char *strings[], int values[], int severities[], size_t nElements, size_t *nIn)
Reads enum strings, values, and severities from the port driver.
Definition: asynPortClient.h:726
asynInt32Client(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:88
virtual asynStatus write(epicsInt8 *value, size_t nElements)
Writes an epicsInt8 array to the port driver.
Definition: asynPortClient.h:384
virtual asynStatus registerInterruptUser(interruptCallbackGenericPointer pCallback, void *userPvt=0)
Registers an interruptCallbackGenericPointer function that the driver will call when there is a new v...
Definition: asynPortClient.h:642
Class for asyn port clients to communicate on the asynOctet interface.
Definition: asynPortClient.h:247
Class for asyn port clients to communicate on the asynOption interface.
Definition: asynPortClient.h:653
virtual asynStatus registerInterruptUser(interruptCallbackUInt32Digital pCallback, epicsUInt32 mask, void *userPvt=0)
Registers an interruptCallbackUInt32Digital function that the driver will call when there is a new va...
Definition: asynPortClient.h:188
asynFloat64Client(const char *portName, int addr, const char *drvInfo, double timeout=DEFAULT_TIMEOUT)
Constructor for asynFloat64Client class.
Definition: asynPortClient.h:207
virtual asynStatus getBounds(epicsInt32 *low, epicsInt32 *high)
Returns the lower and upper limits of the range of values from the port driver.
Definition: asynPortClient.h:113
asynFloat32ArrayClient(const char *portName, const char *drvInfo, int addr=0, double timeout=DEFAULT_TIMEOUT)
Definition: asynPortClient.h:517
virtual asynStatus clearInterrupt(epicsUInt32 mask)
Clears the interrupt mask in the driver.
Definition: asynPortClient.h:175
virtual asynStatus setOutputEos(const char *eos, int eosLen)
Sets the output end-of-string terminator in the driver.
Definition: asynPortClient.h:326
virtual asynStatus read(char *buffer, size_t bufferLen, size_t *nActual, int *eomReason)
Reads a char buffer from the port driver.
Definition: asynPortClient.h:290