![]() |
VR-Forces 4.0.4 Class Documentation
|
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, in this case the HLA13 and HLA1516 drivers.
When using accessories to extend the protocol-specific workings, it is important to note the following:
This accessory introduces the concept of the DtNetworkMessageInterface which is used to as a base class for subclasses that want to send specific content of a PDU to the GUI thread. The developer will create a subclass (e.g. DtTestInteractionInterface) to store the content of the PDU they wish to communicate to the GUI. Then, the receivedNetworkMessage call of the DtVrfDriver is used to communicate that message to the GUI thread.
On the GUI side, the developer registers for callbacks for a particular network message by using the registerNetworkMessageInterfaceCallback method of the DtNetworkMessageCallbackManager class. When a message of this type is received, the boost bound method is called in response.
This example also shows how to use an event signaler to signal events from the GUI thread to the network thread. In this case in response to a menu item being selected the VR-Link comment interaction being published on the network.
Since this example is loaded as a plugin Select Settings, Plugins... and on the Plugins Editor page, use the combo box at the top of the page to select the plug-in. Then enable the Load Plugin checkbox for the networkCallbackManager example and re-start VR-Forces.
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 <vrfGuiCore/vrfGuiExportPlugin.h> #include "networkCallbackManagerAccessory.h" #include "DtTestInteractionInterface.h" #include "exampleMenu.h" #include <vrfGuiCore/DtNetworkMessageCallbackManager.h> #include <vrvCore/DtDe.h> #include <vrvCore/DtAccessoryManager.h> #include <vrvCoreQt/DtQtMenuAssembler.h> #include <QtGui/QMessageBox> using namespace makVrv; using namespace makVrf; void initPluginMenus(DtVrvApplication& app, DtDe& de) { //First, register the creators with the menu assember DtQtMenuAssembler::instance(de).registerMenu(new DtCallbackMenu(de)); DtQtMenuAssembler::instance(de).registerMenu(new DtCallbackMenuItem(de)); //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 app.masterModeMenuConfiguration().addMenuPathBefore(DtMenuPath::mainMenu("DtCallbackMenu"), DtMenuPath::mainMenu("DtTaskMenu")); //Now, register the DtCallbackMenuItem as an item of DtCallbackMenu app.masterModeMenuConfiguration().addMenuPath( DtMenuPath::mainMenu("DtCallbackMenu").item("DtCallbackMenuItem")); } void DtTestInteractionInterfaceCallback(DtNetworkMessageInterface* iface) { DtTestInteractionInterface* inter = dynamic_cast<DtTestInteractionInterface*>(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 DtAccessoryManager::instance(*de).addAccessory(new DtNetworkCallbackManagerAccessory()); DtVrvApplication* igApp = DtVrvApplication::findFromDe(*de); if(igApp) { initPluginMenus(*igApp, *de); //Add callbacks for test interaction callback and test pdu callback makVrf::DtNetworkMessageCallbackManager::instance(*de).networkInterfaceMessageSignal( DtTestInteractionInterface::theName()).connect(boost::bind(&DtTestInteractionInterfaceCallback, _1)); } return true; } void DtPluginInformation(DtVrfPluginInformation& info) { 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 = "68 Moulton Street - Cambridge, MA 02138"; info.pluginContactPhone = "(617) 876 8085"; }