예제 #1
0
        private void OnJoinFederationHelloWorld(object sender, EventArgs e)
        {
            try
            {
                // Join to federation
                sampleFederateAmbassador = new XrtiFederateAmbassador(rtiAmbassador);
                mobileServices           = new MobileFederateServices(new DoubleValuedLogicalTimeFactory(), new DoubleValuedLogicalTimeIntervalFactory());
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution(peerName, federationName, sampleFederateAmbassador, mobileServices);

                EvokeCallbackMenuItem.Enabled         = true;
                EvokeCallbacksMenuItem.Enabled        = true;
                SetTimeConstrainedMenuItem.Enabled    = true;
                SetTimeRegulatingMenuItem.Enabled     = true;
                TimeAdvanceRequestMinMenuItem.Enabled = true;
                TimeAdvanceRequestMenuItem.Enabled    = true;
                Example1MenuItem.Enabled = true;
                Example2MenuItem.Enabled = true;
                Example3MenuItem.Enabled = true;
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error(exception.Message);
                }
                MessageBox.Show(exception.Message);
            }
        }
예제 #2
0
        public void TestJoinWithInvalidFederate()
        {
            /// try and join a federation using empty name
            try
            {
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("", federationName, federateAmbassador, mobileServices);
                Assert.Fail("No exception while joining a with empty federate name");
            }
            catch (RTIinternalError)
            {
                // SUCCESS
            }
            catch (Exception e)
            {
                Assert.Fail("Invalid exception while trying to join federation using null name", e);
            }

            // try and join a federation using null name
            try
            {
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution(null, federationName, federateAmbassador, mobileServices);
                Assert.Fail("No exception while joining a with null federate name");
            }
            catch (RTIinternalError)
            {
                // SUCCESS
            }
            catch (Exception e)
            {
                Assert.Fail("Invalid exception while trying to join federation using empty name", e);
            }
        }
예제 #3
0
        public void TestDestroyWithFederate()
        {
            //Build a Uri using a file path
            FileInfo file    = new FileInfo(Sxta.Rti1516ResourcesNames.HelloWorldObjectModel);
            Uri      fileUri = new Uri("file://" + file.FullName);

            try
            {
                //Create Federation
                rtiAmbassador.CreateFederationExecution(federationName, fileUri);
                // Join to federation
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", federationName, federateAmbassador, mobileServices);
            }
            catch (Exception e)
            {
                Assert.Fail("Exception while setting up destroyWithFederates test", e);
            }

            try
            {
                // destroy the federation //
                rtiAmbassador.DestroyFederationExecution(federationName);
                Assert.Fail("Was able to destroy a federation with active federates");
            }
            catch (FederatesCurrentlyJoined)
            {
                // SUCCESS
            }
            catch (Exception e)
            {
                Assert.Fail("Wrong exception while destroying federation with active federates", e);
            }
        }
예제 #4
0
        public virtual void JoinSimulation(IRTIambassador rtiAmb, string federateType, string federation)
        {
            if (rtiAmb == null)
            {
                throw new System.ArgumentNullException("Rti ambassador could not be null");
            }

            rtiAmbassador = rtiAmb;

            InitLogSystem();

            federationName = federation;

            try
            {
                //Build a Uri using a file path
                FileInfo file    = new FileInfo(this.FomList[0].Uri);
                Uri      fileUri = new Uri("file://" + file.FullName);

                //Create Federation
                rtiAmbassador.CreateFederationExecution(federationName, fileUri);
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error(exception.Message);
                }
            }

            try
            {
                // PATCH ANGEL: Si está inicializado el federateAmbassador no se crea de nuevo
                if (federateAmbassador == null)
                {
                    federateAmbassador = new XrtiFederateAmbassador(rtiAmbassador);
                }

                if (mobileServices == null)
                {
                    mobileServices = new MobileFederateServices(new LongValuedLogicalTimeFactory(), new LongValuedLogicalTimeIntervalFactory());
                }

                // Join to federation
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution(federateType,
                                                                                       federationName,
                                                                                       federateAmbassador,
                                                                                       mobileServices);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Failed while joining to :" + federateAmbassador + ". Exception :" + e.Message);
                }
            }
        }
예제 #5
0
 public void TestJoinFederationEmptyName()
 {
     try
     {
         IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", "", federateAmbassador, mobileServices);
         Assert.Fail("No exception while joining a non-existent federation (empty name)");
     }
     catch (FederationExecutionDoesNotExist)
     {
         // SUCCESS
     }
     catch (Exception e)
     {
         Assert.Fail("Invalid exception while joining wrong federation (empty name)", e);
     }
 }
예제 #6
0
 public void JoinFederation()
 {
     try
     {
         // Join to federation
         IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", federationName, federateAmbassador, mobileServices);
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error(e.Message);
         }
         Assert.Fail("Failed while testing a valid join request: " + e.Message);
     }
 }
예제 #7
0
 public void TestJoinInvalidMobileServices()
 {
     try
     {
         IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", federationName, federateAmbassador, null);
         Assert.Fail("No exception while joining with null mobile services");
     }
     catch (RTIinternalError)
     {
         // SUCCESS
     }
     catch (Exception e)
     {
         Assert.Fail("Invalid exception while joining with null mobile services", e);
     }
 }
예제 #8
0
 public void TestJoinNonExistentFederation()
 {
     try
     {
         // Join to federation
         IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", "noSuchFederation", federateAmbassador, mobileServices);
         Assert.Fail("No exception while joining a non-existent federation");
     }
     catch (FederationExecutionDoesNotExist)
     {
         // SUCCESS
     }
     catch (Exception e)
     {
         Assert.Fail("Invalid exception while trying to join a non-existent federation", e);
     }
 }
예제 #9
0
        public void TestJoinAlreadyExecutionMember()
        {
            // set up by running a valid join
            try
            {
                // Join to federation
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("USA", federationName, federateAmbassador, mobileServices);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error(e.Message);
                }
                Assert.Fail("Failed while testing a valid join request: " + e.Message);
            }

            // try and join the rtiamb to a second federation
            try
            {
                IFederateHandle federateHandle = rtiAmbassador.JoinFederationExecution("aValidName", federationName + "2", federateAmbassador, mobileServices);
                Assert.Fail("No exception while joining two federations through same ambassador");
            }
            catch (FederateAlreadyExecutionMember)
            {
                // SUCCESS
            }
            catch (RTIinternalError)
            {
                // ALSO VALID
            }
            catch (Exception e)
            {
                Assert.Fail("Invalid exception while joining two federations with same ambassador", e);
            }

            // clean up for the next test
            Resign();
        }
예제 #10
0
 public virtual void InitiateFederateRestore(string label, IFederateHandle federateHandle)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #11
0
 /// <summary>
 ///  Constructor.
 /// </summary>
 /// <param name="pHandle">the federate handle
 /// </param>
 /// <param name="pStatus">the federate status
 /// </param>
 public FederateHandleSaveStatusPair(IFederateHandle pHandle, SaveStatus pStatus)
 {
     handle = pHandle;
     status = pStatus;
 }
 /// <summary> 
 /// Constructor.
 /// </summary>
 /// <param name="pHandle">the federate handle
 /// </param>
 /// <param name="pStatus">the restore status
 /// </param>
 public FederateHandleRestoreStatusPair(IFederateHandle pHandle, RestoreStatus pStatus)
 {
     handle = pHandle;
     status = pStatus;
 }
 /// <summary>
 ///  Constructor.
 /// </summary>
 /// <param name="pHandle">the federate handle
 /// </param>
 /// <param name="pStatus">the federate status
 /// </param>
 public FederateHandleSaveStatusPair(IFederateHandle pHandle, SaveStatus pStatus)
 {
     handle = pHandle;
     status = pStatus;
 }
예제 #14
0
 public virtual void InformAttributeOwnership(IObjectInstanceHandle theObject, IAttributeHandle theAttribute, IFederateHandle theOwner)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #15
0
 public virtual void InitiateFederateRestore(string label, IFederateHandle federateHandle)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #16
0
 public virtual void InformAttributeOwnership(IObjectInstanceHandle theObject, IAttributeHandle theAttribute, IFederateHandle theOwner)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #17
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="pHandle">the federate handle
 /// </param>
 /// <param name="pStatus">the restore status
 /// </param>
 public FederateHandleRestoreStatusPair(IFederateHandle pHandle, RestoreStatus pStatus)
 {
     handle = pHandle;
     status = pStatus;
 }