Пример #1
0
//
// Publish Car object attributes
// This method is not thread safe but should only be called once during initialization!
//
void HLAmodule::publishCar() 
      throw (
         FederateNotExecutionMember, 
         RestoreInProgress, 
         SaveInProgress, 
         NotConnected, 
         RTIinternalError, 
         AttributeNotDefined, 
         ObjectClassNotDefined)
{
    AttributeHandleSet carAttributes;
    carAttributes.insert(_positionAttributeHandle);
    carAttributes.insert(_fuelLevelAttributeHandle);
    carAttributes.insert(_nameAttributeHandle);
    carAttributes.insert(_licensePlateAttributeHandle);
    carAttributes.insert(_fuelTypeAttributeHandle);

    _rtiAmbassador->publishObjectClassAttributes(_objectClassCarHandle, carAttributes); 
}
Пример #2
0
/*
 * This method will inform the RTI about the types of data that the federate will
 * be creating, and the types of data we are interested in hearing about as other
 * federates produce it.
 */
void ExampleCPPFederate::publishAndSubscribe()
{
	////////////////////////////////////////////
	// publish all attributes of ObjectRoot.A //
	////////////////////////////////////////////
	// before we can register instance of the object class ObjectRoot.A and
	// update the values of the various attributes, we need to tell the RTI
	// that we intend to publish this information

	// package the information into a handle set
	AttributeHandleSet attributes;// = AttributeHandleSet();
	attributes.insert( this->aaHandle );
	attributes.insert( this->abHandle );
	attributes.insert( this->acHandle );

	// do the actual publication
	rtiamb->publishObjectClassAttributes( this->aHandle, attributes );

	/////////////////////////////////////////////////
	// subscribe to all attributes of ObjectRoot.A //
	/////////////////////////////////////////////////
	// we also want to hear about the same sort of information as it is
	// created and altered in other federates, so we need to subscribe to it
	rtiamb->subscribeObjectClassAttributes( this->aHandle, attributes );

	/////////////////////////////////////////////////////
	// publish the interaction class InteractionRoot.X //
	/////////////////////////////////////////////////////
	// we want to send interactions of type InteractionRoot.X, so we need
	// to tell the RTI that we're publishing it first. We don't need to
	// inform it of the parameters, only the class, making it much simpler

	// do the publication
	rtiamb->publishInteractionClass( this->xHandle );

	////////////////////////////////////////////////////
	// subscribe to the InteractionRoot.X interaction //
	////////////////////////////////////////////////////
	// we also want to receive other interaction of the same type that are
	// sent out by other federates, so we have to subscribe to it first
	rtiamb->subscribeInteractionClass( this->xHandle );
}