Midas Message Functions (msg_xxx)
[The midas.h & midas.c]


Functions

INT cm_get_error (INT code, char *string)
INT cm_set_msg_print (INT system_mask, INT user_mask, int(*func)(const char *))
INT cm_msg_log (INT message_type, const char *message)
INT cm_msg_log1 (INT message_type, const char *message, const char *facility)
INT cm_msg (INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
INT cm_msg1 (INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
INT cm_msg_register (void(*func)(HNDLE, HNDLE, EVENT_HEADER *, void *))
INT cm_msg_retrieve (INT n_message, char *message, INT buf_size)


Function Documentation

INT cm_get_error ( INT  code,
char *  string 
)

Convert error code to string. Used after cm_connect_experiment to print error string in command line programs or windows programs.

Parameters:
code Error code as defined in midas.h
string Error string
Returns:
CM_SUCCESS

Definition at line 291 of file midas.c.

Referenced by cm_connect_experiment().

INT cm_msg ( INT  message_type,
const char *  filename,
INT  line,
const char *  routine,
const char *  format,
  ... 
)

This routine can be called whenever an internal error occurs or an informative message is produced. Different message types can be enabled or disabled by setting the type bits via cm_set_msg_print().

Attention:
Do not add the "\n" escape carriage control at the end of the formated line as it is already added by the client on the receiving side.
   ...
   cm_msg(MINFO, "my program", "This is a information message only);
   cm_msg(MERROR, "my program", "This is an error message with status:%d", my_status);
   cm_msg(MTALK, "my_program", My program is Done!");
   ...
Parameters:
message_type (See MIDAS Macros).
filename Name of source file where error occured
line Line number where error occured
routine Routine name.
format message to printout, ... Parameters like for printf()
Returns:
CM_SUCCESS

Definition at line 600 of file midas.c.

Referenced by al_check(), al_reset_alarm(), al_trigger_alarm(), analyzer_init(), bk_list(), bm_close_buffer(), bm_copy_from_cache(), bm_flush_cache(), bm_open_buffer(), bm_push_event(), bm_receive_event(), bm_remove_event_request(), bm_request_event(), bm_send_event(), bm_set_cache_size(), bm_skip_event(), bm_update_read_pointer(), bm_validate_client_index(), bm_validate_client_pointers(), bm_wait_for_free_space(), bm_wakeup_producers(), check_polled_events(), close_buffers(), cm_check_client(), cm_check_deferred_transition(), cm_cleanup(), cm_connect_experiment1(), cm_deregister_transition(), cm_disconnect_experiment(), cm_get_watchdog_info(), cm_list_experiments(), cm_register_deferred_transition(), cm_register_transition(), cm_set_client_info(), cm_set_transition_sequence(), cm_shutdown(), cm_transition(), db_check_record(), db_close_database(), db_copy(), db_copy_xml(), db_create_key(), db_create_link(), db_create_record(), db_delete_key1(), db_enum_key(), db_find_key(), db_get_data(), db_get_data_index(), db_get_key(), db_get_key_info(), db_get_key_time(), db_get_link(), db_get_link_data(), db_get_record(), db_get_value(), db_load(), db_lock_database(), db_open_database(), db_open_record(), db_paste(), db_paste_node(), db_protect_database(), db_save(), db_save_struct(), db_save_xml(), db_save_xml_key(), db_set_data(), db_set_data_index(), db_set_record(), db_set_value(), db_unlock_database(), dm_buffer_create(), el_submit(), hs_dump(), load_fragment(), main(), readout_thread(), receive_trigger_event(), register_equipment(), rpc_flush_event(), rpc_register_functions(), rpc_send_event(), rpc_set_option(), scan_fragment(), send_event(), source_booking(), source_scan(), source_unbooking(), tr_start(), update_odb(), and ybk_list().

INT cm_msg1 ( INT  message_type,
const char *  filename,
INT  line,
const char *  facility,
const char *  routine,
const char *  format,
  ... 
)

This routine is similar to cm_msg(). It differs from cm_msg() only by the logging destination being a file given through the argument list i.e:facility

For internal use only.

Attention:
Do not add the "\n" escape carriage control at the end of the formated line as it is already added by the client on the receiving side. The first arg in the following example uses the predefined macro MINFO which handles automatically the first 3 arguments of the function (see MIDAS Macros).
 ...
   cm_msg1(MINFO, "my_log_file", "my_program"," My message status:%d", status);
   ...
//----- File my_log_file.log
Thu Nov  8 17:59:28 2001 [my_program] My message status:1
Parameters:
message_type See MIDAS Macros.
filename Name of source file where error occured
line Line number where error occured
facility Logging file name
routine Routine name
format message to printout, ... Parameters like for printf()
Returns:
CM_SUCCESS

Definition at line 732 of file midas.c.

INT cm_msg_log ( INT  message_type,
const char *  message 
)

Write message to logging file. Called by cm_msg.

Attention:
May burn your fingers
Parameters:
message_type Message type
message Message string
Returns:
CM_SUCCESS

Definition at line 353 of file midas.c.

Referenced by cm_msg().

INT cm_msg_log1 ( INT  message_type,
const char *  message,
const char *  facility 
)

Write message to logging file. Called by cm_msg().

For internal use only.

Parameters:
message_type Message type
message Message string
facility Message facility, filename in which messages will be written
Returns:
CM_SUCCESS

Definition at line 445 of file midas.c.

Referenced by cm_msg1().

INT cm_msg_register ( void(*)(HNDLE, HNDLE, EVENT_HEADER *, void *)  func  ) 

Register a dispatch function for receiving system messages.

Definition at line 864 of file midas.c.

INT cm_msg_retrieve ( INT  n_message,
char *  message,
INT  buf_size 
)

Retrieve old messages from log file

Parameters:
n_message Number of messages to retrieve
message buf_size bytes of messages, separated by
characters. The returned number of bytes is normally smaller than the initial buf_size, since only full lines are returned.
*buf_size Size of message buffer to fill
Returns:
CM_SUCCESS

Definition at line 894 of file midas.c.

INT cm_set_msg_print ( INT  system_mask,
INT  user_mask,
int(*)(const char *)  func 
)

Set message masks. When a message is generated by calling cm_msg(), it can got to two destinatinons. First a user defined callback routine and second to the "SYSMSG" buffer.

A user defined callback receives all messages which satisfy the user_mask.

int message_print(const char *msg)
{
  char str[160];

  memset(str, ' ', 159);
  str[159] = 0;
  if (msg[0] == '[')
    msg = strchr(msg, ']')+2;
  memcpy(str, msg, strlen(msg));
  ss_printf(0, 20, str);
  return 0;
}
...
  cm_set_msg_print(MT_ALL, MT_ALL, message_print);
...
Parameters:
system_mask Bit masks for MERROR, MINFO etc. to send system messages.
user_mask Bit masks for MERROR, MINFO etc. to send messages to the user callback.
func Function which receives all printout. By setting "puts", messages are just printed to the screen.
Returns:
CM_SUCCESS

Definition at line 336 of file midas.c.

Referenced by cm_connect_experiment1(), and main().


Midas DOC Version 2.0.2 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk