The f18 program simulates a simple HLA or DIS vehicle.
By default, that vehicle is n F/A18 flying in a circle, just off the coast of California, USA, but you can control the entity type, location and route.
The f18 generates predictable HLA entity update messages (or DIS entity state PDUs), so it is a useful tool for debugging applications that receive and interpret these messages. It can also fire munitions and react to detonations.
The F18 is composed of two major classes:
The F18 example is contained in several major files:
The main application:
#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;
}