StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rtsMonitor.h
1 #ifndef _RTS_MONITOR_H_
2 #define _RTS_MONITOR_H_
3 
4 
5 #include <RC_Config.h> /* for TRIGGERS_MAX of the day... */
6 
7 /* LINUX issues */
8 #ifndef SHM_SHARE_MMU
9 #define SHM_SHARE_MMU 0
10 #endif
11 
12 
13 
14 /* unused ! */
15 #define RTS_MON_SHM_KEY 0xffab0000
16 
17 
18 
19 
20 /*
21  Default monitoring host.
22  Default monitoring UDP port.
23 */
24 
25 #define RTS_MON_PORT 8100
26 
27 
28 #ifdef RTS_PROJECT_PP
29  #define RTS_MON_HOST "130.199.91.18" /* old pp2pp host, deprecated */
30 #else
31  #ifdef RTS_DAQMAN
32  #define RTS_MON_HOST RTS_DAQMAN
33  #else
34  #define RTS_MON_HOST "boothost" /* only really good for vxworks but I leave it in */
35  #endif
36 #endif
37 
38 
39 #define RTS_MON_FILE "/RTS/log/monServer.dta" /* always! */
40 
41 
42 /*
43  All the items are unsigned ints because I don't want to deal
44  with allignment problems on var. compilers/platforms.
45  All MUST be BigEndian!
46  Correction...actually, the endianess is determined through the "task" i.e.
47  task should be less than 255 and if it isn't, the we need to swap...
48 
49 */
50 
51 
52 
53 #define RTS_MON_VERSION_OLD 0x000000003 /* in yyyy.xxxx BCD format */
54 #define RTS_MON_VERSION 0x000000003 /* in yyyy.xxxx BCD format */
55 
56 #define RTS_MON_VERSION_X_FLAG 0x10000000
57 #define RTS_MON_VERSION_X (RTS_MON_VERSION_X_FLAG | RTS_MON_VERSION) /* FY04 (Oct03) extended version */
58 
59 /* total number of entities (i.e. node-task pairs we support) */
60 #define RTS_MON_MAX_NODES 768
61 
62 #define RTS_MON_USER_WORDS 100 /* NX4bytes of storage for user defined entries */
63 #define RTS_MON_SYS_WORDS 17 /* DO NOT MODIFY UNLESS ONE CHANGES THE rtsMonStruct ! */
64 
65 struct rtsMonRequired /* this represents the minimum packet necessary */
66 {
67  unsigned int size ; /* size in bytes of this message */
68  unsigned int node ; /* daq Node Id of this sender */
69  unsigned int task ; /* DAQ TaskId of the sender */
70  unsigned int version ; /* version of this struct - see DAQ_MON_VERSION */
71  unsigned int tim ; /* current time in UNIX seconds */
72  unsigned int state ; /* 0 OFF, 1 ON, 2 AUX */
73 };
74 
75 // Added by jml: I need the bare header which I use to construct
76 // local monitor structures.
77 //
78 // ie: struct jmlRtsMonL1Full {
79 // rtsMonHeader head;
80 // rtsMonL1 l1;
81 // };
82 //
83 // Then it is easy to send, I can use sizeof, I only need one variable
84 // etc... The user words in rtsMonStruct always screws me up...
85 
86 struct rtsMonHeader {
87  unsigned int size ; /* size in bytes of this message */
88  unsigned int node ; /* RTS Node Id of this sender */
89  unsigned int task ; /* RTS TaskId of the sender */
90  unsigned int version ; /* version of this struct - see RTS_MON_VERSION */
91  unsigned int tim ; /* current time in UNIX seconds */
92  unsigned int state ; /* RC States */
93  unsigned int tknIn ; /* last announced token */
94  unsigned int tknOut ; /* last released token */
95  unsigned int tknBad ; /* last erroneus token */
96  unsigned int couEvtsIn ; /* tokens currently in the system */
97  unsigned int couEvtsRun ; /* events in this run */
98  unsigned int couEvtsAll ; /* events since boot */
99  unsigned int couEvtsBad ; /* rejected events because of errors in this run */
100  unsigned int busy ; /* % of time the system was BUSY i.e. incapable of new events */
101  unsigned int evtsSec ; /* input rate in events/second */
102  unsigned int kbSecEvb ; /* rate in kB/sec to the EVB */
103  unsigned int kbSecAux ; /* rate in kB/sec to the L3 system */
104 };
105 
106 struct rtsMonStruct {
107 /* these MUST be present! */
108  unsigned int size ; /* size in bytes of this message */
109  unsigned int node ; /* RTS Node Id of this sender */
110  unsigned int task ; /* RTS TaskId of the sender */
111  unsigned int version ; /* version of this struct - see RTS_MON_VERSION */
112  unsigned int tim ; /* current time in UNIX seconds */
113  unsigned int state ; /* RC States */
114 /* these should be present although one can use 0xffffffff to signify Not Applicable */
115  unsigned int tknIn ; /* last announced token */
116  unsigned int tknOut ; /* last released token */
117  unsigned int tknBad ; /* last erroneus token */
118  unsigned int couEvtsIn ; /* tokens currently in the system */
119  unsigned int couEvtsRun ; /* events in this run */
120  unsigned int couEvtsAll ; /* events since boot */
121  unsigned int couEvtsBad ; /* rejected events because of errors in this run */
122  unsigned int busy ; /* % of time the system was BUSY i.e. incapable of new events */
123  unsigned int evtsSec ; /* input rate in events/second */
124  unsigned int kbSecEvb ; /* rate in kB/sec to the EVB */
125  unsigned int kbSecAux ; /* rate in kB/sec to the L3 system */
126 /* used for user defined entries --> see comment below */
127  unsigned int user[RTS_MON_USER_WORDS] ;
128 } ;
129 
130 
131 // old! total size in shared memory
132 #define RTS_MON_DATA_SIZE_V3 (sizeof(struct rtsMonStruct)*RTS_MON_MAX_NODES)
133 
134 // new X-tended version...
135 #define RTS_MON_PACKET_SIZE (10*1024)
136 #define RTS_MON_DATA_SIZE (RTS_MON_PACKET_SIZE*RTS_MON_MAX_NODES)
137 
138 
139 /*
140  Maximum values of <name,value> strings in user space after which
141  the display program will chop the string off.
142  Used to prevent crashes and to ease the display formatting.
143 */
144 #define RTS_MON_NAME_MAX 12
145 #define RTS_MON_VAL_MAX 24
146 
147 
148 /* value which means "Not Applicable" and will be shown as "N.A." in the display */
149 #define RTS_MON_NA 0xFFFFFFFF
150 #define RTS_MON_NA_STRING "N.A."
151 
152 /*
153  based upon the size ("size") the displaying program will determine the amount of
154  user-added variables (if any) at the end of the structure.
155  The "user" field is treated as a sequence of zero-terminated C strings which will
156  be displayed in pairs <name,value> i.e.
157  "File Name :","Myfile","Really bad tokens","123" etc.
158 
159 */
160 
161 
162 struct rtsMonGB {
163  struct {
164  char name[32] ; // if strlen() == NULL, unused..
165  u_int off_id ; // offline id number i.e. 5001
166  u_int fired ; // received from trigger
167  u_int rate ; // rate of above
168  u_int l3_sent ; // sent to L3
169  u_int aborted_gb ; // released by GB
170  u_int aborted_l3 ; // released by L3
171  u_int aborted_l25 ; // released as L2.5
172  u_int err ; // events with error
173  u_int built ; // events built _successfully_
174  u_int xpress ; // events sent to xpress stream
175  } trgs[TRIGGERS_MAX+1] ; // TRIGGERS_MAX are the usual, last is the sum
176 } ;
177 
178 
180 /* these MUST be present! */
181  unsigned int size ; /* size in bytes of this message */
182  unsigned int node ; /* RTS Node Id of this sender */
183  unsigned int task ; /* RTS TaskId of the sender */
184  unsigned int version ; /* version of this struct - see RTS_MON_VERSION */
185  unsigned int tim ; /* current time in UNIX seconds */
186  unsigned int state ; /* RC States */
187 /* these should be present although one can use 0xffffffff to signify Not Applicable */
188  unsigned int tknIn ; /* last announced token */
189  unsigned int tknOut ; /* last released token */
190  unsigned int tknBad ; /* last erroneus token */
191  unsigned int couEvtsIn ; /* tokens currently in the system */
192  unsigned int couEvtsRun ; /* events in this run */
193  unsigned int couEvtsAll ; /* events since boot */
194  unsigned int couEvtsBad ; /* rejected events because of errors in this run */
195  unsigned int busy ; /* % of time the system was BUSY i.e. incapable of new events */
196  unsigned int evtsSec ; /* input rate in events/second */
197  unsigned int kbSecEvb ; /* rate in kB/sec to the EVB */
198  unsigned int kbSecAux ; /* rate in kB/sec to the L3 system */
199 
200  int deadtime[32] ;
201  int clock[32] ; // the clock of the TCD; or TCU for "Trigger"
202  unsigned int cpu_busy ;
203 
204  struct {
205  int sca_hz ;
206  int sca_dead ;
207  int l0_evts ;
208  int l0_hz ;
209  int abt ;
210  } l0[65] ;
211 
212 } ;
213 
214 struct rtsMonTCD {
215  int deadtime[32] ;
216  int clock[32] ; // the clock of the TCD; or TCU for "Trigger"
217 } ;
218 
219 
220 struct rtsMonSCA {
221  struct {
222  char name[32] ;
223  u_int rate ;
224  } trgs[TRIGGERS_MAX] ; // 0-32 are normal, the rest is reserved
225 
226 } ;
227 
229  struct {
230  // char name[32];
231  u_int enabled;
232  u_int rate;
233  u_int deadtime;
234  } trgs[TRIGGERS_MAX+1];
235  u_int detector_deadtime[16];
236 };
237 
238 struct rtsMonEVB {
239  u_int mb_run ; // MB stored in this run
240  u_int gb_free ; // still free on all disks
241  u_int gb_all ; // total capacity on all discs (for %-free calc...)
242  // stuff pertaining to RCF goes here..
243 
244  u_int run_number ; // hm, this is old, why do I have this here? *shrug*
245  struct rtsMonGB gb ; // new in FY09 -- EVB sends GB stuff as well!
246 } ;
247 
249  u_int mon[RTS_MON_SYS_WORDS];
250  // General
251  u_int mb_run; // total data size for this run
252  u_int gb_free; // free disk space
253  u_int gb_all; // total disk space
254 
255  // RCF
256  u_int files_sent; // sent within last resets on the hour
257  u_int files_waiting; // waiting to be sent
258 
259  // By trigger Information
260  struct {
261  u_int off_id ; // offline id number i.e. 5001
262 
263  u_int fired ; // received from trigger
264  u_int rate ; // rate of above
265  u_int built ; // events built _successfully_
266 
267  u_int aborted_l25 ; // released as L2.5
268  u_int err ; // events with error (det timeout, evb resources)
269  u_int spurious; // events with spurious (trg timeout, evt overrun)
270 
271  u_int stream; // which stream evts sent to
272 
273  } trgs[TRIGGERS_MAX+1] ; // 0-31 are the usual, 32 is the sum
274 };
275 
276 
277 
278 // RCF writers structure
279 // the usual state is:
280 // RC_PRESENT or RC_NONE dormant
281 // RC_READY attempting to connect to RCF
282 // RC_RUNNING currently writing to RCF
283 // RC_ERROR an RCF error encountered
284 // Usual monioring words are:
285 // kbSecEvb is the last known rate
286 struct rtsMonRCF {
287  char type[20];
288  int curr_run;
289  int curr_idx;
290  struct {
291  u_int run ; // run number ; 0 means invalid/empty
292  u_int mb_done ; // MB already stored for this run
293  u_int mb_all ; // ...of MB total for this run
294  u_int seq_done ; // part number already stored
295  u_int seq_all ; //... of parts remaining
296  } runs[11] ;
297 
298  // runs[0] is the _current_ run _if_ the state is either RC_RUNNING or RC_ERROR
299  // runs[10] is the summary of remaining runs:
300  // run is the _number_ of runs remaining
301  // mb_all is the MB remaining
302  // seq_all is the sequences remaining
303 };
304 
305 
306 // xtended structure used by RC/handler
307 // The "state" from the standard header is used as the general state
308 // The couEvtsRun from the standard header is the number of "scheduled"
309 // events.
310 // If not running the data should reflect the state of the last known
311 // run...
312 struct rtsMonRC {
313  u_int run ; // run number
314  u_int type ; // PEDESTAL etc.
315  char config[128] ; // Configuration name
316  char dest[64] ; // EVB destination name
317  u_int t_start ; // Start run time
318  u_int t_end ; // Stop run time (0 if not yet finished)
319  u_int accepted ; // bits: 1 operator rejected, 2 force stop by sombody, 4 unsuccessfull end
320  u_int node_count ; // the count of nodes following (all of which are in the run...)
321  u_short err_node ; // jml... the node that caused the last stop run
322  u_short n_err_node;
323  struct {
324  u_short node ;
325  u_short task ;
326  u_int state ;
327  } nodes[256] ;
328  struct {
329  char name[32] ; // if strlen() == NULL, unused..
330  u_int off_id ; // offline id number i.e. 5001
331  } trgs[TRIGGERS_MAX] ;
332 } ;
333 
334 
335 struct rtsMonL1 { // used by GL3 as well!
336  u_int late_events ; // number of events above the time cutoff (i.e. 7 ms)
337  u_int max_us ; // the current maximum turaround time (in us)
338  struct {
339  u_int off_id ; // offline id number
340  u_int accepted ; // fired in the run so far
341  u_int rate ; // rate/sec of "accepted"
342  u_int aborted ; // number of evebts aborted in this run
343  } trgs[TRIGGERS_MAX+1] ; // 0-31 are per trigger, 32 is the total sum...
344 } ;
345 
346 struct rtsMonDET {
347  u_int val_rbs ; // valid RBs
348  u_int cfg_rbs ; // configured
349  u_int buffs ; // EVB/SL3 buffers free
350  u_int evtsSpur ; // spurious events; evtsBad are only the bad ones _with_ the Trigger
351  u_char rb_status[12] ; // USED in DDL dets!
352  u_int dbg_ctrs[10] ; // 10 debug counters
353 } ;
354 
355 
356 
358 // 2011 L0/L1 updates
360 
361 // This is the only packet coming from L0
362 //
363 // Standard packet + TCU fired by trigger.
364 //
365 struct rts2011MonL0 {
366  rtsMonHeader head;
367 
368  struct {
369  u_int off_id;
370  u_int fired;
371  u_int rate;
372  } trg[TRIGGERS_MAX + 1];
373 };
374 
375 // This is the only packet coming from L1
376 //
377 // Standard packet + L1 counters by trigger.
378 //
379 struct rts2011MonL1 {
380  rtsMonHeader head;
381 
382  struct {
383  u_int rate;
384  u_int deadtime;
385  } scaler[TRIGGERS_MAX + 1];
386 
387  u_int detector_dead[16];
388 };
389 
390 
391 // This is the update to the evbSuperMon struct
392 //
394  rtsMonHeader head;
395 
396  // General
397  u_int mb_run; // total data size for this run
398  u_int gb_free; // free disk space
399  u_int gb_all; // total disk space
400 
401  // RCF
402  u_int files_sent; // sent within last resets on the hour
403  u_int files_waiting; // waiting to be sent
404 
405  // By trigger Information
406  struct {
407  u_int off_id ; // offline id number i.e. 5001
408 
409  u_int fired ; // received from trigger
410  u_int fired_rate;
411 
412  u_int built ; // events built _successfully_
413  u_int built_rate;
414 
415  u_int l1_abort;
416  u_int l1_abort_rate;
417 
418  u_int l2_abort;
419  u_int l2_abort_rate;
420 
421  u_int l3_abort;
422  u_int l3_abort_rate;
423 
424  u_int err;
425  u_int err_rate;
426 
427  u_int stream; // which stream evts sent to
428  } trgs[TRIGGERS_MAX+1] ;
429 
430  u_int detectorErrors[RTS_NUM_SYSTEMS];
431 };
432 
433 // new, FY13, slow controls monitoring (via scDeamon)
434 struct rtsMonSC {
435  rtsMonHeader head ;
436 
437  int rich_scalers[32] ;
438  float mag_field ;
439 
440  short blu_ions ;
441  short blu_energy ;
442  char blu_status[32] ;
443 
444  short yel_ions ;
445  short yel_energy ;
446  char yel_status[32] ;
447 
448  char mcr_vote[32] ;
449 
450  u_int phys_on ;
451  u_int phys_off ;
452 
453  u_int tcu_clock ;
454  u_int zdc_corrected ;
455  u_int reserved[9] ;
456 };
457 
459  rtsMonHeader head;
460 
461  // By trigger Information
462  struct {
463  u_int off_id ; // offline id number i.e. 5001
464 
465  u_int daq_cnt ; // received from EVB
466  u_int daq_rate;
467 
468  u_int l4_accept;
469  u_int l4_accept_rate;
470  } trgs[TRIGGERS_MAX+1] ;
471 };
472 
474  rtsMonHeader head;
475 };
476 
478  rtsMonHeader head;
479 
480  // General
481  u_int gb_free; // free disk space
482  u_int gb_all; // total disk space
483 
484  // RCF
485  u_int files_sent; // sent within last resets on the hour
486  u_int files_waiting; // waiting to be sent
487 };
488 
490  rtsMonHeader head; // all values according to token...
491 
492  u_int evtsManaged; // eventsIn by tmtoken rather than token
493  u_int evtsEvb[10]; // eventsIn by tmtoken by evb
494 };
495 
496 
497 // TPC Gating grid monitoring
498 struct ggMonStruct {
499  struct rtsMonHeader m ;
500 
501  u_short mode ;
502  u_short hv ;
503 
504  u_int status[12] ;
505  u_short adc[12][4][3] ;
506  u_short dac[12][4][3] ;
507 } ;
508 
509 
510 #endif