Exemple #1
0
        /// <summary>
        /// Add an event to the list
        /// </summary>
        public void Add(Event e)
        {
            // Add event to list
            events.Add(e);

            // Sort list on EventTime
            events.Sort((x, y) => x.EventTime.CompareTo(y.EventTime));
        }
Exemple #2
0
        /// <summary>
        /// Remove event from the list
        /// </summary>
        public void Remove(Event e)
        {
            // Check if event is in queue
            if (events.Contains(e))
            {
                // Get events index
                int index = events.IndexOf(e);

                // Remove event at found index
                events.RemoveAt(index);
            }
        }
Exemple #3
0
        /// <summary>
        /// Run the simulation
        /// </summary>
        public void RunSimulation()
        {
            while (!(activeEvent is EndSimulationEvent))
            {
                // Get next event from calender
                activeEvent = calender.GetNextEvent();

                // Update global clock
                Global.Clock = activeEvent.EventTime;

                if (activeEvent is ArrivalEvent)
                {
                    // Tell event to execute
                    activeEvent.Execute(calender, resourceManager, statistics, rGen, entityFactory, eventFactory);
                }

                if (activeEvent is SwitchCompleteEvent)
                {
                    // Tell event to execute
                    activeEvent.Execute(calender, resourceManager, statistics, rGen, entityFactory, eventFactory);
                }

                if(activeEvent is ProcessingCompleteEvent)
                {
                    // Tell event to execute
                    activeEvent.Execute(calender, resourceManager, statistics, rGen, entityFactory, eventFactory);
                }

                // Update simulation statistics
                statistics.UpdateLists(calender, resourceManager);
                statistics.NotifyDisplays();

                // Control the speed of the loop
                System.Threading.Thread.Sleep(Global.SimulationSpeed);
            }

            // Gives user feedback at the end of the simulation
            if(Global.ExportCSV)
                OpenSaveFileDialog();
            else
                MessageBox.Show("The simulation completed successfully", "Simulation Complete");
        }