Ejemplo n.º 1
0
        protected void SimulationMoveActor(Actor anActor, Home aTarget)
        {
            if (isActorInLocation(anActor, anActor.Home))
            {
                if (anActor.Home.BoxesCount > 0 || initialTime)
                {
                    // Función que calcule la llegada
                    ILogicalTime         currentTime = rti.QueryLogicalTime();
                    ILogicalTimeInterval intervalTimeArriveAtTheTarget = GetArrivalTimeToTarget(anActor, aTarget);
                    ILogicalTime         timeArriveAtTheTarget         = currentTime.Add(intervalTimeArriveAtTheTarget);

                    NotifiesBoxInHouse(timeArriveAtTheTarget);

                    MoveActor(anActor, aTarget);

                    anActor.Home.BoxesCount = 0;
                }
            }
            else
            {
                initialTime = false;

                if (!isActorInTarget(anActor, aTarget))
                {
                    MoveActor(anActor, aTarget);
                }
                // El muñeco está en el destino
                else
                {
                    scenario.MoveActorToHome(anActor.Home.PosX, anActor.Home.PosY);
                    sendedBoxInHouseInteraction = false;
                }
            }
        }
Ejemplo n.º 2
0
        public void EnableTimeRegulation(ILogicalTimeInterval theLookahead)
        {
            lock (this)
            {
                /* 1. Process exceptions */

                VerifyFederateIsExecutionMember();

                CheckIsRegulating();

                // If the calling federate is in pending on calling the enabledTimeRegulation service
                CheckTimeRegulationPending();

                CheckValidLookahead(theLookahead);

                // if the calling federate is in time advancing state
                CheckAdvancing();

                /* 2. Compute logical time */

                ILogicalTime maxTime = federate.HLAlogicalTime.Add(theLookahead);

                String federationName = ((Sxtafederate)this.federate).HLAfederationNameJoined;
                IList <Sxtafederate> constrainedFederates = metaFederateAmbassador.GetConstrainedFederates(federationName);

                foreach (Sxtafederate constrainedFederate in constrainedFederates)
                {
                    // it is not the calling federate
                    if (constrainedFederate != this.federate)
                    {
                        if (constrainedFederate.HLAlogicalTime.CompareTo(maxTime) >= 0)
                        {
                            maxTime = constrainedFederate.HLAlogicalTime;

                            // COMMENT ANGEL: He omitido lo del EPSILON porque no entiendo que función tiene
                            // CONTESTACIÓN: Debe añadirse una cantidad suficientemente peq para que no sea justamente el tiempo lógico del regulado
                            maxTime = maxTime.Add(logicalTimeIntervalFactory.MakeEpsilon());
                        }
                    }
                }

                PendingTime = maxTime.Subtract(theLookahead);

                /* 3. Set lookahead and pending flag */

                federate.HLAlookahead = theLookahead;
                TimeRegulating        = Status.PENDING;

                /* 4. Send all RO messages to the calling federate */

                lrc.TickRO();

                /* 5. Judge whether the calling federate is granted to be regulating */

                if (this.federate.HLAtimeConstrained)
                {
                    // The invocation of this service shall be considered an implicit TARA service invocation
                    bTimeAdvanceRequestAvailable = Status.PENDING;

                    ComputeGALT();

                    if (PendingTime.CompareTo(federate.HLAGALT) <= 0)
                    {
                        // All messages with time stamp <= pending time in the calling
                        // federate's TSO queue are sent to the federate
                        lrc.TickTSO(PendingTime);

                        bTimeAdvanceRequestAvailable = Status.ON;
                        TimeRegulating = Status.ON;

                        this.federate.HLAlogicalTime = PendingTime;
                        this.federateAmbassador.TimeRegulationEnabled(federate.HLAlogicalTime);
                    }
                    else
                    {
                        // All messages with time stamp <= GALT in the calling
                        // federate's TSO queue are sent to the federate
                        lrc.TickTSO(federate.HLAGALT);
                    }
                }
                else
                {
                    bTimeAdvanceRequestAvailable = Status.ON;
                    TimeRegulating = Status.ON;

                    this.federate.HLAlogicalTime = PendingTime;
                    this.federateAmbassador.TimeRegulationEnabled(federate.HLAlogicalTime);
                }
            }
        }
Ejemplo n.º 3
0
 public virtual void AdvanceTime()
 {
     rtiAmbassador.EvokeMultipleCallbacks(2.0, 10.0);
     time = time.Add(interval);
 }