My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
AntennaRoachMsg.h
Go to the documentation of this file.
1 #ifndef GCP_ANTENNA_CONTROL_ANTENNAROACHMSG_H
2 #define GCP_ANTENNA_CONTROL_ANTENNAROACHMSG_H
3 
11 #include "gcp/util/common/GenericTaskMsg.h"
12 
13 #include "gcp/control/code/unix/libunix_src/common/netobj.h"
14 #include "gcp/util/common/Debug.h"
15 #include "gcp/util/specific/Directives.h"
16 
17 namespace gcp {
18  namespace antenna {
19  namespace control {
20 
26 
27  public:
28 
32  enum MsgType {
33  INVALID ,
34  CONNECT ,
35  DISCONNECT ,
36  READ_DATA ,
37  WRITE_DATA ,
38  ROACH_CMD
39  };
40 
41  // these are bogus. we never refer to these.
42  enum roachCmdId {
43  ROACH_COMMAND
44  };
45 
50 
54  double currTime_; // in mjd
55 
59  union {
60  struct {
61  unsigned cmdId;
62  char* stringCommand;
63  float fltVal;
64  int roachNum;
65  } roach;
66  } body;
67 
68  //------------------------------------------------------------
69  // Methods for packing messages
70  //------------------------------------------------------------
71 
72  //------------------------------------------------------------
73  // Pack a command to read data from the receiver
74  //------------------------------------------------------------
75  inline void packReadDataMsg()
76  {
78  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
79 
80  type = READ_DATA;
81  // number of roach = roachNum;
82  }
83 
84  //------------------------------------------------------------
85  // Pack a command to write data from the receiver to disk
86  //------------------------------------------------------------
87  inline void packWriteDataMsg(gcp::util::TimeVal& currTime)
88  {
90  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
91 
92  type = WRITE_DATA;
93 
94  currTime_ = currTime.getTimeInSeconds();
95 
96  }
97 
98  //------------------------------------------------------------
99  // Pack a command to connected to receiver backend
100  //------------------------------------------------------------
101  inline void packConnectMsg()
102  {
103  genericMsgType_ =
104  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
105 
106  type = CONNECT;
107  }
108 
109  //------------------------------------------------------------
110  // Pack a command to disconnect the receiver
111  //------------------------------------------------------------
112  inline void packDisconnectMsg()
113  {
114  genericMsgType_ =
115  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
116 
117  type = DISCONNECT;
118  }
119 
120  //------------------------------------------------------------
121  // Pack a general command
122  //------------------------------------------------------------
123  inline void packRoachCmdMsg(float fltVal, int roachNumber, char* stringCommand)
124  {
125  genericMsgType_ =
126  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
127 
128  type = ROACH_CMD;
129 
130  body.roach.fltVal = fltVal;
131  body.roach.roachNum = roachNumber;
132  body.roach.stringCommand = stringCommand;
133  // we'll convert the message into what issueCommand wants
134  // in execute command
135 
136  };
137 
138  }; // End class AntennaRoachMsg
139 
140  }; // End namespace control
141  }; // End namespace antenna
142 } // End namespace gcp
143 
144 #endif // End #ifndef
Definition: GenericTaskMsg.h:31
double currTime_
Definition: AntennaRoachMsg.h:54
Definition: AntennaRoachMsg.h:24
MsgType
Definition: AntennaRoachMsg.h:32
GenericMsgType genericMsgType_
Definition: GenericTaskMsg.h:50
Definition: TimeVal.h:55
union gcp::antenna::control::AntennaRoachMsg::@18 body
double getTimeInSeconds() const
Definition: TimeVal.cc:589
MsgType type
Definition: AntennaRoachMsg.h:49