VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add FOM Class (addFomClassGui)

The Add FOM Class GUI example demonstrates the following:

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.

/*******************************************************************************
** 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 = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 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.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_simulationCreated.connect(
}
}
{
if (myDriver)
{
(myDriver->connection());
myDriver->signal_simulationCreated.disconnect(
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) 2017 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrf;
{
}
{
return "DtSomeOtherAttributePageItem";
}
{
objectDataStateViewCollection()->findStateView(state->id());
if (objDataView)
{
// Lookup the current value of the state property for SomeOtherAttribute
const DtRwPropertiesStructure* someOtherAttr =
objDataView->state().myStateProperties.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 Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)