otsdaq_components  v2_02_00
FrontEndFirmwareBase.h
1 #ifndef _ots_FrontEndFirmwareBase_h_
2 #define _ots_FrontEndFirmwareBase_h_
3 
4 #include <string>
5 #include <iostream>
6 #include <vector>
7 #include "otsdaq-core/MessageFacility/MessageFacility.h"
8 #include "otsdaq-core/Macros/CoutMacros.h"
9 
10 namespace ots
11 {
12 
13 
15 {
16 
17 public:
18  //factory method for choosing network protocol
19 
20  //FrontEndFirmwareBase (void){;}
21  FrontEndFirmwareBase (unsigned int version = -1):version_(version){;}
22  virtual ~FrontEndFirmwareBase (void){;}
23  virtual void init (void){;}
24 
25  const unsigned int getVersion () {return version_;}
26 
27  //These should never be called directly if used correctly, but
28  //not all classes will implement every function (so no pure virtuals). Should be obvious
29  //that the wrong thing is happening if these are called because exceptions are thrown!
30 
31  virtual std::string read (char* address) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return "";};
32  virtual void read (std::string& buffer, char* address, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
33  virtual void read (std::string& buffer, uint64_t address, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
34  virtual void read (std::string& buffer, uint32_t address, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
35 
36  virtual std::string write (char* address, char* data) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return "";};
37  virtual void write (std::string& buffer, char* address, char* data, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
38 
39  virtual void setDataDestination (std::string& buffer, const std::string& ip, const uint16_t port, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
40  virtual void write (std::string& buffer, uint64_t address, uint64_t data, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
41  virtual void write (std::string& buffer, uint32_t address, uint32_t data, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
42  virtual void waitSet (std::string& buffer, uint32_t address, uint32_t data, uint32_t timeout = 255, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
43  virtual void waitClear (std::string& buffer, uint32_t address, uint32_t data, uint32_t timeout = 255, bool clearBuffer=true) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
44  virtual unsigned int getNumberOfBufferedCommands (std::string& buffer) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return 0;};
45  // virtual std::string compareSendAndReceive (const std::string& sentBuffer, std::string& acknowledgment) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return "";};
46  virtual uint32_t createRegisterFromValue (std::string& readBuffer, std::string& receivedValue) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return 0;};
47  //virtual uint64_t createRegisterFromValue (std::string& readBuffer, std::string& receivedValue) {__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return 0;};
48 
49 
50  //purdue firmware
51 // virtual std::string setDataDestination (std::string ip, unsigned int port);
52 // virtual unsigned int waitSet (std::string& buffer, unsigned int address, unsigned int data, unsigned int timeout = 255);
53 // virtual unsigned int waitClear (std::string& buffer, unsigned int address, unsigned int data, unsigned int timeout = 255);
54 // virtual unsigned int getNumberOfBufferedCommands (std::string& buffer);
55 // virtual std::string compareSendAndReceive (const std::string& sentBuffer, std::string& acknowledgment);
56 // virtual uint32_t createRegisterFromValue (std::string& readBuffer, std::string& receivedValue);
57 
58  //FSSROtsFirmware
59 // virtual void makeDACSequence (FirmwareSequence<uint64_t>& sequence, unsigned int channel, const ROCStream& rocStream);
60 // virtual void makeMaskSequence (FirmwareSequence<uint64_t>& sequence, unsigned int channel, const ROCStream& rocStream);
61 // virtual void makeDACSequence (FirmwareSequence<uint32_t>& sequence, unsigned int channel, const ROCStream& rocStream);
62 // virtual void makeDACBuffer (std::string& buffer, unsigned int channel, const ROCStream& rocStream);
63 // virtual void makeDACBuffer (std::vector<std::string>& buffer, unsigned int channel, const ROCStream& rocStream);
64 // virtual void makeMaskSequence (FirmwareSequence<uint32_t>& sequence, unsigned int channel, const ROCStream& rocStream);
65 // virtual void makeMaskBuffer (std::string& buffer, unsigned int channel, const ROCStream& rocStream);
66 
67  //for generic interface
68  /*these functions have to be in FirmwareBase because the FEWOtsGenericInterface wants to access them
69  *through a pointer to FirmwareBase. Might want to change how that works.
70  */
71 // virtual std::string readCSRRegister(void)
72 // {
73 // __SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");
74 // std::cout << __COUT_HDR_FL__ << "Something bad happened!" << std::endl;
75 // return "";
76 // };
77 // virtual void makeDACBuffer(std::vector<std::string>& buffer, unsigned int channel, const ROCStream& rocStream){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
78 // virtual void makeMaskBuffer(std::string& buffer, unsigned int channel, const ROCStream& rocStream){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return;};
79 
80  //static FrontEndFirmwareBase* getInstance(std::string choice, unsigned int version);
81 
82  const unsigned int version_;
83 };
84 
85 
86 
87 }
88 
89 #endif