VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sensor Component

This subclass of DtSimComponent will check to see if there are any emitter systems in the area that could sense a fixed wing.


VR-Forces provides a component class, DtSimComponent (simCmpnt.h), so we can derive our radar sensor from this component. Anytime you create a new component, you have to provide the following member items in your new class:

The string returned by the type() function is the key into the component factory that VR-Forces uses to instantiate new components. See compTypes.h for the set of string types for VR-Forces component classes.
Implementing the Radar Warning Receiver Class
The radar warning receiver class, DtSimpleRadarWarningReceiver (simpleRadarWarnRx.h), needs to detect the emissions and notify any interested controllers that it has detected one or more radars. In this example it merely checks for anything sending out emissions within a 5 Km radius. The class has a VR-Link DtReflectedEmitterSystem- List data member, myReflectedEmitterList, which it uses to gain knowledge of all entities generating emission PDUs over the network.
If it finds any, it extracts the host ID of the emitter and places that host ID on an emitter list port. The radar warning receiver uses the existing DtEntityListOutputPort class to communicate the identity of the set of radars it has detected in the current tick. It will ultimately be connected to the radar warning response controller that will receive the data on the emitter list port (a list of detected radars) and use that information to drive its behavior.
Adding a Sensor Component
As a provider of data (the list of detected emitters), the DtSimpleRadarWarningReceiver has a DtEntityListPort data member, myEmitterListPort. It is responsible for creating and setting values on the port. Each tick, it does the following:

void DtSimpleRadarWarningReceiver::tick()
{
   if(!entity())
   {
      return;
   }
   if(!myEmitterListPort)
   {
      return;
   }
   if (myEmitterListPort->attemptToActivate())
   {
      myEmitterListPort->emptyList();
      DtReflectedEmitterSystem* emitterSystem;
      for(emitterSystem = myReflectedEmitterList->first(); emitterSystem;
            emitterSystem = emitterSystem->next())
      {
         DtGlobalObjectDesignator emitterSystemHostId =
              emitterSystem->emitterSysRep()->hostId();
         if(emitterSystemHostId == myGlobalId)
         {
            continue;
         }
         DtVrfObject* emitterEntity = mySimManager->vrfObjectManager()->
                 lookupVrfObjectByGlobalId(emitterSystemHostId);
         if(!emitterEntity)
         {
            continue;
         }
         DtListItem beamItem = emitterSystem->emitterSysRep()->
                   beamList()->first();
         DtEmitterBeamRepository *beamSR = NULL;
         bool found = false;
         while (beamItem && !found)
         {
            beamSR = (DtEmitterBeamRepository) beamItem->data();
            if (beamSR->ERP() > 0)
            {
               double rangeSquaredToEmitter = DtDistSqr(
                    entity()->vrfState()->localPosition(),
                    emitterEntity->vrfState()->localPosition());
               if(rangeSquaredToEmitter < 25000000.0)
               {
                  myEmitterListPort->addEntity(emitterEntity->objectIdentifier());
                  found = true;
               }
            }
            beamItem = beamItem->next();
         }
      }
   }
}


Header file:


Implementation:


Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)