}
while (!_rtiFederate->getTimeConstrainedEnabled()) {
- _rtiFederate->processMessage();
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessage()) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
}
return true;
}
while (!_rtiFederate->getTimeRegulationEnabled()) {
- _rtiFederate->processMessage();
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessage()) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
}
return true;
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
- return _rtiFederate->processMessage();
+
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessage()) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
+ return true;
}
bool
SG_LOG(SG_NETWORK, SG_WARN, "HLA: Accessing unconnected federate!");
return false;
}
- return _rtiFederate->processMessages(timeout.toSecs(), 0);
+
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessages(timeout.toSecs(), 0)) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
+ return true;
}
bool
}
while (_rtiFederate->getTimeAdvancePending()) {
- _rtiFederate->processMessage();
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessage()) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
}
if (_timeConstrainedByLocalClock) {
double rest = (systemTime - SGTimeStamp::now()).toSecs();
if (rest < 0)
break;
- _rtiFederate->processMessages(rest, rest);
+ if (RTIFederate::ProcessMessageFatal == _rtiFederate->processMessages(rest, rest)) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
}
}
// Now flush just what is left
- while (_rtiFederate->processMessages(0, 0));
+ while (true) {
+ RTIFederate::ProcessMessageResult result = _rtiFederate->processMessages(0, 0);
+ if (RTIFederate::ProcessMessageLast == result)
+ break;
+ if (RTIFederate::ProcessMessageFatal == result) {
+ SG_LOG(SG_NETWORK, SG_WARN, "HLA: Fatal error on processing messages!");
+ return false;
+ }
+ }
return true;
}
return true;
}
-bool
+RTI13Federate::ProcessMessageResult
RTI13Federate::processMessage()
{
- bool result = _tick();
+ ProcessMessageResult result = _tick();
_federateAmbassador->processQueues();
return result;
}
-bool
+RTI13Federate::ProcessMessageResult
RTI13Federate::processMessages(const double& minimum, const double& maximum)
{
- bool result = _tick(minimum, 0);
+ ProcessMessageResult result = _tick(minimum, 0);
_federateAmbassador->processQueues();
- if (!result)
- return false;
+ if (result != ProcessMessagePending)
+ return result;
SGTimeStamp timeStamp = SGTimeStamp::now() + SGTimeStamp::fromSec(maximum);
do {
result = _tick(0, 0);
_federateAmbassador->processQueues();
- } while (result && SGTimeStamp::now() <= timeStamp);
+ } while (result == ProcessMessagePending && SGTimeStamp::now() <= timeStamp);
return result;
}
-bool
+RTI13Federate::ProcessMessageResult
RTI13Federate::_tick()
{
if (!_ambassador.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Ambassador is zero while calling _tick().");
- return false;
+ return ProcessMessageFatal;
}
try {
- return _ambassador->tick();
+ if (_ambassador->tick())
+ return ProcessMessagePending;
+ return ProcessMessageLast;
} catch (RTI::SpecifiedSaveLabelDoesNotExist& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Specified save label does not exist: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
} catch (RTI::ConcurrentAccessAttempted& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Concurrent access attempted: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
} catch (RTI::RTIinternalError& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Internal error: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
}
- return false;
+ return ProcessMessageFatal;
}
-bool
+RTI13Federate::ProcessMessageResult
RTI13Federate::_tick(const double& minimum, const double& maximum)
{
if (!_ambassador.valid()) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Ambassador is zero while calling _tick().");
- return false;
+ return ProcessMessageFatal;
}
try {
- return _ambassador->tick(minimum, maximum);
+ if (_ambassador->tick(minimum, maximum))
+ return ProcessMessagePending;
+ return ProcessMessageLast;
} catch (RTI::SpecifiedSaveLabelDoesNotExist& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Specified save label does not exist: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
} catch (RTI::ConcurrentAccessAttempted& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Concurrent access attempted: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
} catch (RTI::RTIinternalError& e) {
SG_LOG(SG_NETWORK, SG_WARN, "RTI: Internal error: " << e._name << " " << e._reason);
- return false;
+ return ProcessMessageFatal;
}
- return false;
+ return ProcessMessageFatal;
}
virtual bool queryLITS(SGTimeStamp& timeStamp);
/// Process messages
- virtual bool processMessage();
- virtual bool processMessages(const double& minimum, const double& maximum);
+ virtual ProcessMessageResult processMessage();
+ virtual ProcessMessageResult processMessages(const double& minimum, const double& maximum);
// helper functions for the above
- bool _tick();
- bool _tick(const double& minimum, const double& maximum);
+ ProcessMessageResult _tick();
+ ProcessMessageResult _tick(const double& minimum, const double& maximum);
virtual RTI13ObjectClass* createObjectClass(const std::string& name, HLAObjectClass* hlaObjectClass);
virtual RTI13InteractionClass* createInteractionClass(const std::string& name, HLAInteractionClass* interactionClass);
virtual bool queryGALT(SGTimeStamp& timeStamp) = 0;
virtual bool queryLITS(SGTimeStamp& timeStamp) = 0;
+ enum ProcessMessageResult {
+ ProcessMessagePending,
+ ProcessMessageLast,
+ ProcessMessageFatal
+ };
+
/// Process messages
- virtual bool processMessage() = 0;
- virtual bool processMessages(const double& minimum, const double& maximum) = 0;
+ virtual ProcessMessageResult processMessage() = 0;
+ virtual ProcessMessageResult processMessages(const double& minimum, const double& maximum) = 0;
virtual RTIObjectClass* createObjectClass(const std::string& name, HLAObjectClass* hlaObjectClass) = 0;
virtual RTIInteractionClass* createInteractionClass(const std::string& name, HLAInteractionClass* interactionClass) = 0;