本文整理汇总了C++中Country::PublishAndSubscribe方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::PublishAndSubscribe方法的具体用法?C++ Country::PublishAndSubscribe怎么用?C++ Country::PublishAndSubscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::PublishAndSubscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hw_main
//.........这里部分代码省略.........
cout << "FED_HW: JOINING FEDERATION EXECUTION: " << exeName << endl;
federateId = rtiAmb.joinFederationExecution(myCountry->GetName(),
fedExecName,
&fedAmb);
Jointed = RTI::RTI_TRUE;
}
catch (RTI::FederateAlreadyExecutionMember &e)
{
cerr << "FED_HW: ERROR: " << myCountry->GetName()
<< " already exists in the Federation Execution "
<< fedExecName << "." << endl;
cerr << e << endl;
return -1;
}
catch (RTI::FederationExecutionDoesNotExist)
{
cerr << "FED_HW: ERROR: " << fedExecName << " Federation Execution "
<< "does not exist." << endl;
rtiAmb.tick(2.0, 2.0);
}
catch (RTI::Exception &e)
{
cerr << "FED_HW: ERROR:_JFE" << e << endl;
return -1;
}
} // end of while
cout << "FED_HW: JOINED SUCCESSFULLY: " << exeName
<< ": Federate Handle = " << federateId << endl;
Country::Init(&rtiAmb);
myCountry->PublishAndSubscribe();
myCountry->Register();
// Set time step to 10
const RTIfedTime timeStep(10.0);
timeAdvGrant = RTI::RTI_FALSE;
try
{
cout << "FED_HW: ENABLING AYSNCHRONOUS DELIVERY" << endl;
rtiAmb.enableAsynchronousDelivery();
}
catch (RTI::Exception &e)
{
cerr << "FED_HW: ERROR:" << e << endl;
}
if (timeManaged)
{
//////////////////////////////////////////////////////////////////////////
// Set the Time Management parameters
// This version of HelloWorld operates as a time-stepped
// simulation. This means that it should be constrained
// and regulating.
//////////////////////////////////////////////////////////////////////////
try
{
cout << "FED_HW: ENABLING TIME CONTRAINT" << endl;
//////////////////////////////////////////////////////////////////////////
// Turn on constrained status so that regulating
// federates will control our advancement in time.
//////////////////////////////////////////////////////////////////////////
示例2: hw_main
//.........这里部分代码省略.........
// going to call its class type and its attribute's types.
//
// This is stored globally even though it is
// theoretically possible for a federate to join more
// than one Federation Execution and thus
// possibly have more than one Run-Time mapping.
//
// Note: This has not been tested and may not work.
// This would require having an RTIambassador for
// each FederationExecution.
//------------------------------------------------------
Country::Init( &rtiAmb );
//------------------------------------------------------
// Publication/Subscription
//
// Declare my interests to the RTI for the object and
// interaction data types I want to receive. Also tell
// the RTI the types of data I can produce.
//
// Note: In publication I am telling the RTI the type
// of data I CAN produce not that I necessarily will.
// In this program we will create all data types that
// are published however in more advance applications
// this convention allows migration of object &
// attributes to other simulations as neccessary
// through the Ownership Management services.
//
// NOTE: Each time an object or interaction class is
// subscribed or published it replaces the previous
// subscription/publication for that class.
//------------------------------------------------------
myCountry->PublishAndSubscribe();
//------------------------------------------------------
// Register my object with the federation execution.
// This requires invoking the registerObject service
// which returns an HLA object handle.
//------------------------------------------------------
myCountry->Register();
// Set time step to 10
const RTIfedTime timeStep(10.0);
timeAdvGrant = RTI::RTI_FALSE;
try
{
cout << "FED_HW: ENABLING ASYNCHRONOUS DELIVERY" << endl;
//------------------------------------------------------
// Turn on asynchronous delivery of receive ordered
// messages. This will allow us to receive messages that
// are not TimeStamp Ordered outside of a time
// advancement.
//------------------------------------------------------
rtiAmb.enableAsynchronousDelivery();
}
catch ( RTI::Exception& e )
{
cerr << "FED_HW: ERROR:" << e << endl;
}
if(TimeManaged)
{
//------------------------------------------------------