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

Table of Contents

Overview

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

Expected Result

exampleDisConnection.png
DIS Connection Result

Example details

It shows how to create a new Dis 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 a DIS driver and populates its exercise settings directly in code (see exampleDisConnectionInit.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 a plug-in. You can run it by running ./bin64/exampleDisConnection_stealth.bat (on Windows) or ./bin64/exampleDisConnection_stealth.sh (on Linux). Menu "Settings->Connections...", you will see the "MyDisDriver" connection that was added. For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleDisConnectionInit.cxx

/******************************************************************************
** Copyright (c) 2025 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <vrvDis/vrvDis.h>
#include <vl/exerciseConnInitializerDIS.h>
#include <boost/bind/bind.hpp>
{
return true;
}
namespace makVrv
{
namespace vrvExampleDisConnection
{
static vrvSignalsLib::connection postInitializeConnection;
//name for example driver that this example creates
static const std::string exampleDriverName = "myDisDriver";
//Create the example dis driver
void createDriver(DtDe* de)
{
// We're done with the signal, so disconnect from it
postInitializeConnection.disconnect();
//Step 1: Create the DIS driver.
DtDisDriver* disDriver = dynamic_cast<DtDisDriver*>(
createDriver(std::string("DtDisDriver"), exampleDriverName));
// Step 2: Get the DtVrlApplicationInitializer and set desired parameters.
DtVrlApplicationInitializer& exConnInitializer = disDriver->exerciseSettings();
exConnInitializer.setExerciseId(1);
exConnInitializer.setMulticastTtl(-1);
exConnInitializer.setPort(3000);
exConnInitializer.setReceiveBufferSize(1048576);
exConnInitializer.setSendBufferSize(-1);
exConnInitializer.setSiteId(2);
exConnInitializer.setUseAsynchIO(true);
// Step 3: Add the DIS driver to the display engine.
// The driver is now owned by the display engine. Do not delete it.
de->driverManager().addDriver(disDriver);
}
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)
}
}
}

exampleDisConnectionInit.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_EXAMPLEDISCONNECTION
// Export plugging function bool initDeModule(DtDe* de);
namespace makVrv
{
class DtDe;
namespace vrvExampleDisConnection
{
}
}

exampleDisConnection.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#ifndef exampleDisConnection_H_
#define exampleDisConnection_H_
#ifdef _WIN32
#ifdef EXAMPLEDISCONNECTION_EXPORTS
#define DT_DLL_EXAMPLEDISCONNECTION __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEDISCONNECTION __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEDISCONNECTION
#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)