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
Select the RTI connection
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
#include <vl/exerciseConnInitializer.h>
#include <boost/filesystem.hpp>
#include <boost/bind/bind.hpp>
{
return true;
}
namespace makVrv
{
namespace vrvExampleHla1516eConnection
{
static vrvSignalsLib::connection postInitializeConnection;
static const std::string exampleDriverName = "myHla1516eDriver";
void createDriver(DtDe* de)
{
postInitializeConnection.disconnect();
DtHla1516eDriver* hla1516eDriver = dynamic_cast<DtHla1516eDriver*>(
createDriver(std::string("DtHla1516eDriver"), exampleDriverName));
boost::filesystem::path loadPath = boost::filesystem::system_complete(
de->dePathConfiguration().driverPath());
loadPath += "/HLA 1516 Evolved.DtHla1516eDriver";
{
DtConfiguration settings;
settings.setName("HLA 1516 Evolved.DtHla1516eDriver");
std::string federateName = "VR-Vantage HLA 1516 Evolved Example Driver";
settings.setOptionalParameters(record.
settings());
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;
}
de->driverManager().addDriver(hla1516eDriver);
}
{
try
{
postInitializeConnection = de.signal_postInitialize.connect(boost::bind(
&createDriver, &de));
DtDeInitializer initializer = de.deInitializer();
std::vector< std::string > autoStartList = initializer.autoStartDrivers();
autoStartList.push_back(exampleDriverName);
initializer.setAutoStartDrivers(autoStartList);
de.setDeInitializer(initializer);
}
DtCATCH_AND_PROPAGATE(DtCorruptedState)
}
}
}
exampleHla1516eConnectionInit.h
#pragma once
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEHLA1516ECONNECTION
namespace makVrv
{
class DtDe;
namespace vrvExampleHla1516eConnection
{
}
}
exampleHla1516eConnection.h
#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