VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Add Set (Back-End) (addSetSim)

Table of Contents

The Add Set example creates a new "Set" command that allows a user to set an entity's ordered speed and heading.

When the command is initiated, specified and executed in the front-end by the user, a Set message will be sent to an entity-specific controller in the back-end. The larger architecture of set sommands in the VR Forces back-end is described in Tasks, Sets, Commands, and Reports.

The Add Set back-end example demonstrates the following:

Creating and Registering a New Set Command

The DtSetSpeedAndHeadingRequest class is a child of the DtSetDataRequest class, and is the central object defining a set command in the back-end. The DtSetDataRequest contains the netRepSIze(), the setToNet() and setFromNet() methods used to send and receive set commands from the network. The derived class, DtSetSpeedAndHeadingRequest, contains the central parameters of the set command (mySpeed and myHeading) as well as their accessor and mutator methods. It also contains the creator() static method used by the factory to create the object, which is registered in DtInitializeVrfPlugin (plugin.cxx).

Extending Functionality by Overriding Existing Controllers

The series of new controllers classes in this example, MyHumanSetController, MyLocalEntitySetController, MyFixedWingSetController and MyAirVehicleSetController, are derived from the default set controllers DtHumanSetController, DtLocalEntitySetController, DtFixedWingSetController and DtAirVehicleSetController, respectively. They stand with very minor modifications - a processSpeedAndHeading() method that applies the commanded speed and heading to the proper entity SR, and a setSpeedAndHeadingCallback() that is registered with the DtSetDataManager for callbacks. All of the other methods for processing set commands are inherited and retained from the originating class.

The respective entity-specific default set controllers are overridden in the factory with the new set controllers in DtInitializeVrfPlugin (plugin.cxx).

Usage

In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin. Then launch VR-Forces.

To view the new behavior:

  1. Create a new scenario.
  2. Create a lifeform entity (e.g. "DI US M16"). Any ground vehicle, air vehicle, and/or lifeform will work with this example.
  3. Right-click on entity and select the new entry 'Set > Speed and Heading...".
  4. In the 'Set Heading and Speed' dialog, select the desired heading and ordered speed for the entity.
  5. Click OK to exit the dialog. The entity will snap to the new heading.
  6. Give the entity a movement task. It will move at the speed specified in the 'Set Heading and Speed' request.

Please note that "speed" refers to "ordered speed," i.e., the speed at which the entity will travel when it is tasked to move. If the entity does not have a destination or move task, setting "speed" to a non-zero value will not make the entity move.

Classes

DtSetSpeedAndHeadingRequestThe subclass of DtSetDataRequest that is used to communicate the new set request.
MyLocalEntitySetControllerThe subclass of DtLocalEntitySetController that is used to implement the new set command.
MyAirVehicleSetControllerThe subclass of DtAirVehicleSetController that is used to implement the new set command.
MyFixedWingEntitySetControllerThe subclass of DtFixedWingEntitySetController that is used to implement the new set command.
MyHumanSetControllerThe subclass of DtHumanSetController that is used to implement the new set command.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

#include "vrfcgf/vrfPluginExtension.h"
#include "setSpeedAndHeading.h"
#include "myLclEntSetCtlr.h"
#include "myHumanSetController.h"
#include "myFixWngSetCtlr.h"
#include "myAirVehSetCtlr.h"

#include "vrfcgf/cgf.h"
#include "vrfcgf/factoryManager.h"
#include "vrfobjcore/simComponentTypes.h"

using namespace vrfAddSetExample;

extern "C" {

   DT_VRF_DLL_PLUGIN void DtPluginInformation(DtVrfPluginInformation& info)
   {
      info.pluginName = "Add Set Sim";
      info.pluginDescription = "Back-end plugin to process new Set Speed and Heading command";
      info.pluginVersion = "1.00";
      info.pluginCreator = "MAK Technologies";
      info.pluginCreatorEmail = "sales@mak.com";
      info.pluginContactWebPage = "www.mak.com";
      info.pluginContactMailingAddress = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
      info.pluginContactPhone = "(617) 876 8085";
   }

   DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
   {
      cgf->factoryManager()->componentFactory()->addCreatorFcn(
         DtLocalEntitySetControllerType, MyLocalEntitySetController::creator);  

      cgf->factoryManager()->componentFactory()->addCreatorFcn(
         DtHumanSetControllerType, MyHumanSetController::creator);  

      cgf->factoryManager()->componentFactory()->addCreatorFcn(
         DtAirVehicleSetControllerType, MyAirVehicleSetController::creator);  

      cgf->factoryManager()->componentFactory()->addCreatorFcn(
         DtFixedWingEntitySetControllerType, 
         MyFixedWingEntitySetController::creator);  

      cgf->factoryManager()->setDataRequestFactory()->addCreatorFcn(
         DtSetSpeedAndHeadingType, 
         DtSetSpeedAndHeadingRequest::creator);
      
      return true;
   }
}


Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)