1 #ifndef GCP_UTIL_NETMSG_H
2 #define GCP_UTIL_NETMSG_H
11 #include "gcp/util/common/AntNum.h"
12 #include "gcp/util/common/Debug.h"
13 #include "gcp/util/common/Exception.h"
14 #include "gcp/util/common/LogStream.h"
15 #include "gcp/util/common/NetSendStr.h"
16 #include "gcp/util/common/Mutex.h"
20 #include "gcp/control/code/unix/libunix_src/common/netobj.h"
21 #include "gcp/control/code/unix/libunix_src/specific/rtcnetcoms.h"
36 GREETING = gcp::control::NET_GREETING_MSG,
40 LOG = gcp::control::NET_LOG_MSG,
44 ID = gcp::control::NET_ID_MSG,
49 NAV_UPDATE = gcp::control::NET_NAV_UPDATE_MSG,
53 DRIVE_DONE = gcp::control::NET_DRIVE_DONE_MSG,
57 BENCH_DONE = gcp::control::NET_BENCH_DONE_MSG,
61 SCAN_DONE = gcp::control::NET_SCAN_DONE_MSG,
65 SOURCE_SET = gcp::control::NET_SOURCE_SET_MSG,
69 CALTERT_DONE = gcp::control::NET_CALTERT_DONE_MSG,
73 IFMOD_DONE = gcp::control::NET_IFMOD_DONE_MSG,
77 CAN_DONE = gcp::control::NET_CAN_DONE_MSG,
81 SCRIPT_DONE = gcp::control::NET_SCRIPT_DONE_MSG,
109 inline void packGreetingMsg(
unsigned int id,
117 body.msg.greeting.revision = revision;
118 body.msg.greeting.nReg = nReg;
119 body.msg.greeting.nByte = nByte;
126 inline unsigned maxMsgLen() {
127 return gcp::control::NET_LOG_MAX;
133 inline void packLogMsg(std::string message,
bool isError,
134 unsigned seq=0,
bool end=0) {
136 int length = message.length();
138 length = (length > gcp::control::NET_LOG_MAX) ?
139 gcp::control::NET_LOG_MAX : length;
143 strncpy(
body.msg.log.text, message.c_str(), length);
147 body.msg.log.text[length] =
'\0';
148 body.msg.log.bad = isError;
149 body.msg.log.seq = seq;
150 body.msg.log.end = end;
156 inline void packAntennaIdMsg(
unsigned int id) {
166 inline void packNavUpdateMsg() {
173 inline void packDriveDoneMsg(
unsigned seq) {
175 body.msg.drive_done.seq = seq;
181 inline void packBenchDoneMsg(
unsigned seq) {
183 body.msg.bench_done.seq = seq;
189 inline void packScanDoneMsg(
unsigned seq) {
191 body.msg.scan_done.seq = seq;
197 inline void packScriptDoneMsg(
unsigned seq) {
199 body.msg.scriptDone.seq = seq;
205 inline void packSourceSetMsg(
unsigned seq) {
207 body.msg.source_set.seq = seq;
213 inline void packCalTertDoneMsg(
unsigned seq) {
215 body.msg.calTertDone.seq = seq;
221 inline void packIFModDoneMsg(
unsigned seq) {
223 body.msg.IFModDone.seq = seq;
229 inline void packCanCommandDoneMsg(
unsigned seq) {
231 body.msg.canDone.seq = seq;
234 inline friend std::ostream& operator<<(std::ostream& os,
const NetMsg& rhs) {
238 "GreetingMsg" << std::endl <<
239 "antenna " << rhs.body.antenna << std::endl <<
240 "revision " << rhs.body.msg.greeting.revision << std::endl <<
241 "nReg " << rhs.body.msg.greeting.nReg << std::endl <<
242 "nByte " << rhs.body.msg.greeting.nByte << std::endl;
245 os <<
"Other NetMsg" << std::endl;
257 #endif // End #ifndef GCP_UTIL_NETMSG_H
MsgType type
Definition: NetMsg.h:87
MsgType
Definition: NetMsg.h:32
Definition: rtcnetcoms.h:216
Id
Definition: AntNum.h:37
gcp::control::RtcNetMsg body
Definition: NetMsg.h:92