/// <summary>
        /// Gives the time of activation of a sub-step
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="time"></param>
        /// <returns>True if the provided rule has been activated</returns>
        public double GetNextSubStepActivationTime(SubStep aSubStep)
        {
            double retVal    = -1;
            bool   stepFound = false;

            foreach (ModelEvent modelEvent in Events)
            {
                if (modelEvent is SubStepActivated)
                {
                    SubStepActivated subStepActivated = modelEvent as SubStepActivated;
                    if (stepFound)
                    {
                        retVal = subStepActivated.Time;
                        break;
                    }
                    else
                    {
                        if (subStepActivated.SubStep == aSubStep)
                        {
                            stepFound = true;
                        }
                    }
                }
            }

            if (retVal == -1)
            {
                retVal = CurrentTime;
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gives the time of activation of a sub-step
        /// </summary>
        /// <param name="aSubStep"></param>
        /// <returns>True if the provided rule has been activated</returns>
        public double GetNextSubStepActivationTime(SubStep aSubStep)
        {
            double retVal    = -1;
            bool   stepFound = false;

            foreach (ModelEvent modelEvent in Events)
            {
                if (modelEvent is SubStepActivated)
                {
                    SubStepActivated subStepActivated = modelEvent as SubStepActivated;
                    if (stepFound)
                    {
                        retVal = subStepActivated.Time;
                        break;
                    }

                    if (subStepActivated.SubStep == aSubStep)
                    {
                        stepFound = true;
                    }
                }
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (retVal == -1)
            {
                retVal = CurrentTime;
            }

            return(retVal);
        }
        /// <summary>
        /// Gives the time of activation of a sub-step
        /// </summary>
        /// <param name="subStep"></param>
        /// <returns>True if the provided rule has been activated</returns>
        public double GetSubStepActivationTime(SubStep subStep)
        {
            double retVal = -1;

            if (SubStepActivationCache.ContainsKey(subStep))
            {
                SubStepActivated subStepActivated = SubStepActivationCache[subStep];
                if (subStepActivated != null)
                {
                    retVal = subStepActivated.Time;
                }
            }

            return(retVal);
        }
 /// <summary>
 ///     Positions a substep in the time line
 /// </summary>
 /// <param name="currentTime"></param>
 /// <param name="subStep"></param>
 /// <returns></returns>
 private void PositionSubStep(double currentTime, SubStep subStep)
 {
     SubStepActivated subStepActivated = new SubStepActivated(subStep, null) {Time = currentTime};
     PositionHandler.RegisterEvent(subStepActivated);
     foreach (Action action in subStep.Actions)
     {
         VariableUpdate variableUpdate = new VariableUpdate(action, action, null);
         PositionHandler.RegisterEvent(variableUpdate);
     }
     foreach (Expectation expectation in subStep.Expectations)
     {
         Expect expect = new Expect(expectation, null);
         PositionHandler.RegisterEvent(expect);
     }
 }