Messages Between Objects

Messages allow communication between objects. A message has parameters port, destination, and value. Example:

There are three ways to read the message body, depending on the message type:
  1. msg_data is always available in the message action code, and it keeps the value of the message body (int or float). If the message sent was of a vector type, msg_data will have the value 0. For example,
          var = msg_data;
    
  2. msg_type is always available too, and indicates the type of the message by an integer: 0 means an integer or float number, 1 means an integer vector (INT_VEC), and 2 indicates a float vector (FLOAT_VEC). E.g.
          if ( msg_type == 1 ) { ... }
    
  3. integer vector type: the vector can be copied to a local integer vector, through the function get_msg_data:
          int vec[10];
          get_msg_data(vec);
    
    In this last case, if the sent vector is longer than the local vector, the excess part of the sent vector will be dropped. On the other hand, if the local vector is longer than the sent vector, the rest of the local vector will be 0-filled.

Guilherme Dutra Gonzaga Jaime 2010-10-27