VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add State Component (addStateComponentSim)

Table of Contents

The Add Simulation Command example demonstrates the following:

The Add State Component example adds a new state component to an entity. State components are used to store data for both the current and next frames, double buffered for better multithreaded access. They represent composable chunks of data relevant to the entity itself.

How to Run the Example

This example demonstrates how to add a new kind of state component.

  1. Copy AddStateComponent.fed, AddStateComponent.xml, and AddStateComponent_evolved.xml from examples to the bin64 directory.
  2. Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application.

Usage

In the Launcher:

  1. In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.
  2. If you are using HLA, edit FED File Name to be AddStateComponent.fed (HLA 1.3), AddStateComponet.xml (HLA 1516-2000), or AddStateComponent_evolved.xml (HLA Evolved).
  3. Launch VR-Forces.

To view the new behavior:

  1. Start VR-Forces GUI and SIM.
  2. Load the scenario developer_toolkit_examples/addStateComponent/addStateComponent.scnx.
  3. Right-click on the USMC M16 entity and select 'Information... from the context menu - to display the entity Information dialog'.
  4. Expand the Object Console section and change the notify level to Info.
  5. Click on the 'play' button.
  6. The Object Console within the entity Information dialog should periodically print out the temperature of the entity. It should fluctuate a bit over time as the actuator updates it.
  7. If you are using HLA, a new attributed named "Temperature" should be updated periodically for the entity as it changes.
  After the example run is completed - remove the previously copied FED File Name (e.g. AddStateComponent_evolved.xml) from the bin64 directory.
  Restore the previously set FED File Name within the Launcher dialog.

Classes

DtInternalTemperatureStateComponentThe subclass of DtFrameStateInterface that is used to store the internal temperature of an entity.
DtTemperatureMonitorActuatorThe subclass of DtActuatorComponent that updates the internal temperature of the entity.
DtIndividualLocalEntityNetInterfaceWithTemperatureThe subclass of DtSimIndividualLocalEntityWithPropertiesNetInterface that copies the temperature from the state component to a network state repository.
DtEntityStateRepWithTemperatureThe subclass of DtExtEntityStateRepository that adds storage for the temperature attribute for output to the network by VR-Link.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2021 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#include <vrfcgf/cgf.h>
#if DtHLA
#include <vl/exerciseConn.h>
#endif
extern "C" {
{
info.pluginName = "Add State Component Sim";
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)
{
// Add state component to human types
"DtInternalTemperatureStateComponentCreator");
// Register the component with its factory
#if DtHLA
// Optionally, if we wish to also publish internal temperature to an HLA attribute
// we can register a new network interface class.
// If you wish to publish an additional attribute in DIS, you can either use state properties
// (which can also be used in HLA - please see the addStateProperty example) or you can use
// VR-Link to add a custom attribute record. Please see the VR-Link API for more details.
// Find the exercise connection from the communications manager's VR-Link communication interface
if (vrlinkInterface)
{
// Register the network interface classes
// Now call configFomMapper to register functions to encode and decode the new attribute.
configFomMapper(vrlinkInterface->exerciseConnection()->fomMapper());
}
#endif
return true;
}
#if DtHLA
DT_VRF_DLL_PLUGIN void DtUnloadVrfPlugin()
{
}
#endif
}

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)