otsdaq_components  v2_03_00
OtsUDPHardware.h
1 #ifndef _ots_OtsUDPHardware_h_
2 #define _ots_OtsUDPHardware_h_
3 
4 #include "otsdaq-components/DAQHardware/FrontEndHardwareBase.h"
5 #include "otsdaq-core/NetworkUtilities/TransceiverSocket.h"
6 
7 namespace ots
8 {
9 class OtsUDPHardware : public TransceiverSocket, public FrontEndHardwareBase
10 {
11  public:
12  OtsUDPHardware(std::string hostIPAddress,
13  unsigned int hostPort,
14  std::string boardIPAddress,
15  unsigned int boardPort,
16  unsigned int version = -1,
17  bool verbose = false);
18  virtual ~OtsUDPHardware(void);
19 
20  virtual void write(const std::string& sendBuffer) throw(std::runtime_error);
21  virtual void write(const std::vector<std::string>& sendBuffers) throw(
22  std::runtime_error);
23  virtual void writeAndAcknowledge(const std::string& sendBuffer,
24  int timeoutSeconds = -1) throw(std::runtime_error);
25  virtual void writeAndAcknowledge(const std::vector<std::string>& sendBuffers,
26  int timeoutSeconds = -1) throw(std::runtime_error);
27  virtual void read(const std::string& sendBuffer,
28  std::string& receiveBuffer,
29  int timeoutSeconds = -1) throw(std::runtime_error);
30  virtual void read(const std::vector<std::string>& sendBuffers,
31  std::vector<std::string>& receiveBuffers,
32  int timeoutSeconds = -1) throw(std::runtime_error);
33 
34  virtual int flushRead() throw(std::runtime_error) { return clearReadSocket(); }
35 
36  void read(const std::string& sendBuffer,
37  uint64_t& receiveQuadWord,
38  int timeoutSeconds = -1) throw(std::runtime_error);
39  void read(const std::string& sendBuffer,
40  std::vector<uint64_t>& receiveQuadWords,
41  int timeoutSeconds = -1) throw(std::runtime_error);
42  void read(const std::vector<std::string>& sendBuffers,
43  std::vector<std::vector<uint64_t> >& receiveQuadWordsVector,
44  int timeoutSeconds = -1) throw(std::runtime_error);
45  int clearReadSocket();
46  //
47  // virtual int write(uint64_t address, const std::string& value){return 0;}
48  // virtual int read (uint64_t address, std::string& value){return 0;}
49 
50  protected:
51  OtsUDPHardware(std::string boardIPAddress,
52  unsigned int boardPort,
53  unsigned int version = -1,
54  bool verbose = false);
55  Socket OtsUDPBoard_;
56  std::string acknowledgment_;
57  bool verbose_;
58 };
59 }
60 
61 #endif