VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Using the New Classes in an Application

Once all of these classes are set up, they can be used in applications just like VR-Link's normal publishers, reflected object lists, and reflected objects, as in testObj.cxx.

After you build the testObj example, run two copies of it. You should see each print out state data that it receives from the other.


/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include "testPub.h"
#include "refTestList.h"
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "ObjTest" );
DtExerciseConn conn("example-vrlExtend", "TestObj", (DtFomMapper*) NULL);
DtClock* clock = conn.clock();
// Create a reflected test list
ReflectedTestList rtl(&conn);
// Create a test publisher
TestPublisher pub(&conn);
// Grab a pointer to its state repository
TestStateRepository* tsr = pub.tsr();
// Set some data
tsr->setVector(DtVector(1,2,3));
// Run the main loop for 20 seconds
DtTime beginTime = clock->absRealTime();
while (clock->absRealTime() < beginTime + 20.0)
{
clock->setSimTime(clock->absRealTime());
conn.drainInput();
// Print the state of the first object in the list:
if (rtl.first())
{
rtl.first()->tsr()->printData();
}
// Change the value of "Number" once a second
tsr->setNumber((int) clock->simTime());
// Tick the publisher, causing data to be sent when necessary.
pub.tick();
// Sleep till next iteration
DtSleep(0.2);
}
return 0;
}

Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)