VR-Link API Documentation for HLA 1.3
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) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/


#include <vl/exerciseConn.h>
#include "testPub.h"
#include "refTestList.h"

// For DtSleep
#include <vlutil/vlProcessControl.h>

int main()
{
   DtExerciseConn conn("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 May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)