This is a simple program that prints all received HLA Interactions and all HLA Object updates.
#if DtHLA
#include "stealthControlRegister.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
int keybrdTick( void );
std::string clearScreen("");
const std::string theSeperator("************************************************************\n");
#if !DtHLA_1516
std::map<RTI::ObjectHandle, DtDdmFederateAmbassador::DtRegionInfo> myRegionInfo;
#else
std::map<RTI::ObjectInstanceHandle, DtDdmFederateAmbassador::DtRegionInfo> myRegionInfo;
#endif
RTI::DimensionHandle myXHandle;
RTI::DimensionHandle myYHandle;
#if VXWORKS
#define main realMain
#endif
void DtRtiShutdownHandler(const char * label, void* finished)
{
int* finishedInt = (int*)finished;
if (*finishedInt)
{
DtWarn <<
"Shutting down: " << label << std::endl;
}
*finishedInt = 0;
}
{
std::vector<DtString> result;
std::vector<DtString> fomModuleNames;
fomModuleNames.insert(fomModuleNames.end(), cmdLineFomModuleNames.
getValue().begin(), cmdLineFomModuleNames.
getValue().end());
if (suppressDefaultModules == false)
{
bool foundVRFExt = false;
bool foundDIGuy = false;
bool foundLgrControl = false;
bool foundVRFAggregate = false;
bool foundDynamicTerrain = false;
std::vector<DtString>::iterator modName = fomModuleNames.begin();
std::vector<DtString>::iterator end = fomModuleNames.end();
while ( modName != end )
{
if ( modName->findString("MAK-") != -1 && modName->findString("_evolved") != -1 )
{
if ( modName->findString("-VRFExt-") != -1 )
{
DtInfo <<
"Override MAK-VRFExt-4_evolved.xml with " << *modName << std::endl;
foundVRFExt = true;
}
else if ( modName->findString("-DIGuy-") != -1 )
{
DtInfo <<
"Override MAK-DIGuy-4_evolved.xml with " << *modName << std::endl;
foundDIGuy = true;
}
else if ( modName->findString("-LgrControl-") != -1 )
{
DtInfo <<
"Override MAK-LgrControl-2_evolved.xml with " << *modName << std::endl;
foundLgrControl = true;
}
else if ( modName->findString("-VRFAggregate-") != -1 )
{
DtInfo <<
"Override MAK-VRFAggregate-3_evolved.xml with " << *modName << std::endl;
foundVRFAggregate = true;
}
else if ( modName->findString("-DynamicTerrain-") != -1 )
{
DtInfo <<
"Override MAK-DynamicTerrain-2_evolved.xml with " << *modName << std::endl;
foundDynamicTerrain = true;
}
}
++modName;
}
if ( ! foundVRFExt )
{
result.push_back( "MAK-VRFExt-4_evolved.xml" );
}
if ( ! foundDIGuy )
{
result.push_back( "MAK-DIGuy-6_evolved.xml" );
}
if ( ! foundLgrControl )
{
result.push_back( "MAK-LgrControl-2_evolved.xml" );
}
if ( ! foundVRFAggregate )
{
result.push_back( "MAK-VRFAggregate-3_evolved.xml" );
}
if ( ! foundDynamicTerrain )
{
result.push_back( "MAK-DynamicTerrain-2_evolved.xml" );
}
}
result.insert( result.end(), fomModuleNames.begin(), fomModuleNames.end() );
std::vector<DtString>::iterator res = fomModuleNames.begin();
std::vector<DtString>::iterator resEnd = fomModuleNames.end();
while ( res != resEnd )
{
DtInfo <<
"Loading FOM module " << *res << std::endl;
++res;
}
return result;
}
int main( int argc, char* argv[] )
{
DtCmdLine::ValueArg<int> rprFomRevision(
"",
"rprFomRevision",
"Internal revision of the implementation of the RPR FOM version",
false, 1,
"int", cmd );
#if DtHLA_1516_EVOLVED
DtCmdLine::SwitchArg suppressDefaultModules(
"s",
"suppressDefaultModules",
"Do not load Default FOM Modules automatically",
false, cmd );
#endif
cmd.add( raw );
cmd.add( clearScreenSwitch );
cmd.add( fullReport );
cmd.add( ddmDump );
cmd.add( showRegionData );
cmd.add( subWithDdm );
cmd.parse( argc, argv );
if (clearScreenSwitch)
{
clearScreen = "\033[H\033[2J";
}
if (ddmDump || showRegionData)
{
}
if ( !fomMapperLib.getValue().isEmpty() )
{
if ( fomMapperInitData.getValue().isEmpty() )
{
#if DtHLA_1516_EVOLVED
std::vector<DtString> fomModules = selectFomModules(fomModuleNames, suppressDefaultModules.getValue());
fedFileName.getValue().c_str(),
fomMapperLib.getValue().c_str(), (void*)0,
"", fomModules, &status);
#else
fedType.
c_str(), fomMapperLib.getValue().c_str(),
fedFileName.getValue().c_str(), (void*)0, &status );
#endif
}
else
{
#if DtHLA_1516_EVOLVED
std::vector<DtString> fomModules = selectFomModules(fomModuleNames, suppressDefaultModules.getValue());
fedFileName.getValue().c_str(),
fomMapperLib.getValue().c_str(),
(void*)fomMapperInitData.getValue().c_str(),
"", fomModules, &status );
#else
fedType.
c_str(), fomMapperLib.getValue().c_str(),
fedFileName.getValue().c_str(),
(void*)fomMapperInitData.getValue().c_str(), &status );
#endif
}
{
return 1;
}
}
else
{
#if DtHLA_1516_EVOLVED
std::vector<DtString> fomModules = selectFomModules(fomModuleNames, suppressDefaultModules.getValue());
"", fedType.
c_str(), fedFileName.getValue(),
mapper, "", fomModules,
&status );
#else
fedType.
c_str(), mapper, fedFileName.getValue().c_str(), &status );
#endif
{
return 1;
}
{
DtStealthControlRegister(exConn);
}
}
int forever = 1;
#ifdef DtHLA
#endif
if(passiveSubs)
{
}
if (subWithDdm)
{
try
{
geodOrigin.getGeocentric(geocentricPoint);
geodRegion->setRegionBounds(geocentricPoint, regionSize.getValue(),
regionSize.getValue());
region = geodRegion;
regionSet->insert(region);
}
catch (RTI::Exception& except)
{
std::cout << "Caught exception creating region: " << except << std::endl;
std::cout << "Exiting..." << std::endl;
return -1;
}
{
std::cout << "Caught exception creating region: " << except << std::endl;
std::cout << "Exiting..." << std::endl;
return -1;
}
}
if (ddmDump || showRegionData)
{
if (fedAmb)
{
try
{
#if !DtHLA_1516
RTI::SpaceHandle spaceHandle = exConn->
rtiAmb()->getRoutingSpaceHandle(
"BenchmarkGeographicSpace");
"X", spaceHandle);
"Y", spaceHandle);
#else
#endif
}
catch (RTI::Exception& )
{
}
catch (...)
{
}
}
}
{
}
else
{
}
#if DtHLA_1516
for (std::list<DtObjClassDesc*>::const_iterator item = fom->
objClassList().begin();
++item)
{
#else
objClassDesc;
{
#endif
if ( includeMom || !momObjectClass
{
if (rootObjectClass && (objClassDesc->
handle() != rootObjectClass->
handle()))
{
}
}
}
#if DtHLA_1516
for (std::list<DtInterClassDesc*>::const_iterator item = fom->
interClassList().begin();
++item)
{
#else
intClassDesc;
{
#endif
if ( includeMom || !momInterClass
|| (momInterClass && !intClassDesc->
isOfClass( momInterClass->
handle() )) )
{
if (rootInterClass && (intClassDesc->
handle() != rootInterClass->
handle()))
{
}
}
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
if ( !raw )
{
}
#if DtHLA_1516
region );
#else
#endif
while( forever )
{
if ( keybrdTick() == -1 )
{
break;
}
}
if (forever)
{
#if DtHLA_1516
for (std::list<DtObjClassDesc*>::const_iterator item = fom->
objClassList().begin();
++item)
{
#else
objClassDesc;
{
#endif
if (includeMom || !momObjectClass
{
}
}
#if DtHLA_1516
for (std::list<DtInterClassDesc*>::const_iterator item = fom->
interClassList().begin();
++item)
{
#else
intClassDesc;
{
#endif
if (includeMom || !momInterClass
{
}
}
}
if (subWithDdm)
{
delete regionSet;
region.reset();
}
return 0;
}
{
DtString lastProducingFederateName =
"Unknown";
#if DtHLA_1516_EVOLVED
#endif
if (ddmDump)
{
bool printProducingFederate = false;
{
std::map<RTI::ObjectHandle, DtDdmFederateAmbassador::DtRegionInfo>::iterator iter =
if (iter == myRegionInfo.end())
{
myRegionInfo[obj->
objectId()] = regionInfo;
std::cout
<< clearScreen
<< theSeperator
<< "*************** Update at "
<<
"Object: " << obj->
objectId() <<
"\n"
<<
"Name: " << obj->
name() <<
"\n";
#if DtHLA_1516_EVOLVED
if (!lastProducingFederateName.
isEmpty())
{
std::cout
<< "Updated by Federate: "
<< lastProducingFederateName
<< "\n";
}
#endif
std::cout
<< "DDM Info: " << "\n"
<<
" -- Lower X Bound: " << regionInfo.
lowerXBound <<
"\n"
<<
" -- Upper X Bound: " << regionInfo.
upperXBound <<
"\n"
<<
" -- Lower Y Bound: " << regionInfo.
lowerYBound <<
"\n"
<<
" -- Upper Y Bound: " << regionInfo.
upperYBound <<
"\n";
}
else
{
{
myRegionInfo[obj->
objectId()] = regionInfo;
std::cout
<< clearScreen
<< theSeperator
<< "*************** Update at "
<<
"Object: " << obj->
objectId() <<
"\n"
<<
"Name: " << obj->
name() <<
"\n";
#if DtHLA_1516_EVOLVED
if (!lastProducingFederateName.
isEmpty())
{
std::cout
<< "Updated by Federate: "
<< lastProducingFederateName << "\n";
}
#endif
std::cout
<< "DDM Info: " << "\n"
<<
" -- Lower X Bound: " << regionInfo.
lowerXBound <<
"\n"
<<
" -- Upper X Bound: " << regionInfo.
upperXBound <<
"\n"
<<
" -- Lower Y Bound: " << regionInfo.
lowerYBound <<
"\n"
<<
" -- Upper Y Bound: " << regionInfo.
upperYBound <<
"\n";
}
}
}
else
{
std::cout
<< clearScreen
<< theSeperator
<< "*************** Update at "
<< theSeperator
<<
"Object: " << obj->
objectId() <<
"\n"
<<
"Name: " << obj->
name() <<
"\n";
#if DtHLA_1516_EVOLVED
if (!lastProducingFederateName.
isEmpty())
{
std::cout
<< "Updated by Federate: "
<< lastProducingFederateName
<< "\n";
}
#endif
std::cout
<< "DDM Info: " << "\n"
<< " -- No DDM Region information set." << "\n";
}
}
else
{
std::cout
<< clearScreen
<< theSeperator
<< "*************** Update at "
<< theSeperator;
#if DtHLA_1516_EVOLVED
if (!lastProducingFederateName.
isEmpty())
{
std::cout
<< "Updated by Federate: "
<< lastProducingFederateName;
std::cout
<< "\n";
}
#endif
if ( raw )
{
}
else
{
msg.
print( obj, fullReport );
}
if (showRegionData)
{
std::cout << "DDM Region Data: ";
{
std::cout
<< "\n"
<<
" -- Lower X Bound: " << regionInfo.
lowerXBound <<
"\n"
<<
" -- Upper X Bound: " << regionInfo.
upperXBound <<
"\n"
<<
" -- Lower Y Bound: " << regionInfo.
lowerYBound <<
"\n"
<<
" -- Upper Y Bound: " << regionInfo.
upperYBound <<
"\n";
}
else
{
std::cout << "None" << "\n";
}
}
std::cout << std::endl;
}
}
{
}
{
}
{
std::cout << clearScreen << theSeperator << "*************** Interaction at "
if (!ddmDump)
{
if ( raw )
{
}
else
{
}
if (showRegionData)
{
std::cout << "DDM Region Data: ";
{
std::cout << std::endl;
std::cout <<
" -- Lower X Bound: " << regionInfo.
lowerXBound << std::endl;
std::cout <<
" -- Upper X Bound: " << regionInfo.
upperXBound << std::endl;
std::cout <<
" -- Lower Y Bound: " << regionInfo.
lowerYBound << std::endl;
std::cout <<
" -- Upper Y Bound: " << regionInfo.
upperYBound << std::endl;
}
else
{
std::cout << "None" << std::endl;
}
}
std::cout << std::endl;
}
else
{
{
std::cout <<
" -- Lower X Bound: " << regionInfo.
lowerXBound << std::endl;
std::cout <<
" -- Upper X Bound: " << regionInfo.
upperXBound << std::endl;
std::cout <<
" -- Lower Y Bound: " << regionInfo.
lowerYBound << std::endl;
std::cout <<
" -- Upper Y Bound: " << regionInfo.
upperYBound << std::endl;
}
else
{
std::cout << "-- No Interaction Region" << std::endl;
}
}
}
int keybrdTick()
{
if ( !keyPtr )
{
return 0;
}
switch( *keyPtr )
{
case 'q':
case 'Q':
{
return -1;
}
default:
{
std::cout << "Unrecognized command key <"<< *keyPtr <<">" << std::endl;
break;
}
}
return 0;
}
#endif // DtHLA