|
Version: 18-Jun-2002 / jn
This program uses as input an external
message buffer
(MSG_BUFFER), which contains the messages sent by other tasks.
The program detects the new messages. If a new one is found, it is
sent via UDP Broadcast to the local net and is put in an internal
buffer of the last read messages. But before the new message is
compared with the messages in the internal buffer. If the same
message already is present during the last ~10 seconds, the message
is not sent, but only put in the internal buffer. If the message in
the Message Buffer was sent with NO_TIME, the actual system
time is added to the message.
Accessing the Message
Buffer
The access to the external
message buffer by other tasks
is
performed by special functions ( see here). So,
the message handler object file must first be
loaded
together with the external message buffer (MSG_BUFFER)
to give the other tasks access to these functions and the buffer.
The functions and Macros are
defined
in a file: message_send_doc.cpp. It can be included like a
header file in a general messageID-file
describing the single messages ( look
here). All these functions are available, if the message handler
is loaded. It is not necessary to start the message handler.
The following functions
give access to the general
message
buffer:
(They put their messages in
the
message buffer.)
-
int send_error(char *stxt,int severity,int
mainID,int subID,char *sender,char *txt,double time);
-
int send_terror(double time,char *stxt,int
severity,int mainID,int subID,char *sender,char *txt);
-
int send_info(char *stxt,int severity,int
mainID,int subID,char *sender,char *txt,double time);
-
int send_tinfo(double time,char *stxt,int
severity,int mainID,int subID,char *sender,char *txt);
These routines directly
send their messages :
(They
bypass
the message buffer and the handler and directly send via UDP
broadcast.)
The following C-functions
manage the message handler
task:
-
start_message_hdl(int <debug>)
This function starts the message handler as a
background task with a predefined priority. If <debug> is a
number not equal 0, the task will print out more messages.
-
stop_message_hdl()
This function frees the resources of the task and
kills it.
The handler is a C++ class
object named MessageHdl with
the following public member
functions:
Looks continuously for new messages in the
Message Buffer, compares these with those in the internal buffer and
eventually sends them.
General Message Code Files
(Message_IDs_???.h)
All messages send with
the message sending
routines should
be defined in a message code file (Message_IDs_???.h). Here
the general messages with their ID, severity, sender etc. and a text
are defined. In that way the call to the sending routines is much
easier and the messages all are well documented in that file.
Example of general and
message definitions in
the
Message_IDs_???.h file:
#include
„...message_send_doc.cpp“
/*----- Name
dieses Computers
aus Environment*/
extern char
ThisComputer[64];
#ifndef
DIESER_SENDER
#define
DIESER_SENDER ThisComputer
#endif
#ifndef NO_TIME
#define
NO_TIME (double)(-1.)
#endif
#ifndef NO_TEXT
#define
NO_TEXT (char *)"
"
#endif
/*-- Examples for messages */
#define DISPLAY_START_ID SEND_SEVERITY_INFO,1,0,DIESER_SENDER \
,(char
*)" UDP-DISPLAY Handler successfully started "
#define DISPLAY_STOP_ID SEND_SEVERITY_WARN,1,1,DIESER_SENDER \
,(char
*)" ***** UDP-DISPLAY Handler DELETED *****"
/* -- End of message_ID file */
A call to a message routine
then has the following
form:
send_info(NO_TEXT,DISPLAY_START_ID,NO_TIME);
or with an additive text,
which is appended to the
standard
text of that message:
char text[64],
int i;
sprintf(text,“ appended
message %d“,i);
send_info(text,DISPLAY_START_ID,NO_TIME);
|