The Add FOM Class GUI example demonstrates the following:
- How to build a plugin module for the VR-Forces Gui
- How to add new FOM object class that can be mapped to an existing object type supported by VR-Forces
- How to receive and process FOM attributes that cannot be mapped to existing object attributes in VR-Forces
- How to add new items to the entity Information dialog
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
-
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.
-
Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application.
Usage
In the Launcher:
-
Choose an HLA 1516 Evolved protocol configuration.
-
Set the addFomClass plugin to load.
-
Add AlternateEntity_evolved.xml to the list of FOM modules.
-
Set the RPR FOM version to 2.0.
-
Start VR-Forces.
To view the new behavior:
-
Load the addFomClass developer toolkit example scenario
-
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.
-
Right-click on the entity and select Information... to open its information window.
-
Find the Some Other Attribute entry on the State Data page, which is updated via the SomeOtherAttribute state property.
-
By default, after the very first scenario load - the text should read "0.0 | 0".
-
Select the entity and open the Set->Some Other Attribute dialog. Set the two fields to new values.
-
The Some Other Attribute entry on the State Data page will update.
After the example run is completed:
- Remove the AlternateEntity_evolved.xml FOM module from the bin64 directory.
- Remove the AlternateEntity_evolved.xml from the list of FOM modules in the Launcher.
Plugin Entry Points
using namespace makVrv;
using namespace makVrf;
{
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageConfiguration().
addPagePathBefore(DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtSomeOtherAttributePageItem"),
DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtEntityAcceleration"));
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
return true;
}
{
info.
pluginDescription =
"Example on adding a new FOM class that maps to an entity.";
}
#include "../addFomClassSim/configFomMap.h"
#include <vrvVrl/DtEntityStateInterceptor.inl>
#include <boost/bind/bind.hpp>
#include <iostream>
using namespace makVrv;
using namespace makVrf;
, myDriver(0)
{
#ifdef DtHLA
#ifdef DtHLA_1516
#ifdef DtHLA_1516_EVOLVED
myName="DtAddFomClassGuiHLA1516eAccessory";
#else
myName="DtAddFomClassGuiHLA1516Accessory";
#endif
#else
myName="DtAddFomClassGuiHLA13Accessory";
#endif
#endif
}
{
{
}
}
{
{
myDriver->signal_connectionCreated.connect(
}
}
{
{
myDriver->signal_connectionCreated.disconnect(
if (vrlCon)
{
}
}
}
{
if(dd)
{
return true;
}
return false;
}
{
if (vrlCon)
{
}
}
{
if (vrlCon)
{
}
}
using namespace makVrf;
{
}
{
return "DtSomeOtherAttributePageItem";
}
{
if (someOtherAttr)
{
boost::optional<double> field1 =
boost::optional<int> field2 =
if (field1 && field2)
{
return (QString::number(*field1) + " | " + QString::number(*field2));
}
}
return "";
}
{
return QObject::tr("Some Other Attribute");
}