AlcapDAQ  1
Functions | Variables
diag.h File Reference
#include <stdarg.h>

Go to the source code of this file.

Functions

void diag_print_setup ()
 
void diag_print_impl (int level, char *format, va_list ap)
 
void diag_print (int level, char *format,...)
 

Variables

int diag_print_threshold
 
int diag_cm_msg_threshold
 

Function Documentation

void diag_print ( int  level,
char *  format,
  ... 
)
inline

Definition at line 9 of file diag.h.

References diag_cm_msg_threshold, diag_print_impl(), diag_print_setup(), and diag_print_threshold.

10 {
11  if(diag_print_threshold < 0) {
13  }
14 
15  // Return immediately if we don't even need to format the message.
16  if(level > diag_print_threshold && level > diag_cm_msg_threshold) {
17  return;
18  }
19 
20  va_list argp;
21  va_start(argp, format);
22  diag_print_impl(level, format, argp);
23  va_end(argp);
24 
25 }
void diag_print_impl ( int  level,
char *  format,
va_list  ap 
)

Definition at line 35 of file diag.cpp.

References diag_cm_msg_threshold, frontend_name, last_message_time, num_messages_this_second, printf(), and time.

Referenced by diag_print().

36 {
37  // Format the message.
38  char buffer[4096];
39  vsnprintf(buffer, sizeof(buffer), format, argp);
40 
41  // Print on standard output
42  // if (level <= diag_print_threshold) {
43  printf("%s", buffer);
44  fflush(stdout);
45  // }
46 
47  // Send to cm_msg
48  if(level <= diag_cm_msg_threshold) {
49 
50  // Be careful to avoid sending too many messages...let's limit ourselves
51  // to 10 per second.
52 
53  time_t now = time(NULL);
54  if(last_message_time == now) {
56  if(num_messages_this_second < 1) {
57  cm_msg(MINFO, frontend_name, buffer);
58  }
59  } else {
61  }
62 
63  last_message_time = now;
64  }
65 }
void diag_print_setup ( )

Definition at line 22 of file diag.cpp.

References crate_number, diag_cm_msg_threshold, diag_print_threshold, and odb_get_int().

Referenced by diag_print().

23 {
24  // Read the diagnostic print thresholds from the ODB
26  odb_get_int("/Equipment/Crate %d/Settings/Diagnostic Print Level", crate_number);
28  odb_get_int("/Equipment/Crate %d/Settings/Operator Message Level", crate_number);
29 }

Variable Documentation

int diag_cm_msg_threshold

Definition at line 11 of file diag.cpp.

Referenced by diag_print(), diag_print_impl(), and diag_print_setup().

int diag_print_threshold

Definition at line 10 of file diag.cpp.

Referenced by diag_print(), diag_print_setup(), read_periodic_event(), and read_trigger_event().