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 <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 Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)