![]() |
VR-Forces 4.8 Class Documentation
|
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:
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).
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).
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:
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.
| DtSetSpeedAndHeadingRequest | The subclass of DtSetDataRequest that is used to communicate the new set request. |
| MyLocalEntitySetController | The subclass of DtLocalEntitySetController that is used to implement the new set command. |
| MyAirVehicleSetController | The subclass of DtAirVehicleSetController that is used to implement the new set command. |
| MyFixedWingEntitySetController | The subclass of DtFixedWingEntitySetController that is used to implement the new set command. |
| MyHumanSetController | The subclass of DtHumanSetController that is used to implement the new set command. |
/*******************************************************************************
** 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;
}
}