VR-Link API Documentation for DIS
Test PDU application

This file contains the Test PDU application, which sends and receives Test PDUs.


/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#include "testPdu.h"

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

#include <iostream>

void varCb(TestPdu* pdu, void*)
{
   std::cout << "Received Test PDU!\n";
   pdu->print();
   std::cout << std::endl;
}

int main()
{
   DtExerciseConn conn(3000, 1, 1, 1);
   
   DtClock* clock = conn.clock();   
   
   // Register the callback on incoming TestPdus.
   TestPdu::addCallback(&conn, varCb, NULL);

   while (1)
   {
      clock->setSimTime(clock->absRealTime());
      conn.drainInput();
      
      // Send a TestPdu.
      TestPdu pdu;
      pdu.setA(4);
      pdu.setB(0,1);
      pdu.setB(1,1);
      pdu.setB(2,1);
      pdu.setB(3,1);
      pdu.setC(10.0);
      conn.sendStamped(pdu);

      // Now change the length of "b" (the value of "a") to 2 and send again.
      pdu.setA(2);
      conn.sendStamped(pdu);

      DtSleep(1.0);
   }

   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)