VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
10.2 - Sending an Interface Message

Table of Contents

You can send an interface message to a VR-Forces application using the DtVrfMessageInterface's createAndDeliver() member function.

The specification of the member function is:

bool DtSimManager::createAndDeliverMessage(const DtSimulationAddress & recipient, const DtSimInterfaceContent & content);

The following example shows an application sending a create object message to a back-end, telling it to create a new phase line. Since the DtIfCreateVrfObject is declared on the stack, it will be deleted automatically.

// Address of the VR-Forces application to send the create message
DtSimulationAddress backendAddr;
. . .
DtVector start(0., 0., 0.);
DtVector end(0., 100., 0.);
DtIfCreateVrfObject phaseLineContent;
// Set the address of the back-end we want to have simulate the object.
phaseLineContent.setVrfProcessAddress(backendAddr);
phaseLineContent.setObjectName("Phase Line Alpha");
phaseLineContent.addVertex(start);
phaseLineContent.addVertex(end);
mySimManager->createAndDeliverMessage(backendAddr, phaseLineContent);

10.2.1 Addressing a Message

The recipient portion of a DtSimInterfaceMessage directs the message to a particular VR-Forces application. Specific objects within a VR-Forces application receive messages by registering callbacks for them. Interface messages are addressed to a VR-Forces application by its DtSimulationAddress (hostStructs.h). The simulation address is the site ID:application number pair that uniquely identifies an application participating in a simulation exercise.

You can broadcast an interface message to all VR-Forces applications by specifying the address DtSimSendToAll. It represents the simulation address (site ID: -1 application number: -1), indicating all VR-Forces applications on the network.

In a VR-Forces application, you can get your own simulation address through the Simulation Manager, for example:

DtSimulationAddress* address = simManager->messageAddress();
DtInfo("My simulation address site Id: %d application Id: %d\n",
address->siteId(), address->applicationId());

In an application using the Remote Control API (such as a GUI), you can get the simulation address of all VR-Forces applications currently participating in an exercise through the DtVrfRemoteController. The DtVrfRemoteController class has a backend() member function that returns a DtList of simulation addresses of all of the VR-Forces applications on the network in the same session. For example, to print out the addresses of all of the VR-Forces applications currently participating in an exercise:

DtListItem* item;
for(item = remoteController->backends().first(); item; item = item->next())
{
DtSimulationAddress* addr = (DtSimulationAddress*)item->data();
DtInfo("VR-Forces application address %s\n", addr->string());
}

[<< The Message Interface] [Home] [Top of Page] [Receiving Interface Messages >>]


Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)