My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Control.h
1 #ifndef CONTROL_H
2 #define CONTROL_H
3 
11 #include <list>
12 #include <vector>
13 
14 // Shared control code includes
15 
16 #include "gcp/control/code/unix/libunix_src/specific/rtcnetcoms.h"
17 
18 // SZA antenna code includes
19 
20 #include "gcp/util/common/FdSet.h"
21 #include "gcp/util/common/GenericTask.h"
22 #include "gcp/util/common/Logger.h"
23 #include "gcp/util/common/LogMsgHandler.h"
24 #include "gcp/util/common/NetCommHandler.h"
25 #include "gcp/util/common/TcpClient.h"
26 
27 #include "gcp/grabber/common/ControlMsg.h"
28 #include "gcp/grabber/common/GrabberNetCmdForwarder.h"
29 
30 #define CONTROL_TASK_FWD_FN(fn) void (fn)(ControlMsg* msg)
31 
32 namespace gcp {
33  namespace grabber {
34 
39  class Master;
40 
45  class Control :
46  public gcp::util::GenericTask<ControlMsg> {
47 
48  public:
49 
53  ~Control();
54 
55  //------------------------------------------------------------
56  // Task message forwarding methods
57  //------------------------------------------------------------
58 
62  CONTROL_TASK_FWD_FN(forwardControlMsg);
63 
64  private:
65 
69  GrabberNetCmdForwarder* forwarder_;
70 
74  friend class Master;
75 
79  static Control* control_;
80 
85  gcp::util::NetCommHandler netCommHandler_;
86 
90  Master* parent_;
91 
95  gcp::util::TcpClient client_;
96 
100  std::string host_;
101 
105  bool connected_;
106 
110  gcp::util::LogMsgHandler logMsgHandler_;
111 
116  Control(Master* master);
117 
121  bool isConnected();
122 
126  bool connect();
127 
131  void disconnect();
132 
136  void connectControl(bool reEnable);
137 
141  void disconnectControl();
142 
146  void serviceMsgQ();
147 
151  void sendControlConnectedMsg(bool connected);
152 
156  static LOG_HANDLER_FN(sendLogMsg);
157 
162  static LOG_HANDLER_FN(sendErrMsg);
163 
164  static void sendNetMsg(std::string& logStr, bool isErr);
165 
171  void processMsg(ControlMsg* taskMsg);
172 
176  void packNetMsg(ControlMsg* msg);
177 
181  static NET_READ_HANDLER(netCmdReadHandler);
182 
186  static NET_SEND_HANDLER(netMsgSentHandler);
187 
192  static NET_ERROR_HANDLER(netErrorHandler);
193 
194  }; // End class Control
195 
196  }; // End namespace grabber
197 }; // End namespace gcp
198 
199 
200 #endif // End #ifndef
Definition: ControlMsg.h:17
Definition: GrabberNetCmdForwarder.h:19
CONTROL_TASK_FWD_FN(forwardControlMsg)
Definition: TcpClient.h:18
Definition: Master.h:46
~Control()
Definition: Control.cc:53
Definition: LogMsgHandler.h:25
Definition: NetCommHandler.h:18
Definition: Control.h:45
Definition: GenericTask.h:33