Listen is a simple listen-only VR-Link application which has been extended to take advantage of HLA Evolved Specific functionality.
With each iteration of the loop, the program prints an entity's updated, dead-reckoned position in topographic coordinates. If a fire PDU or interaction is detected on the network, the program prints a message showing the entity ID of the attacker.
To exit, press the 'q' key. This example works with the Talk example.
- Connecting to An Exercise
The program creates an exercise connection (DtExerciseConn.) This connection serves as the program's interface to an exercise. After it's regular connection features, it then loads an HLA Evolved FOM Module that defines the update rate reduction parameters of the aircraft.
- Update Rate Reduction
HLA Evolved allows us to subscribe to an object but only receive a limited subset of updates based on time. In order to do this, one must pass the name of the string defineding update rate reduction in the FOM (in this case "everyFiveSeconds") to the DtReflectedEntityList. VR-Link takes care of the rest.
- Tracking Federates
In addition to tracking updates and interactions, HLA Evolved provides a way to access the name of the producing federate. One can access this federate by calling the producingFederate() function available in all objects and interactions in an HLA Evolved exercise. You must enable the conveyProducingFederate FOM switch for this to work.
#include <iostream>
int keybrdTick(void);
unsigned int numUpdates = 0;
bool hasDiscovered = false;
double updatesPerSecond = 0.0;
{
std::cout << "Fire Interaction from "
if ( producingFederate.
size() )
{
std::cout << " Federate Name " << producingFederate;
}
std::cout << std::endl;
}
int main(int argc, char** argv)
{
try
{
appInit.setFederateType( "Listen Evolved Example" );
appInit.setExecName( "MAK-RPR-2.0" );
appInit.setRprFomVersion( 2.0 );
appInit.setRprFomRevision( 1 );
appInit.parseCmdLine();
appInit.addFomModule("updateRate.xml");
try
{
}
catch(...)
{
DtFatal <<
"Update Rate Reduction failed.\n"
"This may be due to using a lightweight connection,\nor a non-standard compliant RTI.\n";
return -1;
}
int forever = 1;
while (forever)
{
if (keybrdTick() == -1)
break;
if (first)
{
double refLongitude =
DtDeg2Rad(-121.326577);
DtTopoView topoView(esr, refLatitude, refLongitude);
updatesPerSecond = ((
double)(numUpdates)) / ((
double)(effectiveCurrTime));
std::cout << " num updates / second = " << updatesPerSecond ;
if ( lastProducingFederate.
size() )
{
std::cout << ". Last Update from " << lastProducingFederate ;
}
std::cout << std::endl;
}
}
}
return 0;
}
int keybrdTick()
{
if (keyPtr && (*keyPtr == 'q' || *keyPtr == 'Q'))
return -1;
else
return 0;
}
#if DtHLA
{
++numUpdates;
if ( 0 == numUpdates )
{
initialTime = curr;
}
}
{
hasDiscovered = false;
}
{
if ( !hasDiscovered )
{
}
hasDiscovered = true;
}
#endif