#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>
using namespace rti1516;
using namespace std;
std::wstring const& fedName,
std::wstring const& fedFile)
{
wcout << L"createFederationExecution "
<< fedName.c_str() << L" "
<< fedFile.c_str() << endl;
try
{
}
catch(FederationExecutionAlreadyExists& ex)
{
wcout << L"Could not create Federation Execution: "
<< L"FederationExecutionAlreadyExists: "
<< ex.what().c_str() << endl;
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl
<< L"Could not create Federation Execution: " << endl;
exit(0);
}
wcout << L"Federation Created." << endl;
}
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
{
joined = true;
}
catch(FederationExecutionDoesNotExist)
{
wcout << L"FederationExecutionDoesNotExist, try "
<< numTries << L" out of "
<< maxTry << endl;
continue;
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
return;
}
}
if (joined)
wcout << L"Joined Federation." << endl;
else
{
wcout << L"Giving up." << endl;
exit(0);
}
}
std::wstring const& federationName)
{
wcout << L"Resign and Destroy Federation" << endl;
}
{
wcout << L"Query save status\n";
int count = 0;
while ( count++ < 100
{
}
{
wcout << L"Timed out waiting for status response\n";
}
else
{
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;
}
}
}
}
{
bool saveOk = true;
int count = 0;
wcout << L"Request federation save with label " << label.c_str() << endl;
while (count++ < 100
{
}
{
saveOk = false;
{
wcout << L"Timed out waiting for initiate federate save\n";
}
}
return saveOk;
}
{
bool saveOk = true;
int count = 0;
while ( count++ < 100
{
}
{
saveOk = false;
{
wcout << L"Timed out waiting for federation saved\n";
}
}
return saveOk;
}
{
bool saveOk = true;
int count = 0;
try
{
if ( performRequest )
{
}
{
wcout << L"Federate save begun\n";
wcout << L"Federate save complete\n";
}
}
{
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;
}
return saveOk;
}
{
int count = 0;
while ( count++ < 100
{
}
{
wcout << L"Timed out waiting for restore status\n";
}
else
{
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;
}
}
}
}
{
int count = 0;
bool restoreOk = true;
wcout << L"Request federation restore with label " << label.c_str() << endl;
while (count++ < 100
{
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for request federation restore succeeded.\n";
}
}
return restoreOk;
}
{
bool restoreOk = true;
wcout << L"Wait for restore begun\n";
int count = 0;
while (count++ < 100
{
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for federation restore begun.\n";
}
}
return restoreOk;
}
{
bool restoreOk = true;
wcout << L"Wait for initiate restore\n";
int count = 0;
while (count++ < 100
{
}
{
restoreOk = false;
}
{
restoreOk = false;
wcout << L"Timed out waiting for initiate federate restore.\n";
}
{
<< L
" does not match current handle " <<
theFederateHandle.toString().c_str() << endl;
wcout << L"Unable to complete restore\n";
restoreOk = false;
count = 0;
while ( count++ < 100
{
}
{
wcout << L"Timed out waiting for federation not restored.\n";
}
}
return restoreOk;
}
{
bool restoreOk = true;
wcout << L"Wait for federation restored\n";
int count = 0;
while ( count++ < 100
{
}
{
restoreOk = false;
{
wcout << L"Timed out waiting for federation restored.\n";
}
}
return restoreOk;
}
{
bool restoreOk = true;
int count = 0;
try
{
if ( performRequest )
{
{
}
}
{
{
wcout << L"Federate restore complete\n";
}
}
}
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;
}
{
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;
}
return restoreOk;
}
{
try
{
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
wcout << L"Could not get object class handle: "
return false;
}
std::wstring attrName;
try
{
attrName = L"AccelerationVector";
attrName = L"VelocityVector";
attrName = L"Orientation";
attrName = L"DeadReckoningAlgorithm";
attrName = L"WorldLocation";
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
wcout << L"Could not get attribute handle "
<< attrName.c_str() << endl;
return false;
}
int cnt=0;
try
{
cnt=1;
}
{
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");
try
{
unsigned int objId = abs(getpid());
std::wstringstream pid;
pid << objId;
objectName += pid.str();
int count = 0;
{
}
if (count < 100)
{
objectName);
}
else
{
wcout << L"Failed waiting for reserve object name "
<< objectName.c_str() << endl;
return false;
}
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
wcout << L"Could not Register Object "
<< objectName.c_str()
<< L" with class "
return false;
}
wcout << L"Registered object "
<< objectName.c_str()
<< L" with class name "
return true;
}
{
try
{
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
wcout << L"Could not get interaction class handle: "
return false;
}
std::wstring paramName;
try
{
paramName = L"EventIdentifier";
paramName = L"FireControlSolutionRange";
paramName = L"FireMissionIndex";
paramName = L"FiringLocation";
paramName = L"FiringObjectIdentifier";
paramName = L"FuseType";
paramName = L"InitialVelocityVector";
paramName = L"MunitionObjectIdentifier";
paramName = L"MunitionType";
paramName = L"QuantityFired";
paramName = L"RateOfFire";
paramName = L"TargetObjectIdentifier";
paramName = L"WarheadType";
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
wcout << L"Could not get parameter handle "
<< paramName.c_str() << endl;
return false;
}
int cnt=0;
try
{
cnt=1;
}
{
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: "
<< L" with handle: "
return true;
}
int main(
int argc,
char** argv)
{
std::cout << "MAK rtiSimple version 1516" << std::endl;
try
{
std::vector< std::wstring > args;
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;
}
}
if (argc > 2)
{
}
if (argc > 3)
{
}
std::auto_ptr < RTIambassador > rtiAmbAP =
rtiAmb = rtiAmbAP.release();
#ifdef WIN32
WSADATA data;
WSAStartup(MAKEWORD(1,1), &data);
#endif
long count=0;
bool doConnect = true;
bool connected = false;
while (1)
{
if (doConnect)
{
doConnect = false;
joinFedEx(*rtiAmb, fedAmb, federateType, federationName);
{
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
return 0;
}
{
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
return 0;
}
attrValues.clear();
iter++)
{
attrValues[iter->second].setData(temp.c_str(), temp.length()+1);
}
paramValues.clear();
iter2++)
{
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());
attrValues,
if ( count % 5 == 0 )
{
wcout << L"Sending interaction..." << endl;
paramValues,
}
{
{
break;
}
}
{
{
break;
}
}
}
if (key < 0)
{
break;
}
else if ('c' == key || 'C' == key )
{
doConnect = !connected;
}
else if ('d' == key || 'D' == key )
{
if (connected)
{
try
{
connected = false;
}
{
wcout << L"RTI Exception: "
<< ex.
what().c_str() << endl;
}
}
}
else if ('s' == key || 'S' == key )
{
if (connected)
{
const wstring saveLabel(L"rtiSimpleSave");
{
break;
}
}
}
else if ('r' == key || 'R' == key )
{
if (connected)
{
const wstring savedLabel(L"rtiSimpleSave");
{
break;
}
}
}
#ifdef WIN32
Sleep(2000);
#else
sleep(2);
#endif
}
if (connected)
{
}
}
{
wcout << L"RTI Exception (main loop): "
<< ex.
what().c_str() << endl;
}
if (rtiAmb != 0)
{
delete rtiAmb;
rtiAmb = 0;
}
#ifdef WIN32
WSACleanup();
#endif
return 0;
}
#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 () {}
throw (UnableToPerformSave, FederateInternalError)
{
wcout << L"initiateFederateSave: " << label.c_str() << endl;
myData.myReceivedInitiateFederateSave = true;
myData.mySaveLabel = label;
}
{
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;
}
throw (FederateInternalError)
{
wcout << L"federationRestoreStatusResponse" << endl;
myData.myReceivedFederationRestoreStatusResponse = true;
myData.myFederateHandleRestoreStatus = theFederateStatusVector;
}
std::wstring const & theObjectInstanceName)
throw (
UnknownName,
FederateInternalError)
{
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,
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,
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") "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< (theType ==
RELIABLE ? L
"RELIABLE " : L
"BEST_EFFORT ")
<< L"#attributes: " << theAttributeValues.size() << endl;
}
ObjectInstanceHandle theObject,
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") "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< (theType ==
RELIABLE ? L
"RELIABLE " : L
"BEST_EFFORT ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#attributes: " << theAttributeValues.size() << endl;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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") "
<< (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;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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") "
<< (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;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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") "
<< (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;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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 r: "
<< myData.objectInstanceMap[theObject].c_str() << L"("
<< theObject.toString().c_str() << 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;
}
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< (theType ==
RELIABLE ? L
"RELIABLE " : L
"BEST_EFFORT ")
<< L"#parameters: " << theParameterValues.size() << endl;
}
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << L" "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< (theType ==
RELIABLE ? L
"RELIABLE " : L
"BEST_EFFORT ")
<< L"#regions: " << theSentRegionHandleSet.size() << L" "
<< L"#parameters: " << theParameterValues.size() << endl;
}
LogicalTime const & theTime,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << 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;
}
LogicalTime const & theTime,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << 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;
}
LogicalTime const & theTime,
MessageRetractionHandle theHandle)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError)
{
const char* tag = theUserSuppliedTag.size() ?
(const char*)theUserSuppliedTag.data() : "";
wcout << L"receiveInteraction: "
<< theInteraction.toString() << 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;
}
LogicalTime const & theTime,
MessageRetractionHandle theHandle,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError) {}
ObjectInstanceHandle theObject,
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") "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ") << endl;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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") "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ") << endl;
}
ObjectInstanceHandle theObject,
LogicalTime const & theTime,
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") "
<< (sentOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< theTime.toString().c_str() << L" "
<< (receivedOrder ==
RECEIVE ? L
"RECEIVE " : L
"TIMESTAMP ")
<< theHandle.toString().c_str() << endl;
}
#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;
bool myReceivedRequestFederationRestoreSucceeded;
bool myReceivedRequestFederationRestoreFailed;
bool myReceivedFederationRestoreBegun;
bool myReceivedInitiateFederateRestore;
bool myReceivedFederationRestored;
bool myReceivedFederationNotRestored;
bool myReceivedFederationRestoreStatusResponse;
std::wstring myRestoreLabel;
std::map<ObjectClassHandle, std::wstring> objectClassMap;
std::map<ObjectInstanceHandle, std::wstring> objectInstanceMap;
std::map<InteractionClassHandle, std::wstring> interactionClassMap;
};
{
public:
throw ();
std::wstring const & label)
throw (UnableToPerformSave, FederateInternalError);
throw (FederateInternalError);
throw (FederateInternalError);
virtual void federationSaveStatusResponse(
throw (FederateInternalError);
throw (FederateInternalError);
throw (FederateInternalError);
throw (FederateInternalError);
std::wstring const & label,
throw (SpecifiedSaveLabelDoesNotExist,
CouldNotInitiateRestore,
FederateInternalError);
throw (FederateInternalError);
throw (FederateInternalError);
virtual void federationRestoreStatusResponse(
theFederateStatusVector)
throw (FederateInternalError);
virtual
void
objectInstanceNameReservationSucceeded(std::wstring const &
theObjectInstanceName)
throw (UnknownName,
FederateInternalError);
virtual
void
objectInstanceNameReservationFailed(std::wstring const &
theObjectInstanceName)
throw (UnknownName,
FederateInternalError);
ObjectInstanceHandle theObject,
std::wstring const & theObjectInstanceName)
throw (
CouldNotDiscover,
ObjectClassNotKnown,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
LogicalTime const & theTime,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
LogicalTime const & theTime,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
LogicalTime const & theTime,
MessageRetractionHandle theHandle)
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
(ObjectInstanceHandle theObject,
LogicalTime const & theTime,
MessageRetractionHandle theHandle,
throw (ObjectInstanceNotKnown,
AttributeNotRecognized,
AttributeNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
MessageRetractionHandle theHandle)
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
MessageRetractionHandle theHandle,
throw (InteractionClassNotRecognized,
InteractionParameterNotRecognized,
InteractionClassNotSubscribed,
InvalidLogicalTime,
FederateInternalError);
virtual
void
throw (ObjectInstanceNotKnown,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
throw (ObjectInstanceNotKnown,
FederateInternalError);
virtual
void
LogicalTime const & theTime,
MessageRetractionHandle theHandle)
throw (ObjectInstanceNotKnown,
InvalidLogicalTime,
FederateInternalError);
public:
};
#endif