VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F18 Example

Table of Contents

The f18 program simulates a simple HLA or DIS vehicle.

By default, that vehicle is an F/A-18 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, react to detonations, enable/disable IFF Systems, and send lethal interactions.

Major Components of the F18 Example

The F18 is composed of five major classes:

The Vehicle Sim Class and subcomponents

The class DtVehicleSim is responsible for simulating the Aircraft. This class directly handles modeling the general characteristics (e.g., entity type and appearance) and spatial representation (position, velocity, accleration, and orientation). It uses separate component classes to model warfare (fire/detonate), emitter, and IFF functionality - DtWarfareComponent, DtEmitterComponent, and DtIffComponent.

The F18 Initialization Class

The DtF18Initializer class is a subclass of VR-Link's DtVrlApplicationInitializer. This class processes the command line and reads the F18's mtl file.

VR-Link Advanced Configuration

The F18 Config Example Code config.cxx serves an an example of how to re-configure VR-Link to interpret FOM attributes and parameters differently. Specifically, after calling the configVrl function on a DtExerciseConn, a VR-Link-based application will assume that the "Position" atttribute of the "BaseEntity" object class (and its subclasses) should be encoded in outgoing messages and interpreted in incoming messages as three doubles in the order: Z, Y, X, rather than the standard X, Y, Z. The same will be true for the "FiringLocation" parameter of the "WeaponFire" interaction.

To demonstrate modifying the FOM to replace existing attributes or parameters, you can edit the .fed file to replace "Position" and "FiringLocation" with different attribute and parameter names, such as "ReversePosition" and "ReverseFiringLocation". If you do this, you will need to replace the names in this file as well (in the calls to addAttributeEncoder, addAttributeDecoder, addParameterEncoder and addParameterDecoder), so that the encoding and decoding functions will be associated with the correct parameter and attribute names.

This file is commented out and not part of the default f18. To add this functionality, compile with DtReverse defined.

How to Run the Example

  1. Launch 2 F18 examples from your VR-Link install's bin64 directory using the same protocol.
  2. To toggle enabling and disabling of Emitters, press the 'e' key in the F18 console application.
  3. To change emitter beam scan data for this aircraft, press the 'd' key.
  4. To toggle enabling and disabling of IFF, press the 'i' key.
  5. To toggle enabling and disabling of Lethal IFF Interrogation, press 'l' key.
  6. To send an interrogation of Mode 5, press the '5' key.
  7. To send a Lethal IFF Interaction, press the 's' key.
  8. To fire munitions at a nearby target, press the 'f' key.
  9. For usage information, press the 'h' key.
  10. To exit, press the 'q' key.
Note
To send any interrogation, the IFF System for the aircrafts must be enabled. Lethal Interrogation will only force a Mode 5 Reply, regardless of Mode 5 IsOn attribute status. Interrogations will only provide transponder information for Modes included in the interrogation whose isOn attribute is set to true.

Example Code

Main Application

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
#include "multiF18Init.h"
#include <stdlib.h>
#include <iostream>
#ifndef _WIN32
#include <sys/socket.h>
#endif
// *****************************************************************
// *************************** GLOBALS *****************************
// *****************************************************************
DtTime timeOutInterval = 12.0; // seconds
DtTime timeThreshold = 5.0; // seconds
double translationThreshold = 1.0; // meters
double rotationThreshold = DtDeg2Rad( 3.0 ); // radians
// Static functions
static int keybrdTick( );
#if VXWORKS
#define main realMain
#endif
// *****************************************************************
// *************************** MAIN *******************************
// *****************************************************************
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "Parallel-F18" );
try
{
// get the PID so we can run multiple F18's
int pid = DtGetPid();
DtString pidStr( pid );
// get the Application name
DtString appName = "VR-Link F18 " + pidStr;
DtF18Initializer initializer( argc, argv, appName);
#if DtDIS
// Set the default DIS version
initializer.setDisVersionToSend( 7 );
#else
// Set the default FED File, executable, and version
initializer.setFedFileName( DtDefaultRpr2Fom );
#endif
initializer.parseCmdLine();
initializer.setApplicationNumber( pid );
DtString defaultF18Name( initializer.f18Name() );
defaultF18Name += " " + pidStr;
initializer.setF18Name( defaultF18Name );
#ifdef DtHLA
initializer.setFederateType( "Parallel F18" );
initializer.setFederateName(defaultF18Name);
#endif
// Create an instance of our simulator
DtMultiVehicleFed simulator;
// Set up default static values
// This is the only DIS specific code in this file.
#if DtDIS
// MUST use async I/O in parallel mode for thread saftey
// Sync I/O in DIS not yet thread safe
initializer.setUseAsynchIO(true);
#endif
// Connect to the exercise or RTI
simulator.initializeExConn(DtTime(timeThreshold), &initializer);
DtExerciseConn* exConn = simulator.exerciseConn();
DtClock* clock = exConn->clock();
#ifdef DtHLA
// Let other VR-Link federates know that we are initializing
// Helps control request update calls when creating many entities
// Requests are delayed until all federates are initialized or executing
std::cout << "[" << clock->elapsedRealTime() << ", 0] Initializing" << std::endl;
exConn->setExecutionStatus(vrlstatus_initializing);
simulator.drainInput(0.1);
#endif
DtTime frameTime = initializer.deltaTime();
// initialize the fleet
simulator.initializeFleet(0, initializer.count(), &initializer);
simulator.drainInput(frameTime);
simulator.publish();
#ifdef DtHLA
// Let other VR-Link federates know that we are initialized
exConn->setExecutionStatus(vrlstatus_initialized);
simulator.drainInput(0.1);
std::cout << "[" << clock->elapsedRealTime() << ", 0] Initialized" << std::endl;
#endif
// Simulation loop
int forever = 1;
DtTime dt = frameTime;
DtTime outputTime = 0.0;
double outputInterval = initializer.outputInterval();
#ifdef DtHLA
// Let other VR-Link federates know that we are executing
std::cout << "[" << clock->elapsedRealTime() << ", 0] Executing" << std::endl;
exConn->setExecutionStatus(vrlstatus_executing);
simulator.drainInput(0.1);
#endif
// Reset elapsed time to 0 to match initial simulation time
clock->init();
unsigned long frameCount = 1;
double totalDrainDuration = 0.0;
double totalSimDuration = 0.0;
double totalPubDuration = 0.0;
double totalIdle = 0.0;
double totalFrameDuration = 0.0;
int numberFrameOverflows = 0;
double totalOverflow = 0.0;
DtTime lastTime = clock->absRealTime();
std::cout << std::fixed;
while( forever ) // to keep cfront quiet
{
DtTime idle = 0.0;
DtTime startTime = clock->absRealTime();
dt = startTime - lastTime;
simulator.setSimTime(clock->elapsedRealTime());
// process incoming data
DtTime before = clock->absRealTime();
simulator.drainInput(frameTime);
DtTime drainDuration = clock->absRealTime() - before;
totalDrainDuration += drainDuration;
if ( input.keybrdTick( ) == -1 ) break;
// Perform simulation for the current time frame
before = clock->absRealTime();
simulator.simulate();
DtTime simDuration = clock->absRealTime() - before;
totalSimDuration += simDuration;
// Publish simulation changes
before = clock->absRealTime();
simulator.publish();
DtTime pubDuration = clock->absRealTime() - before;
totalPubDuration += pubDuration;
//frameDuration = drainDuration + simDuration + pubDuration;
DtTime frameDuration = clock->absRealTime() - startTime;
totalFrameDuration += frameDuration;
if (frameDuration < frameTime)
{
idle = frameTime - frameDuration;
totalIdle += idle;
dt = frameTime;
}
else
{
dt = frameDuration;
idle = -1.0;
numberFrameOverflows++;
totalOverflow += frameDuration - frameTime;
}
if (outputInterval <= 0.0 || outputTime < startTime)
{
outputTime = clock->absRealTime() + outputInterval;
std::cout << "[" << std::setprecision(2) << simulator.simTime() << ", " << frameCount << "] #entities: " << simulator.numberRemoteEntities()
<< " total=" << std::setprecision(6) << frameDuration << "(" << totalFrameDuration / frameCount << ")"
<< " idle=" << idle << "(" << totalIdle/frameCount << ")"
<< " drain=" << drainDuration << "(" << totalDrainDuration / frameCount << ")"
<< " sim=" << simDuration << "(" << totalSimDuration / frameCount << ")"
<< " pub=" << pubDuration << "(" << totalPubDuration / frameCount << ")"
<< " #FO=" << numberFrameOverflows << "(" << (numberFrameOverflows > 0 ? totalOverflow/numberFrameOverflows : 0) << ")"
<< std::endl;
numberFrameOverflows = 0;
totalOverflow = 0.0;
}
if (idle > 0.0)
{
// wait for real time to catch up to simulated time
DtTime sleepTime = simulator.sleep(idle);
}
lastTime = startTime;
frameCount++;
}
simulator.dismantleFleet(); // Dismantle the fleet of vehicles
simulator.dismantleExConn(); // Dismantle exercise connection
}
DtCATCH_AND_WARN(std::cout);
return 0;
}

Vehicle Sim Class and subcomponents

Vehicle Sim Header

/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
#pragma once
#include <vl/topoView.h>
{
public:
DtVehicleSim( double refLat, double refLon,
const DtEntityIdentifier& id, const DtEntityType& type,
const char* name, const char* markings,
const DtDeadReckonTypes alg, bool haveArtParts,
DtTime timeSpacing);
virtual ~DtVehicleSim();
virtual void init( DtConstVector initPos, double initSpeed,
double initHeading, double initTRadius,
double initPitch, bool autoRoll, double initRoll, int num );
virtual void simulate();
virtual void fireMunition( const DtGlobalObjectDesignator& tg );
virtual void fireMunition();
virtual void detonateMunition();
virtual void munitionUpdate();
virtual void reactToDetonation();
virtual int checkDetonation();
virtual void reactToDamage();
virtual bool isDestroyed();
virtual DtTime timeDestroyed();
virtual void toggleEmissions();
virtual void enableEmissions();
virtual void disableEmissions();
virtual void emissionsUpdate();
public:
// Set the current detonation for reaction.
static void setLethalDetonationRange( double range );
static void setMunitionFlightTime( DtTime time );
// set the delta time for next simTick update
static void setSimDeltaTime(DtTime theDt) { myDt = theDt; }
protected:
// delta time for next simTick update
static DtTime myDt;
// Current detonation, if any.
protected:
virtual void moveArtParts();
protected:
float mySpeed;
float myTurnRadius;
float myTurnRate;
double myBeamTime;
float myTurretAz;
float myGunElev;
protected:
static double theLethalDetonationRange;
};

Vehicle Sim Source

/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
#include "vehicleSim.h"
#include <vlutil/vlUtil.h>
#include <vlutil/vlPrint.h>
#ifndef effZero
#define effZero 1.0E-30
#endif
// delta time for next simTick update
DtVehicleSim::DtVehicleSim( double refLat, double refLon,
const DtEntityIdentifier& id, const DtEntityType& type,
const char* name, const char* markings,
const DtDeadReckonTypes alg, bool haveArtParts,
DtObjectPublisherContainer &pubContainer, DtTime timeSpacing) :
myTimeSpacing(timeSpacing),
myPublishedObjects(pubContainer),
mySysPub( 0 )
{
myExConn = conn;
#if DtHLA
myEntityPub = new DtEntityPublisher( type, conn, name );
#elif DtDIS
myEntityPub = new DtEntityPublisher( type, conn, id );
#else
#error "Please Choose Protocol!"
#endif
// Add object to collection for later publication (in parallel)
myPublishedObjects.add(myEntityPub);
myESR = myEntityPub->entityStateRep();
myESR->setEntityType( type );
myESR->setGuise( type );
myESR->setMarkingText( markings );
myESR->setForceId( DtForceFriendly );
myESR->setAlgorithm( alg );
myESR->setEntityId( id );
myTopoView = new DtTopoView( myESR, refLat, refLon );
myRel = rel;
myFire = 0;
myDetonateTime = 0.0;
myTimeDestroyed = -1.0;
myIsDestroyed = false;
myEmissionsEnabled = false;
myHaveArtParts = haveArtParts;
}
{
}
void DtVehicleSim::init( DtConstVector initPos, double initSpeed,
double initHeading, double initTRad,
double initPitch, bool autoRoll, double initRoll, int num)
{
myPos = initPos;
mySpeed = initSpeed;
myTurnRadius = initTRad;
myTurnRate = ( ( initTRad != 0.0 ) ? ( initSpeed / initTRad ) : 0.0 );
// hack to make roll roughly proportional to turnRate for rates
// about 1/5 rad/sec
double roll = ( autoRoll ) ?
atan( 5.0 * myTurnRate ) : DtDeg2Rad( initRoll );
myEuler = DtTaitBryan( DtDeg2Rad( initHeading ),
DtDeg2Rad( initPitch ), roll );
float psi = myEuler.psi();
float cosPsi = cos( psi );
float sinPsi = sin( psi );
float phi = myEuler.phi();
float cosPhi = cos( phi );
float sinPhi = sin( phi );
myVel = DtVector32( cosPsi * mySpeed, sinPsi * mySpeed, 0.0 );
float timeOffset = (float)myTimeSpacing * (float)num;
for (int i = 0; i < 3; i++)
{
myPos[i] += myVel[i] * timeOffset;
}
// force a constant rate turn
myAccel = DtVector32( -myScalarAccel * sinPsi, myScalarAccel * cosPsi, 0.0 );
myRotRate = DtVector32( 0.0, sinPhi * myTurnRate, cosPhi * myTurnRate );
myTurretAz = 0.0;
myGunElev = 0.0;
{
DtArticulatedPart& turret = artPartList->getPart(DtPrimaryTurret1);
DtArticulatedPart& gun = artPartList->getPart(DtPrimaryGun1);
artPartList->attachPart(&gun, &turret);
}
}
{
// Update kinematic position, velocity, acceleration and orientation
double psi = DtModPerZero( ( myEuler.psi() + ( myTurnRate * myDt ) ), M_2PI );
myEuler.setPsi( psi );
for( int i=0; i<3; ++i )
{
myPos[i] += ( myVel[i] + 0.5 * myAccel[i] * myDt ) * myDt;
myVel[i] += myAccel[i] * myDt;
}
myAccel[0] = -myScalarAccel * sin( psi );
myAccel[1] = myScalarAccel * cos( psi );
myAccel[2] = 0.0;
// Simulate articulated parts, if any.
{
}
// Now that we're done simulating, tell the entity publisher
// about our current state:
// Simulate subsystems
munitionUpdate(); // Simulate munitions created by this vehicle, if any.
emissionsUpdate(); // Simulate emissions from this vehicle, if any.
}
{
DtClock* clock = myExConn->clock();
if ( clock->simTime() >= 2.0)// && clock->simTime() <= 10.0 )
{
}
else
{
}
if ( clock->simTime() >= 2.0)// && clock->simTime() <= 20.0 )
{
}
else
{
}
myGunElev = myGunElev + myGunElevRate * (float) myDt;
}
{
theDetonation = detonation;
}
{
if ( checkDetonation() )
{
}
}
{
double distance;
switch( theDetonation->result() )
{
{
{
DtInfo("Direct hit! Going down!\n");
return 1;
}
}
// fall through
{
if ( distance < theLethalDetonationRange )
{
DtInfo("Indirect hit only %s m away! Going down!\n",
DtToString(distance).c_str());
return 1;
}
else
{
return 0;
}
}
default:
{ // ignore it
return 0;
}
}
}
{
myVel = DtVector32( 0.0, 0.0, 0.0 );
myAccel = DtVector32( 0.0, 0.0, 0.0 );
myRotRate = DtVector32( 0.0, 0.0, 0.0 );
myTurnRate= 0.0;
mySpeed = 0.0;
myIsDestroyed = true;
}
{
{
DtInfo("Emissions enabled.\n");
// Create emitter system
// Add it to publications
// Attach emitter system to entity
DtVector32 vec( 6.4f, 0.0, 0.0 );
// Create beam
myBeam = mySysPub->esr()->addBeam( 1 );
#if DtHLA
// HLA Only - In DIS a beam is not a separate object and
// also an emittingSystemID would be just an integer...
#endif
myBeam->setFrequency( 8999999488.000000 );
myBeam->setERP( 70 );
myBeam->setAzimuthSweep( 0.0523599f );
myBeam->setElevationCenter( 0.349066f );
myBeam->setElevationSweep( 0.523599f );
myBeamTime = 0.0;
}
}
{
{
DtInfo("Emissions disabled.\n");
// Remove it from publications
}
}
{
{
}
else
{
}
}
{
{
// Update beam
float beamAngle = (float)cos( myBeamTime );
myBeam->setAzimuthCenter( beamAngle );
}
}
// return the vehicle that is nearest to ours
static DtReflectedEntity* nearestEntity( const DtObjectId& me,
{
DtReflectedEntity* nearest = 0;
double minDistSqr = 0.0;
// Loop through the entities in the rel
for( DtReflectedEntity* entity = rel->first();
entity;
entity = entity->next() )
{
if ( entity->id() == me ) continue;
double distSqr = DtDistSqr(
entity->entityStateRep()->location(), geocPos );
if ( distSqr < minDistSqr || !nearest )
{
nearest = entity;
minDistSqr = distSqr;
}
}
return nearest;
}
{
DtReflectedEntity* nearest = nearestEntity(
if ( nearest )
{
fireMunition( nearest->globalId() );
}
}
{
if ( myFire )
{
return;
}
myFire->setRange( 1000.0 );
myFire->setRate( 0 );
#if DtHLA
myExConn->setObjectIdForEventId( myEntityPub->globalId() );
#endif
DtSidewinder, 0, 0 ) );
DtInfo("Sending fire interaction\n");
}
{
if ( !myFire )
{
return;
}
// Sidewinder Missile
DtEntityType sidewinder(2,1,255,1,1,3,0);
det.setMunitionType(sidewinder);
det.setTargetId(myFire->targetId());
det.setVelocity( DtVector32( 0.0, 0, 0 ) );
det.setEntityLocation( DtVector32( 0.0, 0.0, 0.0 ) );
if ( ent )
{
// Get vector from fire location to detonation location
DtVector difference = myFire->location() - ent->esr()->location();
// Velocity = Distance / Time
DtVector32 velocity;
velocity.setX(difference.x() / theMunitionFlightTime);
velocity.setY(difference.y() / theMunitionFlightTime);
velocity.setZ(difference.z() / theMunitionFlightTime);
det.setVelocity(velocity);
det.setWorldLocation( ent->entityStateRep()->location() );
det.setResult( DtDetResEntityImpact );
}
else
{
// just detonate 1000 meters under us.
det.setVelocity(DtVector32(0.0, 0.0, 1000.0f / theMunitionFlightTime));
det.setWorldLocation( DtVector( myPos[0], myPos[1], myPos[2] + 1000.0 ) );
det.setResult( DtDetResDetonation );
}
DtInfo("Sending detonation interaction\n");
}
{
{
}
}
{
return myIsDestroyed;
}
{
}
{
}
{
}

Warfare Component Header

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// warfareComponent.h - handles weapon fire and detonation for DtVehicleSim
#pragma once
// Forward declarations to minimize header dependencies
{
public:
void tick();
static void theDetonationCb(DtDetonationInteraction* inter, void* self);
private:
};

Warfare Component Source

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// warfareComponent.cxx - handles weapon fire and detonation for DtVehicleSim
#include "vehicleSim.h"
#include <vlutil/vlPrint.h>
static double sLethalDetonationRange = 20.0;
static DtTime sMunitionFlightTime = 3.0;
: myOwner(owner)
, myExConn(conn)
, myRel(rel)
, myEntityPub(entPub)
, myESR(esr)
, myFire(nullptr)
, myDetonateTime(0.0)
{
}
{
// ensure cleanup
if (myFire)
{
}
}
{
if (myFire)
{
return;
}
myFire->setRange(1000.0);
#if DtHLA
myExConn->setObjectIdForEventId(myEntityPub->globalId());
#endif
DtInfo("Sending fire interaction\n");
myDetonateTime = myExConn->clock()->simTime() + sMunitionFlightTime;
}
{
reinterpret_cast<DtWarfareComponent *>(self)->processDetonation(inter);
}
{
if (!myFire)
{
return;
}
DtEntityType sidewinder(2, 1, 225, 1, 1, 3, 0);
det.setMunitionType(sidewinder);
det.setTargetId(myFire->targetId());
det.setVelocity(DtVector32(0.0, 0, 0));
det.setEntityLocation(DtVector32(0.0, 0.0, 0.0));
if (ent)
{
DtVector difference = myFire->location() - ent->esr()->location();
DtVector32 velocity;
velocity.setX(difference.x() / sMunitionFlightTime);
velocity.setY(difference.y() / sMunitionFlightTime);
velocity.setZ(difference.z() / sMunitionFlightTime);
det.setVelocity(velocity);
det.setWorldLocation(ent->entityStateRep()->location());
det.setResult(DtDetResEntityImpact);
}
else
{
det.setVelocity(DtVector32(0.0, 0.0, 1000.0f / sMunitionFlightTime));
const DtVector &pos = myOwner->position();
det.setWorldLocation(DtVector(pos[0], pos[1], pos[2] + 1000.0));
det.setResult(DtDetResDetonation);
}
DtInfo("Sending detonation interaction\n");
}
{
{
}
}
{
std::cout << "Received Detonation!" << std::endl;
if (checkDetonation(detInter))
{
}
}
{
double distance;
switch (detInter->result())
{
if (myEntityPub->globalId() == detInter->targetId())
{
DtInfo("Direct hit! Going down!\n");
return 1;
}
// fall through
{
distance = DtDistance(detInter->worldLocation(), myEntityPub->esr()->location());
if (distance < sLethalDetonationRange)
{
DtInfo("Indirect hit only %s m away! Going down!\n",
DtToString(distance).c_str());
return 1;
}
else
{
return 0;
}
}
default:
return 0;
}
}

Emitter Component Header

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// emitterComponent.h - encapsulates radar emissions for DtVehicleSim
#pragma once
// Forward declarations to avoid heavy includes in header
public:
void enable();
void disable();
void toggle();
void tick(double dt);
bool enabled() const;
protected:
static bool emitterSystemDiscoveryCondition(DtReflectedObject* refObj, void* usr);
DtString generateEmbeddedSystemName(const char* baseName);
protected:
bool myEnabled;
};

Emitter Component Source

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// emitterComponent.cxx - encapsulates radar emissions for DtVehicleSim
#include "vehicleSim.h"
#include <vlutil/vlPrint.h>
: myOwner(owner)
, myExConn(conn)
, myRel(rel)
, myESR(esr)
, myEmitterPub(nullptr)
, myBeam(nullptr)
, myRefEmitList(new DtReflectedEmitterSystemList(conn))
, myEnabled(false)
{
myRefEmitList->setDiscoveryCondition(emitterSystemDiscoveryCondition, this);
myRefEmitList->addEmitterSystemAdditionCallback(emitterSystemAdditionCallback, this);
myRefEmitList->addEmitterSystemRemovalCallback(emitterSystemRemovalCallback, this);
}
{
{
}
}
{
if (myEnabled)
{
return;
}
DtInfo("Emissions enabled.\n");
myEnabled = true;
#if DtHLA
#else
#endif
DtVector32 vec(6.4f, 0.0, 0.0);
myBeam->setFrequency(5.000000);
myBeam->setERP(70);
myBeam->setAzimuthSweep(0.0523599f);
myBeam->setBeamWidth(0.03946123);
radarBeamScanData.setCircleScanData(15.4);
myBeam->setScanData(radarBeamScanData);
}
{
if (!myEnabled)
{
return;
}
DtInfo("Emissions disabled.\n");
myEnabled = false;
myBeam = nullptr;
}
{
if (myEnabled)
{
}
else
{
enable();
}
}
void DtEmitterComponent::tick(double /*dt*/)
{
{
}
}
{
if (!myEnabled)
{
DtInfo("Enable Emitters before changing scan data!\n");
return;
}
if (!beamSR)
{
DtInfo("Cannot find RadarBeam. Enable Emitters before changing scan data!\n");
return;
}
DtRadarBeamScanDataVariantStruct scanDataVarStruct = beamSR->scanData();
switch (scanDataVarStruct.scanPatternType())
{
DtInfo("Unknown scan pattern type, setting Circle...\n");
scanDataVarStruct.setCircleScanData(15.4);
beamSR->setScanData(scanDataVarStruct);
break;
DtInfo("Circle scan pattern type, setting Sector...\n");
scanDataVarStruct.setSectorScanData(25.4);
beamSR->setScanData(scanDataVarStruct);
break;
DtInfo("Sector scan pattern type, setting Raster...\n");
scanDataVarStruct.setRasterScanData(100, 23.5);
beamSR->setScanData(scanDataVarStruct);
break;
DtInfo("Raster scan pattern type, setting Spiral...\n");
scanDataVarStruct.setSpiralScanData(32.5, 23.5);
beamSR->setScanData(scanDataVarStruct);
break;
DtInfo("Spiral scan pattern type, removing scan data...\n");
beamSR->setScanData(scanDataVarStruct);
break;
}
}
{
reinterpret_cast<DtEmitterComponent *>(usr)->onEmitterSystemUpdate(obj);
}
{
reinterpret_cast<DtEmitterComponent *>(usr)->onEmitterSystemAddition(obj);
}
{
reinterpret_cast<DtEmitterComponent *>(usr)->onEmitterSystemRemoval(obj);
}
{
return reinterpret_cast<DtEmitterComponent *>(usr)->onEmitterSystemDiscovery(dynamic_cast<DtReflectedEmitterSystem *>(refObj));
}
{
// Note: This method will be called whenever the emitter system attributes are
// reflected or any of its beam attributes are reflected.
DtInfo("Updated Emitter %s\n",
DtToString(obj->emitterSysRep()->entityId().string()).c_str());
}
{
}
{
}
{
return (refEmitter && refEmitter->emitterSysRep()->emitterFunction() != DtEmissionFuncOther &&
myRel->lookup(refEmitter->esr()->hostId()));
}
{
return myEnabled;
}
{
}

IFF Component Header

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// iffComponent.h - encapsulates IFF systems for DtVehicleSim
#pragma once
#if DtDIS
#endif
// Forward declarations to minimize header dependencies
#if DtHLA
#endif
{
public:
void enable();
void disable();
void toggle();
void tick(double dt);
void enableLethal();
void disableLethal();
void toggleLethal();
protected:
bool enabled() const { return myEnabled; }
bool lethalEnabled() const { return myLethalEnabled; }
static void theLethalInterrogationCb(DtInterrogationInteraction* inter, void* self);
static void theIffReplyCb(DtReplyInteraction* inter, void* self);
static void iffAddedCb(DtReflectedIff* obj, void* userData);
static void iffRemovedCb(DtReflectedIff* obj, void* userData);
static void printIff(DtReflectedIff* obj, void* userData);
protected:
bool myEnabled;
};

IFF Component Source

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
// iffComponent.cxx - encapsulates IFF systems for DtVehicleSim
#include "iffComponent.h"
#include "vehicleSim.h"
#include <vlutil/vlPrint.h>
#if DtHLA
#endif
#if DtDIS
#include <vl/pdu.h>
#endif
: myOwner(owner)
, myExConn(conn)
, myRel(rel)
, myESR(esr)
, myIffTransponderPub(nullptr)
, myIffInterrogatorPub(nullptr)
, myRefIffList(new DtReflectedIffList(conn))
, myEnabled(false)
, myLethalEnabled(false)
{
myRefIffList->addIffAdditionCallback(iffAddedCb, this);
myRefIffList->addIffRemovalCallback(iffRemovedCb, this);
#ifdef DtHLA
DtInterrogationInteraction::addCallback(myExConn, theLethalInterrogationCb, this);
#elif DtDIS
myExConn, theLethalInterrogationCb, DtIffInteractionTypeInterrogation, this);
#endif
}
// IFF mode codes are traditionally expressed in octal (each digit is 0-7).
// setCode() expects the binary (decimal) equivalent of those octal digits.
// Pass the octal value as a plain integer literal, e.g. iffCodeFromOctal(33)
// returns 0x1b (27 decimal), matching mode 1 code 33 octal.
static DtU16 iffCodeFromOctal(int octalDigits)
{
DtU16 result = 0;
int shift = 0;
while (octalDigits > 0)
{
result |= static_cast<DtU16>((octalDigits % 10) << shift);
octalDigits /= 10;
shift += 3;
}
return result;
}
{
}
{
if (myEnabled)
{
return;
}
DtInfo("IFF Systems enabled.\n");
myEnabled = true;
#if DtHLA
DtVector32 relPosition = DtVector32::zero();
std::vector<DtModeType> enableModes = { DtMode1, DtMode2, DtMode3A, DtMode3C, DtMode5, DtModeS };
relPosition,
enableModes,
myOwner->generateEmbeddedSystemName("IFFTransponder").c_str());
relPosition,
enableModes,
myOwner->generateEmbeddedSystemName("IFFInterrogator").c_str());
#else
myIffInterrogatorPub = new DtIffPublisher(DtIffAtcNavaidsInterrogator, myExConn);
#endif
DtIffStateRepository* iffTransponderSr = myIffTransponderPub->isr();
DtIffStateRepository* iffInterrogatorSr = myIffInterrogatorPub->isr();
#ifdef DtHLA
DtEventId transponderEventId(myIffTransponderPub->globalId(), myExConn->nextEventId().eventNum());
DtEventId interrogatorEventId(myIffInterrogatorPub->globalId(), myExConn->nextEventId().eventNum());
#elif DtDIS
DtEventId transponderEventId(
DtEventId interrogatorEventId(
#endif
iffTransponderSr->setHostId(myESR->globalId());
iffTransponderSr->setEventId(transponderEventId);
iffTransponderSr->setModeEnabled(DtMode1, true);
iffTransponderSr->setModeEnabled(DtMode2, true);
iffTransponderSr->setModeEnabled(DtMode3A, true);
iffTransponderSr->setModeEnabled(DtMode3C, true);
iffTransponderSr->setModeEnabled(DtMode5, true);
iffTransponderSr->setModeEnabled(DtModeS, true);
iffTransponderSr->setSystemIsOperational(true);
iffTransponderSr->setSystemIsOn(true);
iffTransponderSr->setSystemName(DtIffAtcNavaidsMarkX);
iffTransponderSr->setSystemDesignator(5);
#if DtDIS
// Populate a concrete Layer 3 IFFData variable record so packet captures
// do not report the default "Other/0" system name for antenna location.
iffTransponderSr->setLayer3DataAvailable(true);
DtIffAntennaLocationRecord transponderAntennaRecord;
transponderAntennaRecord.setSystemName(iffTransponderSr->systemName());
transponderAntennaRecord.setAntennaReferenceNumber(1);
transponderAntennaRecord.setAntennaStatus(DtAntennaStatusAbleToEmit);
iffTransponderSr->setNumIffRecords(1, 3);
iffTransponderSr->setIffRecord(0, transponderAntennaRecord, 3);
#endif
// Mode 1
// iffTransponderSr->mode1()->setCode(0x1b); // octal: 33
iffTransponderSr->mode1()->setCode(iffCodeFromOctal(33)); // octal: 33
iffTransponderSr->mode1()->setIsOn(true);
iffTransponderSr->mode1()->setIsDamaged(true);
iffTransponderSr->mode1()->setIsMalfunctioning(false);
iffTransponderSr->mode1()->setExtendedCodeIsSet(true);
// Mode 2
// iffTransponderSr->mode2()->setCode(0x2bb); // octal: 1273
iffTransponderSr->mode2()->setCode(iffCodeFromOctal(1273)); // octal: 1273
iffTransponderSr->mode2()->setIsOn(true);
iffTransponderSr->mode2()->setIsDamaged(false);
iffTransponderSr->mode2()->setIsMalfunctioning(true);
// Mode 3A
// iffTransponderSr->mode3A()->setCode(0xfca); // octal: 7712
iffTransponderSr->mode3A()->setCode(iffCodeFromOctal(7712)); // octal: 7712
iffTransponderSr->mode3A()->setIsOn(true);
iffTransponderSr->mode3A()->setIsDamaged(false);
iffTransponderSr->mode3A()->setIsMalfunctioning(true);
// Mode 3C
iffTransponderSr->mode3C()->setIsOn(true);
iffTransponderSr->mode3C()->setIsDamaged(true);
iffTransponderSr->mode3C()->setIsMalfunctioning(false);
iffTransponderSr->mode3C()->setAltitudeAvailable(true);
iffTransponderSr->mode3C()->setAltitude(33);
// Mode 5
iffTransponderSr->mode5()->setIsOn(false);
iffTransponderSr->mode5()->setIsDamaged(true);
iffTransponderSr->mode5()->setIsMalfunctioning(true);
iffTransponderSr->mode5()->setPseudoCryptoCode(4093);
iffTransponderSr->mode5()->setPseudoCryptoCodeAvailable(true);
msgFormats.setMessageFormat0Included(true);
msgFormats.setMessageFormat10Included(true);
msgFormats.setMessageFormat12Included(true);
iffTransponderSr->mode5()->setMessageFormatsCapable(msgFormats);
iffTransponderSr->mode5()->setSpecificInformation(
iffTransponderSr->mode5()->setReply(DtMode5ReplyEnum8_Valid);
iffTransponderSr->mode5()->setSquitterIsOn(true);
iffTransponderSr->mode5()->setPin(377);
iffTransponderSr->mode5()->setNationalOrigin(0);
iffTransponderSr->mode5()->setFigureOfMerit(255);
iffTransponderSr->mode5()->setLineTestIsEnabled(true);
iffTransponderSr->mode5()->setLocationDataIsPresent(true);
iffTransponderSr->mode5()->setLocationErrorDataIsPresent(true);
// Mode 5 layer 3 - Enhanced Mode 1 attributes
iffTransponderSr->mode5()->setEnhancedMode1Code1(1);
iffTransponderSr->mode5()->setEnhancedMode1Code2(2);
iffTransponderSr->mode5()->setEnhancedMode1Code3(3);
iffTransponderSr->mode5()->setEnhancedMode1Code4(4);
iffTransponderSr->mode5()->setEnhancedMode1On(true);
iffTransponderSr->mode5()->setEnhancedMode1DamageStatus(false);
iffTransponderSr->mode5()->setEnhancedMode1MalfunctionStatus(false);
// Mode 5 layer 3 - Crypto Control IFF Data Record
iffTransponderSr->mode5()->setCryptoControlDataIsPresent(true);
// Mode S
iffTransponderSr->modeS()->setIsOn(true);
iffTransponderSr->modeS()->setIsDamaged(true);
iffTransponderSr->modeS()->setIsMalfunctioning(true);
levelsPresent.setLevel1IsPresent(true);
levelsPresent.setLevel4IsPresent(true);
iffTransponderSr->modeS()->setLevelsPresent(levelsPresent);
iffTransponderSr->modeS()->setSpecificInformation(
iffTransponderSr->modeS()->setAircraftAddress(11305708);
const DtU8 aircraftId[8] = {'A', 'A', 'L', '2', '6', '9', '3', 0};
iffTransponderSr->modeS()->setAircraftIdentification(aircraftId);
iffTransponderSr->modeS()->setSquitterIsOn(true);
iffTransponderSr->modeS()->setAltitudeAvailable(true);
iffTransponderSr->modeS()->setAirbornePositionReportDataIsPresent(true);
iffTransponderSr->modeS()->setAirborneVelocityReportDataIsPresent(true);
iffTransponderSr->modeS()->setSurfacePositionReportDataIsPresent(true);
iffTransponderSr->modeS()->setIdentificationReportDataIsPresent(true);
iffTransponderSr->modeS()->setEventDrivenReportDataIsPresent(true);
dapSource.setMachNumberDataIsPresent(true);
dapSource.setGroundSpeedDataIsPresent(false);
dapSource.setTrueAirspeedDataIsPresent(false);
iffTransponderSr->modeS()->setDAPSource(dapSource);
iffTransponderSr->modeS()->setLocationErrorDataIsPresent(true);
iffInterrogatorSr->setHostId(myESR->globalId());
iffInterrogatorSr->setEventId(interrogatorEventId);
iffInterrogatorSr->setModeEnabled(DtMode1, true);
iffInterrogatorSr->setModeEnabled(DtMode2, true);
iffInterrogatorSr->setModeEnabled(DtMode3A, true);
iffInterrogatorSr->setModeEnabled(DtMode3C, true);
iffInterrogatorSr->setModeEnabled(DtMode5, true);
iffInterrogatorSr->setModeEnabled(DtModeS, true);
iffInterrogatorSr->setSystemIsOperational(true);
iffInterrogatorSr->setSystemIsOn(true);
iffInterrogatorSr->setSystemName(DtIffAtcNavaidsMarkX);
iffInterrogatorSr->setSystemDesignator(7);
#if DtDIS
iffInterrogatorSr->setLayer3DataAvailable(true);
DtIffAntennaLocationRecord interrogatorAntennaRecord;
interrogatorAntennaRecord.setSystemName(iffInterrogatorSr->systemName());
interrogatorAntennaRecord.setAntennaReferenceNumber(1);
interrogatorAntennaRecord.setAntennaStatus(DtAntennaStatusAbleToEmit);
iffInterrogatorSr->setNumIffRecords(1, 3);
iffInterrogatorSr->setIffRecord(0, interrogatorAntennaRecord, 3);
#endif
}
{
if (!myEnabled)
{
return;
}
DtInfo("IFF System disabled.\n");
myEnabled = false;
DtDELETE(myIffTransponderPub);
DtDELETE(myIffInterrogatorPub);
}
{
if (myEnabled)
{
}
else
{
enable();
}
}
void DtIffComponent::tick(double /*dt*/)
{
{
myIffInterrogatorPub->tick();
myIffTransponderPub->tick();
}
}
{
{
return;
}
DtInfo("Lethal IFF Interrogation enabled.\n");
if (myIffTransponderPub == nullptr)
{
#if DtHLA
DtVector32 relPosition = DtVector32::zero();
std::vector<DtModeType> enableModes = {DtMode5};
myESR->entityId(), relPosition, enableModes, myOwner->generateEmbeddedSystemName("IFFTransponder").c_str());
#else
myIffTransponderPub = new DtIffPublisher(DtIffAtcNavaidsTransponder, myExConn);
#endif
}
if (myIffInterrogatorPub == nullptr)
{
#if DtHLA
DtVector32 relPosition = DtVector32::zero();
std::vector<DtModeType> enableModes = {DtMode5};
myESR->entityId(), relPosition, enableModes, myOwner->generateEmbeddedSystemName("IFFInterrogator").c_str());
#else
myIffInterrogatorPub = new DtIffPublisher(DtIffAtcNavaidsInterrogator, myExConn);
#endif
}
}
{
if (!myIffTransponderPub || !myIffInterrogatorPub)
{
DtWarn("IFF System is not enabled; enter 'i' to enable IFF system .\n");
return;
}
{
DtWarn("Reflected IFF System is not enabled; enable IFF system in other console.\n");
return;
}
{
return;
}
DtIffStateRepository* iffInterrogatorSr = myIffInterrogatorPub->isr();
// Send a Mode 5 Interrogation Interaction.
DtInterrogationInteraction interrogationInteraction;
DtGlobalObjectDesignator interrogatingObjId = myIffInterrogatorPub->globalId();
#ifdef DtHLA
DtEventId interactiveEventId(interrogatingObjId, myExConn->nextEventId().eventNum());
interrogationInteraction.setDataCommunicationsSpecificInformation(
interrogationInteraction.setIFFSystemIdentifier(iffInterrogatorSr->systemId());
#elif DtDIS
interrogationInteraction.setEventId(myExConn->nextEventId());
DtIffAtcNavaidsSystemID sysId(iffInterrogatorSr->systemType(), iffInterrogatorSr->systemName(),
(DtIffAtcNavaidsSysMode)iffInterrogatorSr->systemMode());
interrogationInteraction.setSystemID(sysId);
interrogationInteraction.setEmittingEntityID(myIffInterrogatorPub->globalId());
operat.setSystemStatus(87); // i.e. 01010111
operat.setInformationLayers(40); // i.e. 00101000
interrogationInteraction.setOperational(operat);
#endif
interModes.setModesIncluded(false, false, false, false, true, false, false, false, false, false);
interrogationInteraction.setInterrogatedModes(interModes);
interrogationInteraction.setInterrogatingId(interrogatingObjId);
interrogationInteraction.setInteractiveEventId(interactiveEventId);
interrogationInteraction.setInterrogatedId(interrogatedObjId);
interrogationInteraction.setLethal(false);
myExConn->sendStamped(interrogationInteraction);
myIffInterrogatorPub->tick();
myIffTransponderPub->tick();
DtInfo("Sending non-lethal mode 5 interrogation interaction: \n");
interrogationInteraction.printData();
DtInfo(" \n ********************************************************* \n ");
}
{
{
DtInfo("Lethal IFF Interrogation disabled.\n");
myLethalEnabled = false;
}
}
{
{
}
else
{
}
}
{
{
DtWarn("Toggle Lethal Interrogation before attempting to send a lethal interaction.\n");
return;
}
if (!myIffTransponderPub || !myIffInterrogatorPub)
{
}
DtInterrogationInteraction interrogationInteraction;
DtEventId interactiveEventId = DtEventId();
DtGlobalObjectDesignator emittingEntityId = myIffInterrogatorPub->globalId();
DtGlobalObjectDesignator interrogatingObjId = myIffInterrogatorPub->globalId();
DtGlobalObjectDesignator interrogatedObjId;
{
DtWarn("No Reflected IFF System found; enable IFF system in other console.\n");
return;
}
else
{
interrogatedObjId = myRefIffList->first()->globalId();
}
DtIffStateRepository* iffInterrogatorSr = myIffInterrogatorPub->isr();
#ifdef DtHLA
interrogationInteraction.setDataCommunicationsSpecificInformation(
interrogationInteraction.setIFFSystemIdentifier(iffInterrogatorSr->systemId());
interactiveEventId.setEventNum(myExConn->nextEventId().eventNum());
interactiveEventId.setGlobalId(interrogatingObjId);
#elif DtDIS
interrogationInteraction.setEventId(myExConn->nextEventId());
DtIffAtcNavaidsSystemID sysId(iffInterrogatorSr->systemType(), iffInterrogatorSr->systemName(),
(DtIffAtcNavaidsSysMode)iffInterrogatorSr->systemMode());
interrogationInteraction.setSystemID(sysId);
interrogationInteraction.setEmittingEntityID(emittingEntityId);
operat.setSystemStatus(87);
interrogationInteraction.setOperational(operat);
#endif
interModes.setModesIncluded(true, true, true, false, true, true, false, false, false, false);
interrogationInteraction.setInterrogatedModes(interModes);
interrogationInteraction.setInterrogatingId(interrogatingObjId);
interrogationInteraction.setInteractiveEventId(interactiveEventId);
interrogationInteraction.setInterrogatedId(interrogatedObjId);
interrogationInteraction.setLethal(true);
myExConn->sendStamped(interrogationInteraction);
myIffInterrogatorPub->tick();
myIffTransponderPub->tick();
DtInfo("Sending lethal interrogation interaction: \n");
interrogationInteraction.printData();
}
{
#ifdef DtDIS
{
return;
}
#endif
DtIffStateRepository* iffTransponderSr = myIffTransponderPub ? myIffTransponderPub->isr() : nullptr;
if (inter->isLethal())
{
DtInfo("\n*********************************************************\n");
DtInfo("Received lethal interrogation interaction!\n");
inter->printData();
if (myIffTransponderPub == nullptr)
{
}
DtReplyInteraction replyInteraction;
replyInteraction.setInterrogatedModes(inter->interrogatedModesStruct());
#ifdef DtHLA
replyInteraction.setDataCommunicationsSpecificInformation(
replyInteraction.setIFFSystemIdentifier(iffTransponderSr->systemId());
#elif DtDIS
replyInteraction.setEventId(myExConn->nextEventId());
replyInteraction.setEmittingEntityID(myIffTransponderPub->globalId());
sysId.setSystemType(iffTransponderSr->systemType());
sysId.setSystemName(iffTransponderSr->systemName());
sysId.setSystemMode((DtIffAtcNavaidsSysMode)iffTransponderSr->systemMode());
replyInteraction.setSystemID(sysId);
#endif
replyInteraction.setInterrogatingId(inter->interrogatingId());
replyInteraction.setInteractiveEventId(inter->interactiveEventId());
replyInteraction.setInterrogatedId(inter->interrogatedId());
replyInteraction.setLethal(inter->isLethal());
myExConn->sendStamped(replyInteraction);
if (myIffTransponderPub)
{
myIffTransponderPub->tick();
}
if (myIffInterrogatorPub)
{
myIffInterrogatorPub->tick();
}
DtInfo << "\n********************************************************* \n ";
DtInfo << "Sending lethal reply interaction: " << std::endl;
replyInteraction.printData();
DtInfo << "\n********************************************************* \n ";
}
else
{
DtInfo("\n*********************************************************\n");
DtInfo("Received non-lethal interrogation interaction!\n");
inter->printData();
if (!myIffTransponderPub)
{
DtWarn("No IFF Systems active; enable IFF Systems.\n");
}
else
{
DtReplyInteraction replyInteraction;
replyInteraction.setInterrogatedModes(inter->interrogatedModesStruct());
#ifdef DtHLA
replyInteraction.setDataCommunicationsSpecificInformation(
replyInteraction.setIFFSystemIdentifier(iffTransponderSr->systemId());
#elif DtDIS
replyInteraction.setEventId(myExConn->nextEventId());
replyInteraction.setEmittingEntityID(myIffTransponderPub->globalId());
sysId.setSystemType(iffTransponderSr->systemType());
sysId.setSystemName(iffTransponderSr->systemName());
sysId.setSystemMode((DtIffAtcNavaidsSysMode)iffTransponderSr->systemMode());
replyInteraction.setSystemID(sysId);
replyInteraction.setOperational(inter->operational());
#endif
replyInteraction.setInterrogatingId(inter->interrogatingId());
replyInteraction.setInteractiveEventId(inter->interactiveEventId());
replyInteraction.setInterrogatedId(inter->interrogatedId());
replyInteraction.setLethal(inter->isLethal());
myExConn->sendStamped(replyInteraction);
myIffTransponderPub->tick();
myIffInterrogatorPub->tick();
DtInfo << "Sending non-lethal reply interaction: " << std::endl;
replyInteraction.printData();
}
}
}
{
#ifdef DtDIS
{
return;
}
#endif
DtInfo("\n*********************************************************\n");
DtInfo("%s\n", DtToString((inter->isLethal() ? "Received reply to lethal interrogation interaction!"
: "Received reply to non-lethal interrogation interaction!"))
.c_str());
inter->printData();
if (refIffObj == nullptr)
{
DtWarn("No Reflected IFF Object found.\n");
}
else
{
DtIffStateRepository* iffTransponderSr = refIffObj->isr();
if (interModes.mode1Included() && iffTransponderSr->mode1() && iffTransponderSr->mode1()->isOn())
{
iffTransponderSr->mode1()->printData();
}
if (interModes.mode2Included() && iffTransponderSr->mode2() && iffTransponderSr->mode2()->isOn())
{
iffTransponderSr->mode2()->printData();
}
if (interModes.mode3AIncluded() && iffTransponderSr->mode3A() && iffTransponderSr->mode3A()->isOn())
{
iffTransponderSr->mode3A()->printData();
}
if (interModes.modeCIncluded() && iffTransponderSr->mode3C() && iffTransponderSr->mode3C()->isOn())
{
iffTransponderSr->mode3C()->printData();
}
if (interModes.mode4Included() && iffTransponderSr->mode4() && iffTransponderSr->mode4()->isOn())
{
iffTransponderSr->mode4()->printData();
}
if (interModes.mode5Included() && iffTransponderSr->mode5())
{
if (iffTransponderSr->mode5()->isOn() || inter->isLethal())
{
iffTransponderSr->mode5()->printData();
}
else
{
DtInfo("Mode 5 is OFF, but was not interrogated using lethal mode. No reply.\n");
}
}
if (interModes.modeSIncluded() && iffTransponderSr->modeS() && iffTransponderSr->modeS()->isOn())
{
iffTransponderSr->modeS()->printData();
}
}
}
{
((DtIffComponent*)vehicle)->processLethalInterrogation(inter);
}
{
((DtIffComponent*)vehicle)->processInterrogationReply(inter);
}
// A callback for when a new DtReflectedEnvironmentProcess object is added.
void DtIffComponent::iffAddedCb(DtReflectedIff* obj, void* userData)
{
DtInfo("*** Discovered %s\n", DtToString(obj->globalId()).c_str());
// register a callback for when an existing object is updated.
}
// A callback for when a new DtReflectedEnvironmentProcess object is added.
void DtIffComponent::iffRemovedCb(DtReflectedIff* obj, void* userData)
{
DtInfo("*** Removed %s\n", DtToString(obj->globalId()).c_str());
}
// A callback for when a IFF object is updated.
void DtIffComponent::printIff(DtReflectedIff* obj, void* userData)
{
// DtInfo << "*** Updated " << obj->globalId() << std::endl;
// obj->isr()->printData();
}

F18 Initializer Class

F18 Initializer Header

/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
#pragma once
{
public:
DtF18Initializer(int argc, char* argv[], DtString AppName, DtString filepath = DtDefaultConfigFile);
virtual ~DtF18Initializer();
private:
public:
virtual void parseCmdLine() override;
virtual void setInitialPosition(const DtVector& loc);
virtual DtVector initialPosition() const;
virtual void setLispFileName(const DtString& name);
virtual DtString lispFileName() const;
virtual void setDeadReckonAlgorithm(unsigned long alg);
virtual unsigned long deadReckonAlgorithm() const;
virtual void setInitialTurnRadius(double radius);
virtual double initialTurnRadius() const;
virtual void setInitialSpeed(double speed);
virtual double initialSpeed() const;
virtual void setEntityTypeStr(const DtString& type);
virtual DtString entityTypeStr() const;
virtual void setF18Markings(const DtString& markings);
virtual DtString f18Markings() const;
virtual void setF18Name(const DtString& name);
virtual DtString f18Name() const;
virtual void setDestroyedToFinalDelay(double delay);
virtual double destroyedToFinalDelay() const;
virtual void setInitialHeading(double heading);
virtual double initialHeading() const;
virtual void setLethalDetonationRange(double range);
virtual double lethalDetonationRange() const;
virtual void setMunitionFlightTime(double time);
virtual double munitionFlightTime() const;
virtual void setInitialPitch(double pitch);
virtual double initialPitch() const;
virtual void setInitialRoll(double roll);
virtual double initialRoll() const;
virtual void setAutoRoll(bool onOff);
virtual bool autoRoll() const;
virtual void setEntityNumber(int number);
virtual int entityNumber() const;
virtual void setHaveArtParts(bool onOff);
virtual bool haveArtParts() const;
virtual void setDeltaTime(DtTime time);
virtual DtTime deltaTime() const;
virtual void setRefLatitude(double lat);
virtual double refLatitude() const;
virtual void setRefLongitude(double lon);
virtual double refLongitude() const;
protected:
virtual void initializeMtlParams() override;
virtual void loadMtlFile(const DtString& fileName) override;
protected:
};

F18 Initializer Source

/****************************************************************************
* Copyright (c) 1992-2026 MAK Technologies, Inc
* All rights reserved.
****************************************************************************/
#include "f18Init.h"
#include <vlpi/disEnums.h>
#include <stdio.h>
// Constructor -- Initialize the base class (will initialize protocol-specific
// parameters), command line arguments and mtl parameters
DtF18Initializer::DtF18Initializer( int argc, char* argv[], DtString appName, DtString filepath)
: DtVrlApplicationInitializer( argc, argv, appName, filepath)
, myInitialPosition(settings(), "initialPosition", DtVector(0.0, 0.0, -1230.0),
"Initial Location", DtBaseConfigVariable::DtScopeBoth, false, "L" )
, myLispFileName(settings(), "&lispFile", "f18.xml", "LISP File Name" )
, myDeadReckonAlgorithm(settings(), "deadReckonAlgorithm", DtDrDrmRvw, "Dead Reckon Algorithm",
DtBaseConfigVariable::DtScopeBoth, false, "D" )
, myInitialTurnRadius(settings(), "initialTRadius", -250.0, "Initial Turn Radius",
DtBaseConfigVariable::DtScopeBoth, false, "r" )
, myInitialSpeed(settings(), "initialSpeed", 40.0, "Initial Speed" )
, myEntityTypeString(settings(), "entity&TypeStr", "1:2:225:1:9:0:0", "Entity Type String" )
, myMarkings(settings(), "f18&Markings", "MAK-VRLink-F18", "F18 Markings" )
, myName(settings(), "f18Name", "MAK-F18", "F18 Object Name" )
, myDestroyedToFinalDelay(settings(), "&destroyedToFinalDelay", 20.0,
"Destroyed To Final Delay" )
, myInitialHeading(settings(), "initial&Heading", 180.0, "Initial Heading" )
, myTopoOrigin(settings(), "topo&Origin", "35.699760,-121.326577",
"Topographic Coordinate System Origin" )
, myWorldPosition( settings(), "worldPos", DtVector(0.0,0.0,0.0),
"Initial Position in Geocentric Coordinates", DtBaseConfigVariable::DtScopeBoth, false, "W" )
, myLethalDetonationRange( settings(), "lethalDetonationRange", 20.0, "Lethal Detonation Range",
DtBaseConfigVariable::DtScopeConfigFile )
, myMunitionFlightTime( settings(), "munitionFlightTime", 3.0, "Munition Flight Time",
DtBaseConfigVariable::DtScopeConfigFile )
, myInitialPitch( settings(), "initialPitch", 0.0, "Initial Pitch",
DtBaseConfigVariable::DtScopeConfigFile )
, myInitialRoll( settings(), "initialRoll", 0.0, "Initial Roll",
DtBaseConfigVariable::DtScopeConfigFile )
, myAutoRoll( settings(), "autoRoll", true, "Auto Roll",
DtBaseConfigVariable::DtScopeConfigFile )
, myEntityNumber( settings(), "entNum", 1, "Entity Number",
DtBaseConfigVariable::DtScopeConfigFile )
, myHaveArtParts( settings(), "haveArtParts", false, "Have Articulated Parts",
DtBaseConfigVariable::DtScopeConfigFile )
, myRefLatitude( settings(), "refLatitude", 35.699760, "Reference Latitude",
DtBaseConfigVariable::DtScopeConfigFile )
, myRefLongitude( settings(), "refLongitude", -121.326577, "Reference Longitude",
DtBaseConfigVariable::DtScopeConfigFile )
, myDeltaTime( settings(), "deltaTime", 0.05, "Delta Time",
DtBaseConfigVariable::DtScopeConfigFile )
, myMtlAutoRoll( 1 )
, myMtlHaveArtParts( 0 )
, myMtlInitialPosition( 0.0, 0.0, -1230.0 )
{
settings().setChangeOnce(true);
}
{
}
{
myMtlEnv->registerVar( "haveArtParts", &myMtlHaveArtParts );
myMtlEnv->registerVar( "initialPos[0]", &myMtlInitialPosition[0] );
myMtlEnv->registerVar( "initialPos[1]", &myMtlInitialPosition[1] );
myMtlEnv->registerVar( "initialPos[2]", &myMtlInitialPosition[2] );
}
{
}
// Parses the command line
{
// Note that we're manually parsing the command line here in order to
// see whether a file has been specified. This is due to the support of
// MTL files. If the command line is parsed, and then an MTL file is loaded,
// the command line values will be overridden. This is not the case with XML.
// As long as "changeOnce" is set to true on the application settings object,
// values can only be changed once. In other words, if the command line is parsed,
// and values are set, and a file is then loaded, the values set by the command
// line will not be overridden. This is not the case with MTL yet.
for ( int index = 1; index < myArgc; ++index )
{
if ( ! strcmp(myArgv[index],"-l") || ! strcmp(myArgv[index],"--lispFile") )
{
if ( index + 1 < myArgc )
{
break;
}
}
}
if ( myInitialPosition.isSet() )
{
// NOTE: only -L specifies X, Y, and -Z (north, east, and up)
// All local positions are north, east, down [not up]
DtVector posVec = myInitialPosition.value();
posVec[2] = -posVec[2];
myInitialPosition.setValue( posVec );
}
{
double refLat = myRefLatitude.defaultValue();
double refLon = myRefLongitude.defaultValue();
int numReads = sscanf( myTopoOrigin.value().c_str(), "%lf,%lf", &refLat, &refLon );
if ( numReads > 0 )
{
if ( numReads > 1 )
{
}
}
}
if ( myWorldPosition.isSet() )
{
DtGeodeticCoord initPos;
initPos.setGeocentric( myWorldPosition.value() );
}
}
//--------------------------------------------------------------
// ACCESSORS/MODIFIERS
// Provide a way to inspect/modify the data
//--------------------------------------------------------------
{
myInitialPosition.setValue( loc );
}
{
return myInitialPosition.value();
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
myMarkings.setValue( markings );
}
{
return myMarkings.value();
}
{
myName.setValue( name );
}
{
return myName.value();
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
return myInitialRoll.value();
}
{
myAutoRoll.setValue( onOff );
}
{
return myAutoRoll.value();
}
{
}
{
}
{
}
{
return myRefLatitude.value();
}
{
}
{
}
{
}
{
}
{
}
{
return myDeltaTime.value();
}

F18 Config Example Code

/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
#if DtHLA
#if DtReverse
#include <vl/fomMapper.h>
// Encoder function to be used for the "Position" attribute.
void DtPosEncoder( const DtEntityStateRepository& stateRep,
RTI::AttributeHandleValuePairSet* avList,
RTI::AttributeHandle handle )
{
DtVector loc = stateRep.location();
DtNet64Vector netVal( loc[2], loc[1], loc[0] );
avList->add( handle, (char*)&netVal, sizeof( DtNet64Vector ) );
}
// Decoder function to be used for the "Position" attribute.
void DtPosDecoder( DtEntityStateRepository* stateRep,
const RTI::AttributeHandleValuePairSet& avlist,
int pairSetIndex )
{
DtNet64Vector netVal;
RTI::ULong length = 0;
avlist.getValue( pairSetIndex, (char*)&netVal, length );
stateRep->setLocation( DtVector( netVal[2], netVal[1], netVal[0] ) );
}
// Encoder function to be used for the "FiringLocation" parameter.
void DtFirePosEncoder( const DtFireInteraction& fire,
RTI::ParameterHandleValuePairSet* pvList,
RTI::ParameterHandle handle )
{
DtVector loc = fire.location();
DtNet64Vector netVal( loc[2], loc[1], loc[0]);
pvList->add( handle, (char*)&netVal, sizeof( DtNet64Vector ) );
}
// Decoder function to be used for the "FiringLocation" parameter.
void DtFirePosDecoder( DtFireInteraction* fire,
const RTI::ParameterHandleValuePairSet& pvlist,
int pairSetIndex )
{
DtNet64Vector netVal;
RTI::ULong length = 0;
pvlist.getValue( pairSetIndex, (char*)&netVal, length );
fire->setLocation( DtVector( netVal[2], netVal[1], netVal[0] ) );
}
// configVrl tells the DtExerciseConn's DtFomMapper that the functions
// defined above should be used in place of the default encoding
// and decoding functions for the specified attributes and parameters.
void configVrl( DtExerciseConn* exConn )
{
exConn->fomMapper()->stateEncoderFactory()->
addAttributeEncoder( "BaseEntity", "Position",
(DtHlaStateEncoder::DtAttributeEncoder)DtPosEncoder );
exConn->fomMapper()->stateDecoderFactory()->
addAttributeDecoder( "BaseEntity", "Position",
(DtHlaStateDecoder::DtAttributeDecoder)DtPosDecoder );
exConn->fomMapper()->interactionEncoderFactory()->
addParameterEncoder( "WeaponFire", "FiringLocation",
(DtInteractionEncoder::DtParameterEncoder)DtFirePosEncoder );
exConn->fomMapper()->interactionDecoderFactory()->
addParameterDecoder( "WeaponFire", "FiringLocation",
(DtInteractionDecoder::DtParameterDecoder)DtFirePosDecoder );
}
#endif // DtReverse
#endif // DtHLA

Document ID: Generated on Mon Sep 28 00:09:32 EDT 2026 from SVN revision 295353
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)