Beispiel #1
0
        } // end of RemoveScheduledEvent

        #endregion

        #region RunSimulationModel

        /// <summary>
        /// Runs the entire simulation model, start and endtime are specified by the model
        /// </summary>
        /// <param name="simModel">The simulation model to be ran</param>
        /// <returns></returns>
        public void RunSimulationModel(SimulationModel simModel)
        {
            DateTime currentTime = simModel.StartTime;

            while (!SimulationModel.StopSimulation(currentTime))
            {
                DateTime newTime;
                bool     modelRunning = RunSingleStepSimulationModel(currentTime, out newTime);

                if (modelRunning)
                {
                    currentTime = newTime;
                } // end if
            }     // end while

            SimulationModel.CreateSimulationResultsAfterStop();
        } // end of RunSimulationModel
Beispiel #2
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