VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Test PDU application

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


/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include "testPdu.h"
#include <iostream>
void varCb( TestPdu* pdu, void* )
{
std::cout << "Received Test PDU!" << std::endl;
pdu->print();
std::cout << std::endl;
}
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "PduTest" );
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 Fri May 15 06:36:13 EDT 2015 from SVN revision 153263
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)