My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
ReceiverConfigConsumer.h
Go to the documentation of this file.
1 #ifndef GCP_RECEIVER_RECEIVERCONFIGCONSUMER_H
2 #define GCP_RECEIVER_RECEIVERCONFIGCONSUMER_H
3 
14 #include <iostream>
15 
16 #include "gcp/receiver/specific/XMLConsumer.h"
17 
18 #include "Utilities/HardwareManagerClient.h"
19 
20 namespace gcp {
21 
22  namespace mediator {
23  class Scanner;
24  }
25 
26  namespace receiver {
27 
28  class FpgaBoardManager;
29  class SquidBoardManager;
30 
32  public:
33 
34  // Enumerate the types of commands we will send to the HWM
35 
36  enum Command {
37  TYPE_NONE, // No command
38  TYPE_GETBOARDS, // GetBoards command
39  TYPE_GETSQUIDS, // GetSquids command
40  TYPE_GETSEQID, // GetSeqId command
41  TYPE_GETREGS // GetAllRegisters command
42  };
43 
44  // Enumerate the types of squid controller IDs that boards can have
45 
46  enum SquidId {
47  SQUID_NONE = 0x0,
48  SQUID_A = 0x1,
49  SQUID_B = 0x2,
50  };
51 
52  struct Board {
53  int id_;
54  SquidId squid_;
55 
56  Board() {
57  id_ = -1;
58  squid_ = SQUID_NONE;
59  }
60 
61  Board(unsigned id, SquidId squid) {
62  id_ = id;
63  squid_ = squid;
64  }
65 
66  friend ostream& operator<<(ostream& os, const Board& brd);
67  };
68 
73  std::string host="localhost",
74  unsigned short port=5207,
75  bool send_connect_request=true);
76 
77  // Destructor.
78 
79  virtual ~ReceiverConfigConsumer();
80 
81  // Get the next set of data from the server
82 
83  bool getData();
84 
85  // Request the list of boards
86 
87  bool requestBoards();
88 
89  // Request the list of boards
90 
91  bool ReceiverConfigConsumer::requestSquids();
92 
93  // Request the hardware configuration status (has anything
94  // changed?)
95 
96  bool ReceiverConfigConsumer::requestHardwareStatus();
97 
98  // Request configuration data fgrom the HardwareManager
99 
100  bool ReceiverConfigConsumer::requestHardwareConfiguration();
101 
102  // Generic method to send a command to the HWM
103 
104  bool sendCommand(MuxReadout::HardwareManagerClient::Cmd* cmd,
105  Command type);
106 
107  // Read configuration data from the HardwareManager
108 
109  bool ReceiverConfigConsumer::readResponse();
110 
111  // Return the last command we sent
112 
113  MuxReadout::HardwareManagerClient::Cmd* getLastSentCommand();
114 
115  bool readBoardInfo(MuxReadout::HardwareManagerClient::Cmd* cmd);
116 
117  bool readSquidInfo(MuxReadout::HardwareManagerClient::Cmd* cmd);
118 
119  bool readHardwareStatus(MuxReadout::HardwareManagerClient::Cmd* cmd);
120 
121  bool readHardwareConfiguration(MuxReadout::HardwareManagerClient::Cmd* cmd);
122  // Report a connection error
123 
124  void reportError();
125 
126  // Report connection success
127 
128  void reportSuccess();
129 
130  // Main loop -- service our message queue
131 
132  void serviceMsgQ();
133 
134  private:
135 
136  MuxReadout::HardwareManagerClient::Cmd* getBoardsCmd_;
137  MuxReadout::HardwareManagerClient::Cmd* getSquidsCmd_;
138  MuxReadout::HardwareManagerClient::Cmd* getSeqIdCmd_;
139  MuxReadout::HardwareManagerClient::Cmd* getRegsCmd_;
140 
141  int seqId_;
142 
143  std::vector<Board> boards_;
144  bool haveBoardInfo_;
145  bool getDataPending_;
146 
147  Command type_;
148 
149  FpgaBoardManager* fpgaBm_;
150  SquidBoardManager* squidBm_;
151 
152  }; // End class ReceiverConfigConsumer
153 
154  } // End namespace receiver
155 } // End namespace gcp
156 
157 
158 
159 #endif // End #ifndef GCP_RECEIVER_RECEIVERCONFIGCONSUMER_H
void reportSuccess()
Definition: ReceiverConfigConsumer.cc:430
Definition: SquidBoardManager.h:29
bool sendCommand(MuxReadout::HardwareManagerClient::Cmd *cmd, Command type)
Definition: ReceiverConfigConsumer.cc:175
Definition: script.h:529
bool getData()
Definition: ReceiverConfigConsumer.cc:115
Definition: Scanner.h:58
bool requestBoards()
Definition: ReceiverConfigConsumer.cc:142
void reportError()
Definition: ReceiverConfigConsumer.cc:420
void serviceMsgQ()
Definition: ReceiverConfigConsumer.cc:460
virtual ~ReceiverConfigConsumer()
Definition: ReceiverConfigConsumer.cc:79
ReceiverConfigConsumer(gcp::mediator::Scanner *scanner, std::string host="localhost", unsigned short port=5207, bool send_connect_request=true)
Definition: ReceiverConfigConsumer.cc:22
Definition: XMLConsumer.h:29
Definition: FpgaBoardManager.h:29
MuxReadout::HardwareManagerClient::Cmd * getLastSentCommand()
Definition: ReceiverConfigConsumer.cc:255
Definition: ReceiverConfigConsumer.h:31
Definition: ReceiverConfigConsumer.h:52