My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
ControlMsg.h
1 #ifndef CONTROLMSG_H
2 #define CONTROLMSG_H
3 
11 #include "gcp/util/common/GenericTaskMsg.h"
12 #include "gcp/util/common/NetMsg.h"
13 
14 #include "gcp/mediator/specific/AntennaControlMsg.h"
15 #include "gcp/mediator/specific/GrabberControlMsg.h"
16 #include "gcp/mediator/specific/ReceiverControlMsg.h"
17 #include "gcp/mediator/specific/WxControlMsg.h"
18 
19 namespace gcp {
20 namespace mediator {
21 
22  class ControlMsg :
24 
25  public:
26 
30  enum MsgType {
31 
32  // Messages for this task
33 
34  CONNECT, // A message to connect to the control port.
35  INIT, // A greeting message from the control port.
36  NETMSG, // A network message intended for the controller.
37 
38  // Messages for tasks spawned by this one.
39 
40  ANTENNA_CONTROL_MSG, // A message for our Antenna Control task
41 
42  GRABBER_CONTROL_MSG, // A message for the task controlling the
43  // delay engine and lobe rotator
44 
45  WX_CONTROL_MSG, // A message for the task controlling the
46  // weather station
47 
48  RECEIVER_CONTROL_MSG,// A message the the task running scripts
49  // to control the receiver
50 
51  };
52 
57 
61  union {
62 
63  struct {
64  bool start;
65  } init;
66 
67  gcp::util::NetMsg networkMsg;
68 
73 
78 
83 
88 
89  } body;
90 
91  //------------------------------------------------------------
92  // Methods for returning pointers to messages intended for other
93  // tasks
94  //------------------------------------------------------------
95 
96  inline AntennaControlMsg* getAntennaControlMsg()
97  {
99  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
100 
101  type = ANTENNA_CONTROL_MSG;
102 
103  return &body.antennaControlMsg;
104  }
105 
106  inline GrabberControlMsg* getGrabberControlMsg()
107  {
108  genericMsgType_ =
109  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
110 
111  type = GRABBER_CONTROL_MSG;
112 
113  return &body.grabberControlMsg;
114  }
115 
116  inline ReceiverControlMsg* getReceiverControlMsg()
117  {
118  genericMsgType_ =
119  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
120 
121  type = RECEIVER_CONTROL_MSG;
122 
123  return &body.receiverControlMsg;
124  }
125 
126  inline WxControlMsg* getWxControlMsg()
127  {
128  genericMsgType_ =
129  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
130 
131  type = WX_CONTROL_MSG;
132 
133  return &body.wxControlMsg;
134  }
135 
136  //------------------------------------------------------------
137  // Methods for packing messages intended for the
138  // Control task
139  //------------------------------------------------------------
140 
144  inline void packConnectMsg() {
145 
146  genericMsgType_ =
147  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
148 
149  type = CONNECT;
150  }
151 
155  inline void packInitMsg(bool start) {
156 
157  genericMsgType_ =
158  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
159 
160  type = INIT;
161 
162  body.init.start = start;
163  }
164 
169  {
170  genericMsgType_ =
171  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
172 
173  type = NETMSG;
174 
175  return &body.networkMsg;
176  }
177 
178  }; // End class ControlMsg
179 
180 } // End namespace mediator
181 } // End namespace gcp
182 
183 #endif // End #ifndef
Definition: GenericTaskMsg.h:31
ReceiverControlMsg receiverControlMsg
Definition: ControlMsg.h:82
GrabberControlMsg grabberControlMsg
Definition: ControlMsg.h:77
gcp::util::NetMsg * getNetMsg()
Definition: ControlMsg.h:168
Definition: GrabberControlMsg.h:21
MsgType type
Definition: ControlMsg.h:56
WxControlMsg wxControlMsg
Definition: ControlMsg.h:87
union gcp::mediator::ControlMsg::@187 body
GenericMsgType genericMsgType_
Definition: GenericTaskMsg.h:50
Definition: WxControlMsg.h:16
Definition: NetMsg.h:26
Definition: AntennaControlMsg.h:25
MsgType
Definition: ControlMsg.h:30
AntennaControlMsg antennaControlMsg
Definition: ControlMsg.h:72
void packConnectMsg()
Definition: ControlMsg.h:144
Definition: ControlMsg.h:22
Definition: ReceiverControlMsg.h:21
void packInitMsg(bool start)
Definition: ControlMsg.h:155