The playFile program creates a logger, opens a logger tape, and plays it back.
Periodic messages output the current tape time. If 'q' is pressed playback stops and the program exits\ immediately, otherwise it will continue to the end of the tape at which point it will exit.
#include <vlutil/vlProcessControl.h>
#include <vlutil/vlPrint.h>
#include <cmdLine/cmdLine.h>
#if DtDIS
#include <vl/dExConnInit.h>
#endif
#if DtHLA
#include <vl/hExConnInit.h>
#endif
using namespace MAKLogger;
#if DtDIS
const char defaultFileName[] = "..\\logger_tapes\\maklanddemoDIS.lgr";
#elif DtHLA_1516_EVOLVED
const char defaultFileName[] = "..\\logger_tapes\\maklanddemoHLA1516e_vrlink_evolved_xml.lgr";
#elif DtHLA_1516
const char defaultFileName[] = "..\\logger_tapes\\maklanddemoHLA1516_vrlink_xml.lgr";
#else
const char defaultFileName[] = "..\\logger_tapes\\maklanddemoHLA13.lgr";
#endif
bool keyCheck(const char* keysToCheck)
{
if(DtKbHit())
{
char c = DtGetCh();
return strchr(keysToCheck,c) != 0;
}
return false;
}
int playFile(int argc, char** argv)
{
DtCmdLine::UnlabeledMultiArg<DtString> filenameArg("Filename","The name of the logger file to write.","string");
DtCmdLine::ValueArg<double> playbackSpeed("s","speed", "The playback speed.",false, 1.0,"double");
cmdLine.add(&filenameArg);
cmdLine.add(playbackSpeed);
cmdLine.parse(argc,argv);
std::vector<DtString> values = filenameArg.getValue();
if(values.size() == 0)
{
values.push_back(defaultFileName);
}
try
{
#if DtDIS
DtDisLogger* aLogger = DtDisLogger::create(true);
#endif
#if DtHLA
#endif
DtExerciseConnInitializer exConnInit;
#if DtHLA
#if DtHLA_1516_EVOLVED
exConnInit.setFedFileName("VR-Link_evolved.xml");
#elif DtHLA_1516
exConnInit.setFedFileName("VR-Link.xml");
#else
exConnInit.setFedFileName("VR-Link.fed");
#endif
#endif
{
DtInfo << "Unable to connect." << std::endl;
return 1;
}
delete simInterface;
if(!pbInterface)
{
DtInfo << "Error: Unable to create playback interface." << std::endl;
return 1;
}
{
DtInfo << "Unable to open file: " << filename << "." << std::endl;
return 1;
}
if (playbackSpeed.isSet())
{
DtInfo << "Setting playback speed to " << playbackSpeed.getValue() << std::endl;
}
{
DtInfo << "Unable to play file." << std::endl;
return 1;
}
double printDelay = 1.0;
double printLoopTotal = 0;
double loopDelay = .1;
DtInfo << "Playing file: " << filename << "." << std::endl;
DtInfo << "Press 'q' or 'enter' to quit." << std::endl;
{
if(printLoopTotal >= printDelay)
{
DtInfo <<
"Current Time = " << pbInterface->
currentTime() <<
"." << std::endl;
printLoopTotal = 0.0;
}
printLoopTotal += loopDelay;
DtSleep(loopDelay);
if(keyCheck("q\r")) break;
}
{
DtInfo << "Stopping playback." << std::endl;
}
DtInfo << "Finished playing file." << std::endl;
DtRestoreKbHit();
delete pbInterface;
delete aLogger;
}
{
DtInfo << output << std::endl;
return 0;
}
return 0;
}
int main(int argc, char** argv)
{
return playFile(argc,argv);
}