My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
AntennaControlMsg.h
1 #ifndef GCP_ASSEMBLER_ANTENNACONTROLMSG_H
2 #define GCP_ASSEMBLER_ANTENNACONTROLMSG_H
3 
11 #include "gcp/util/common/AntNum.h"
12 #include "gcp/util/common/Debug.h"
13 
14 #include "gcp/util/common/GenericTaskMsg.h"
15 #include "gcp/antenna/control/specific/AntennaMasterMsg.h"
16 
17 // Do not move these around. GCC3.2.2 is easily confused
18 
19 #include "gcp/control/code/unix/libunix_src/specific/rtcnetcoms.h"
20 #include "gcp/control/code/unix/libunix_src/common/tcpip.h"
21 
22 namespace gcp {
23 namespace mediator {
24 
27 
28  public:
29 
33  enum MsgType {
34 
35  // Flag an antenna as reachable/unreachable
36 
37  FLAG_ANTENNA,
38 
39  // We are starting/finishing recording initialization sequence
40 
41  INIT,
42 
43  // The start of an initialization script
44 
45  BEGIN_INIT,
46 
47  // The end of an initialization script
48 
49  END_INIT,
50 
51  // A net command to be sent directly to the antenna socket.
52 
53  NETCMD,
54 
55  // A message intended for the master task
56 
57  ANTENNA_MASTER_MSG,
58 
59  // Weather data
60 
61  WEATHER
62  };
63 
68 
72  union {
73 
77  struct {
78  unsigned antenna; // The mask of antennas which changed
79  // state
80  bool flag; // True to flag, false to unflag.
81 
82  } flagAntenna;
83 
88  struct {
89  bool start;
90  } init;
91 
95  struct {
96  gcp::control::NetCmdId opcode;
98  } netCmd;
99 
104 
105  } body;
106 
111 
115  bool init_;
116 
117  //------------------------------------------------------------
118  // Methods for returning pointers to messages for threads
119  // managed by this task.
120  //------------------------------------------------------------
121 
122  // Don't muck with the value of init_ here -- if it is set, we
123  // don't it to be reset just by a call to this method to
124  // retrieve it.
125 
126  inline gcp::antenna::control::AntennaMasterMsg* getMasterMsg()
127  {
128  genericMsgType_ =
129  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
130 
131  type = ANTENNA_MASTER_MSG;
132 
133  return &body.antennaMasterMsg;
134  }
135 
136  //------------------------------------------------------------
137  // Methods for packing messages to the AntennaControl
138  // task
139  //------------------------------------------------------------
140 
145  inline void packBeginInitMsg() {
146  initialize();
147 
148  type = BEGIN_INIT;
149  }
150 
155  inline void packEndInitMsg() {
156  initialize();
157 
158  type = END_INIT;
159  }
160 
164  inline void packInitMsg(bool start) {
165  initialize();
166 
167  type = INIT;
168 
169  body.init.start = start;
170  }
171 
176  inline void packFlagAntennaMsg(unsigned antenna, bool flag) {
177  initialize();
178 
179  DBPRINT(true, gcp::util::Debug::DEBUG6, "");
180 
181  type = FLAG_ANTENNA;
182 
183  body.flagAntenna.antenna = antenna;
184  body.flagAntenna.flag = flag;
185  }
186 
191  gcp::control::NetCmdId opcode) {
192  initialize();
193 
194  antennas = (gcp::util::AntNum::Id)cmd->antennas;
195 
196  type = NETCMD;
197 
198  body.netCmd.cmd = *cmd;
199  body.netCmd.opcode = opcode;
200  }
201 
202  private:
203 
204  // Private initialization method
205 
206  inline void initialize() {
207  genericMsgType_ =
208  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
209  init_ = false;
210  }
211 
212  }; // End class AntennaControlMsg
213 
214 } // End namespace mediator
215 } // End namespace gcp
216 
217 #endif // End #ifndef
Definition: GenericTaskMsg.h:31
void packBeginInitMsg()
Definition: AntennaControlMsg.h:145
void packFlagAntennaMsg(unsigned antenna, bool flag)
Definition: AntennaControlMsg.h:176
gcp::util::AntNum::Id antennas
Definition: AntennaControlMsg.h:110
struct gcp::mediator::AntennaControlMsg::@183::@185 init
union gcp::mediator::AntennaControlMsg::@183 body
Definition: AntennaMasterMsg.h:31
struct gcp::mediator::AntennaControlMsg::@183::@186 netCmd
void packEndInitMsg()
Definition: AntennaControlMsg.h:155
struct gcp::mediator::AntennaControlMsg::@183::@184 flagAntenna
gcp::antenna::control::AntennaMasterMsg antennaMasterMsg
Definition: AntennaControlMsg.h:103
GenericMsgType genericMsgType_
Definition: GenericTaskMsg.h:50
Definition: rtcnetcoms.h:2462
Definition: AntennaControlMsg.h:25
void packInitMsg(bool start)
Definition: AntennaControlMsg.h:164
MsgType
Definition: AntennaControlMsg.h:33
MsgType type
Definition: AntennaControlMsg.h:67
Id
Definition: AntNum.h:37
void packRtcNetCmdMsg(gcp::control::RtcNetCmd *cmd, gcp::control::NetCmdId opcode)
Definition: AntennaControlMsg.h:190
bool init_
Definition: AntennaControlMsg.h:115