Message Handler

The message handler relays messages generated by the SIMULIA Co-Simulation Services to your client's message handler.

This page discusses:

Message Handler Callback Function

The client must register a message handler with the SIMULIA Co-Simulation Services (see Establishing Connections). The message handler is a callback function called by the SIMULIA Co-Simulation Services to convey information, warning, and error messages to the client's message handler.

Member labels are provided separately from the message. This allows the client to translate the node or element numbers into a different number or label space, if needed, prior to presenting them to the user or to graphically present them in a CAE environment.

The message handler takes the following arguments:

iSeverity
Indicates whether this is an information, warning, or error message.
iMsg
Constant character string containing the message.
iNumNodes
If the message pertains to nodes, defines how many nodes are returned in the nodes argument.
iNodes
List of nodes.
iNumElements
If the message pertains to elements, defines how many elements are returned in the elements argument.
iElements
List of elements.

Example

The following example illustrates a basic message handler:

void myMessageHandler ( const SMAMpfMessageHandlerSeverity severity, 
                        const char* msg, 
                        const int numNodes, 
                        const int* nodes, 
                        const int numElements, 
                        const int* elements)
{
    switch (severity) {
       case SMACseMsgHandler_InformationalMessage:  // -- Informational Message, continue execution 
            if (numNodes > 0) {
                // convert nodes to client's user node labels if needed,
                // print message and node labels using client's message routine
                // possible propagate message and nodes to CAE application for visualization  
            }else if (numElems > 0) {
                // convert elements to client's user element labels if needed (e.g. element id and face id for surface facets),
                // print message and element labels using client's message routine
                // possible propagate message and elements to CAE application for visualization  
            } else {
                // print message only.
            }
            break;
       case SMACseMsgHandler_WarningMessage:  // -- Warning Message, continue execution 
           if (numNodes > 0) {
                // convert nodes to client's user node labels if needed,
                // print message and node labels using client's message routine
                // possible propagate message and nodes to CAE application for visualization  
            }else if (numElems > 0) {
                // convert elements to client's user element labels if needed (e.g. element id and face id for surface facets),
                // print message and element labels using client's message routine
                // possible propagate message and elements to CAE application for visualization  
            } else {
                // print message only.
            }
       case SMACseMsgHandler_ErrorMessage:  // -- Error Message, terminate execution 
            if (numNodes > 0) {
                // convert nodes to client's user node labels if needed,
                // print message and node labels using client's message routine
                // possible propagate message and nodes to CAE application for visualization  
            }else if (numElems > 0) {
                // convert elements to client's user element labels if needed (e.g. element id and face id for surface facets),
                // print message and element labels using client's message routine
                // possible propagate message and elements to CAE application for visualization  
            } else {
                // print message only.
            }
            break;
   }