当前位置: 首页>>代码示例>>C++>>正文


C++ Country::PublishAndSubscribe方法代码示例

本文整理汇总了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.
				 //////////////////////////////////////////////////////////////////////////
开发者ID:huidesign,项目名称:Projects,代码行数:67,代码来源:HelloWorld.cpp

示例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)
    {
      //------------------------------------------------------
开发者ID:huidesign,项目名称:Projects,代码行数:67,代码来源:HelloWorld.cpp


注:本文中的Country::PublishAndSubscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。