CARMA C++
PmacCommsMsg.h
Go to the documentation of this file.
1 #ifndef PMACCOMMSMSG_H
2 #define PMACCOMMSMSG_H
3 
13 
15 
16 namespace sza {
17  namespace util {
18 
19 
20  class PmacCommsMsg :
22 
23  public:
24 
28  enum MsgType {
29  CONNECT,
30  DISCONNECT,
31  SETMEM
32  };
33 
37  MsgType type;
38 
39  union {
40 
41  struct {
42  unsigned short offset;
43  unsigned short length;
44  unsigned char data[PMAC_DATA_MAX_LEN];
45  } setmem;
46 
47  } body;
48 
52  inline void packConnectMsg()
53  {
55  sza::util::GenericTaskMsg::TASK_SPECIFIC;
56 
57  type = CONNECT;
58  }
59 
63  inline void packDisconnectMsg()
64  {
66  sza::util::GenericTaskMsg::TASK_SPECIFIC;
67 
68  type = DISCONNECT;
69  }
70 
74  inline void packSetMemMsg(unsigned short offset,
75  unsigned short length,
76  unsigned char* data)
77  {
78  if(length > PMAC_DATA_MAX_LEN)
79  throw sza::util::
80  sza::util::Error("PmacCommsMsg::packSetMemMsg: "
81  "data array too large.\n");
82 
84  sza::util::GenericTaskMsg::TASK_SPECIFIC;
85 
86  type = SETMEM;
87 
88  body.setmem.offset = offset;
89  body.setmem.length = length;
90 
91  for(unsigned i=0; i < length; i++)
92  body.setmem.data[i] = data[i];
93  }
94 
95  }; // End class PmacCommsMsg
96 
97  }; // End namespace util
98 }; // End namespace sza
99 
100 #endif // End #ifndef
Tagged: Thu Nov 13 16:53:43 UTC 2003.
Tagged: Fri Nov 14 12:39:34 UTC 2003.
GenericMsgType genericMsgType_
A type for this message.
A class to encapsulate message types for a generic task.
Tagged: Fri Nov 14 12:39:33 UTC 2003.