VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MC02 Listen Example

MC02 is an complex DDM extension to RPR which creates all sorts of regions for different types of entities.

MC02 Listen is exactly like Listen , but adds HLA MC02 DDM to the mix.


/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include <vl/topoView.h>
#include <iostream>
#include "mc02Regions.h"
int keybrdTick();
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "MC02-Listen" );
// Create a connection to the exercise or federation execution.
DtVrlApplicationInitializer appInit(argc, argv, "VR-Link MC02 Listen");
appInit.setExecName("VR-LinkMC02");
appInit.setFedFileName("VR-LinkMC02.fed");
appInit.parseCmdLine();
DtExerciseConn exConn(appInit);
DtDDMRegionSP blueRegion;
try
{
DtBoost::shared_ptr<DtBlueAirRegion> baRegion(new DtBlueAirRegion(&exConn));
baRegion->notifyRtiOfUpdate();
blueRegion = baRegion;
DtDDMRegionSet blueRegSet;
blueRegSet.insert(blueRegion);
rel = new DtReflectedEntityList(&exConn, false, &blueRegSet);
}
catch (DtException& regionException)
{
DtWarn << "Caught exception: " << regionException << std::endl;
return 1;
}
// Initialize VR-Link time.
DtClock* clock = exConn.clock();
int forever = 1;
while (forever)
{
// Check if user hit 'q' to quit.
if (keybrdTick() == -1)
break;
// Tell VR-Link the current value of simulation time.
clock->setSimTime(clock->elapsedRealTime());
// Process any incoming messages.
exConn.drainInput();
// Find the first entity in the reflected entity list.
DtReflectedEntity *first = rel->first();
if (first)
{
// Grab its state repository, where we can inspect its data.
// Create a topographic view on the state repository, so we
// can look at position information in topographic coordinates.
double refLatitude = DtDeg2Rad( 35.699760);
double refLongitude = DtDeg2Rad(-121.326577);
DtTopoView topoView(esr, refLatitude, refLongitude);
// Print the position.
// Since it returns a DtString, we need to force it to const char*
// with a cast.
std::cout << "Position of first entity: "
<< topoView.location().string() << std::endl;
std::cout << "\tName: " << first->globalId() << std::endl;
}
// Sleep till next iteration.
DtSleep(0.1);
}
return 0;
}
int keybrdTick()
{
char *keyPtr = DtPollBlockingInputLine();
if (keyPtr && (*keyPtr == 'q' || *keyPtr == 'Q'))
return -1;
else
return 0;
}


Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)