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

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

It shows how to create a new Dis 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/exampleDisConnection_stealth.bat (on Windows) or ./bin/exampleDisConnection_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleDisConnectionInit.cxx

/******************************************************************************
** Copyright (c) 2016 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <vrvDis/vrvDis.h>
#include <boost/bind.hpp>
{
return true;
}
namespace makVrv
{
namespace vrvExampleDisConnection
{
//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
de->signal_postInitialize.disconnect(boost::bind(
&createDriver, de));
//Step 1: Create the DIS driver.
DtDisDriver* disDriver = dynamic_cast<DtDisDriver*>(
createDriver(std::string("DtDisDriver"), exampleDriverName));
// Step 2: Create the DIS Connection initializer and add it to the DIS driver.
DtDisExerciseConnInitializer exConnInitializer;
exConnInitializer.setExerciseId(1);
exConnInitializer.setMulticastTtl(-1);
exConnInitializer.setPort(3000);
exConnInitializer.setReceiveBufferSize(1048576);
exConnInitializer.setSendBufferSize(-1);
exConnInitializer.setSiteId(2);
exConnInitializer.setUseAsynchIO(true);
disDriver->setExerciseSettings(exConnInitializer);
// 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
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) 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_EXAMPLEDISCONNECTION
// Export plugging function bool initDeModule(DtDe* de);
namespace makVrv
{
class DtDe;
namespace vrvExampleDisConnection
{
}
}

exampleDisConnection.h

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


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