otsdaq_components  v2_02_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 
10 class OtsUDPHardware : public TransceiverSocket, public FrontEndHardwareBase
11 {
12 
13 public:
14  OtsUDPHardware (std::string hostIPAddress, unsigned int hostPort, std::string boardIPAddress, unsigned int boardPort, unsigned int version = -1, bool verbose = false);
15  virtual ~OtsUDPHardware(void);
16 
17  virtual void write (const std::string& sendBuffer) throw(std::runtime_error);
18  virtual void write (const std::vector<std::string>& sendBuffers) throw(std::runtime_error);
19  virtual void writeAndAcknowledge(const std::string& sendBuffer, int timeoutSeconds = -1) throw(std::runtime_error);
20  virtual void writeAndAcknowledge(const std::vector<std::string>& sendBuffers, int timeoutSeconds = -1) throw(std::runtime_error);
21  virtual void read (const std::string& sendBuffer , std::string& receiveBuffer, int timeoutSeconds = -1) throw(std::runtime_error);
22  virtual void read (const std::vector<std::string>& sendBuffers, std::vector<std::string>& receiveBuffers, int timeoutSeconds = -1) throw(std::runtime_error);
23 
24  virtual int flushRead () throw(std::runtime_error) {return clearReadSocket();}
25 
26  void read (const std::string& sendBuffer, uint64_t& receiveQuadWord, int timeoutSeconds = -1) throw(std::runtime_error);
27  void read (const std::string& sendBuffer, std::vector<uint64_t>& receiveQuadWords, int timeoutSeconds = -1) throw(std::runtime_error);
28  void read (const std::vector<std::string>& sendBuffers, std::vector<std::vector<uint64_t> >& receiveQuadWordsVector, int timeoutSeconds = -1) throw(std::runtime_error);
29  int clearReadSocket ();
30  //
31 // virtual int write(uint64_t address, const std::string& value){return 0;}
32 // virtual int read (uint64_t address, std::string& value){return 0;}
33 
34 protected:
35  OtsUDPHardware (std::string boardIPAddress, unsigned int boardPort, unsigned int version = -1, bool verbose = false);
36  Socket OtsUDPBoard_;
37  std::string acknowledgment_;
38  bool verbose_;
39 
40 };
41 
42 
43 }
44 
45 #endif