/* */ import org.omg.CORBA.*; import RTIcap.*; /** * * This is callback object to receive RTI messages. * We used the following callback messages for this demo program: * **
*
* *
- discoverObjectInstance *
- removeObjectInstance[With Time] *
- reflectAttributeValues[WithTime] *
- provideAttributeValueUpdate *
- turnUpdatesOnForObjectInstance *
- turnUpdatesOffForObjectInstance *
- timeAdcanceGrant *
- timeRegulationEnabled *
- timeConstrainedEnabled *
* @date May 11, 1998 ( Updated May 11, 1998 ) * @author H. Timucin Ozdemir * */ public class HwFederateAmbassador extends RTIcap._FederateAmbassadorImplBase { HelloWorld boss; EntityManager entManager; public HwFederateAmbassador(EntityManager _entManager, HelloWorld father) { entManager = _entManager; boss = father; }// end of HwFederateAmbassador() public void synchronizationPointRegistrationSucceeded(String theLabel) throws RTIcap.FederateInternalError { } public void synchronizationPointRegistrationFailed(String theLabel) throws RTIcap.FederateInternalError { } public void announceSynchronizationPoint(String theLabel, String theTag) throws RTIcap.FederateInternalError { } public void federationSynchronized(String theLabel) throws RTIcap.FederateInternalError { } public void initiateFederateSave(String theLabel) throws RTIcap.UnableToPerformSave, RTIcap.FederateInternalError { } public void federationSaved() throws RTIcap.FederateInternalError { } public void federationNotSaved() throws RTIcap.FederateInternalError { } public void requestFederationRestoreSucceeded(String theLabel) throws RTIcap.FederateInternalError { } public void requestFederationRestoreFailed(String theLabel) throws RTIcap.FederateInternalError { } public void federationRestoreBegun() throws RTIcap.FederateInternalError { } public void initiateFederateRestore(String theLabel, short handle) throws RTIcap.SpecifiedLabelDoesNotExist, RTIcap.CouldNotRestore, RTIcap.FederateInternalError { } public void federationRestored() throws RTIcap.FederateInternalError { } public void federationNotRestored() throws RTIcap.FederateInternalError { } public void startRegistrationForObjectClass(short theClass) throws RTIcap.ObjectClassNotPublished, RTIcap.AttributeNotPublished, RTIcap.FederateInternalError { } public void stopRegistrationForObjectClass(short theClass) throws RTIcap.ObjectClassNotPublished, RTIcap.AttributeNotPublished, RTIcap.FederateInternalError { } public void turnInteractionsOn(short theHandle) throws RTIcap.InteractionClassNotPublished, RTIcap.FederateInternalError { } public void turnInteractionsOff(short theHandle) throws RTIcap.InteractionClassNotPublished, RTIcap.FederateInternalError { } public void startUpdates(short theClass, short[] theAttributes) throws RTIcap.ObjectClassNotPublished, RTIcap.AttributeNotPublished, RTIcap.FederateInternalError { } public void stopUpdates(short theClass, short[] theAttributes) throws RTIcap.ObjectClassNotPublished, RTIcap.AttributeNotPublished, RTIcap.FederateInternalError { } /** * Add this new discovered object to the EntityManager. */ public void discoverObjectInstance(int theObject, short theObjectClass) throws RTIcap.CouldNotDiscover, RTIcap.ObjectClassNotKnown, RTIcap.InvalidFederationTime, RTIcap.FederateInternalError { Country c = entManager.getEntity(theObject); if(c==null) entManager.add(theObject,new Country(theObject)); }// end of discoverObjectInstance() /** * Update attributes. */ public void reflectAttributeValuesWithTime(int theObject, RTIcap.AttributeHandleValuePair[] theAttributes, double theTime, String theTag, RTIcap.EventRetractionHandle theHandle) throws RTIcap.ObjectNotKnown, RTIcap.AttributeNotKnown, RTIcap.FederateOwnsAttributes, RTIcap.InvalidFederationTime, RTIcap.FederateInternalError { reflectAttributeValues(theObject,theAttributes,theTag); }// end of reflectAttributeValuesWithTime() /** * * Find the objects in the EntityManager and updates their received * attributes. Note that, CDR provided us the necessary decode/encode * mechanism for various data types. * */ public void reflectAttributeValues(int theObject, RTIcap.AttributeHandleValuePair[] theAttributes, String theTag) throws RTIcap.ObjectNotKnown, RTIcap.AttributeNotKnown, RTIcap.FederateOwnsAttributes, RTIcap.FederateInternalError { Country c = entManager.getEntity(theObject); //System.out.println(" in reflectAttributeValues("+theObject+")"); if( c != null ) { //System.out.println(theObject+" is found "); for(int i=0;i