VR-Link API Documentation for DIS
Home
Namespaces
Classes
Files
Examples
Libraries
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 <
vlutil/vlProcessControl.h
>
#include <
vlutil/vlMiniDumper.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.
DtProtocolVersionToSend
= 7;
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 Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (
www.mak.com
)