An example that creates multiple F18 entities and demonstrates how to parallelize the simulation.
#include <stdlib.h>
#include <iostream>
#ifndef _WIN32
#include <sys/socket.h>
#endif
DtTime timeOutInterval = 12.0;
double translationThreshold = 1.0;
static int keybrdTick( );
#if VXWORKS
#define main realMain
#endif
int main( int argc, char* argv[] )
{
try
{
DtString appName =
"VR-Link F18 " + pidStr;
#if DtDIS
initializer.setDisVersionToSend(7);
#else
initializer.setExecName("MAK-RPR-2.0");
initializer.setRprFomVersion(2.0);
#endif
initializer.setApplicationNumber( pid );
DtString defaultF18Name( initializer.f18Name() );
defaultF18Name += " " + pidStr;
initializer.setF18Name( defaultF18Name );
#ifdef DtHLA
initializer.setFederateType( defaultF18Name );
#endif
initializer.parseCmdLine();
#if DtDIS
DtEntityPublisher::setDfltTimeThreshold( timeThreshold );
initializer.setUseAsynchIO(true);
#endif
int forever = 1;
while( forever )
{
if ( keybrdTick( ) == 0 ) break;
simulator.
sleep(initializer.deltaTime());
}
}
return 0;
}
int keybrdTick( )
{
if ( !keyPtr ) return 1;
switch( *keyPtr )
{
case 'q':
case 'Q':
return 0;
default:
std::cout << "Unrecognized command key " << *keyPtr << std::endl;
break;
}
return 1;
}
#include "vehicleSim.h"
#include <stdio.h>
#include <iostream>
{
}
{
}
{
std::cout << "Opening connection..." << std::endl;
{
std::cerr << "Failed to open connection error: " << status << "." << std::endl;
return;
}
#if DtHLA
#if DtHLA_1516
for (std::list<DtObjClassDesc*>::const_iterator item = fom->
objClassList().begin();
++item)
{
#else
for (classDesc = fom->firstObjClass();
classDesc;
classDesc = fom->nextObjClass(classDesc))
{
#endif
}
#endif
std::cout << "Connection open, status=" << status << "." << std::endl;
}
{
if (num > 0)
{
}
pubContainer);
return myVehicle;
}
{
for (int nVehicle=0; nVehicle<theNumVehicles; ++nVehicle) {
}
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}