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
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 6.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
#include <vl/exerciseConnInitializerDIS.h>
#include <boost/bind/bind.hpp>
{
return true;
}
{
namespace vrvExampleDisConnection
{
static vrvSignalsLib::connection postInitializeConnection;
static const std::string exampleDriverName = "myDisDriver";
void createDriver(DtDe* de)
{
postInitializeConnection.disconnect();
DtDisDriver* disDriver = dynamic_cast<DtDisDriver*>(
createDriver(std::string("DtDisDriver"), exampleDriverName));
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);
de->driverManager().addDriver(disDriver);
}
{
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)
}
}
}
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
Contains makVrv::DtDisDriver class.
Contains makVrv:DtMasterScene class.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
static DtDriverFactory & instance(DtDe &de)
Get the instance of the factory.
Contains DLL export macros.
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
DT_DLL_EXAMPLEDISCONNECTION void init(DtDe &anIG)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
Contains DLL export macros.
exampleDisConnectionInit.h
#pragma once
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEDISCONNECTION
{
class DtDe;
namespace vrvExampleDisConnection
{
}
}
#define DT_DLL_EXAMPLEDISCONNECTION
Definition exampleDisConnection.h:19
exampleDisConnection.h
#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