VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add FOM Class (addFomClassGui)

Table of Contents

The Add FOM Class GUI example demonstrates the following:

Adding a New FOM Object Class

The Add FOM Class example shows how to add a new FOM object class that is not part of the RPR FOM and is therefore not typically supported by VR-Forces. It shows how to map this new object class to an existing RPR-based object, assuming the concepts being simulated are similar, which can then be displayed in the GUI. It also shows how additional attributes that cannot be mapped can be received and displayed in the Information dialog. For more details on this example, please see the Add FOM Class Sim example plugin, which configures the sim to also publish and subscribe this object class.

This example creates a new accessory that is used to configure the VR-Link FOM mapper so that instances of the AlternateEntity FOM class can be decoded to an entity state repository, which is based on the RPR FOM entity classes. It also adds the AlternateEntity FOM class as a supported class of the DtExtendedPropertiesEntityPublisher and DtExtendedPropertiesEntityList classes in order to process additional FOM attributes as state properties.

This example then registers a new page data item to display the SomeOtherAttribute state property. This property is populated by updates to the attribute of the same name in the AlternateEntity object class. This page data item queries the state view of the DtVrfObjectDataState to get the latest state property values.

How to Run the Example

  1. Copy the AlternateEntity_evolved.xml FOM module from examples to the bin64 directory. Note that his FOM module is for HLA Evolved. If you are using another HLA version you will need to edit your FOM to add in the new FOM class.
  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. Choose an HLA 1516 Evolved protocol configuration.
  2. Set the addFomClass plugin to load.
  3. Add AlternateEntity_evolved.xml to the list of FOM modules.
  4. Set the RPR FOM version to 2.0.
  5. Start VR-Forces.

To view the new behavior:

  1. Load the addFomClass developer toolkit example scenario
  2. Notice the entity that appears. It is published using AlternateEntity FOM class. This can be verified by running another application that subscribes to this class or using some inspection tool of your RTI.
  3. Right-click on the entity and select Information... to open its information window.
  4. Find the Some Other Attribute entry on the State Data page, which is updated via the SomeOtherAttribute state property.
  5. By default, after the very first scenario load - the text should read "0.0 | 0".
  6. Select the entity and open the Set->Some Other Attribute dialog. Set the two fields to new values.
  7. The Some Other Attribute entry on the State Data page will update.

After the example run is completed:

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2018 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file examplePlugin.cxx
//\brief Loads the plugin and initializes menu items
//This file defines the generic DT_DLL_VRF_PLUGIN_EXPORT_MACRO. Use that macro when
//you want to export symbols. Also, in your CMakeLists.txt file, make sure to
//define the VRFPLUGIN_EXPORTS define to tell the compiler to define the macro as an
//export
#include <vrvCore/DtDe.h>
using namespace makVrv;
using namespace makVrf;
// Entry point that must be defined by all plugins, this is called as part of the process that loads the plugin, before the de
// is fully initialized
bool initDeModule(DtDe* de)
{
// Add the accessory to the accessory manager. It will get the option
// to install itself into any DtDriver objects that are created.
// The accessory will configure the FOM mapper.
// Add the new menu items into the state page path of the entity information page.
// Pages are now prefaced by the section they are in (if they are in a section)
// so must reference the page as <section name>.<page name>
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageConfiguration().
addPagePathBefore(DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtSomeOtherAttributePageItem"),
DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtEntityAcceleration"));
// And now add the information item creators to be created when these items want to be displayed
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
registerPageDataItemCreator(new DtSomeOtherAttributePageItemCreator);
return true;
}
{
info.pluginName = "addFomClassGui";
info.pluginDescription = "Example on adding a new FOM class that maps to an entity.";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "support@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}
/******************************************************************************
** Copyright (c) 2018 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include "../addFomClassSim/configFomMap.h"
#include <vrvVrl/DtEntityStateInterceptor.inl>
#include <boost/bind/bind.hpp>
#include <iostream>
using namespace makVrv;
using namespace makVrf;
//The accessory used by the VR-Vantage network drivers to add the new extended state data
//item (mass) to VR-Forces extended state data
, myDriver(0)
{
#ifdef DtHLA
#ifdef DtHLA_1516
#ifdef DtHLA_1516_EVOLVED
myName="DtAddFomClassGuiHLA1516eAccessory";
#else
myName="DtAddFomClassGuiHLA1516Accessory";
#endif
#else
myName="DtAddFomClassGuiHLA13Accessory";
#endif
#endif
}
{
if (myDriver)
{
}
}
//Called when the driver is first installed. Set up some
//signals to be notified when the driver is connected to the
//network
{
if (myDriver)
{
myDriver->signal_connectionCreated.connect(
boost::bind(&DtAddFomClassGuiAccessory::slot_onSimulationCreated, this, boost::placeholders::_1));
}
}
{
if (myDriver)
{
(myDriver->connection());
myDriver->signal_connectionCreated.disconnect(
boost::bind(&DtAddFomClassGuiAccessory::slot_onSimulationCreated, this, boost::placeholders::_1));
if (vrlCon)
{
}
}
myDriver = 0;
}
//Override to make sure that this accessory is compatible with the driver being created
{
if(dd)
{
return true;
}
return false;
}
{
(myDriver->connection());
if (vrlCon)
{
}
}
{
(myDriver->connection());
if (vrlCon)
{
configFomMapper(vrlCon->exerciseConn(), true);
}
}
/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrf;
{
}
{
return "DtSomeOtherAttributePageItem";
}
{
// Lookup the current value of the state property for SomeOtherAttribute
const DtRwPropertiesStructure* someOtherAttr =
state->stateProperties().findProperty<DtRwPropertiesStructure>("SomeOtherAttribute");
if (someOtherAttr)
{
// Find each field within the structure
boost::optional<double> field1 =
someOtherAttr->findFieldValue<double>("Field1");
boost::optional<int> field2 =
someOtherAttr->findFieldValue<int>("Field2");
if (field1 && field2)
{
return (QString::number(*field1) + " | " + QString::number(*field2));
}
}
return "";
}
{
return QObject::tr("Some Other Attribute");
}

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)