simpleDDMSimple13.cxx and simpleDDMFedAmb13.cxx (simpleDDMFedAmb13.h) have the RTI calls and federate ambassador calls for the HLA 1.3 version of simpleDDM.
This page has the code for the following files:
simpleDDMSimple13.cxx
#ifdef DtHLA13
#ifdef WIN32
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#include <winsock2.h>
#include <process.h>
#include <windows.h>
#else
#include <unistd.h>
#include <stdio.h>
#endif
#include <cstdlib>
using namespace std;
:
myNumberOfDimensions(myNumExtents),
myHourlyInteraction("hourlyChime"),
myQuarterlyInteraction("quarterlyChime"),
mySecondsDimensionName("seconds"),
myUTCDimensionName("UTCn"),
mySpaceName("WallClock"),
myInterClassName("Chimes"),
myClassName("BaseEntity"),
myAttrName("clockPosition"),
myRTIamb(0),
myFedAmb(0)
{
myFederationName = "MAKsimpleDDM";
myFederationFile = "MAKsimpleDDM.fed";
myFederateType = "rtisimple13";
}
:
myNumberOfDimensions(data.myNumberOfDimensions),
myHourlyInteraction(data.myHourlyInteraction),
myQuarterlyInteraction(data.myQuarterlyInteraction),
mySecondsDimensionName(data.mySecondsDimensionName),
myUTCDimensionName(data.myUTCDimensionName),
myInterClassName(data.myInterClassName),
myClassName(data.myClassName),
myAttrName(data.myAttrName)
{
}
{
{
}
{
}
}
{
vector< string > args;
}
{
cout << "createFederationExecution "
try
{
}
catch(RTI::FederationExecutionAlreadyExists& ex)
{
cout << "Could not create Federation Execution: "
<< "FederationExecutionAlreadyExists: "
<< ex._name << " "
<< ex._reason << endl;
return false;
}
catch(RTI::Exception& ex)
{
cout << "Could not create Federation Execution: " << endl
<< "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl;
exit(0);
}
cout << "Federation Created" << endl;
return true;
}
{
bool joined=false;
const int maxTry = 10;
int numTries = 0;
cout << "joinFederationExecution "
while (!joined && numTries++ < maxTry)
{
try
{
joined = true;
}
catch(RTI::FederationExecutionDoesNotExist)
{
cout << "FederationExecutionDoesNotExist, try "
<< numTries << "out of "
<< maxTry << endl;
continue;
}
catch(RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl;
return false;
}
}
if (joined)
cout << "Joined Federation." << endl;
else
{
cout << "Giving up." << endl;
exit(0);
}
return true;
}
{
}
{
try
{
theSpaceHandle );
theSpaceHandle );
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not "
<< " get SpaceHandle or DimensionHandle " << endl;
return false;
}
try
{
{
}
else
{
}
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: " << ex._name << " "
<< ex._reason << endl << "Could not "
<< " create Region" << endl;
return false;
}
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not "
<< " notify about region mods" << endl;
return false;
}
}
else
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not "
<< " notify about region mods" << endl;
return false;
}
}
return true;
}
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not get object class handle: "
return false;
}
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not get attribute handle "
return false;
}
string initialPosition("0");
initialPosition.c_str(),
initialPosition.length() + 1);
{
return false;
}
try
{
{
}
else
{
cout << "Subscribed to object: "
<< endl;
}
}
catch(RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl;
cout << "Could not "
return false;
}
{
RTI::Region* theRegions[numHandle];
string objectName("UTC_publisher_");
stringstream zoneID;
objectName += zoneID.str();
try
{
#if 0
#endif
}
catch(RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not Register Object "
<< " with class "
return false;
}
cout << "Registered object "
<< " with class name "
}
return true;
}
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not get interaction class handle: "
return false;
}
string paramName;
try
{
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not get parameter handle "
<< paramName.c_str() << endl;
return false;
}
try
{
{
}
else
{
}
}
catch (RTI::Exception& ex)
{
cout << "RTI Exception: "
<< ex._name << " "
<< ex._reason << endl
<< "Could not "
<< " to interaction." << endl;
return false;
}
{
cout << "Subscribed to interaction class: "
<< " with handle: "
}
return true;
}
{
stringstream ss;
string tagForThisUpdate(ss.str());
tagForThisUpdate.c_str(),
tagForThisUpdate.length());
try
{
tagForThisUpdate.c_str());
}
catch (RTI::Exception& ex)
{
cout << "Caught Exception in update Attribute values\n"
<< ex._name << " " << ex._reason << endl;
}
}
{
DtParamNameHandleMap::const_iterator iterAtHour =
stringstream ss;
ss << "13-" << myUpdateCount++;
string tagForThisUpdate(ss.str());
try
{
iterAtHour->first.c_str(),
iterAtHour->first.length() + 1);
tagForThisUpdate.c_str(),
}
catch (RTI::Exception& ex)
{
cout << "Caught Exception in send Interaction with Regions\n"
<< ex._name << " " << ex._reason << endl;
}
}
{
DtParamNameHandleMap::const_iterator iterAtQuarter =
stringstream ss;
ss << "13-" << myUpdateCount++;
string tagForThisUpdate(ss.str());
try
{
iterAtQuarter->first.c_str(),
iterAtQuarter->first.length() + 1);
tagForThisUpdate.c_str(),
}
catch (RTI::Exception& ex)
{
cout << "Caught Exception in send Interaction with Regions\n"
<< ex._name << " " << ex._reason << endl;
}
}
{
{
myUTCZone = newUTC;
{
}
else
{
}
}
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "Caught Exception when changing bounds\n"
<< ex._name
<< " "
<< ex._reason
<< " " << endl;
}
}
else
{
try
{
}
catch (RTI::Exception& ex)
{
cout << "Caught Exception\n"
<< ex._name
<< " "
<< ex._reason
<< " " << endl;
}
}
}
{
try
{
}
catch(RTI::Exception& ex)
{
cout << "rti13 Exception (during tick): "
<< ex._name << " " << ex._reason << endl;
return false;
}
return true;
}
{
try
{
}
catch(RTI::Exception& ex)
{
cout << "rti13 Exception (during tick): "
<< ex._name << " " << ex._reason << endl;
return false;
}
return true;
}
{
{
string pos_string;
ostringstream oss ;
oss << pos;
pos_string = oss.str();
pos_string.c_str(), pos_string.length() + 1);
}
else
{
cout << "You must initialize the maps before calling this function.";
}
}
#endif
simpleDDMFedAmb13.cxx
#ifdef WIN32
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#endif
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <cstdlib>
using namespace std;
void printAttributes(const RTI::AttributeHandleValuePairSet& attributes,
{
for (unsigned int iloop = 0; iloop < attributes.size(); iloop++)
{
RTI::ULong length = attributes.getValueLength(iloop);
cout << attributes.getHandle(iloop) << " "
<< attributes.getValuePointer(iloop,length) << endl;
}
}
void printParameters(const RTI::ParameterHandleValuePairSet& params)
{
for (unsigned int iloop = 0; iloop < params.size(); iloop++)
{
cout << params.getHandle(iloop) << " "
<< params.getValuePointer(iloop,length) << endl;
}
}
std::string timeToString(RTI::FedTime const& time)
{
char* buff = new char[time.getPrintableLength()+1];
((RTI::FedTime &)time).getPrintableString(buff);
std::string timeStr(buff);
delete [] buff;
return timeStr;
}
NullFederateAmbassador(),
myData(data)
{
}
throw (RTI::FederateInternalError)
{
}
const char* theObjectName)
throw (
RTI::CouldNotDiscover,
RTI::ObjectClassNotKnown,
RTI::FederateInternalError)
{
cout << "discoverObjectInstance: "
<< theObjectName << "("
<< theObject << ") of class "
<< myData.objectClassMap[theObjectClass].c_str() << "( "
<< theObjectClass << ")" << endl;
myData.objectInstanceMap[theObject] = theObjectName;
}
const RTI::AttributeHandleValuePairSet& theAttributes,
const RTI::FedTime& theTime,
const char *theTag,
throw (
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateOwnsAttributes,
RTI::InvalidFederationTime,
RTI::FederateInternalError)
{
}
const RTI::AttributeHandleValuePairSet& theAttributes,
const char *theTag)
throw (
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateOwnsAttributes,
RTI::FederateInternalError)
{
RTI::ULong length = theAttributes.getValueLength(0);
char* dataPointer = theAttributes.getValuePointer(0,length);
bool havePosition = false;
for (unsigned int iloop = 0; !havePosition && iloop < theAttributes.size(); iloop++)
{
if (handle == myData.myPositionHandle
&& theAttributes.getValueLength(iloop) > 0)
{
myData.position = atoi(theAttributes.getValuePointer(iloop, length));
havePosition = true;
}
}
if (!havePosition)
{
cout << "Received reflect with no or NULL position\n";
}
else
{
cout << "Received Pos (" << myData.position;
if ( myData.position < myData.lowerListen )
{
cout << ") less than subscribe Region [";
}
else if ( myData.position > myData.upperListen )
{
cout << ") greater than subscribe Region [";
}
else
{
cout << ") inside subscribe Region [";
}
cout << myData.lowerListen << "," << myData.upperListen << ")\n";
}
}
const RTI::ParameterHandleValuePairSet& theParameters,
const RTI::FedTime& theTime,
const char *theTag,
throw (
RTI::InteractionClassNotKnown,
RTI::InteractionParameterNotKnown,
RTI::InvalidFederationTime,
RTI::FederateInternalError)
{
cout << "receiveInteraction: "
<< myData.interactionClassMap[theInteraction].c_str() << "( "
<< theInteraction << ") "
<< timeToString(theTime).c_str() << " "
<< (theTag ? theTag : "") << " "
<< "#parameters: " << theParameters.size() << endl;
printParameters(theParameters);
}
const RTI::ParameterHandleValuePairSet& theParameters,
const char *theTag)
throw (
RTI::InteractionClassNotKnown,
RTI::InteractionParameterNotKnown,
RTI::FederateInternalError)
{
cout << "receiveInteraction: "
<< myData.interactionClassMap[theInteraction].c_str() << "( "
<< theInteraction << ") "
<< (theTag ? theTag : "") << " "
<< "#parameters: " << theParameters.size() << endl;
printParameters(theParameters);
}
const RTI::FedTime& theTime,
const char *theTag,
throw (
RTI::ObjectNotKnown,
RTI::InvalidFederationTime,
RTI::FederateInternalError)
{
cout << "removeObjectInstance: "
<< myData.objectInstanceMap[theObject].c_str() << "("
<< theObject << ") "
<< timeToString(theTime).c_str() << " "
<< (theTag ? theTag : "") << endl;
}
const char *theTag)
throw (
RTI::ObjectNotKnown,
RTI::FederateInternalError)
{
cout << "removeObjectInstance: "
<< myData.objectInstanceMap[theObject].c_str() << "("
<< theObject << ") "
<< (theTag ? theTag : "") << endl;
}
const RTI::AttributeHandleSet& theAttributes)
throw (
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateInternalError)
{
if ( myData.enableScopeAdvisories )
{
cout<< "********************************\n"
<< "****Attributes entering scope***\n"
<< "********************************\n";
}
}
const RTI::AttributeHandleSet& theAttributes)
throw (
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateInternalError)
{
if ( myData.enableScopeAdvisories )
{
cout<< "********************************\n"
<< "****Attributes exiting scope****\n"
<< "********************************\n";
}
}
moc_simpleDDMAclock.cxx
simpleDDMAclock.cxx
#ifdef SIMPLEDDMGUI
#include <QWidget>
#include <QtCore/QDateTime>
#include <QtGui/QPainter>
#include <QtGui/QBitmap>
#include <QPushButton>
#include <QLineEdit>
#include <QtCore/QSize>
#include <QSizePolicy>
#include <QLayout>
#include <QtCore/QTimer>
#include <QApplication>
#include <string>
NUMSECONDSPERMINUTE * NUMMINUTESPERHOUR;
bool isClockWise,
int zone,
bool displayRegion,
const char *name )
:
myMinSeconds(0),
myMinHour(0.0f),
myMinMinutes(0),
myMaxSeconds(1),
myMaxMinutes(1),
myMaxHour(1.0f),
myHours(-1.0f),
myMinutes(0),
mySeconds(0),
myPublisher(isPublisher),
clockWise(isClockWise),
myDrawArc(displayRegion),
myUTCzone(zone),
initialized(false)
{
internalTimer = new QTimer(this);
connect(internalTimer, SIGNAL(timeout()), this, SLOT(update()));
internalTimer->start(1000);
resize(200, 200);
vLayout = new QVBoxLayout( this );
setLayout( vLayout );
vSpacer = new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding );
vLayout->addItem(vSpacer);
hLayout = new QHBoxLayout( this );
vLayout->addLayout( hLayout );
hSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum );
clockwiseButton = new QPushButton(this);
setUTCButton = new QPushButton(this);
utcLineEdit = new QLineEdit(this);
}
{
{
}
QWidget::closeEvent(arg);
}
{
}
{
{
}
else
{
utcLineEdit->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
}
{
}
else
{
}
{
{
}
else
{
}
}
}
{
{
{
{
}
}
else
{
}
}
}
{
}
{
{
QPainter paint( this );
}
}
{
const int widthOfWindow = 1000;
const int heightOfWindow = 1300;
const int diameterOfCircle = 1000;
const int radiusOfCircle = (int)(diameterOfCircle / 2.0f);
const float timeLineWidthPercent = .88f;
const float circleInUsePercentage = .9f;
const int circleDiameterInUse = (int)((float)diameterOfCircle * circleInUsePercentage);
const int wOrigin = - ( circleDiameterInUse / 2 );
const int widthOfLeftHash = (int)(wOrigin * timeLineWidthPercent);
const int widthOfRightHash = (int)(( wOrigin + circleDiameterInUse ) * timeLineWidthPercent);
const int heightOfTopOfHash = (wOrigin + (int)(circleDiameterInUse * 1.15f));
const int heightOfBottomOfHash = (wOrigin + (int)(circleDiameterInUse * 1.2f));
const int heightOfTimeline = (int)((heightOfTopOfHash + heightOfBottomOfHash) / 2.0f);
const int heightOfCurrentPositionTick = heightOfTimeline + (int)( diameterOfCircle * .02f );
const int numDegreesPerHour = 30;
const int numDegreesPerMinute = numDegreesPerHour / 5;
const int numDegreesPerSecond = numDegreesPerMinute;
const int QT3oclockOffset = 90;
const int lengthOfHourHand = (int) ( radiusOfCircle * .4f);
const int lengthOfMinuteHand = (int) ( radiusOfCircle * .6f);
const int lengthOfSecondHand = (int) (radiusOfCircle * .8f);
const int widthOfHourHand = (int) (radiusOfCircle * .03f);
const int widthOfMinuteHand = (int) (radiusOfCircle * .025f);
const int widthOfSecondHand = (int) (radiusOfCircle * .016f);
QColor minuteColor;
QColor secondColor;
QColor hourColor;
QColor BlackColor = QColor(0,0,0);
paint->save();
{
minuteColor = QColor(150,0,40);
secondColor = QColor(0,0,150);
hourColor = QColor(150,40,170);
}
else
{
minuteColor = BlackColor;
secondColor = BlackColor;
hourColor = BlackColor;
}
QPen arcPenStyle;
arcPenStyle.setWidth(4);
paint->setWindow( -radiusOfCircle, -radiusOfCircle,
widthOfWindow,
heightOfWindow );
paint->setBrushOrigin(QPoint(0,0));
QRect v = paint->viewport();
int d = qMin( v.width(), v.height() );
paint->setViewport( v.left() + (v.width()-d)/2,
v.top() + (v.height()-d)/2, d, d );
paint->save();
arcPenStyle.setColor(hourColor);
paint->setPen(arcPenStyle);
{
paint->drawArc( -radiusOfCircle,
-radiusOfCircle,
diameterOfCircle,
diameterOfCircle,
(int)(-myMinHoursinQT),
(int)( -lenInQt) );
arcPenStyle.setWidth(3);
paint->setPen(arcPenStyle);
int startingWidth = (int)(((float)wOrigin * timeLineWidthPercent) +
((float)circleDiameterInUse * timeLineWidthPercent));
int endingWidth = (int)(((float)wOrigin * timeLineWidthPercent) +
((float)circleDiameterInUse * timeLineWidthPercent));
paint->drawLine(
QPoint(startingWidth,heightOfBottomOfHash),
QPoint(endingWidth,heightOfBottomOfHash) );
}
arcPenStyle.setColor(BlackColor);
arcPenStyle.setWidth(2);
paint->setPen(arcPenStyle);
paint->drawLine(
QPoint(widthOfLeftHash,heightOfTopOfHash),
QPoint(widthOfLeftHash,heightOfBottomOfHash ));
paint->drawLine(
QPoint(widthOfRightHash,heightOfTopOfHash),
QPoint(widthOfRightHash,heightOfBottomOfHash ));
arcPenStyle.setWidth(2);
paint->setPen(arcPenStyle);
paint->drawLine(
QPoint(widthOfLeftHash,heightOfTimeline),
QPoint(widthOfRightHash, heightOfTimeline) );
arcPenStyle.setWidth(7);
paint->setPen(arcPenStyle);
{
float centerOfCurrentPosition = ((wOrigin * timeLineWidthPercent) +
* (circleDiameterInUse * timeLineWidthPercent));
paint->drawLine(
QPoint( (int)(centerOfCurrentPosition - 2.5f) , heightOfCurrentPositionTick) ,
QPoint( (int)(centerOfCurrentPosition + 2.5f) , heightOfCurrentPositionTick) );
}
paint->restore();
{
const int numPts = 4;
QPointF pts[numPts];
paint->save();
float numHoursInDegrees = (
myHours * numDegreesPerHour) - QT3oclockOffset;
float numMinutesInDegrees = (
myMinutes * numDegreesPerMinute) - QT3oclockOffset;
float numSecondsInDegrees = (
mySeconds * numDegreesPerSecond) - QT3oclockOffset;
paint->rotate( numHoursInDegrees );
pts[0].setX( -widthOfHourHand );
pts[0].setY( 0 );
pts[1].setX( 0 );
pts[1].setY( -widthOfHourHand );
pts[2].setX( lengthOfHourHand );
pts[2].setY( 0 );
pts[3].setX( 0 );
pts[3].setY( widthOfHourHand );
paint->setPen(Qt::NoPen);
paint->setBrush(hourColor);
paint->drawConvexPolygon( pts, numPts );
paint->setPen(Qt::SolidLine);
paint->restore();
paint->save();
paint->setPen(Qt::NoPen);
paint->setBrush(minuteColor);
paint->rotate( numMinutesInDegrees );
pts[0].setX( -widthOfMinuteHand );
pts[0].setY( 0 );
pts[1].setX( 0 );
pts[1].setY( -widthOfMinuteHand );
pts[2].setX( lengthOfMinuteHand );
pts[2].setY( 0 );
pts[3].setX( 0 );
pts[3].setY( widthOfMinuteHand );
paint->drawConvexPolygon( pts, numPts );
paint->setPen(Qt::SolidLine);
paint->setBrush(Qt::SolidPattern);
paint->restore();
paint->save();
paint->setPen(Qt::NoPen);
paint->setBrush(secondColor);
paint->rotate( numSecondsInDegrees );
pts[0].setX( -widthOfSecondHand );
pts[0].setY( 0 );
pts[1].setX( 0 );
pts[1].setY( -widthOfSecondHand );
pts[2].setX( lengthOfSecondHand );
pts[2].setY( 0 );
pts[3].setX( 0 );
pts[3].setY( widthOfSecondHand );
paint->drawConvexPolygon( pts, numPts );
paint->setPen(Qt::SolidLine);
paint->restore();
}
paint->setBrushOrigin(QPoint(50,50));
{
paint->drawLine( (int)(radiusOfCircle *.93), 0,
(int)(radiusOfCircle * .95), 0 );
paint->rotate( 30 );
}
paint->restore();
}
#endif // SIMPLEDDMGUI
simpleDDMDisplay.cxx
#ifdef SIMPLEDDMGUI
#include "qapplication.h"
#ifdef WIN32
#include <winsock2.h>
#include <process.h>
#include <windows.h>
#else
#include <unistd.h>
#include <pthread.h>
#endif
#ifdef WIN32
DWORD WINAPI qtWindowThreadProc( LPVOID lpParam )
#else
void* qtWindowThreadProc(void* lpParam)
#endif
{
clockDisplay* ourParent = (clockDisplay*) lpParam;
int numberOfArgs = 0;
QApplication ourQapp(numberOfArgs, args);
ourParent->a = &ourQapp;
ourParent->ourAnalogClock =
new analogClock( ourParent->isPublisher(),
ourParent->isClockWise(),
ourParent->zone(),
ourParent->areRegionsDisplayed() );
ourParent->ourAnalogClock->resize( 300, 300 );
ourParent->setHasAClock(true);
ourParent->ourAnalogClock->show();
int result = ourParent->a->exec();
ourParent->setHasAClock(false);
ourParent->closed = true;
#ifdef WIN32
return 0;
#else
return 0;
#endif
}
clockDisplay::clockDisplay(bool pub, bool cw, bool showReg, int zone)
:
mySeconds(0),
myMinutes(0),
myHours(0.0f),
myUpperBoundRegion(0),
myLowerBoundRegion(1),
myAreRegionsDisplayed(showReg),
myHaveAClock(false),
closed(false),
closing(false),
myIsPublisher(pub),
myIsClockWise(cw),
myUTCZone(zone)
{
initializeQTDisplay();
}
clockDisplay::~clockDisplay()
{
setHasAClock(false);
}
void clockDisplay::initializeQTDisplay()
{
#ifdef WIN32
DWORD name;
HANDLE qtThread;
qtThread = CreateThread(
NULL, 0, qtWindowThreadProc,
this, 0, &name );
{
ExitProcess(0);
}
while ( false == hasAClock() )
Sleep(150);
Sleep(300);
#else
pthread_t windowThread;
pthread_create( &windowThread,
NULL, qtWindowThreadProc,
this);
while ( false == hasAClock() )
{
usleep(150);
}
#endif //ifdef Win32
}
void clockDisplay::setTime(int seconds)
{
if ( hasAClock() )
{
ourAnalogClock->setTime(seconds);
ourAnalogClock->update();
}
}
void clockDisplay::setTime(float hour, float min, float sec)
{
if ( hasAClock() )
{
ourAnalogClock->setTime(hour, min, sec);
ourAnalogClock->update();
}
}
void clockDisplay::setBoundsRegionInSeconds(int lower, int upper)
{
if ( hasAClock() )
{
if ( myAreRegionsDisplayed )
{
ourAnalogClock->setRangeInSeconds(lower, upper);
ourAnalogClock->update();
}
}
}
bool clockDisplay::isClockWise()
{
if (hasAClock())
{
return ourAnalogClock->getClockWise();
}
else
{
return myIsClockWise;
}
}
void clockDisplay::toggleClockWise()
{
if (hasAClock())
{
ourAnalogClock->toggle();
}
else
{
myIsClockWise = !myIsClockWise;
}
}
int clockDisplay::zone()
{
if (hasAClock())
{
return ourAnalogClock->zone();
}
else
{
return myUTCZone;
}
}
void clockDisplay::setZone(int newZone)
{
if ( hasAClock() )
{
ourAnalogClock->setZone(newZone);
myUTCZone = newZone;
}
else
{
myUTCZone = newZone;
}
}
#endif // SIMPLEDDMGUI
simpleDDMFederate.cxx
#ifdef WIN32
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#include <winsock2.h>
#include <process.h>
#include <windows.h>
#else
#include <unistd.h>
#include <stdio.h>
#endif
using namespace std;
:
myListenUpperBound(GREATESTSecondsInRegion),
myListenLowerBound(LOWESTSecondsInRegion),
mySendUpperBound(LOWESTSecondsInRegion+1),
mySendLowerBound(LOWESTSecondsInRegion),
myIsPublisher(false),
myCurrentposition(0),
myUpdateCount(0),
mySizeToInc(1),
mySendRangeSize(500.0f),
myEnableScopeAdvisories(false),
myInitialized(false),
myClosed(false),
myMapsInitialized(false),
myRegionValid(false),
myUTCZone(LOWESTUTCInRegion)
{
}
:
myListenUpperBound(data.myListenUpperBound),
myListenLowerBound(data.myListenLowerBound),
mySendUpperBound(data.mySendUpperBound),
mySendLowerBound(data.mySendLowerBound),
myIsPublisher(data.myIsPublisher),
myCurrentposition(data.myCurrentposition),
myUpdateCount(data.myUpdateCount),
mySizeToInc(data.mySizeToInc),
mySendRangeSize(data.mySendRangeSize),
myEnableScopeAdvisories(data.myEnableScopeAdvisories),
myInitialized(data.myInitialized),
myClosed(data.myClosed),
myMapsInitialized(data.myMapsInitialized),
myRegionValid(data.myRegionValid),
myUTCZone(LOWESTUTCInRegion)
{
}
{
}
simpleDDMKeyboard.cxx
#ifdef WIN32
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#include <conio.h>
#else
#include <unistd.h>
#endif
{
#ifndef WIN32
tcgetattr(0,&initial_settings);
#endif
}
{
#ifndef WIN32
tcsetattr(0, TCSANOW, &initial_settings);
#endif
}
{
#ifdef WIN32
return _kbhit();
#else
unsigned char ch;
int nread;
nread = read(0,&ch,1);
if (nread == 1)
{
return 1;
}
return 0;
#endif
}
{
char ch;
#ifdef WIN32
ch = _getch();
#else
{
}
else
read(0,&ch,1);
#endif
return ch;
}
{
char key = ' ';
return 0;
if (key == 'q' || key == 'Q')
{
return -1;
}
return 1;
return 2;
return 3;
return 4;
else if (key == 'p' || key == 'P')
return 5;
else
return 6;
}
simpleDDMMain.cxx
#ifdef WIN32
#pragma warning(disable: 4290)
#pragma warning(disable: 4786)
#include <winsock2.h>
#include <process.h>
#include <windows.h>
#include <exception>
#include <string>
#else
#include <unistd.h>
#include <stdio.h>
#endif
#include <iterator>
#ifdef SIMPLEDDMGUI
#endif //defined SIMPLEDDMGUI
#if defined(DtHLA13)
#elif defined(DtHLA13DLC)
#elif defined(DtHLA1516)
#elif defined(DtHLA1516E)
#else
#endif
using namespace std;
#ifndef SIMPLEDDMGUI
class clockDisplay {};
#endif //defined SIMPLEDDMGUI
template< class T >
const string& value,
T& dest );
void changeBounds( int lower,
int upper,
int zone,
clockDisplay* aClock = 0);
void SetPosition( int seconds,
clockDisplay* aDisplay = 0 );
void SetPositionAndChangeBounds( int seconds,
clockDisplay* aDisplay = 0 );
clockDisplay* aDisplay = 0);
clockDisplay* aDisplay = 0);
clockDisplay* aDisplay);
bool theUseGui = true;
bool theDisplayRegionExtents = true;
float theSendRangeTolerance(20.0f);
float theSizeOfToleratedSendRange(1);
const int theDefaultZone = 0;
int theCurrentPosition(0);
int theLastPosition(0);
int theZone(theDefaultZone);
bool theClockWise = true;
bool theChangeClockwiseDirection = false;
bool thePauseClock = false;
#ifdef WIN32
unsigned int theSleepInterval = 2;
#else
unsigned int theSleepInterval = 200;
#endif
bool thePrintUpdate = true;
int main(int argc, char** argv)
{
std::cout << "MAK simpleDDM " << std::endl;
clockDisplay* ourDisplay = 0;
#if defined(DtHLA13)
#elif defined(DtHLA1516)
#elif defined(DtHLA1516E)
ourFed = new simpleDDMFederate1516e();
#else
ourFed = new simpleDDMFederate1516_2025();
#endif
if (!parseCmdLine(argc, argv, ourFed))
return 0;
try
{
if ( theUseGui )
{
ourDisplay = createDisplay(ourFed);
}
{
return 0;
}
{
return 0;
}
{
SetPosition(theCurrentPosition, ourFed);
}
ourFed->
tick(0.0000001, 0.005);
bool finished(false);
while (!finished)
{
{
if (theUseGui)
{
if (syncOurZoneWithGui(ourFed, ourDisplay))
{
#ifdef SIMPLEDDMGUI
ourDisplay->zone(),
ourFed,
ourDisplay );
#endif
}
}
if (ourFed->
position() != theCurrentPosition )
{
theCurrentPosition = ourFed->
position();
SetPosition(theCurrentPosition, ourFed, ourDisplay);
}
}
else
{
checkForClockwiseChange(ourFed, ourDisplay);
if( !thePauseClock )
{
if ( theClockWise )
{
theLastPosition = theCurrentPosition;
if ( theCurrentPosition >= thePositionUpperBound )
{
theCurrentPosition = thePositionLowerBound
+ (theCurrentPosition - thePositionUpperBound);
}
}
else
{
theLastPosition = theCurrentPosition;
if ( theCurrentPosition < thePositionLowerBound )
{
theCurrentPosition = thePositionUpperBound
- (thePositionLowerBound - theCurrentPosition);
}
}
SetPositionAndChangeBounds(theCurrentPosition, ourFed, ourDisplay);
if ( (theCurrentPosition % (60 * 60 * 3)) == 0 )
{
}
else if ( (theCurrentPosition % ( 60 * 60 )) == 0 )
{
}
}
}
if (!ourFed->
tick(0.0000001, 0.005))
{
finished = true;
}
if (checkInput(ourFed, ourDisplay) < 0)
{
finished = true;
}
#ifdef WIN32
Sleep(theSleepInterval);
#else
usleep(theSleepInterval);
#endif
}
if( ourFed )
{
delete ourFed;
ourFed = 0;
}
}
#if defined(DtHLA13) || defined(DtHLA13DLC)
#if defined(DtHLA13)
catch (RTI::Exception& ex)
#elif defined(DtHLA13DLC)
#endif
{
cout << "RTI Exception (main loop): "
if( ourFed )
{
delete ourFed;
}
}
#else
#if defined(DtHLA1516)
catch (rti1516::Exception& ex)
#elif defined(DtHLA1516E)
catch (rti1516e::Exception& ex)
#elif defined(DtHLA1516_2025)
catch (rti1516_2025::Exception& ex)
#endif
{
cout <<
"RTI Exception (main loop): " <<
DtToString(ex.what()) << endl;
if( ourFed )
{
delete ourFed;
}
}
#endif
catch ( ... )
{
cout << "Caught unknown exception "
<< endl;
if( ourFed )
{
delete ourFed;
}
return 1;
}
return 0;
}
{
clockDisplay* tempDisplay = 0;
#ifdef SIMPLEDDMGUI
theClockWise,
theDisplayRegionExtents,
theZone != 0);
{
theZone, ourFed, tempDisplay );
}
else
{
theZone, ourFed, tempDisplay );
}
#endif
return tempDisplay;
}
void SetPosition( int seconds,
clockDisplay* aDisplay )
{
if (thePrintUpdate && !theUseGui && aFederate->
isPublisher())
{
cout << ".";
}
#ifdef SIMPLEDDMGUI
if (aDisplay)
{
aDisplay->setTime(seconds);
}
#endif
}
void SetPositionAndChangeBounds( int seconds,
clockDisplay* aDisplay )
{
int lowerPos(0);
int upperPos(0);
bool updated(false);
SetPosition(seconds, aFederate, aDisplay);
{
{
changeBounds( thePositionLowerBound,
thePositionUpperBound, theZone, aFederate, aDisplay);
}
return;
}
if ( theClockWise )
{
if ( theCurrentPosition < theLastPosition)
{
updated = true;
lowerPos = theCurrentPosition;
if (upperPos > thePositionUpperBound)
{
upperPos = thePositionUpperBound;
}
}
else if ( (theCurrentPosition + theSizeOfToleratedSendRange) >= aFederate->
sendUpperBound() )
{
if ( (theCurrentPosition + aFederate->
sendRangeSize()) < thePositionUpperBound )
{
updated = true;
lowerPos = theCurrentPosition;
}
{
updated = true;
lowerPos = theCurrentPosition;
upperPos = thePositionUpperBound;
}
}
if (updated)
{
changeBounds( lowerPos, upperPos, theZone, aFederate, aDisplay);
}
}
else
{
if ( theCurrentPosition > theLastPosition)
{
updated = true;
upperPos = theCurrentPosition;
if (lowerPos < thePositionLowerBound)
{
updated = true;
lowerPos = thePositionLowerBound;
}
}
else if ( (theCurrentPosition - theSizeOfToleratedSendRange) <= aFederate->
sendLowerBound() )
{
if ( (theCurrentPosition - aFederate->
sendRangeSize()) > thePositionLowerBound )
{
updated = true;
upperPos = theCurrentPosition;
}
{
updated = true;
lowerPos = thePositionLowerBound;
upperPos = theCurrentPosition;
}
}
if (updated)
{
changeBounds(lowerPos, upperPos, theZone, aFederate, aDisplay);
}
}
}
void changeBounds( int lower,
int upper,
int zone,
clockDisplay* aDisplay)
{
{
cout << "The limits on seconds Subscriptions are [" << simpleDDMFederate::LOWESTSecondsInRegion
<< " , " << simpleDDMFederate::GREATESTSecondsInRegion << ")\n";
}
else if (lower >= upper)
{
cout << "You must set the Lowerbound to be < your Upper bound\n";
}
{
cout << "The limits on theZone are [" << simpleDDMFederate::LOWESTUTCInRegion
<< " , " << simpleDDMFederate::GREATESTUTCInRegion << ")\n";
#ifdef SIMPLEDDMGUI
if ( aDisplay)
{
aDisplay->setZone(theZone);
}
#endif
}
else
{
theZone = zone;
if (thePrintUpdate && !aDisplay && aFederate->
isPublisher())
{
cout << endl;
}
cout << "Setting Bounds to seconds Range ("
<< lower << "," << upper << ")" << " in zone " << zone << endl;
#ifdef SIMPLEDDMGUI
if ( aDisplay )
{
aDisplay->setBoundsRegionInSeconds(lower, upper );
aDisplay->setZone(zone);
}
#endif
}
}
clockDisplay* aDisplay)
{
bool zoneWasChanged = false;
#ifdef SIMPLEDDMGUI
if ( theUseGui && aDisplay)
{
if ( aFederate->
zone() != aDisplay->zone() )
{
zoneWasChanged = true;
}
}
#endif
return zoneWasChanged;
}
clockDisplay* aDisplay)
{
bool directionWasChanged = false;
#ifndef SIMPLEDDMGUI
if (theChangeClockwiseDirection)
{
theClockWise = !theClockWise;
directionWasChanged = true;
theChangeClockwiseDirection = false;
cout << "Change direction to " << (theClockWise ? "ClockWise" : "CounterClockWise") << endl;
}
#else
if ( theUseGui && aDisplay)
{
if (theChangeClockwiseDirection)
{
aDisplay->toggleClockWise();
theClockWise = aDisplay->isClockWise();
directionWasChanged = true;
theChangeClockwiseDirection = false;
}
else
if ( theClockWise != aDisplay->isClockWise() )
{
theClockWise = aDisplay->isClockWise();
directionWasChanged = true;
}
}
#endif
return directionWasChanged;
}
clockDisplay* aDisplay)
{
int result = 1;
int keyboardReturnCode = theInput.keybrdTick();
if (keyboardReturnCode < 0)
{
result = -1;
}
else if (keyboardReturnCode == 1)
{
{
changeBounds(
aFederate,
aDisplay);
}
}
else if (keyboardReturnCode == 2)
{
{
theZone = aFederate->
zone();
changeBounds(
aFederate,
aDisplay);
}
}
else if (keyboardReturnCode == 3)
{
{
theChangeClockwiseDirection = theClockWise;
}
}
else if (keyboardReturnCode == 4)
{
{
theChangeClockwiseDirection = !theClockWise;
}
}
else if (keyboardReturnCode == 5)
{
{
thePauseClock = !thePauseClock;
}
}
else if (keyboardReturnCode != 0)
{
{
cout << "Left Arrow - counter clockwise\n"
<< "Right Arrow - clockwise\n"
<< "P,p - pause/unpause\n"
<< "Q,q - quit\n";
}
else
{
cout << "Up Arrow - increase listen zone\n"
<< "Down Arrow - decrease listen zone\n"
<< "Q,q - quit\n";
}
}
return result;
}
{
float pertinentRange = 500.0f;
int maxSecondsSubscribe(simpleDDMFederate::GREATESTSecondsInRegion);
int minSecondsSubscribe(simpleDDMFederate::LOWESTSecondsInRegion);
vector< string > cmdArgs;
copy( argv + 1, argv + argc, back_inserter( cmdArgs ));
vector< string >::const_iterator cur = cmdArgs.begin();
vector< string >::const_iterator last = cmdArgs.end();
int mult(1);
while ( cur != last )
{
vector< string >::const_iterator next = cur + 1;
if ( *cur == "-h" )
{
return false;
}
else if (*cur == "-fedFile" )
{
++cur;
}
else if (*cur == "-maxSubscribe" )
{
if ( !convert<int> (*cur, *next, maxSecondsSubscribe ) )
return false;
++cur;
}
else if (*cur == "-minSubscribe" )
{
if ( !convert<int> (*cur, *next, minSecondsSubscribe ) )
return false;
++cur;
}
else if (*cur == "-maxSubscribeH" )
{
float maxSecondsSubscribeH;
if ( !convert<float> (*cur, *next, maxSecondsSubscribeH ) )
return false;
++cur;
maxSecondsSubscribe = ((int)(maxSecondsSubscribeH * 60.0f * 60.0f));
}
else if (*cur == "-minSubscribeH" )
{
float minSecondsSubscribeH;
if ( !convert<float> (*cur, *next, minSecondsSubscribeH ) )
return false;
++cur;
minSecondsSubscribe = ((int)(minSecondsSubscribeH * 60.0f * 60.0f));
}
else if (*cur == "-scopeAdvisories" )
{
int tmpscopeAdvisory(-1);
if ( !convert<int> (*cur, *next, tmpscopeAdvisory ) )
return false;
if ( tmpscopeAdvisory == 0 || tmpscopeAdvisory == 1 )
else
return false;
++cur;
}
else if (*cur == "-isPublisher" )
{
int intisPub(0);
if (!convert<int>(*cur, *next, intisPub))
return false;
++cur;
}
else if (*cur == "-clockWise" )
{
int intCW(0);
if (!convert<int>(*cur, *next, intCW))
return false;
theClockWise = intCW != 0;
++cur;
}
else if (*cur == "-increment" )
{
int inc;
if (!convert<int> (*cur, *next, inc) )
return false;
if (inc < 0)
{
}
else if ( inc == 0 )
{
cout << " The publisher has to increment > 0\nTo set your increment to be a fraction"
<< " negative numbers are assigned as follows: (-1 * (1 / input))\n";
return false;
}
else
++cur;
}
else if (*cur == "-multiplier" )
{
if (!convert<int> (*cur, *next, mult))
return 0;
++cur;
}
else if (*cur == "-wait" )
{
int waitTime = 2;
if (!convert<int> (*cur, *next, waitTime) || waitTime < 0)
return false;
#ifdef WIN32
theSleepInterval = waitTime;
#else
theSleepInterval = waitTime * 100;
#endif
++cur;
}
else if (*cur == "-range" )
{
if (!convert<float> (*cur, *next, pertinentRange) )
return false;
++cur;
}
else if (*cur == "-sendRangeTolerance")
{
if (!convert<float> (*cur, *next, theSendRangeTolerance ))
return false;
++cur;
}
else if (*cur == "-timeZone" )
{
if ( !convert<int> (*cur, *next, theZone ) )
return false;
if ( theZone > (int)simpleDDMFederate::GREATESTUTCInRegion
|| theZone < (int)simpleDDMFederate::LOWESTUTCInRegion )
{
return false;
}
++cur;
}
else if (*cur == "-printUpdate" )
{
int printUpdateSwitch(-1);
if ( !convert<int> (*cur, *next, printUpdateSwitch ) )
return false;
if ( printUpdateSwitch == 0 || printUpdateSwitch == 1 )
thePrintUpdate = printUpdateSwitch == 1;
else
return false;
++cur;
}
else if (*cur == "-displayRegion")
{
int tmpdisplayRegion(-1);
if (!convert<int> (*cur, *next, tmpdisplayRegion ))
return false;
if ( tmpdisplayRegion == 0 || tmpdisplayRegion == 1 )
theDisplayRegionExtents = tmpdisplayRegion == 1;
else
return false;
++cur;
}
else if (*cur == "-useGUI" )
{
#ifdef SIMPLEDDMGUI
int intUseGUI(0);
if (!convert<int>(*cur, *next, intUseGUI ))
return false;
if ( theUseGui == 0 || theUseGui == 1 )
theUseGui = intUseGUI == 1;
else
return false;
++cur;
#else
cerr << "Cannot use -useGUI. The GUI is not available in this version of the example.\n"
return false;
#endif
}
else
{
cerr << "Unrecognized command line option: "
<< *cur << "\n"
return false;
}
++cur;
}
if ( (minSecondsSubscribe < (int)simpleDDMFederate::LOWESTSecondsInRegion) ||
(maxSecondsSubscribe > (int)simpleDDMFederate::GREATESTSecondsInRegion) )
{
cout << "The limits on seconds Subscriptions are [" << simpleDDMFederate::LOWESTSecondsInRegion
<< " , " << simpleDDMFederate::GREATESTSecondsInRegion << ")\nExiting...";
return false;
}
if (minSecondsSubscribe >= maxSecondsSubscribe)
{
cout << "You cannot set the Lowerbound to be < your Upper bound\nExiting...\n";
return false;
}
if ( mult < 1 )
{
cout << "You cannot set a multiplier to less than unity\nExiting...\n";
return false;
}
if ( pertinentRange < 0 )
{
cout << "You must have a non-Zero sized range \nExiting...\n";
return false;
}
if ( (theZone < (int)simpleDDMFederate::LOWESTUTCInRegion) ||
(theZone >= (int)simpleDDMFederate::GREATESTUTCInRegion) )
{
cout << "The limits on theZone are [" << simpleDDMFederate::LOWESTUTCInRegion
<< " , " << simpleDDMFederate::GREATESTUTCInRegion << ")\nExiting...";
return false;
}
if ( theSendRangeTolerance > 100 || theSendRangeTolerance < 0 )
{
cout << "The tolerance parameter is expressed as a percentage of your Range\n"
<< " it must be between [1,100]\n";
return false;
}
{
ourFed->
changeBounds(minSecondsSubscribe, maxSecondsSubscribe, theZone);
cout << "Setting initial Bounds to seconds Range ("
<< minSecondsSubscribe << "," << maxSecondsSubscribe << ")"
<< " in zone " << theZone << endl;
}
else
{
cout << "No initial bounds specifed, setting to seconds Range ("
<< 0 << "," << 1 << ")" << " in zone " << theZone << endl;
}
theCurrentPosition = (0);
theSizeOfToleratedSendRange =
((float)ourFed->
sendRangeSize() * (theSendRangeTolerance / 100.0f));
return true;
}
template< class T >
const string& value,
T& dest )
{
{
cerr << "Bad Parameter Value\n"
<< "Param: " << param
<< "\tValue: " << value << endl;
return false;
}
return true;
}
simpleDDMAclock.h
#ifndef ANALOGCLOCK_H
#define ANALOGCLOCK_H
#include <QWidget>
#include <math.h>
#include <QLineEdit>
class QPushButton;
class QVBoxLayout;
class QHBoxLayout;
class QSpacerItem;
{
Q_OBJECT
public:
analogClock(
bool isPublisher,
bool isClockWise,
int zone,
bool displayRegions,
QWidget *parent=0,
const char *name=0 );
inline void setTime(
float hour = 12.0f,
float minute = 0,
float second = 0);
protected:
private:
private slots:
public slots:
private:
};
{
float second = seconds;
}
{
}
{
}
{
}
{
}
{
}
{
}
#endif // ACLOCK_H
simpleDDMDisplay.h
#ifndef DISPLAYFORREGIONEXAMPLE_H_
#define DISPLAYFORREGIONEXAMPLE_H_
#ifdef SIMPLEDDMGUI
#include <vector>
#include <string>
class QApplication;
class clockDisplay
{
public:
clockDisplay( bool pub = false, bool cw = true,
bool showReg = true, int zone = 0 );
~clockDisplay();
clockDisplay(clockDisplay& data);
protected:
void initializeQTDisplay();
public:
float upperBoundRegion();
float lowerBoundRegion();
bool areRegionsDisplayed();
bool isPublisher();
bool isClockWise();
void toggleClockWise();
bool hasAClock();
void setHasAClock(bool newVal);
int zone();
void setZone(int newZone);
void setBoundsRegionInSeconds(int lower, int upper);
void setTime(int seconds);
void setTime(float hour, float min, float sec);
bool myHaveAClock;
bool closed;
bool closing;
QApplication* a;
private:
float mySeconds;
float myMinutes;
float myHours;
float myUpperBoundRegion;
float myLowerBoundRegion;
bool myAreRegionsDisplayed;
bool myIsPublisher;
bool myIsClockWise;
int myUTCZone;
};
inline float clockDisplay::upperBoundRegion()
{
return myUpperBoundRegion;
}
inline float clockDisplay::lowerBoundRegion()
{
return myLowerBoundRegion;
}
inline bool clockDisplay::areRegionsDisplayed()
{
return myAreRegionsDisplayed;
}
inline bool clockDisplay::isPublisher()
{
return myIsPublisher;
}
inline bool clockDisplay::hasAClock()
{
return myHaveAClock;
}
inline void clockDisplay::setHasAClock(bool newVal)
{
myHaveAClock = newVal;
}
#endif // SIMPLEDDMGUI
#endif // DISPLAYFORREGIONEXAMPLE_H_
simpleDDMFedAmb13.h
#ifndef MyFederateAmbassador_H_
#define MyFederateAmbassador_H_
#include "NullFederateAmbassador.hh"
#include <map>
#include <string>
{
public:
};
{
public:
throw (RTI::FederateInternalError);
const char* theObjectName)
RTI::CouldNotDiscover,
RTI::ObjectClassNotKnown,
RTI::FederateInternalError);
const RTI::AttributeHandleValuePairSet& theAttributes,
const RTI::FedTime& theTime,
const char *theTag,
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateOwnsAttributes,
RTI::InvalidFederationTime,
RTI::FederateInternalError);
const RTI::AttributeHandleValuePairSet& theAttributes,
const char *theTag)
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateOwnsAttributes,
RTI::FederateInternalError);
const RTI::ParameterHandleValuePairSet& theParameters,
const RTI::FedTime& theTime,
const char *theTag,
RTI::InteractionClassNotKnown,
RTI::InteractionParameterNotKnown,
RTI::InvalidFederationTime,
RTI::FederateInternalError);
const RTI::ParameterHandleValuePairSet& theParameters,
const char *theTag)
RTI::InteractionClassNotKnown,
RTI::InteractionParameterNotKnown,
RTI::FederateInternalError);
const RTI::FedTime& theTime,
const char *theTag,
RTI::ObjectNotKnown,
RTI::InvalidFederationTime,
RTI::FederateInternalError);
const char *theTag)
RTI::ObjectNotKnown,
RTI::FederateInternalError);
const RTI::AttributeHandleSet& theAttributes)
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateInternalError) ;
const RTI::AttributeHandleSet& theAttributes)
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::FederateInternalError) ;
public:
};
#endif
simpleDDMFederate.h
#ifndef REGIONEXAMPLE_H_
#define REGIONEXAMPLE_H_
#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
{
public:
virtual void sendUpdate(
int currentPosition ) = 0;
virtual void changeBounds(
int lower,
int upper,
int UTCZone) = 0;
virtual bool tick(
double atMost=0.0f) = 0;
virtual bool tick(
double atLeast,
double atMost) = 0;
{
};
protected:
private:
};
{
}
{
{
}
else
{
}
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
#endif
simpleDDMKeyboard.h
#ifndef MYKBHIT_H_
#define MYKBHIT_H_
#ifndef WIN32
#include <termios.h>
#endif
{
public:
enum
{
#ifdef WIN32
#else
#endif
};
protected:
private:
#ifndef WIN32
#endif
};
#endif
simpleDDMSimple13.h
#ifndef REGIONEXAMPLE13_H_
#define REGIONEXAMPLE13_H_
#include <string.h>
#include "RTI.hh"
{
public:
bool tick(
double atMost=0.0f);
bool tick(
double atLeast,
double atMost);
protected:
private:
};
{
}
{
}
{
}
{
}
{
}
{
}
#endif
simpleDDMStringUtil.h
#ifndef stringUtil_H_
#define stringUtil_H_
#include <string>
#include <sstream>
std::string
DtToString(
const std::wstring &in_val);
{
std::wstring temp;
while (*in_val != '\0')
temp += *in_val++;
return temp;
}
inline std::string
DtToString(
const std::wstring &in_val)
{
std::string temp;
std::wstring::const_iterator b = in_val.begin();
const std::wstring::const_iterator e = in_val.end();
while (b != e)
{
temp += static_cast<char>(*b);
++b;
}
return temp;
}
inline std::string
usage()
{
std::ostringstream ostr;
ostr << "Usage:\n"
<< std::setw( 20 ) << " -fedFile "
<< "specify the Fed file name \n"
<< std::setw ( 32 ) << " " << "1.3 Default: (MAKSimpleDDM.fed) \n"
<< std::setw ( 32 ) << " " << "1516 Default: (MAKSimpleDDM.xml) \n"
<< "\nSubscriber parameters\n"
<< std::setw( 20 ) << " -maxSubscribe "
<< "Simple DDM uses just one extent and dimension, \n"
<< std::setw( 32 ) << " " << "this is the subscribers upper range \n"
<< std::setw( 32 ) << " " << "(in seconds)\n"
<< std::setw( 20 ) << " -minSubscribe "
<< "Simple DDM uses just one extent and dimension, \n"
<< std::setw( 32 ) << " " << "this is the subscriber's lower range \n"
<< std::setw( 32 ) << " " << "(in seconds)\n"
<< std::setw( 20 ) << " -maxSubscribeH "
<< "Simple DDM uses just one extent and dimension, \n"
<< std::setw( 32 ) << " " << "this is the subscribers upper range\n"
<< std::setw( 32 ) << " " << "(in hours)\n"
<< std::setw( 20 ) << " -minSubscribeH "
<< "Simple DDM uses just one extent and dimension, \n"
<< std::setw( 32 ) << " " << "this the subscriber's lower range \n"
<< std::setw( 32 ) << " " << "(in hours)\n"
<< std::setw( 20 ) << " -scopeAdvisories "
<< "Whether or not the user wants to receive \n"
<< std::setw( 32 ) << " " << "scoping advisory notices (0 || 1)\n"
<< "\nPublisher parameters\n"
<< std::setw( 20 ) << " -isPublisher "
<< "Whether the application should as publisher or \n"
<< std::setw( 32 ) << " " << "subscriber. (default 0)\n"
<< std::setw( 20 ) << " -clockWise "
<< "Whether the object moves in CW or CCW direction \n"
<< std::setw( 32 ) << " " << "1 = CW (default)\n"
<< std::setw( 20 ) << " -increment "
<< "Increment that the publisher will advance by in seconds\n"
<< std::setw( 32 ) << " " << "modified by multiplier\n"
<< std::setw( 20 ) << " -multiplier "
<< "Multiplier for both advancement upon the extent\n"
<< std::setw( 32 ) << " " << "and lookahead on the extent\n"
<< std::setw( 20 ) << " -wait "
<< "Time interval (in milliseconds) to wait inbetween each update cycle.\n"
<< std::setw( 20 ) << " -range "
<< "Lookahead multiplier that the listening range \n"
<< std::setw( 32 ) << " " << "will subscribe to\n"
<< std::setw( 20 ) << " -sendRangeTolerance "
<< " Describes a percentage of the sending range, \n"
<< std::setw( 32 ) << " " << "how close the sender can get to the \n"
<< std::setw( 32 ) << " " << "extents of the sending range before \n"
<< std::setw( 32 ) << " " << "the Lower and Upper Bound of the \n"
<< std::setw( 32 ) << " " << "sender are re-sent\n"
<< std::setw( 20 ) << " -timeZone"
<< " Sets the UTC zone of the publisher \n"
<< std::setw( 32 ) << " " << "Acceptable Values are from 0 .. 23 \n"
<< std::setw( 32 ) << " " << " Default value is 0, representing GMT\n"
<< std::setw( 20 ) << " -printUpdate "
<< "When GUI is disabled, prints a dot for each update to better\n"
<< std::setw( 32 ) << " " << "distinguish bounds changes\n"
<< "\nDisplay Options \n"
<< std::setw( 20 ) << " -displayRegion "
<< "Whether or not there is distinction in shading \n"
<< std::setw( 32 ) << " " << "in extent of a region and the entire \n"
<< std::setw( 32 ) << " " << "dimension (0 || 1)\n"
#ifdef SIMPLEDDMGUI
<< std::setw( 20 ) << " -useGUI "
<< "Whether the application should run in GUI or \n"
<< std::setw( 32 ) << " " << "console mode. \n"
#endif
<< std::endl;
return ostr.str();
}
#endif