VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleHla1516eConnection

Table of Contents

Overview

This example shows how to create a very simple plug-in that creates a Hla1516e driver and automatically connects to a Hla1516e exercise.

Expected Result

exampleHla1516eConnection1.png
Select the RTI connection
exampleHla1516eConnection2.png
New HLA connection from the connection dialog

Example details

It shows how to create a new Hla1516e Driver object, add it to the driver manager and set it up to start automatically.

Note
This example demonstrates the programmatic pattern for configuring the exercise connection: the plug-in constructs an HLA1516e driver and populates its RTI and federation settings directly in code (see exampleHla1516eConnectionInit.cxx). VR-Vantage 3.2 introduced an alternative, declarative pattern – a shared XML configuration file, appData/settings/connections/MAK-ONE-2026-Config.xml, that every VR-Vantage protocol driver loads automatically at startup. That file (or any file supplied with "--exConnConfigFile <path>") is the recommended way to make VR-Vantage join the same exercise as VR-Forces, VR-Engage, and other MAK ONE products. This example intentionally continues to show the programmatic pattern for callers who prefer explicit code control. See 5.2.7 Exercise Connection Configuration for details.

Building the Example

VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is an application. You can run it by running ./bin64/exampleHla1516eConnection_stealth.bat (on Windows) or ./bin64/exampleHla1516eConnection_stealth.sh (on Linux). When Vantage start it will ask you to select an RTI connection (select the loopback connection). From the menu "Settings->Connections..." you can see the new HLA connection that was added by the plugin. For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleHla1516eConnectionInit.cxx

/******************************************************************************
* Copyright (c) 2024 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
#include <vl/exerciseConnInitializer.h>
#include <boost/filesystem.hpp>
#include <boost/bind/bind.hpp>
{
return true;
}
// Use the VR-Vantage namespace. All classes in VR-Vantage are in this namespace.
namespace makVrv
{
namespace vrvExampleHla1516eConnection
{
static vrvSignalsLib::connection postInitializeConnection;
//name for example driver that this example creates
static const std::string exampleDriverName = "myHla1516eDriver";
//Create the example HLA1516E driver
void createDriver(DtDe* de)
{
// We're done with the signal, so disconnect from it
postInitializeConnection.disconnect();
//Step 1: Create the HLA1516E driver.
DtHla1516eDriver* hla1516eDriver = dynamic_cast<DtHla1516eDriver*>(
createDriver(std::string("DtHla1516eDriver"), exampleDriverName));
// Step 2:
// Start by loading in our current default HLA 1516e configuration file to get the latest
// fom modules in use. The remaining parameters are provided as examples and can be commented out /
// removed to use the values that came from the config file
boost::filesystem::path loadPath = boost::filesystem::system_complete(
de->dePathConfiguration().driverPath());
loadPath += "/HLA 1516 Evolved.DtHla1516eDriver";
if (makArchives::DtXmlFileIo::read(loadPath.string(), record, "DtDriverRecord"))
{
DtConfiguration settings;
settings.setName("HLA 1516 Evolved.DtHla1516eDriver");
std::string federateName = "VR-Vantage HLA 1516 Evolved Example Driver";
settings.setOptionalParameters(record.settings());
// Now we can make changes to what came from the config file
settings.setOptionalParameter("federateName", "VR-Vantage 3.1 Example");
settings.setOptionalParameter("federateType", "VR-Vantage HLA 1516 Evolved Example Driver");
settings.setOptionalParameter("fedFileName", "RPR_FOM_v2.0_1516-2010.xml");
settings.setOptionalParameter("rprFomVersion", "2");
settings.setOptionalParameter("useAdvisories", "1");
settings.setOptionalParameter("useGeographicDdm", "0");
hla1516eDriver->realizeConfiguration(settings);
}
else
{
error << loadPath.string();
de->emitDeError(error, true);
return;
}
// Step 3: Add the Hla1516e driver to the display engine.
// The driver is now owned by the display engine. Do not delete it.
de->driverManager().addDriver(hla1516eDriver);
}
void init(DtDe& de)
{
try
{
//connect to the post initialize signal so the driver is created at
// the proper time
postInitializeConnection = de.signal_postInitialize.connect(boost::bind(
&createDriver, &de));
//Add the example drivers name to the list of drivers to start when
// the De starts all the drivers.
DtDeInitializer initializer = de.deInitializer();
std::vector< std::string > autoStartList = initializer.autoStartDrivers();
//this name needs to match the name used in createDriver() above
// when the driver is created
autoStartList.push_back(exampleDriverName);
initializer.setAutoStartDrivers(autoStartList);
de.setDeInitializer(initializer);
}
DtCATCH_AND_PROPAGATE(DtCorruptedState)
}
}
}

exampleHla1516eConnectionInit.h

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
// Get proper local export symbol
// Setup proper plugin export symbol
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEHLA1516ECONNECTION
// Export plugging function bool initDeModule(DtDe* de);
namespace makVrv
{
class DtDe;
namespace vrvExampleHla1516eConnection
{
}
}

exampleHla1516eConnection.h

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#ifndef exampleHla1516eConnection_H_
#define exampleHla1516eConnection_H_
#ifdef _WIN32
#ifdef EXAMPLEHLA1516ECONNECTION_EXPORTS
#define DT_DLL_EXAMPLEHLA1516ECONNECTION __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEHLA1516ECONNECTION __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEHLA1516ECONNECTION
#endif
#endif

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)