CARMA C++
control.h
1 #ifndef control_h
2 #define control_h
3 
4 #include "carma/szaarrayutils/netobj.h"
5 #include "carma/szautil/SzaPorts.h"
6 
7 namespace sza {
8  namespace array {
9 
10  /*-----------------------------------------------------------------------
11  * Define the ids of client -> control-program commands along with
12  * the corresponding local command containers.
13  */
14  typedef enum {
15  CC_INPUT_CMD /* A command line typed by the user */
16  } CcNetCmdId;
17 
18  /*
19  * The CC_TEXT_LINE command conveys a single text command line to the
20  * control program.
21  */
22 
23  enum {CC_CMD_MAX=255}; /* The max size of a command string (excluding '\0') */
24 
25  typedef struct {
26  char cmd[CC_CMD_MAX+1]; /* The ascii command string (including '\0') */
27  } CcInputCmd;
28 
29  /*
30  * Create a union of the above message containers.
31  */
32  typedef union {
33  CcInputCmd input; /* A command line to be compiled and executed */
34  } CcNetCmd;
35  }
36 }
37 /*
38  * The following network-object description table, defined in control.c,
39  * describes the above commands.
40  */
41 extern const NetObjTable cc_cmd_table;
42 
43 namespace sza {
44  namespace array {
45 
46  /*-----------------------------------------------------------------------
47  * Define the types of messages that are sent to control clients by the
48  * control program.
49  */
50  typedef enum {
51  CC_LOG_MSG, /* A log message to be displayed */
52  CC_REPLY_MSG, /* A reply to a CC_INPUT_CMD command line */
53  CC_SCHED_MSG, /* A message regarding the state of the scheduler */
54  CC_ARC_MSG, /* A message regarding the state of the archiver */
55  CC_PAGE_MSG, /* A message regarding the pager status */
56  CC_PAGECOND_MSG, /* A message regarding the pager status */
57  CC_CONFIG_MSG, /* A message regarding the array configuration */
58  CC_ANT_MSG, /* A message regarding the state of the default
59  antenna selection */
60  CC_CMD_TIMEOUT_MSG
61  } CcNetMsgId;
62 
63  /*
64  * The following interface is for use in sending and receiving messages
65  * sent from the control program to control clients.
66  */
67  // enum {CC_MSG_MAX=131}; /* The max length of a message string (excluding '\0') */
68  enum {CC_MSG_MAX=1000}; /* The max length of a message string (excluding '\0') */
69 
70  /*
71  * Define a log message object.
72  */
73  typedef struct {
74  unsigned seq;
75  NetBool end;
76  NetBool error; /* True if the text is an error message */
77  NetBool interactive; /* True if the text was the result of an interactive message */
78  char text[CC_MSG_MAX+1]; /* The ascii message string (including '\0') */
79  } CcLogMsg;
80 
81  /*
82  * Define a reply message object.
83  */
84  typedef struct {
85  unsigned seq;
86  NetBool end;
87  NetBool error; /* True if the text is an error message */
88  char text[CC_MSG_MAX+1]; /* The ascii message string (including '\0') */
89  } CcReplyMsg;
90 
91  /*
92  * Define a message for reporting changes in the state of the
93  * schedule queue.
94  */
95  typedef struct {
96  char text[CC_MSG_MAX+1]; /* The status message */
97  } CcSchedMsg;
98 
99  /*
100  * Define a message for reporting changes in the state of the
101  * archiver.
102  */
103  typedef struct {
104  char text[CC_MSG_MAX+1]; /* The status message */
105  } CcArcMsg;
106 
107  enum {
108  PAGE_ENABLE = 0x1, // Set if this is an ordinary page enable/disable message
109  PAGE_REG = 0x2, // Set if this is page enable/disable
110  // message was sent because the pager was
111  // activated
112  PAGE_MSG = 0x4, // Set if this is page enable/disable
113  // message was sent because of some other reason
114  };
115 
116  /*
117  * Define a message for reporting changes in the state of the
118  * pager
119  */
120  typedef struct {
121  char text[CC_MSG_MAX+1]; /* The status message */
122  NetEnum mask;
123  NetBool allow;
124  } CcPageMsg;
125 
126  /*
127  * Define a message for reporting changes in the state of the
128  * archiver.
129  */
130  typedef struct {
131  unsigned mode;
132  double min;
133  double max;
134  bool isDelta;
135  bool isOutOfRange;
136  unsigned nFrame;
137  char text[CC_MSG_MAX+1]; /* The status message */
138  } CcPageCondMsg;
139 
140  enum PageCondMode {
141  PAGECOND_ADD,
142  PAGECOND_REMOVE,
143  PAGECOND_CLEAR,
144  PAGECOND_UPDATE,
145  };
146 
147  /*
148  * Define a message for reporting changes in the state of the
149  * array configuration
150  */
151  typedef struct {
152  unsigned mode;
153  unsigned array;
154  unsigned config;
155  int iPad;
156  int iAnt;
157  unsigned antType;
158  } CcConfigMsg;
159 
160  enum ConfigMode {
161  CONFIG_CONFIG,
162  CONFIG_ADDANT,
163  CONFIG_REMANT,
164  CONFIG_CLEAR,
165  CONFIG_UPDATE,
166  };
167  /*
168  * Define a message for reporting changes in the state of the
169  * timeout pager
170  */
171  typedef struct {
172  unsigned mode;
173  unsigned seconds;
174  bool active;
175  } CcCmdTimeoutMsg;
176 
177  enum CmdTimeoutMode {
178  CT_ACTIVE,
179  CT_TIMEOUT
180  };
181 
182  /*
183  * Define a message for reporting changes in the state of the
184  * default antenna selection
185  */
186  typedef struct {
187  char text[CC_MSG_MAX+1]; /* The status message */
188  } CcAntMsg;
189 
190  /*
191  * Define a union of all control-program -> control-client message types.
192  */
193  typedef union {
194  CcLogMsg log; /* A CC_LOG_MSG message */
195  CcReplyMsg reply; /* A CC_REPLY_MSG message */
196  CcSchedMsg sched; /* A CC_SCHED_MSG message */
197  CcArcMsg arc; /* A CC_ARC_MSG message */
198  CcPageMsg page; /* A CC_PAGE_MSG message */
199  CcPageCondMsg pageCond; /* A CC_PAGECOND_MSG message */
200  CcConfigMsg config; /* A CC_CONFIG_MSG message */
201  CcAntMsg ant; /* A CC_ANT_MSG message */
202  CcCmdTimeoutMsg cmdTimeout;
203  } CcNetMsg;
204  }
205 }
206 /*
207  * The following network-object description table, defined in control.c,
208  * describes the messages that are sent from the control program to
209  * control clients.
210  */
211 extern const NetObjTable cc_msg_table;
212 
213 #endif