VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sending Messages

Table of Contents

All messages are sent using the following generic procedure:

  1. Create and fill in a message content class.
  2. Create a DtVrfObjectMessage subclass to wrap the content class.
  3. Fill in the DtVrfObjectMessage subclass with the content and recipient information.
  4. Call one of the sendMessage() member functions on the DtVrfObjectCommunicationInterface of the sending object.

The communication interface fills in the proper data for the message sender.

Messages can be addressed to a specific simulation object by specifying its name in the recipient field, or addressed to every simulation object by setting the recipient string to "DtBroadcast".

Example SM-1 constructs a message with a DtTextReport (textReport.h) message content that is ready to send to an object named "receiverObject".

Example SM-1

DtTextReport textReport;
textReport.setText("text");
DtReportMessage reportMsg;
reportMsg.setRecipient("receiverObject");
reportMsg.setReceiverIsEchelonId(false);
reportMsg.setReport(&textReport);

Sending Simulation Internal Messages

To send the message in Example SM-1 using the simulation internal message system, make the following call:

vrfObject->communicationInterface()->sendSimInternalMessage(&reportMsg);

Sending Radio Messages

An object can have multiple radios, so when you send messages using the radio system, you must choose which radio to send the message on. You can specify the radio by name, ID, or as the default radio. The radio name is the string that identifies the desired radio in the entity’s OPE file. The radio ID is the index of the radio on the local simulation object, starting with 0, and reflects the order the radios are defined in the entity’s OPE file. The default radio is always the first radio listed in the OPE file, and is equivalent to radio ID 0.

To send the message in Example SM-1 using the default radio, use the following call:

vrfObject->communicationInterface()->sendRadioMessage(&reportMsg);

To send the message with a named radio, use the following call:

vrfObject->communicationInterface()->sendRadioMessage("radio-name", &reportMessage);

To send the message with a specific radio ID, use the following call:

vrfObject->communicationInterface()->sendRadioMessage(2, &reportMessage);

The default configuration for most VR-Forces simulation objects has one radio, so it is usually appropriate to send messages using the default radio.


Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)