otsdaq_components  v2_02_00
ROCStream.h
1 #ifndef _ots_ROCStream_h_
2 #define _ots_ROCStream_h_
3 
4 #include "otsdaq-components/DetectorConfiguration/ROCDACs.h"
5 #include "otsdaq-core/Macros/CoutMacros.h"
6 
7 #include <string>
8 #include <iostream>
9 
10 namespace ots
11 {
12 
13 class ROCStream
14 {
15 public:
16  ROCStream(void) :
17  theDetectorID_ (""),
18  theROCType_ (""),
19  theROCStatus_ (""),
20  theFEWROCAddress_(0),
21  theROCMask_ (""),
22  theROCTrimBits_ ("")
23 {;}
24  virtual ~ROCStream(void){;}
25 
26  //Setters
27  void setDetectorID (const std::string& rocName ){theDetectorID_ = rocName;}
28  void setROCType (const std::string& rocType ){theROCType_ = rocType;}
29  void setROCStatus (bool rocStatus ){theROCStatus_ = rocStatus;}
30  void setFEWROCAddress(unsigned int fecROCAddress ){theFEWROCAddress_ = fecROCAddress;}
31  void setROCDACs (const ROCDACs& rocDACs ){theROCDACs_ = rocDACs;}
32  void addDAC (std::string name, unsigned int address, unsigned int value){theROCDACs_.setDAC(name,address,value);}
33  void setROCMask (const std::string& rocMask );
34  void setROCTrimBits (const std::string& rocTrimBits){theROCTrimBits_ = rocTrimBits;}
35 
36  //Getters
37  const std::string& getDetectorID (void) const {return theDetectorID_;}
38  const std::string& getROCType (void) const {return theROCType_;}
39  bool getROCStatus (void) const {return theROCStatus_;}
40  unsigned int getFEWROCAddress(void) const {return theFEWROCAddress_;}
41  const ROCDACs& getROCDACs (void) const {return theROCDACs_;}
42  const std::string& getROCMask (void) const {return theROCMask_;}
43  const std::string& getROCTrimBits (void) const {return theROCTrimBits_;}
44 
45 
46 
47 private:
48  std::string theDetectorID_;
49  std::string theROCType_;
50  bool theROCStatus_;
51  unsigned int theFEWROCAddress_;
52  ROCDACs theROCDACs_;
53  std::string theROCMask_;
54  std::string theROCTrimBits_;
55 };
56 
57 }
58 
60 inline void ots::ROCStream::setROCMask(const std::string& rocMask)
61 {
62 // theROCMask_ = rocMask;
63  theROCMask_.clear();
64  int row = -1;
65  int col = -1;
66  bool openRow = false;
67  bool openCol = false;
68  for(unsigned int i=0; i<rocMask.length(); i++)
69  if(rocMask[i] == '[')
70  if(!openRow)
71  {
72  openRow = true;
73  ++row;
74  }
75  else if(!openCol)
76  {
77  openCol = true;
78  ++col;
79  }
80  else
81  {
82  __SS__ << "Too many [ in bit mask configuration" << std::endl;
83  __COUT_ERR__ << "\n" << ss.str();
84  __SS_THROW__;
85  }
86  else if(rocMask[i] == ']')
87  if(openCol)
88  {
89  openCol = false;
90  --col;
91  }
92  else if(openRow)
93  {
94  openRow = false;
95  --row;
96  }
97  else
98  {
99  __SS__ << "Too many ] in bit mask configuration" << std::endl;
100  __COUT_ERR__ << "\n" << ss.str();
101  __SS_THROW__;
102  }
103  else if(rocMask[i] == '0' || rocMask[i] == '1')
104  theROCMask_ += rocMask[i];//No matrix style mask ... needs to be changed //TODO
105 // std::cout << theROCMask_ << std::endl;
106 }
107 
108 #endif //ots_ROCStream_h