MAK RTIspy API Documentation for HLA Evolved
rtisimple Example Code for HLA 1516

rtiSimple1516.cxx and rtiSimpleFedAmb1516.cxx (rtiSimpleFedAmb1516.h) have the RTI calls and federate ambassador calls for the HLA 1516 version of rtisimple.

This page has the code for the following files:


rtiSimple1516.cxx

/*******************************************************************************
** Copyright (c) 2004 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
// A simple federate that updates an object with attributes whose values
// are the name of the attribute. Objects from other simple federates
// are discovered and reflected. The string values are byte encoded to allow
// compatibility between 1.3 and 1516
#pragma warning(disable: 4251)
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#ifdef WIN32
#include <winsock2.h>
#include <process.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <wchar.h>
#include <sstream>
#include <string>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <RTI/RTI1516.h>
// Handles keyboard input without blocking
using namespace rti1516;
using namespace std;
// Map between strings and attribute handles
typedef std::map<std::wstring, AttributeHandle> DtAttrNameHandleMap;
// Map between strings and parameter handles
typedef std::map<std::wstring, ParameterHandle> DtParamNameHandleMap;
// Data shared between federate and federate ambassador
// The federate handle
// The object class name
std::wstring theClassName = L"BaseEntity";
// The interaction class name
std::wstring theInterClassName = L"WeaponFire";
// The object class handle (to be retrieved from RTI).
// The interaction class handle (to be retrieved from RTI).
// The object instance handle (to be retrieved from the RTI).
ObjectInstanceHandle theObjectHandle;
// Map between strings and attribute handles
// Map between strings and parameter handles
// Create the federation execution
void createFedEx(RTIambassador & rtiAmb,
std::wstring const& fedName,
std::wstring const& fedFile)
{
wcout << L"createFederationExecution "
<< fedName.c_str() << L" "
<< fedFile.c_str() << endl;
try
{
rtiAmb.createFederationExecution(fedName, fedFile);
}
catch(FederationExecutionAlreadyExists& ex)
{
wcout << L"Could not create Federation Execution: "
<< L"FederationExecutionAlreadyExists: "
<< ex.what().c_str() << endl;
}
catch(rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl
<< L"Could not create Federation Execution: " << endl;
exit(0);
}
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
wcout << L"Federation Created." << endl;
}
// Join the federation execution
void joinFedEx(
RTIambassador & rtiAmb, MyFederateAmbassador & fedAmb,
std::wstring const& federateType, std::wstring const& federationName)
{
bool joined=false;
const int maxTry = 10;
int numTries = 0;
wcout << L"joinFederationExecution "
<< federateType.c_str() << L" "
<< federationName.c_str() << endl;
while (!joined && numTries++ < maxTry)
{
try
{
theFederateHandle = rtiAmb.joinFederationExecution(federateType, federationName, fedAmb);
joined = true;
}
catch(FederationExecutionDoesNotExist)
{
wcout << L"FederationExecutionDoesNotExist, try "
<< numTries << L" out of "
<< maxTry << endl;
continue;
}
catch(rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
return;
}
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
if (joined)
wcout << L"Joined Federation." << endl;
else
{
wcout << L"Giving up." << endl;
rtiAmb.destroyFederationExecution(federationName);
exit(0);
}
}
// Resign and destroy the federation execution
std::wstring const& federationName)
{
wcout << L"Resign and Destroy Federation" << endl;
rtiAmb.destroyFederationExecution(federationName);
}
// Save federation
// Query federation save status
{
wcout << L"Query save status\n";
int count = 0;
while ( count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
wcout << L"Timed out waiting for status response\n";
}
else
{
FederateHandleSaveStatusPairVector::const_iterator statusIter = theAmbData.myFederateHandleSaveStatus.begin();
FederateHandleSaveStatusPairVector::const_iterator statusEnd = theAmbData.myFederateHandleSaveStatus.end();
for ( ; statusIter != statusEnd; ++statusIter )
{
wcout << L"Status federate " << statusIter->first.toString().c_str() << L" is ";
switch (statusIter->second)
{
wcout << L"NO_SAVE_IN_PROGRESS\n";
break;
wcout << L"FEDERATE_INSTRUCTED_TO_SAVE\n";
break;
wcout << L"FEDERATE_SAVING\n";
break;
wcout << L"FEDERATE_WAITING_FOR_FEDERATION_TO_SAVE\n";
break;
default:
wcout << L"UNKNOWN\n";
break;
}
}
}
}
// Request federation save and wait for initiate
// Return save status
bool requestFederationSave(RTIambassador & rtiAmb, std::wstring const& label)
{
bool saveOk = true;
int count = 0;
// Turn the signals off
wcout << L"Request federation save with label " << label.c_str() << endl;
// Request the save and wait for the signal that the save has been initiated
// or that the federation has not saved (could be that some other federate
// resigns during save)
rtiAmb.requestFederationSave(label);
while (count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
saveOk = false;
{
wcout << L"Timed out waiting for initiate federate save\n";
}
}
return saveOk;
}
// Wait for federation saved
// Return save status
{
bool saveOk = true;
int count = 0;
// Wait until the RTI signals that the entire federation completed the save
while ( count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
saveOk = false;
{
wcout << L"Timed out waiting for federation saved\n";
}
}
return saveOk;
}
// Perform save federation
// Return save status
bool saveFederation(RTIambassador & rtiAmb, std::wstring const& label, bool performRequest)
{
bool saveOk = true;
int count = 0;
try
{
if ( performRequest )
{
saveOk = requestFederationSave(rtiAmb, label);
}
{
// At this point, the save has been initiated
// and the federate cannot invoke any other calls except
// to complete the save (or resign). It signals to the RTI that
// it will begin saving its own local state
wcout << L"Federate save begun\n";
// Here the federate would save its own state including any context
// information relating to the RTI
// (i.e. what classes are published and subscribed
// object instance handles for registered and discovered objects, etc.
// Once the federate saves is own data, it signals to the RTI that its
// save is complete.
wcout << L"Federate save complete\n";
// Wait until the RTI signals that the entire federation completed the save
saveOk = waitForFederationSaved(rtiAmb);
}
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: " << ex.what().c_str() << endl;
wcout << L"Could not save federation " << label.c_str() << endl;
saveOk = false;
}
catch(exception& stdEx)
{
wcout << L"Standard exception: " << stdEx.what() << endl;
wcout << L"Could not save federation " << label.c_str() << endl;
saveOk = false;
}
catch(...)
{
wcout << L"Unknown exception\n";
wcout << L"Could not save federation " << label.c_str() << endl;
saveOk = false;
}
// Turn the signals off
return saveOk;
}
// Restore federation
// Query restore status
{
// Check the status
int count = 0;
while ( count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
wcout << L"Timed out waiting for restore status\n";
}
else
{
FederateHandleRestoreStatusPairVector::const_iterator statusIter = theAmbData.myFederateHandleRestoreStatus.begin();
FederateHandleRestoreStatusPairVector::const_iterator statusEnd = theAmbData.myFederateHandleRestoreStatus.end();
for ( ; statusIter != statusEnd; ++statusIter )
{
wcout << L"Status federate " << statusIter->first.toString().c_str() << L" is ";
switch (statusIter->second)
{
wcout << L"NO_RESTORE_IN_PROGRESS\n";
break;
wcout << L"FEDERATE_RESTORE_REQUEST_PENDING\n";
break;
wcout << L"FEDERATE_WAITING_FOR_RESTORE_TO_BEGIN\n";
break;
wcout << L"FEDERATE_PREPARED_TO_RESTORE\n";
break;
wcout << L"FEDERATE_RESTORING\n";
break;
wcout << L"FEDERATE_WAITING_FOR_FEDERATION_TO_RESTORE\n";
break;
default:
wcout << L"UNKNOWN\n";
break;
}
}
}
}
// Request the restore and wait for the response.
// Return request status
bool requestFederationRestore(RTIambassador & rtiAmb, std::wstring const& label)
{
int count = 0;
bool restoreOk = true;
wcout << L"Request federation restore with label " << label.c_str() << endl;
// Turn the signals off
rtiAmb.requestFederationRestore(label);
while (count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for request federation restore succeeded.\n";
}
}
return restoreOk;
}
// Wait for restore begun
// Return begun status
{
bool restoreOk = true;
// Wait for the restore begun
wcout << L"Wait for restore begun\n";
int count = 0;
while (count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for federation restore begun.\n";
}
}
return restoreOk;
}
// Wait for initiate restore
// Return initiate status
{
bool restoreOk = true;
// Wait for the initiate restore
wcout << L"Wait for initiate restore\n";
int count = 0;
while (count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
restoreOk = false;
}
{
restoreOk = false;
wcout << L"Timed out waiting for initiate federate restore.\n";
}
{
// In general, a federate must be able to restore any saved state of
// a federate of the same type. Even if a federate submits
// a unique federate type string during join, the current federate
// and object handles may not match those being restored.
// This simplistic federate implementation cannot handle the case where
// the federate and object handles are different.
wcout << L"Restore initiated with handle " << theAmbData.myRestoreFederateHandle.toString().c_str()
<< L" does not match current handle " << theFederateHandle.toString().c_str() << endl;
wcout << L"Unable to complete restore\n";
restoreOk = false;
// Will revert to state before restore was begun
count = 0;
while ( count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
wcout << L"Timed out waiting for federation not restored.\n";
}
}
return restoreOk;
}
// Wait for federation (not) restored
// Return restore status
{
bool restoreOk = true;
// Wait until the RTI signals that the entire federation completed the restore
wcout << L"Wait for federation restored\n";
int count = 0;
while ( count++ < 100
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for federation restored.\n";
}
}
return restoreOk;
}
// Perform restore federation
// Return restore status
bool restoreFederation(RTIambassador & rtiAmb, std::wstring const& label, bool performRequest)
{
bool restoreOk = true;
int count = 0;
try
{
if ( performRequest )
{
if ( requestFederationRestore(rtiAmb, label) )
{
restoreOk = waitForRestoreBegun(rtiAmb);
}
}
{
// At this point, the restore has begun
// and the federate cannot invoke any other calls except
// to complete the restore (or resign). It waits for the
// initiate restore to begin restoring its local state.
if ( restoreOk = waitForInitiateRestore(rtiAmb) )
{
// Here the federate would restore its own state including any context
// information relating to the RTI
// (i.e. what classes are published and subscribed
// object instance handles for registered and discovered objects, etc.
// Once the federate restores its own data, it signals to the RTI that its
// restore is complete.
wcout << L"Federate restore complete\n";
// If the federate was unable to restore its state, it would respond with
// federateRestoreNotComplete();
// Now wait for remaining federation to be restored
restoreOk = waitForFederationRestored(rtiAmb);
}
}
}
catch (rti1516::FederateInternalError& ex)
{
wcout << L"RTI Exception: " << ex.what().c_str() << endl;
wcout << L"Could not restore federation " << label.c_str() << endl;
restoreOk = false;
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: " << ex.what().c_str() << endl;
wcout << L"Could not restore federation " << label.c_str() << endl;
restoreOk = false;
}
catch(exception& stdEx)
{
wcout << L"Standard exception: " << stdEx.what() << endl;
wcout << L"Could not restore federation " << label.c_str() << endl;
restoreOk = false;
}
catch(...)
{
wcout << L"Unknown exception\n";
wcout << L"Could not restore federation " << label.c_str() << endl;
restoreOk = false;
}
// Turn the signals off
return restoreOk;
}
// Publish and subscribe the object class attributes.
// Register an object instance of the class.
{
// Get the object class handle
try
{
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not get object class handle: "
<< theClassName.c_str() << endl;
return false;
}
// Get the attribute handles and construct the name-handle map and
// attribute set
std::wstring attrName;
try
{
attrName = L"AccelerationVector";
theAttrNameHandleMap[attrName] =
hSet.insert(theAttrNameHandleMap[attrName]);
attrName = L"VelocityVector";
theAttrNameHandleMap[attrName] =
hSet.insert(theAttrNameHandleMap[attrName]);
attrName = L"Orientation";
theAttrNameHandleMap[attrName] =
hSet.insert(theAttrNameHandleMap[attrName]);
attrName = L"DeadReckoningAlgorithm";
theAttrNameHandleMap[attrName] =
hSet.insert(theAttrNameHandleMap[attrName]);
attrName = L"WorldLocation";
theAttrNameHandleMap[attrName] =
hSet.insert(theAttrNameHandleMap[attrName]);
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not get attribute handle "
<< attrName.c_str() << endl;
return false;
}
// Publish and subscribe
int cnt=0;
try
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
cnt=1;
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not "
<< (cnt ? L"subscribe" : L"publish") << endl;
return false;
}
std::wstring objectName(L"Talk");
// Reserve object name and register the object instance
try
{
unsigned int objId = abs(getpid());
std::wstringstream pid;
pid << objId;
objectName += pid.str();
rtiAmb.reserveObjectInstanceName(objectName);
int count = 0;
while (count++ < 100 && !theAmbData.myNameReservationReturned)
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
if (count < 100)
{
objectName);
//theObjectHandle = rtiAmb.registerObjectInstance(theClassHandle);
// Add name-handle to map
}
else
{
wcout << L"Failed waiting for reserve object name "
<< objectName.c_str() << endl;
return false;
}
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not Register Object "
<< objectName.c_str()
<< L" with class "
<< theClassName.c_str() << endl;
return false;
}
wcout << L"Registered object "
<< objectName.c_str()
<< L" with class name "
<< theClassName.c_str() << endl;
return true;
}
// Publish and Subscribe to an interaction class
{
// Get the interaction class handle
try
{
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not get interaction class handle: "
<< theInterClassName.c_str() << endl;
return false;
}
// Get the parameter handles and construct the name-handle map
std::wstring paramName;
try
{
paramName = L"EventIdentifier";
theParamNameHandleMap[paramName] =
paramName = L"FireControlSolutionRange";
theParamNameHandleMap[paramName] =
paramName = L"FireMissionIndex";
theParamNameHandleMap[paramName] =
paramName = L"FiringLocation";
theParamNameHandleMap[paramName] =
paramName = L"FiringObjectIdentifier";
theParamNameHandleMap[paramName] =
paramName = L"FuseType";
theParamNameHandleMap[paramName] =
paramName = L"InitialVelocityVector";
theParamNameHandleMap[paramName] =
paramName = L"MunitionObjectIdentifier";
theParamNameHandleMap[paramName] =
paramName = L"MunitionType";
theParamNameHandleMap[paramName] =
paramName = L"QuantityFired";
theParamNameHandleMap[paramName] =
paramName = L"RateOfFire";
theParamNameHandleMap[paramName] =
paramName = L"TargetObjectIdentifier";
theParamNameHandleMap[paramName] =
paramName = L"WarheadType";
theParamNameHandleMap[paramName] =
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not get parameter handle "
<< paramName.c_str() << endl;
return false;
}
// Publish and subscribe
int cnt=0;
try
{
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
cnt=1;
rtiAmb.evokeMultipleCallbacks(0.1, 0.2);
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
wcout << L"Could not "
<< (cnt ? L"publish" : L"subscribe")
<< L" to interaction class." << endl;
return false;
}
wcout << L"Subscribed to interaction class: "
<< theInterClassName.c_str()
<< L" with handle: "
<< theInterClassHandle.toString() << endl;
return true;
}
int main(int argc, char** argv)
{
std::cout << "MAK rtiSimple version 1516" << std::endl;
RTIambassador* rtiAmb = 0;
try
{
// Federate and Federation info
std::vector< std::wstring > args;
std::wstring federationName(L"MAKsimple");
std::wstring federationFile(L"MAKsimple.xml");
std::wstring federateType(L"rtisimple1516");
if (argc > 1)
{
if (strcmp(argv[1], "-h") == 0)
{
wcout << L"Usage: rtisimple1516 [federationName] [federationFile] [federateType]" << endl;
wcout << L"default values: "
<< L"\"" << federationName.c_str() << L"\" "
<< L"\"" << federationFile.c_str() << L"\" "
<< L"\"" << federateType.c_str() << L"\" " << endl;
return 0;
}
federationName = DtToWString(argv[1]);
}
if (argc > 2)
{
federationFile = DtToWString(argv[2]);
}
if (argc > 3)
{
federateType = DtToWString(argv[3]);
}
wcout << L"Using " << RTIname().c_str() << L" " << RTIversion().c_str() << L"\n";
// RTI and Federate Ambassadors
std::auto_ptr < RTIambassador > rtiAmbAP =
rtiAmbFactory->createRTIambassador(args);
rtiAmb = rtiAmbAP.release();
#ifdef WIN32
WSADATA data;
WSAStartup(MAKEWORD(1,1), &data);
#endif
rtiAmb->evokeCallback(0.0);
long count=0;
bool doConnect = true;
bool connected = false;
while (1)
{
if (doConnect)
{
doConnect = false;
// Create the federation
createFedEx(*rtiAmb, federationName, federationFile);
// Join the federation
joinFedEx(*rtiAmb, fedAmb, federateType, federationName);
// Publish, subscribe and register and object
{
resignAndDestroy(*rtiAmb, federationName);
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
return 0;
}
// Publish and subscribe to the required interaction
{
resignAndDestroy(*rtiAmb, federationName);
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
return 0;
}
// Construct an attribute handle value pair set with the
// values containing the attribute names
attrValues.clear();
for (DtAttrNameHandleMap::iterator iter = theAttrNameHandleMap.begin();
iter != theAttrNameHandleMap.end();
iter++)
{
// Attribute values will be just the name of the attribute.
// Format is narrow string representation of attribute name to remain
// compatible with 1.3 simple federate
std::string temp = DtToString(iter->first);
attrValues[iter->second].setData(temp.c_str(), temp.length()+1);
}
// Construct a parameter handle value pair set with the
// values containing the parameter names
paramValues.clear();
for (DtParamNameHandleMap::iterator iter2 = theParamNameHandleMap.begin();
iter2 != theParamNameHandleMap.end();
iter2++)
{
// Parameter values will be just the name of the attribute.
// Format is narrow string representation of parameter name to remain
// compatible with 1.3 simple federate
std::string temp = DtToString(iter2->first);
paramValues[iter2->second].setData(temp.c_str(), temp.length()+1);
}
connected = true;
}
else if (connected)
{
std::stringstream ss;
ss << "1516-" << count++;
std::string tag(ss.str());
// Tag format is narrow string representation compatible
// with 1.3 simple federate
// Update the object
attrValues,
VariableLengthData(tag.c_str(), tag.size()+1));
// Send an interaction every few passes
if ( count % 5 == 0 )
{
wcout << L"Sending interaction..." << endl;
rtiAmb->sendInteraction(
paramValues,
VariableLengthData(tag.c_str(), tag.size()+1));
}
rtiAmb->evokeMultipleCallbacks(0.1, 0.5);
{
// Perform a save operation
if ( !saveFederation(*rtiAmb, theAmbData.mySaveLabel, false) )
{
// Save failed
break;
}
}
{
// Perform a restore operation
if ( !restoreFederation(*rtiAmb, theAmbData.myRestoreLabel, false) )
{
// Restore failed
break;
}
}
}
int key = input.keybrdTick();
if (key < 0)
{
break;
}
else if ('c' == key || 'C' == key )
{
doConnect = !connected;
}
else if ('d' == key || 'D' == key )
{
if (connected)
{
try
{
resignAndDestroy(*rtiAmb, federationName);
connected = false;
}
catch(rti1516::Exception& ex)
{
wcout << L"RTI Exception: "
<< ex.what().c_str() << endl;
}
}
}
else if ('s' == key || 'S' == key )
{
if (connected)
{
// Initiate a save operation
const wstring saveLabel(L"rtiSimpleSave");
if ( !saveFederation(*rtiAmb, saveLabel, true) )
{
// Save failed
break;
}
}
}
else if ('r' == key || 'R' == key )
{
if (connected)
{
// Initiate a restore operation
const wstring savedLabel(L"rtiSimpleSave");
if ( !restoreFederation(*rtiAmb, savedLabel, true) )
{
// Restore failed
break;
}
}
}
#ifdef WIN32
Sleep(2000);
#else
sleep(2);
#endif
}
if (connected)
{
// Resign and destroy federation
resignAndDestroy(*rtiAmb, federationName);
}
}
catch (rti1516::Exception& ex)
{
wcout << L"RTI Exception (main loop): "
<< ex.what().c_str() << endl;
}
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
#ifdef WIN32
WSACleanup();
#endif
return 0;
}

rtiSimpleFedAmb1516.cxx

/*******************************************************************************
** Copyright (c) 2010 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma warning(disable: 4251)
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#include <iostream>
using namespace std;
{
AttributeHandleValueMap::const_iterator iter;
for (iter = attrVals.begin(); iter != attrVals.end(); iter++)
{
wcout << iter->first.toString().c_str() << L" "
<< DtToWString((char*)iter->second.data()).c_str() << endl;
}
}
{
ParameterHandleValueMap::const_iterator iter;
for (iter = paramVals.begin(); iter != paramVals.end(); iter++)
{
wcout << iter->first.toString().c_str() << L" "
<< DtToWString((char*)iter->second.data()).c_str() << endl;
}
}
NullFederateAmbassador(), myData(data) {}
throw () {}
void MyFederateAmbassador::initiateFederateSave(std::wstring const & label)
throw (UnableToPerformSave, FederateInternalError)
{
wcout << L"initiateFederateSave: " << label.c_str() << endl;
myData.myReceivedInitiateFederateSave = true;
myData.mySaveLabel = label;
}
void MyFederateAmbassador::federationSaved() throw (FederateInternalError)
{
wcout << L"federationSaved " << endl;
myData.myReceivedFederationSaved = true;
}
throw (FederateInternalError)
{
wcout << L"federationNotSaved: ";
switch (theSaveFailureReason)
{
wcout << L"RTI_UNABLE_TO_SAVE\n";
break;
wcout << L"FEDERATE_REPORTED_FAILURE_DURING_SAVE\n";
break;
wcout << L"FEDERATE_RESIGNED_DURING_SAVE\n";
break;
wcout << L"RTI_DETECTED_FAILURE_DURING_SAVE\n";
break;
wcout << L"SAVE_TIME_CANNOT_BE_HONORED\n";
break;
default:
wcout << L"UNKNOWN\n";
break;
}
myData.mySaveFailureReason = theSaveFailureReason;
myData.myReceivedFederationNotSaved = true;
}
throw (FederateInternalError)
{
wcout << L"federationSaveStatusResponse" << endl;
myData.myReceivedFederationSaveStatusResponse = true;
myData.myFederateHandleSaveStatus = theFederateStatusVector;
}
throw (FederateInternalError)
{
wcout << L"requestFederationRestoreSucceeded " << label.c_str() << endl;
myData.myReceivedRequestFederationRestoreSucceeded = true;
myData.myRestoreLabel = label;
}
throw (FederateInternalError)
{
wcout << L"requestFederationRestoreFailed " << label.c_str() << endl;
myData.myReceivedRequestFederationRestoreFailed = true;
myData.myRestoreLabel = label;
}
throw (FederateInternalError)
{
wcout << L"federationRestoreBegun" << endl;
myData.myReceivedFederationRestoreBegun = true;
}
std::wstring const & label,
throw (SpecifiedSaveLabelDoesNotExist,
CouldNotInitiateRestore,
FederateInternalError)
{
wcout << L"initiateFederateRestore " << label.c_str()
<< L" " << handle.toString().c_str() << endl;
myData.myReceivedInitiateFederateRestore = true;
myData.myRestoreLabel = label;
myData.myRestoreFederateHandle = handle;
}
throw (FederateInternalError)
{
wcout << L"federationRestored" << endl;
myData.myReceivedFederationRestored = true;
}
throw (FederateInternalError)
{
wcout << L"federationNotRestored: ";
switch (theRestoreFailureReason)
{
wcout << L"RTI_UNABLE_TO_RESTORE\n";
break;
wcout << L"FEDERATE_REPORTED_FAILURE_DURING_RESTORE\n";
break;
wcout << L"FEDERATE_RESIGNED_DURING_RESTORE\n";
break;
wcout << L"RTI_DETECTED_FAILURE_DURING_RESTORE\n";
break;
default:
wcout << L"Unknown reason\n";
break;
}
myData.myReceivedFederationNotRestored = true;
myData.myRestoreFailureReason = theRestoreFailureReason;
}
FederateHandleRestoreStatusPairVector const& theFederateStatusVector)
throw (FederateInternalError)
{
wcout << L"federationRestoreStatusResponse" << endl;
myData.myReceivedFederationRestoreStatusResponse = true;
myData.myFederateHandleRestoreStatus = theFederateStatusVector;
}
std::wstring const & theObjectInstanceName)
throw (
UnknownName,
FederateInternalError)
{
//wcout << L"objectInstanceNameReservationSucceeded: "
// << theObjectInstanceName.c_str() << endl;
myData.myNameReservationReturned =
myData.myNameReservationSucceeded = true;
}
std::wstring const & theObjectInstanceName)
throw (
UnknownName,
FederateInternalError)
{
wcout << L"objectInstanceNameReservationFailed: "
<< theObjectInstanceName.c_str() << endl;
myData.myNameReservationReturned = true;
myData.myNameReservationSucceeded = false;
}
ObjectInstanceHandle theObject,
ObjectClassHandle theObjectClass,
std::wstring const & theObjectInstanceName)
throw (
CouldNotDiscover,
ObjectClassNotKnown,
FederateInternalError)
{
wcout << L"discoverObjectInstance: "
<< theObjectInstanceName.c_str() << L"("
<< theObject.toString().c_str() << L") of class "
<< myData.objectClassMap[theObjectClass].c_str() << L"( "
<< theObjectClass.toString().c_str() << L")" << endl;\
myData.objectInstanceMap[theObject] = theObjectInstanceName;
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p r: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p t o: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p t o r: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p t o m: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< theHandle.toString().c_str() << L" "
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle,
RegionHandleSet const & theSentRegionHandleSet)
throw (
ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"reflectAttributeValues h v u o p t o m r: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString().c_str() << L" "
<< theHandle.toString().c_str() << L" "
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#attributes: " << theAttributeValues.size() << endl;
printAttrValues(theAttributeValues);
}
// 6.9
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< L"#parameters: " << theParameterValues.size() << endl;
printParamValues(theParameterValues);
}
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#parameters: " << theParameterValues.size() << endl;
printParamValues(theParameterValues);
}
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< L"#parameters: " << theParameterValues.size() << endl;
printParamValues(theParameterValues);
}
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#parameters: " << theParameterValues.size() << endl;
printParamValues(theParameterValues);
}
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< (theType == RELIABLE ? L"RELIABLE " : L"BEST_EFFORT ")
<< theTime.toString() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< theHandle.toString() << L" "
<< L"#parameters: " << theParameterValues.size() << endl;
printParamValues(theParameterValues);
}
InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError) {}
ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder)
throw (
ObjectInstanceNotKnown,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"removeObjectInstance: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ") << endl;
}
ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (
ObjectInstanceNotKnown,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"removeObjectInstance: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ") << endl;
}
ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (
ObjectInstanceNotKnown,
InvalidLogicalTime,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size()
? (const char*)theUserSuppliedTag.data() : "";
wcout << L"removeObjectInstance: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << L") "
<< DtToWString(tag) << L" "
<< (sentOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder == RECEIVE ? L"RECEIVE " : L"TIMESTAMP ")
<< theHandle.toString().c_str() << endl;
}

rtiSimpleKeyboard.cxx

/*******************************************************************************
* Adapted from "Beginning Linux Programming", from Wrox Press -- www.wrox.com
*******************************************************************************/
#ifdef WIN32
#include <conio.h>
#else
#include <unistd.h>
#endif
{
#ifndef WIN32
tcgetattr(0,&initial_settings);
new_settings = initial_settings;
new_settings.c_lflag &= ~ICANON;
new_settings.c_lflag &= ~ECHO;
new_settings.c_lflag &= ~ISIG;
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &new_settings);
#endif
}
{
#ifndef WIN32
tcsetattr(0, TCSANOW, &initial_settings);
#endif
}
{
#ifdef WIN32
return _kbhit();
#else
unsigned char ch;
int nread;
if (peek_character != -1) return 1;
new_settings.c_cc[VMIN]=0;
tcsetattr(0, TCSANOW, &new_settings);
nread = read(0,&ch,1);
new_settings.c_cc[VMIN]=1;
tcsetattr(0, TCSANOW, &new_settings);
if (nread == 1)
{
return 1;
}
return 0;
#endif
}
{
char ch;
#ifdef WIN32
ch = _getch();
#else
if (peek_character != -1)
{
}
else
read(0,&ch,1);
#endif
return ch;
}
{
char key = ' ';
if (!kbhit())
return 0;
key = getkey();
while (key != 'q' && key != 'Q' && kbhit())
key = getkey();
return (key == 'q' || key == 'Q') ? -1 : key;
}

rtiSimpleFedAmb1516.h

/*******************************************************************************
** Copyright (c) 2010 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#ifndef MyFederateAmbassador_H_
#define MyFederateAmbassador_H_
#pragma warning(disable: 4251)
#pragma warning(disable: 4786)
#pragma warning(disable: 4290)
#include <RTI/RTI1516.h>
#include <RTI/NullFederateAmbassador.h>
#include <string>
#include <map>
using namespace rti1516;
{
public:
bool myNameReservationReturned;
bool myNameReservationSucceeded;
bool myReceivedInitiateFederateSave;
bool myReceivedFederationSaved;
bool myReceivedFederationNotSaved;
bool myReceivedFederationSaveStatusResponse;
std::wstring mySaveLabel;
SaveFailureReason mySaveFailureReason;
FederateHandleSaveStatusPairVector myFederateHandleSaveStatus;
bool myReceivedRequestFederationRestoreSucceeded;
bool myReceivedRequestFederationRestoreFailed;
bool myReceivedFederationRestoreBegun;
bool myReceivedInitiateFederateRestore;
bool myReceivedFederationRestored;
bool myReceivedFederationNotRestored;
bool myReceivedFederationRestoreStatusResponse;
std::wstring myRestoreLabel;
FederateHandle myRestoreFederateHandle;
RestoreFailureReason myRestoreFailureReason;
FederateHandleRestoreStatusPairVector myFederateHandleRestoreStatus;
std::map<ObjectClassHandle, std::wstring> objectClassMap;
std::map<ObjectInstanceHandle, std::wstring> objectInstanceMap;
std::map<InteractionClassHandle, std::wstring> interactionClassMap;
};
{
public:
throw ();
virtual void initiateFederateSave(
std::wstring const & label)
throw (UnableToPerformSave, FederateInternalError);
virtual void federationSaved()
throw (FederateInternalError);
virtual void federationNotSaved(SaveFailureReason theSaveFailureReason)
throw (FederateInternalError);
virtual void federationSaveStatusResponse(
FederateHandleSaveStatusPairVector const & theFederateStatusVector)
throw (FederateInternalError);
// 4.19
virtual void requestFederationRestoreSucceeded(std::wstring const & label)
throw (FederateInternalError);
virtual void requestFederationRestoreFailed(std::wstring const & label)
throw (FederateInternalError);
// 4.20
virtual void federationRestoreBegun()
throw (FederateInternalError);
// 4.21
std::wstring const & label,
throw (SpecifiedSaveLabelDoesNotExist,
CouldNotInitiateRestore,
FederateInternalError);
// 4.23
virtual void federationRestored()
throw (FederateInternalError);
virtual void federationNotRestored(RestoreFailureReason theRestoreFailureReason)
throw (FederateInternalError);
// 4.25
virtual void federationRestoreStatusResponse(
theFederateStatusVector)
throw (FederateInternalError);
// 6.3
virtual
void
objectInstanceNameReservationSucceeded(std::wstring const &
theObjectInstanceName)
throw (UnknownName,
FederateInternalError);
virtual
void
objectInstanceNameReservationFailed(std::wstring const &
theObjectInstanceName)
throw (UnknownName,
FederateInternalError);
// 6.5
virtual void discoverObjectInstance (
ObjectInstanceHandle theObject,
ObjectClassHandle theObjectClass,
std::wstring const & theObjectInstanceName)
throw (
CouldNotDiscover,
ObjectClassNotKnown,
FederateInternalError);
// 6.7
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
AttributeHandleValueMap const & theAttributeValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle,
RegionHandleSet const & theSentRegionHandleSet)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
// 6.9
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
(InteractionClassHandle theInteraction,
ParameterHandleValueMap const & theParameterValues,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle,
RegionHandleSet const & theSentRegionHandleSet)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
// 6.11
virtual
void
removeObjectInstance(ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder)
throw (ObjectInstanceNotKnown,
FederateInternalError);
virtual
void
removeObjectInstance(ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder)
throw (ObjectInstanceNotKnown,
FederateInternalError);
virtual
void
removeObjectInstance(ObjectInstanceHandle theObject,
VariableLengthData const & theUserSuppliedTag,
OrderType sentOrder,
LogicalTime const & theTime,
OrderType receivedOrder,
MessageRetractionHandle theHandle)
throw (ObjectInstanceNotKnown,
InvalidLogicalTime,
FederateInternalError);
public:
DtTalkAmbData & myData;
};
#endif

rtiSimpleKeyboard.h

/*******************************************************************************
* Adapted from "Beginning Linux Programming", from Wrox Press -- www.wrox.com
*******************************************************************************/
// Utility to allow keyboard input without blocking
#ifndef MYKBHIT_H_
#define MYKBHIT_H_
#ifndef WIN32
#include <termios.h>
#endif
class keyboard
{
public:
// Returns 1 if keyboard input is ready; otherwise, 0
int kbhit();
// Returns character from keyboard if avaialable; otherwise, 0
int keybrdTick();
protected:
// Return character from keyboard input
int getkey();
private:
#ifndef WIN32
struct termios initial_settings, new_settings;
#endif
};
#endif

rtiSimpleStringUtil.h

/*******************************************************************************
** Copyright (c) 2010 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#ifndef stringUtil_H_
#define stringUtil_H_
#include <string>
#include <sstream>
// Convert narrow C string to wide string
inline std::wstring DtToWString(const char * in_val)
{
std::wstring temp;
while (*in_val != '\0')
temp += *in_val++;
return temp;
}
// Convert narrow string to wide string
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;
}
#endif

Document ID: Generated on Fri Mar 14 19:08:55 EDT 2014 from SVN revision 137085
Copyright © 2005-2014 VT MÄK Inc. All Rights Reserved (www.mak.com)