The HLA Netdump example is a simple program that prints all received HLA Interactions and all HLA Object updates to a console.
VR-Link includes this as a tool that can be used to monitor the information sent over the network. It particularly comes in handy as a debug tool, allowing users to see if packets are sent correctly, if there's anything flooding the network, and more.
#if DtHLA
#include "stealthControlRegister.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
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> selectFomModules(std::vector<DtString> cmdLineFomModuleNames)
{
std::vector<DtString> result;
result.insert(result.end(), cmdLineFomModuleNames.begin(), cmdLineFomModuleNames.end());
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::ValueArg<DtString> fomModuleList(
"",
"setFomModuleList",
"Overwrite FOM Modules with list. Accepts a comma separated list of module names.",
false,
"",
"string", cmd);
#endif
DtCmdLine::ValueArg<int> notifyLevelValue(
"n",
"notifyLevel",
"notify level (0-error, 1-warning, 2-info(default), 3-verbose, 4-debug)",
false, 2,
"int", cmd);
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;
if (fomModuleList.getValue() != "")
{
fomModuleList.getValue().tokenize(',', fomModules);
}
else
{
fomModules = selectFomModules(fomModuleNames.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;
if (fomModuleList.getValue() != "")
{
fomModuleList.getValue().tokenize(',', fomModules);
}
else
{
fomModules = selectFomModules(fomModuleNames.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;
if (fomModuleList.getValue() != "")
{
fomModuleList.getValue().tokenize(',', fomModules);
}
else
{
fomModules = selectFomModules(fomModuleNames.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 (...)
{
}
}
}
if (rootObjectClass)
{
std::list<DtObjClassDesc*>::const_reverse_iterator objIter = fom->
objClassList().rbegin();
std::list<DtObjClassDesc*>::const_reverse_iterator objRend = fom->
objClassList().rend();
for (objIter; objIter != objRend; ++objIter)
{
&& (includeMom || !rootMomObjectClass || !objClassDesc->
isOfClass(rootMomObjectClass->
handle())))
{
}
}
}
if (rootInterClass)
{
std::list<DtInterClassDesc*>::const_reverse_iterator interItr = fom->
interClassList().rbegin();
std::list<DtInterClassDesc*>::const_reverse_iterator interRend = fom->
interClassList().rend();
for (interItr; interItr != interRend; ++interItr)
{
&& (includeMom || !rootMomInterClass || !intClassDesc->
isOfClass(rootMomInterClass->
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_EVOLVED
if( !raw )
{
}
if (!raw)
{
}
if (!raw)
{
}
if (!raw)
{
}
if (!raw)
{
}
if (!raw)
{
}
if (!raw)
{
}
if (!raw)
{
}
#endif
#if DtHLA_1516
region );
#else
#endif
while( forever )
{
{
break;
}
}
if (forever)
{
std::list<DtObjClassDesc*>::const_iterator objIter = fom->
objClassList().begin();
std::list<DtObjClassDesc*>::const_iterator objEnd = fom->
objClassList().end();
for (; objIter != objEnd; ++objIter)
{
&& (includeMom || !rootMomObjectClass || !objClassDesc->
isOfClass(rootMomObjectClass->
handle())))
{
}
}
std::list<DtInterClassDesc*>::const_iterator interItr = fom->
interClassList().begin();
std::list<DtInterClassDesc*>::const_iterator interEnd = fom->
interClassList().end();
for (; interItr != interEnd; ++interItr)
{
&& (includeMom || !rootMomInterClass || !interClassDesc->
isOfClass(rootMomInterClass->
handle())))
{
}
}
}
#if DtHLA_1516_EVOLVED
#endif
if (subWithDdm)
{
delete regionSet;
region.reset();
}
return 0;
}
{
DtString lastProducingFederateName =
"Unknown";
#if DtHLA_1516_EVOLVED
lastProducingFederateName = obj->lastProducingFederate();
#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;
}
}
}
#endif // DtHLA