VR-Forces 4.1.1 Class Documentation
Air Vehicle Set Controller

This subclass of the DtAirVehicleSetController registers for the new DtSetSpeedAndHeadingRequest and sets the appropriate values into the VRF state repository.


Header file:

/*******************************************************************************
** Copyright (c) 2006 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: myAirVehSetCtlr.h,v $ $Revision: 1.2 $ $State: Exp $
*******************************************************************************/

//\file myAirVehSetCtlr.h
//\brief MyAirVehicleSetController; handles new DtSetSpeedAndHeadingRequest


#ifndef MyAirVehicleSetController_H_
#define MyAirVehicleSetController_H_


#include "vrfmodel/airVehSetCtlr.h"
#include "vrfobjcore/simRadio.h"

namespace vrfAddSetExample
{

   //\brief MyAirVehicleSetController is a controller that handles new
   //DtSetSpeedAndHeadingRequest.  It replaces the existing DtAirVehicleSetController
   //
   //Uses Descriptor Type: DtComponentDescriptor

   class MyAirVehicleSetController : public DtAirVehicleSetController
   {

   public:

      //\copydoc DtSimComponent(const DtString&,DtVrfObject*,DtSimManager*,
      //DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
   MyAirVehicleSetController(const DtString& name, 
      DtVrfObject* owner,
      DtSimManager* simManager, 
      DtComponentDescriptor* desc = 0,
      DtReaderWriterRegistry* parentRegistry = 0);

      //destructor
   virtual ~MyAirVehicleSetController();

   virtual void processSetSpeedAndHeading(DtSimMessage * msg);

   static void setSpeedAndHeadingCallback(DtSimMessage * msg, void * usrData);

      //\copydoc DtSimComponent(const DtString&,DtVrfObject*,DtSimManager*,
      //DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
      //\return New instance of this class.
   static DtSimComponent * creator(const DtString& name, 
      DtVrfObject* owner,
      DtSimManager* simManager, 
      DtComponentDescriptor* desc = 0,
      DtReaderWriterRegistry* parentRegistry = 0);

   private:
      //Default constructor; should not be called.  Here because the compiler
      //will generate an unprotected one otherwise.
   MyAirVehicleSetController();

      //copy constructor
   MyAirVehicleSetController(const MyAirVehicleSetController& orig);

      //assignment operator
   const MyAirVehicleSetController & operator=(const 
      MyAirVehicleSetController& orig);


   protected:
      //Overrides this so it can register its interest in the set commands.
   virtual void setRadio(DtSimRadio * radio);
   };
}
#endif


Implementation:

/*******************************************************************************
** Copyright (c) 2006 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: myAirVehSetCtlr.cxx,v $ $Revision: 1.1 $ $State: Exp $
*******************************************************************************/

//
//File:        myAirVehSetCtlr.cxx
//
//Class:       MyIndividualLifeFormSetController
//

#include "myAirVehSetCtlr.h"
#include "vrfcore/simMgr.h"
#include "vrfobjcore/vrfObjMgr.h"

#include "vrfobjcore/compTypes.h"
#include "vrfobjcore/simRadio.h"
#include "vrftasks/setDtaTypes.h"
#include "vrfobjcore/setDataManager.h"
#include "vrfobjcore/vrfMvObjSR.h"

#include "vrfmsgs/setDtaRqMsg.h"
#include "setSpeedAndHeading.h"

namespace vrfAddSetExample
{
   //constructor
   MyAirVehicleSetController::MyAirVehicleSetController(
   const DtString& name, 
   DtVrfObject* owner,
   DtSimManager* simManager, 
   DtComponentDescriptor* desc, 
   DtReaderWriterRegistry* parentRegistry) :
   DtAirVehicleSetController(name, owner, simManager, desc, parentRegistry)
   {
   }

   //destructor
   MyAirVehicleSetController::~MyAirVehicleSetController()
   {
   entity()->setDataManager()->removeSetDataCallback(DtSetSpeedAndHeadingType, 
      setSpeedAndHeadingCallback, (void *) this);
   }

   void MyAirVehicleSetController::processSetSpeedAndHeading(DtSimMessage* msg)
   {
   DtSetDataRequestMessage* drMsg = (DtSetDataRequestMessage *) msg;
   DtSetSpeedAndHeadingRequest* req = (DtSetSpeedAndHeadingRequest *)drMsg->setDataRequest();
   DtVrfMovingObjectStateRepository* movingSR = 
      DtVrfMovingObjectStateRepository::isVrfMovingObjectStateRepository(
      localStateRepository());

   if (movingSR)
   {
      movingSR->setOrderedSpeed(req->speed());
   }

   myLocalEntity->place(req->heading());
   objectConsoleInfo() << "Setting heading: " << req->heading() << " and speed: " << req->speed() << std::endl;
   }

   void MyAirVehicleSetController::setSpeedAndHeadingCallback(DtSimMessage* msg, 
   void* usrData)
   {
   ((MyAirVehicleSetController *)usrData)->processSetSpeedAndHeading(msg);
   }

   //overrides this so it can register it's interest in the set commands
   void MyAirVehicleSetController::setRadio(DtSimRadio* radio)
   {
   DtAirVehicleSetController::setRadio(radio);

   entity()->setDataManager()->addSetDataProcessorCallback(DtSetSpeedAndHeadingType, 
      setSpeedAndHeadingCallback, (void *) this);
   }

   DtSimComponent* MyAirVehicleSetController::creator(
   const DtString& name, 
   DtVrfObject* owner,
   DtSimManager* simManager, 
   DtComponentDescriptor* desc, 
   DtReaderWriterRegistry* parentRegistry)
   {
   return new MyAirVehicleSetController(name, owner, simManager, desc,
      parentRegistry);
   }
}

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)