コード例 #1
0
        public Simulation(List <LayoutJsonModel> layout, ConfigJsonModel ConfigJson)
        {
            InitializeComponent();
            // Setting form to fullscreen
            Rectangle resolution = Screen.PrimaryScreen.Bounds;

            this.Size        = resolution.Size;
            this.WindowState = FormWindowState.Maximized;

            // Placing Pauze panel on right location and hiding it
            panelPauze.Visible = false;
            double PauzeWidth  = resolution.Width * 0.20;
            double PauzeHeight = resolution.Height * 0.75;

            this.panelPauze.Size       = new Size((int)PauzeWidth, (int)PauzeHeight);
            this.panelPauze.Top        = (this.ClientSize.Height - panelPauze.Height) / 2;
            this.panelPauze.Left       = 10;
            this.labelGamePauzed.Width = this.panelPauze.Width;
            this.labelInfo.Width       = this.panelPauze.Width;
            this.labelInfo.Height      = this.panelPauze.Height - this.labelGamePauzed.Height;

            // initialize timer for hte
            timer.Tick += new EventHandler(OnTimedEvent);
            double MilisecondsPerHte = 1.0 / ConfigJson.HtesPerSecond;
            int    intervalOne       = Convert.ToInt32(MilisecondsPerHte * 1000); // van seconde milisecondes maken

            timer.Interval = (intervalOne >= 1) ? (int)intervalOne : 1;


            // initialize timer for frame updates
            frameTimer.Tick += new EventHandler(OnFrameTimerUpdate);
            int    FPS       = 60; // fps instelbaar
            double interval2 = (double)1000 / FPS;

            frameTimer.Interval = (interval2 >= 1) ? (int)interval2 : 1;

            // create hotel
            hotel = new Hotel(layout, ConfigJson, timer);
            hotel.Display(MainSimDisplay);
            hotel.hotelPB.Click += HotelPB_Click;
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);

            // create eventmanager
            HotelEventManager.Register(new myEventListener(hotel));
            HotelEventManager.HTE_Factor = (int)ConfigJson.HtesPerSecond;

            // start simulation
            timer.Start();
            frameTimer.Start();
            sw.Start();
            HotelEventManager.Start();
        }
コード例 #2
0
        /***** We kregen de elevator niet goed werken binnen de tijd *****/

        public Hotel(List <LayoutJsonModel> layout, ConfigJsonModel ConfigFile, Timer _timer) // ctor
        {
            HTETimer      = _timer;
            HtesPerSecond = ConfigFile.HtesPerSecond;

            hotelArray    = CreateHotelFromLayout(layout);
            hotelArray    = AssignNeighboursToHotel(hotelArray, ConfigFile.StairDistanceHTE, ConfigFile.ElevatorDistanceHTE);
            entityFactory = new EntityFactory(hotelArray, ConfigFile);

            // set movie duration
            foreach (Area item in hotelArray)
            {
                if (item != null && item.Simtype == SimObject.SimType.Cinema)
                {
                    Cinema cin = item as Cinema;
                    cin.movieDuration = ConfigFile.MovieDurationHTE;
                }
            }
        }
コード例 #3
0
ファイル: Options.cs プロジェクト: hipertom/HotelSimulation
        public Options()
        {
            InitializeComponent();

            #region Opmaak van het form, panel, buttons en textboxen

            // velden gelijk zetten aan wat in de config staat
            // config uitlezen
            ConfigJsonModel config = new ConfigJsonModel();
            config.ReadConfigJson(configPath);
            // velden gelijk zetten
            if (config.HtesPerSecond != 0)
            {
                textBoxHtePerSecond.Text = config.HtesPerSecond.ToString().Replace(",", ".");
            }

            if (config.QueueDeathHTE != 0)
            {
                textBoxQueueDeathHTE.Text = config.QueueDeathHTE.ToString().Replace(",", ".");
            }

            if (config.StairDistanceHTE != 0)
            {
                textBoxStairHTE.Text = config.StairDistanceHTE.ToString().Replace(",", ".");
            }

            if (config.RoomCleaningHTE != 0)
            {
                textBoxRoomCleaningHTE.Text = config.RoomCleaningHTE.ToString().Replace(",", ".");
            }

            if (config.MovieDurationHTE != 0)
            {
                textBoxMovieDuration.Text = config.MovieDurationHTE.ToString().Replace(",", ".");
            }

            if (config.EatHTE != 0)
            {
                textBoxEatHTE.Text = config.EatHTE.ToString().Replace(",", ".");
            }

            // disable color change on hover van buttons
            buttonStart.FlatAppearance.MouseOverBackColor  = buttonStart.BackColor;
            buttonBrowse.FlatAppearance.MouseOverBackColor = buttonBrowse.BackColor;


            // loop door alle text boxes en maak een list om bepaalde uit te sluiten!
            List <Control> exclude = new List <Control>();
            exclude.Add(textBoxFilePath);
            foreach (Control x in panelContainer.Controls) // loop door alle items in panel
            {
                if (x is TextBox && !exclude.Contains(x))  // Controleren of huidige item in loop textbox is en niet in exclude staat
                {
                    ((TextBox)x).AutoSize = false;
                    ((TextBox)x).Size     = new System.Drawing.Size(100, 18);
                }
            }

            #endregion

            // standaard path voor layout bestand zodat je in een keer door kan klikken als het bestand op je desktop staat
            textBoxFilePath.Text = layoutDefaultPath;
        }// end ctor
コード例 #4
0
ファイル: Options.cs プロジェクト: hipertom/HotelSimulation
        }// end ctor

        private void buttonStart_Click(object sender, EventArgs e)
        {
            string path = textBoxFilePath.Text;
            List <LayoutJsonModel> layout = null;

            if (!string.IsNullOrWhiteSpace(path))
            {
                layout = ReadLayoutJson(path);
            }

            // check if is numeriek
            bool isNumeric1 = int.TryParse(textBoxHtePerSecond.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out HteInSeconds);
            bool isNumeric2 = int.TryParse(textBoxQueueDeathHTE.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out QueueDeathHTE);
            bool isNumeric3 = int.TryParse(textBoxStairHTE.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out StairHTE);
            bool isNumeric4 = int.TryParse(textBoxRoomCleaningHTE.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out RoomCleaningHTE);
            bool isNumeric5 = int.TryParse(textBoxMovieDuration.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out MovieDurationHTE);
            bool isNumeric6 = int.TryParse(textBoxEatHTE.Text.Replace(",", "."), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out EatTimeHTE);

            // check of waardes cijfers zijn en niet leeg
            if (!isNumeric1 || !isNumeric2 || !isNumeric3 || !isNumeric4 || !isNumeric5)
            {
                labelError.Text = "Één of meerdere velden zijn niet (correct) ingevuld";
            }
            else
            {
                // waardes moeten groter dan 0 zijn
                if (HteInSeconds <= 0 || QueueDeathHTE <= 0 || StairHTE <= 0 || RoomCleaningHTE <= 0 || MovieDurationHTE <= 0 || EatTimeHTE <= 0)
                {
                    labelError.Text = "Één of meerdere waardes zijn 0 of kleiner!";
                }
                else
                {
                    // of Json list is aan gemaakt
                    if (layout == null)
                    {
                        labelError.Text = "Er is geen (Json) bestand geselecteerd!";
                    }
                    else
                    {
                        // reset
                        labelError.Text = null;

                        // opslaan gegevens
                        ConfigJsonModel config = new ConfigJsonModel()
                        {
                            HtesPerSecond    = HteInSeconds,
                            QueueDeathHTE    = QueueDeathHTE,
                            RoomCleaningHTE  = RoomCleaningHTE,
                            StairDistanceHTE = StairHTE,
                            MovieDurationHTE = MovieDurationHTE,
                            EatHTE           = EatTimeHTE
                        };
                        config.WriteConfigJson(configPath);

                        // sluit huidige & open nieuw form
                        this.Hide();
                        var sim = new Simulation(layout, config);
                        sim.Closed += (s, args) => this.Close();
                        sim.Closed += (s, args) => HotelEvents.HotelEventManager.Stop();
                        sim.Show();
                    }
                }
            }
        }// end buttonStart_Click
コード例 #5
0
 public EntityFactory(Area[,] _hotelArray, ConfigJsonModel _config)
 {
     hotelArray = _hotelArray;
     config     = _config;
 }