VR-Vantage 2.3 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleHla13Connection

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

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 ./bin/exampleHla13Connection_stealth.bat (on Windows) or ./bin/exampleHla13Connection_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleHla13ConnectionInit.cxx

/******************************************************************************
* Copyright (c) 2016 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) 2016 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) 2016 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
/******************************************************************************
** $RCSfile: exampleHla13Connection.h,v $ $Revision: 1.2 $ $State: Exp $
******************************************************************************/
#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


Copyright © 2005-2018 VT MAK. All Rights Reserved (www.mak.com)