DABC (Data Acquisition Backbone Core)  2.9.9
EpicsInput.h
Go to the documentation of this file.
1 // $Id: EpicsInput.h 4464 2020-04-15 12:14:20Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef EZCA_EPICSINPUT_H
17 #define EZCA_EPICSINPUT_H
18 
19 #ifndef DABC_DataIO
20 #include "dabc/DataIO.h"
21 #endif
22 
23 #include "dabc/logging.h"
24 
25 #include <string>
26 #include <vector>
27 #include <cstdint>
28 
29 
30 namespace ezca {
31 
37  class EpicsInput: public dabc::DataInput {
38  protected:
39  std::string fName;
40 
41  /* timeout (in seconds) for readout polling. */
42  double fTimeout;
43 
44  /* full id number for epics subevent*/
45  unsigned fSubeventId;
46 
49 
52 
54  long fCounter;
55 
57  double fEzcaTimeout;
58 
61 
63  bool fEzcaDebug;
64 
67 
68  /* the update flag record is looked at for all read attempts
69  * only if this one switches to some "updated" state,
70  * all the rest of the set up variables are requested
71  * and put into the output buffer*/
72  std::string fUpdateFlagRecord;
73 
74  /* the id number of the current dataset, i.e. the mbs event number*/
75  std::string fIDNumberRecord;
76 
77  /* name of the dabc command receiver that shall be informed
78  * whenever the PVs are updated*/
80 
81  /* contains names of all long integer values to be requested*/
82  std::vector<std::string> fLongRecords;
83  std::vector<long> fLongValues;
84  std::vector<bool> fLongRes;
85 
86  /* contains names of all double values to be requested*/
87  std::vector<std::string> fDoubleRecords;
88  std::vector<double> fDoubleValues;
89  std::vector<bool> fDoubleRes;
90 
92  {
93  fUpdateFlagRecord = "";
94  fIDNumberRecord = "";
96  fLongRecords.clear();
97  fLongValues.clear();
98  fLongRes.clear();
99  fDoubleRecords.clear();
100  fDoubleValues.clear();
101  fDoubleRes.clear();
102  }
103 
104  unsigned NumLongRecords() const { return fLongRecords.size(); }
105 
106  const std::string &GetLongRecord(unsigned i) const { return fLongRecords[i]; }
107 
108  unsigned NumDoubleRecords() const { return fDoubleRecords.size(); }
109 
110  const std::string &GetDoubleRecord(unsigned i) const { return fDoubleRecords[i]; }
111 
112  /* Wrapper for ezca get with long values. Contains error message handling.
113  * Returns ezca error code.*/
114  int CA_GetLong(const std::string &name, long& val);
115 
116  /* Wrapper for ezca get with double values. Contains error message handling
117  * Returns ezca error code.*/
118  int CA_GetDouble(const std::string &name, double& val);
119 
121  std::string CA_ErrorString();
122 
123  const char* CA_RetCode(int ret);
124 
125  bool Close();
126 
127  public:
128  EpicsInput(const std::string &name = "");
129  virtual ~EpicsInput();
130 
131  virtual bool Read_Init(const dabc::WorkerRef& wrk, const dabc::Command& cmd);
132 
133  virtual unsigned Read_Size();
134  virtual unsigned Read_Complete(dabc::Buffer& buf);
135 
136  virtual double Read_Timeout() { return fTimeout; }
137  };
138 
139 }
140 
141 #endif
Reference on memory from memory pool.
Definition: Buffer.h:135
Represents command with its arguments.
Definition: Command.h:99
Interface for implementing any kind of data input.
Definition: DataIO.h:61
Reference on dabc::Worker
Definition: Worker.h:466
The epics easy channel access data input implementation.
Definition: EpicsInput.h:37
double fEzcaTimeout
Timeout for ezca readout.
Definition: EpicsInput.h:57
virtual bool Read_Init(const dabc::WorkerRef &wrk, const dabc::Command &cmd)
Initialize data input, using port and command.
Definition: EpicsInput.cxx:57
const char * CA_RetCode(int ret)
Definition: EpicsInput.cxx:280
int fEzcaRetryCnt
Number of retry in ezca readout.
Definition: EpicsInput.h:60
std::vector< bool > fDoubleRes
Definition: EpicsInput.h:89
int CA_GetDouble(const std::string &name, double &val)
Definition: EpicsInput.cxx:258
std::vector< std::string > fLongRecords
Definition: EpicsInput.h:82
long fCounter
Counter of events, used as mbs event id when event number is not provided.
Definition: EpicsInput.h:54
std::string fName
Definition: EpicsInput.h:39
std::string fIDNumberRecord
Definition: EpicsInput.h:75
virtual double Read_Timeout()
Provide timeout value.
Definition: EpicsInput.h:136
bool fEzcaDebug
Switch on/off epics debug messages.
Definition: EpicsInput.h:63
bool fEzcaAutoError
Automatic error printing.
Definition: EpicsInput.h:66
std::string fUpdateFlagRecord
Definition: EpicsInput.h:72
const std::string & GetLongRecord(unsigned i) const
Definition: EpicsInput.h:106
std::string fUpdateCommandReceiver
Definition: EpicsInput.h:79
long fLastFlagValue
Remember previous flag value which should be change to start readout.
Definition: EpicsInput.h:48
virtual unsigned Read_Complete(dabc::Buffer &buf)
Complete reading of the buffer from source,.
Definition: EpicsInput.cxx:164
std::vector< long > fLongValues
Definition: EpicsInput.h:83
unsigned NumDoubleRecords() const
Definition: EpicsInput.h:108
void ResetDescriptors()
Definition: EpicsInput.h:91
std::vector< bool > fLongRes
Definition: EpicsInput.h:84
std::vector< std::string > fDoubleRecords
Definition: EpicsInput.h:87
long fEventNumber
Event number, read from EPICS record.
Definition: EpicsInput.h:51
int CA_GetLong(const std::string &name, long &val)
Definition: EpicsInput.cxx:248
virtual unsigned Read_Size()
Defines required buffer size for next operation.
Definition: EpicsInput.cxx:97
EpicsInput(const std::string &name="")
Definition: EpicsInput.cxx:36
unsigned fSubeventId
Definition: EpicsInput.h:45
std::vector< double > fDoubleValues
Definition: EpicsInput.h:88
const std::string & GetDoubleRecord(unsigned i) const
Definition: EpicsInput.h:110
std::string CA_ErrorString()
Return error string with error description.
Definition: EpicsInput.cxx:268
virtual ~EpicsInput()
Definition: EpicsInput.cxx:52
unsigned NumLongRecords() const
Definition: EpicsInput.h:104
EPICS E-Z (easy) channel access.
Definition: Definitions.h:26