示例#1
0
文件: Logic.cs 项目: Tvde1/OdoriRails
        public void Simulation()
        {
            SortingAlgoritm sorter = new SortingAlgoritm(AllTracks, repo);

            //De schema moet op volgorde van eerst binnenkomende worden gesorteerd
            schema.Sort((x, y) => x.EntryTime.CompareTo(y.EntryTime));

            //Voor iedere inrijtijd een tram eraan koppellen
            foreach (InUitRijSchema entry in schema.Where(x => x.TramNumber == null))
            {
                foreach (BeheerTram tram in AllTrams.Where(x => x.DepartureTime == null && x.Line == entry.Line))
                {
                    entry.TramNumber = tram.Number;
                    tram.EditTramDepartureTime(entry.ExitTime);
                    break;
                }
            }

            //Too little linebound trams to fill each entry so overflow to other types of trams
            foreach (InUitRijSchema entry in schema.Where(x => x.TramNumber == null))
            {
                foreach (BeheerTram tram in AllTrams.Where(x => x.DepartureTime == null))
                {
                    if ((entry.Line == 5 || entry.Line == 1624) && (tram.Model == TramModel.Dubbel_Kop_Combino || tram.Model == TramModel.TwaalfG)) //No driver lines
                    {
                        entry.TramNumber = tram.Number;
                        tram.EditTramDepartureTime(entry.ExitTime);
                        break;
                    }
                    else if ((entry.Line != 5 || entry.Line != 1624) && tram.Model == TramModel.Combino) //Driver lines
                    {
                        entry.TramNumber = tram.Number;
                        tram.EditTramDepartureTime(entry.ExitTime);
                        break;
                    }
                }
            }

            //Het schema afgaan voor de simulatie
            foreach (InUitRijSchema entry in schema)
            {
                BeheerTram tram = AllTrams.Find(x => x.Number == entry.TramNumber);
                SortTram(sorter, tram);
                form.Invalidate();
                Thread.Sleep(simulationSpeed);
            }

            foreach (BeheerTram tram in AllTrams.Where(x => x.DepartureTime == null))
            {
                SortTram(sorter, tram);
                form.Invalidate();
                Thread.Sleep(simulationSpeed);
            }

            schema = csv.getSchema();
            Update();
        }
示例#2
0
文件: Logic.cs 项目: Tvde1/OdoriRails
        /// <summary>
        /// Constructor: Voert alles uit dat bij de launch uitgevoerd moet worden.
        /// </summary>
        public Logic(Form form)
        {
            if (testing == true)
            {
                simulationSpeed = 50;
            }

            FetchUpdates();
            csv       = new CSVContext();
            schema    = csv.getSchema();
            this.form = form;

            tramFetcher = new System.Windows.Forms.Timer()
            {
                Interval = 5000
            };
            tramFetcher.Tick += tramFetcher_Tick;
            tramFetcher.Start();
        }