The RTI and Federate Ambassadors

To send commands to the RTI, you will need the RTIAmbasador.

RTIambassador rtiamb = RtiFactoryFactory.getRtiFactory().getRtiAmbassador();

To receive RTI events ( new Federates, attribute updates, interactions and etc ) you will need to register your FederateAmbassador.

You must create your own class and extend the NullFederateAmbassador, wich implements the HLA Federate Ambassador interface with all methods doing nothing. This approach makes easy to you to override only the methods you want, keeping your code clean.

public class FederateAmbassador extends NullFederateAmbassador {

  @Override
  public void discoverObjectInstance( ObjectInstanceHandle objectHandle,
                                      ObjectClassHandle theObjectClass,
                                      String objectName ) throws FederateInternalError {
  
    // Here you will be notified by the RTI when a new object raises in somewhere in your Federation 
  
  }


}

Now you have the RTIAmbassador handle and your FederateAmbassador, its time to connect it to the RTI:

FederateAmbassador fedamb = new FederateAmbassador();
rtiamb.connect( fedamb, CallbackModel.HLA_IMMEDIATE );

 

The RTI and Federate Ambassadors

The RTI and Federate Ambassadors

 

 

 

Add Comment