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

Table of Contents

Overview

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

Expected Result

exampleHla13Connection1.png
Select the RTI connection
exampleHla13Connection2.png
New HLA connection from the connection dialog

Example details

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

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/exampleHla13Connection_stealth.bat (on Windows) or ./bin64/exampleHla13Connection_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


exampleHla13ConnectionInit.cxx

/******************************************************************************
* Copyright (c) 2019 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
#include <vl/exerciseConnInitializer.h>
#include <boost/bind.hpp>
{
return true;
}
// Use the VR-Vantage namespace. All classes in VR-Vantage are in this namespace.
namespace makVrv
{
namespace vrvExampleHla13Connection
{
//name for example driver that this example creates
static const std::string exampleDriverName = "myHla13Driver";
//Create the example HLA13 driver
void createDriver(DtDe* de)
{
// We're done with the signal, so disconnect from it
de->signal_postInitialize.disconnect(boost::bind(
&createDriver, de));
//Step 1: Create the HLA13 driver.
DtHla13Driver* hla13Driver = dynamic_cast<DtHla13Driver*>(
createDriver(std::string("DtHla13Driver"), exampleDriverName));
// Step 2: Create the HLA13 Connection initializer and add it to the HLA13 driver.
DtExerciseConnInitializer exConnInitializer;
exConnInitializer.setExecName("VR-Link");
exConnInitializer.setFederateType("VR-Vantage HLA 1.3 Driver");
exConnInitializer.setFedFileName("VR-Link.fed");
exConnInitializer.setRprFomVersion(1);
exConnInitializer.setUseAdvisories(true);
exConnInitializer.setUseGeographicDdm(false);
hla13Driver->setExerciseSettings(exConnInitializer);
// Step 3: Add the Hla13 driver to the display engine.
// The driver is now owned by the display engine. Do not delete it.
de->driverManager().addDriver(hla13Driver);
}
void init(DtDe& de)
{
try
{
//connect to the post initialize signal so the driver is created at
// the proper time
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)
}
}
}

exampleHla13ConnectionInit.h

/******************************************************************************
** Copyright (c) 2019 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_EXAMPLEHLA13CONNECTION
// Export plugging function bool initDeModule(DtDe* de);
namespace makVrv
{
class DtDe;
namespace vrvExampleHla13Connection
{
}
}

exampleHla13Connection.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#ifndef exampleHla13Connection_H_
#define exampleHla13Connection_H_
#ifdef _WIN32
#ifdef EXAMPLEHLA13CONNECTION_EXPORTS
#define DT_DLL_EXAMPLEHLA13CONNECTION __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEHLA13CONNECTION __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEHLA13CONNECTION
#endif
#endif

[<< Examples] [Home] [Top of Page]


Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)