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 GUI

Table of Contents

The Network Callback Manager example demonstrates the following:

In order to incorporate a protocol-specific extension in the VR-Forces front-end, the VR-Vantage Accessories concept is used. An accessory is an external plugin that can be used in association with a particular application driver (scene, transport, etc). In the case of this example, a transport driver is used to extend functionality of the system.

The example adds a new remote entity net interface to read the new reflected state repository that contains the temperature:

{
DtSimObjectNetInterface::factory()->addCreatorFcn(
DtReflectedEntity::setStateRepCreator((DtReflectedEntity::DtStateRepCreator)
// Add the new sim data processor into the system such that when components of type temperature are created, the state view and
// data for that will be created
DtSimDataProcessorManager::instance(*connection).addDataProcessor(iffdp);
}

Make sure to create a new DtEntityStateInterceptor that is derived from the new reflected class

And, when the network interface needs to update itself from the network, it places the internal temperature into the state component:

DtEntityStateRepWithTemperature * netState = dynamic_cast<DtEntityStateRepWithTemperature*>(individualNetworkState());
if (netState)
{
try
{
// Find the state component, and, if it exists, set the temperature. Next frame state is used in order to write in the new information
nextFrameState()->getStateComponent<makVrf::DtInternalTemperatureStateComponent>();
if (stateComp)
{
stateComp->setInternalCoreTemperature(netState->temperature());
}
}
catch(...)
{
// State component does not exist, so, that is ok
}
}

When using accessories to extend the protocol-specific workings, it is important to note the following:

Usage

In the Launcher, . Enable the Add State Component plugin. Add the appropriate FOM module to the FOM modules line in the launcher and launch the front and back-end.

  1. Copy AddStateComponent.fed, AddStateComponent.xml, and AddStateComponent_evolved.xml from examples to the bin64 directory.
  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. Click the Plug-ins button to bring up the Plug-ins Selection dialog.
  4. Enable the Add State Component plugin.
  5. Start the launcher.
  6. Load the addStateComponent developer example.

Plugin Entry Points

examplePlugin.cxx

/*******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file examplePlugin.cxx
//\brief Loads the plugin
//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 "exampleMenu.h"
#include <vrvCore/DtDe.h>
#include <QtWidgets/QMessageBox>
using namespace makVrv;
using namespace makVrf;
void initPluginMenus(DtVrvApplication& app, DtDe& de)
{
//First, register the creators with the menu assember
//Now, add the menu to the master mode configuration. mainMenu indicates that
//the example menu is going to be used as a top-level main menu rather than a
//sub-menu. Add it before the Task menu. To leave off the path will
//put the menu at the end of the menu bar
DtMenuPath::mainMenu("DtTaskMenu"));
//Now, register the DtCallbackMenuItem as an item of DtCallbackMenu
DtMenuPath::mainMenu("DtCallbackMenu").item("DtCallbackMenuItem"));
}
void DtTestInteractionInterfaceCallback(DtNetworkMessageInterface* iface)
{
if (!inter)
{
QMessageBox::warning(0, "Received Incorrect Pdu", "Received Incorrect Pdu");
return;
}
QString message;
message.sprintf("Received pdu message ");
message += inter->message().c_str();
QMessageBox::information(0, "Received Pdu", message);
}
//Implemented to be able to use the INIT_ONCE method
bool initDeModule(DtDe* de)
{
//Add this accessory into the accessory manager so it can be loaded by the VRL drivers
if(igApp)
{
initPluginMenus(*igApp, *de);
//Add callbacks for test interaction callback and test pdu callback
DtTestInteractionInterface::theName()).connect(boost::bind(&DtTestInteractionInterfaceCallback, _1));
}
return true;
}
{
info.pluginName = "networkCallbackManager";
info.pluginDescription = "This is an example of how to send interactions/pdus from the front-end and then receive those pdus/interactions and report that information to the front-end.";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}

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)