Esempio n. 1
0
        /// <summary>
        /// Executes a single Simulation run with the given parameters
        /// </summary>
        public void ExecuteSimulation()
        {
            //Create the simulator using the parameters
            Simulator         sim     = new Simulator(beginTime, duration, callArrivalMultiplier, switchDelayMultiplier, productTypes, maxQueueLength, singleQueueLength, excessiveWait, repNums);
            RunningDisplay    rd      = new RunningDisplay(0, 0, sim);
            StatisticsManager statMan = new StatisticsManager(sim);
            StatisticsDisplay sd      = new StatisticsDisplay(rd.Location.X, (rd.Location.Y + rd.Height), statMan);

            rd.Show();
            sd.Show();

            //Run the simulator
            sim.RunSimulation(SIMULATION_SLEEP);
            rd.Hide();
            rd.Dispose();
        }
        //-------------------------------------------------------------------
        //- METHODS                                                         -
        //-------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the StatisticsDisplay bound to the given StatisticsManager
        /// </summary>
        /// <param name="statsMan">The StatisticsManager instance that this display is bound to</param>
        /// <param name="windowX">The X-Coordinate that the window should start at</param>
        /// <param name="windowY">The Y-Cooridinate that the window should start at</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the given StatisticsManager is null</exception>
        public StatisticsDisplay(int windowX, int windowY, StatisticsManager statsMan)
        {
            // Check that the given StatisticsManager is not null
            if (statsMan != null)
            {
                InitializeComponent();
                this.statsMan = statsMan;
                this.Location = new Point(windowX, windowY);

                //Bind the StatisticsManager.StatisticsUpdated event to the UpdateDisplay method
                statsMan.StatisticsUpdated += new EventHandler(UpdateDisplay);
            }
            else // The given StatisticsManager is null
            {
                throw new ArgumentNullException("statsMan", "Attempted to pass null StatisticsManager to StatisticsDisplay constructor");
            }
        }