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) 2017 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" );
// Send DIS 7 PDUs.
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 Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)