Example #1
0
        } // end of RunSimulationModel

        #endregion

        #region RunSingleStepSimulationModel

        /// <summary>
        /// Runs a single time step of a simulation model, i.e. triggering all events that occur at
        /// the current time
        /// </summary>
        /// <param name="currentTime">Current time of the execution</param>
        /// <param name="newTime">Next time events will occur</param>
        /// <returns>Returns false if no future events exist, else returns true</returns>
        public bool RunSingleStepSimulationModel(DateTime currentTime, out DateTime newTime)
        {
            _currentlyTriggeredEvents.Clear();

            newTime = currentTime;

            // all scheduled behavior of this time is executed
            if (SELlist.NumberEvents == 0)
            {
                newTime = SimulationModel.EndTime;
                return(false);
            }
            else
            {
                while (SELlist.GetFirstEventTime() == currentTime)
                {
                    SELlist.TriggerFirstEvent(this);
                } // end while
            }     // end if

            // perform conditional rules on model
            SimulationModel.PerformModelRules(CurrentlyTriggeredEvents, currentTime, this);

            if (CreateEventLog)
            {
                LoggingEngine.CreateCurrentState(CurrentlyTriggeredEvents, currentTime);
            }

            if (SELlist.NumberEvents > 0)
            {
                newTime = SELlist.GetFirstEventTime();
                return(true);
            }
            else
            {
                newTime = SimulationModel.EndTime;
                return(false);
            } // end if
        }     // end of RunSingleStepSimulationModel