otsdaq_components  v2_05_02_indev
FrontEndFirmwareBase.h
1 #ifndef _ots_FrontEndFirmwareBase_h_
2 #define _ots_FrontEndFirmwareBase_h_
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include "otsdaq/Macros/CoutMacros.h"
8 #include "otsdaq/MessageFacility/MessageFacility.h"
9 
10 namespace ots
11 {
13 {
14  public:
15  // factory method for choosing network protocol
16 
17  // FrontEndFirmwareBase (void){;}
18  FrontEndFirmwareBase(unsigned int version = -1) : version_(version) { ; }
19  virtual ~FrontEndFirmwareBase(void) { ; }
20  virtual void init(void) { ; }
21 
22  unsigned int getVersion() { return version_; }
23 
24  // These should never be called directly if used correctly, but
25  // not all classes will implement every function (so no pure virtuals). Should be
26  // obvious that the wrong thing is happening if these are called because exceptions
27  // are thrown!
28 
29  virtual std::string read(char* /*address*/)
30  {
31  __SS__;
32  __THROW__(ss.str() + "Illegal call to undefined base class member function");
33  return "";
34  };
35  virtual void read(std::string& /*buffer*/, char* /*address*/, bool /*clearBuffer*/ = true)
36  {
37  __SS__;
38  __THROW__(ss.str() + "Illegal call to undefined base class member function");
39  return;
40  };
41  virtual void read(std::string& /*buffer*/, uint64_t /*address*/, bool /*clearBuffer*/ = true)
42  {
43  __SS__;
44  __THROW__(ss.str() + "Illegal call to undefined base class member function");
45  return;
46  };
47  virtual void read(std::string& /*buffer*/, uint32_t /*address*/, bool /*clearBuffer*/ = true)
48  {
49  __SS__;
50  __THROW__(ss.str() + "Illegal call to undefined base class member function");
51  return;
52  };
53 
54  virtual std::string write(char* /*address*/, char* /*data*/)
55  {
56  __SS__;
57  __THROW__(ss.str() + "Illegal call to undefined base class member function");
58  return "";
59  };
60  virtual void write(std::string& /*buffer*/,
61  char* /*address*/,
62  char* /*data*/,
63  bool /*clearBuffer*/ = true)
64  {
65  __SS__;
66  __THROW__(ss.str() + "Illegal call to undefined base class member function");
67  return;
68  };
69 
70  virtual void setDataDestination(std::string& /*buffer*/,
71  const std::string& /*ip*/,
72  const uint16_t /*port*/,
73  bool /*clearBuffer*/ = true)
74  {
75  __SS__;
76  __THROW__(ss.str() + "Illegal call to undefined base class member function");
77  return;
78  };
79  virtual void write(std::string& /*buffer*/,
80  uint64_t /*address*/,
81  uint64_t /*data*/,
82  bool /*clearBuffer*/ = true)
83  {
84  __SS__;
85  __THROW__(ss.str() + "Illegal call to undefined base class member function");
86  return;
87  };
88  virtual void write(std::string& /*buffer*/,
89  uint32_t /*address*/,
90  uint32_t /*data*/,
91  bool /*clearBuffer*/ = true)
92  {
93  __SS__;
94  __THROW__(ss.str() + "Illegal call to undefined base class member function");
95  return;
96  };
97  virtual void waitSet(std::string& /*buffer*/,
98  uint32_t /*address*/,
99  uint32_t /*data*/,
100  uint32_t /*timeout*/ = 255,
101  bool /*clearBuffer*/ = true)
102  {
103  __SS__;
104  __THROW__(ss.str() + "Illegal call to undefined base class member function");
105  return;
106  };
107  virtual void waitClear(std::string& /*buffer*/,
108  uint32_t /*address*/,
109  uint32_t /*data*/,
110  uint32_t /*timeout*/ = 255,
111  bool /*clearBuffer*/ = true)
112  {
113  __SS__;
114  __THROW__(ss.str() + "Illegal call to undefined base class member function");
115  return;
116  };
117  virtual unsigned int getNumberOfBufferedCommands(std::string& /*buffer*/)
118  {
119  __SS__;
120  __THROW__(ss.str() + "Illegal call to undefined base class member function");
121  return 0;
122  };
123  // virtual std::string compareSendAndReceive (const std::string& sentBuffer,
124  // std::string& acknowledgment) {__SS__; __THROW__(ss.str() +
125  // "Illegal call to undefined base class member function"); return "";};
126  virtual uint32_t createRegisterFromValue(std::string& /*readBuffer*/,
127  std::string& /*receivedValue*/)
128  {
129  __SS__;
130  __THROW__(ss.str() + "Illegal call to undefined base class member function");
131  return 0;
132  };
133  // virtual uint64_t createRegisterFromValue (std::string& readBuffer,
134  // std::string& receivedValue) {__SS__; __THROW__(ss.str() + "Illegal call to
135  // undefined base class member function"); return 0;};
136 
137  // purdue firmware
138  // virtual std::string setDataDestination (std::string ip, unsigned int
139  // port); virtual unsigned int waitSet (std::string& buffer,
140  // unsigned int address, unsigned int data, unsigned int timeout = 255); virtual
141  // unsigned int waitClear (std::string& buffer, unsigned int
142  // address, unsigned int data, unsigned int timeout = 255); virtual unsigned int
143  // getNumberOfBufferedCommands (std::string& buffer); virtual std::string
144  // compareSendAndReceive (const std::string& sentBuffer, std::string&
145  // acknowledgment); virtual uint32_t createRegisterFromValue (std::string&
146  // readBuffer, std::string& receivedValue);
147 
148  // FSSROtsFirmware
149  // virtual void makeDACSequence (FirmwareSequence<uint64_t>& sequence,
150  // unsigned int channel, const ROCStream& rocStream); virtual void makeMaskSequence
151  // (FirmwareSequence<uint64_t>& sequence, unsigned int channel, const ROCStream&
152  // rocStream);
153  // virtual void makeDACSequence (FirmwareSequence<uint32_t>& sequence,
154  // unsigned int channel, const ROCStream& rocStream); virtual void makeDACBuffer
155  // (std::string& buffer, unsigned int channel, const ROCStream& rocStream); virtual
156  // void makeDACBuffer (std::vector<std::string>& buffer, unsigned
157  // int channel, const ROCStream& rocStream); virtual void makeMaskSequence
158  // (FirmwareSequence<uint32_t>& sequence, unsigned int channel, const ROCStream&
159  // rocStream);
160  // virtual void makeMaskBuffer (std::string& buffer, unsigned int
161  // channel, const ROCStream& rocStream);
162 
163  // for generic interface
164  /*these functions have to be in FirmwareBase because the FEWOtsGenericInterface wants
165  *to access them through a pointer to FirmwareBase. Might want to change how that
166  *works.
167  */
168  // virtual std::string readCSRRegister(void)
169  // {
170  // __SS__; __THROW__(ss.str() + "Illegal call to undefined base class member
171  // function"); std::cout << __COUT_HDR_FL__ << "Something bad happened!" <<
172  // std::endl; return "";
173  // };
174  // virtual void makeDACBuffer(std::vector<std::string>& buffer, unsigned int
175  // channel, const ROCStream& rocStream){__SS__; __THROW__(ss.str() + "Illegal call
176  // to undefined base class member function"); return;}; virtual void
177  // makeMaskBuffer(std::string& buffer, unsigned int channel, const ROCStream&
178  // rocStream){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class
179  // member function"); return;};
180 
181  // static FrontEndFirmwareBase* getInstance(std::string choice, unsigned int version);
182 
183  const unsigned int version_;
184 };
185 }
186 
187 #endif