public Swiatla(Swiatla sw) { this.schemat = sw.schemat; this.sterowanieSI = false; this.pozycjaWSchemacie = sw.pozycjaWSchemacie; this.pozycja = sw.pozycja; this.odZmiany = new int[sw.odZmiany.Length]; sw.odZmiany.CopyTo(this.odZmiany, 0); schematSi = null; }
// Przejazd pojazdu przez skrzyżowanie public void Przejazd(Swiatla swiatla) { if (pojazdy.Count() == 0) { return; } Pojazd pojazd = pojazdy.First(); if (swiatla.CzyZielone(zrodloSkrzyzowanaia, kierunkiSkrzyzowania[kierunki.FindIndex(k => k == pojazd.KolejneSkrzyzowanie())])) { pojazdy.Dequeue(); pojazd.RuszZeSwiatel(); } }
public Skrzyzowanie(int id, List <PasRuchu> pasy, Swiatla swiatla, SchematRuchu ruch, SchematRuchu usuwanyRuch) { this.id = id; if (id > maxId) { maxId = id; } this.pasyRuchu = pasy; this.swiatla = swiatla; this.generowany = ruch; this.usuwany = usuwanyRuch; int zrodlo = -1; foreach (PasRuchu pas in pasy) { if (pas.Zrodlo() != zrodlo) { zrodlo = pas.Zrodlo(); } } }
public void MapaTestowa() { Skrzyzowanie sk; SchematRuchu sr; SchematSwiatel ss; Swiatla sw; List <PasRuchu> psy; sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 2, 0, new List <int> { 7, 9 }, new List <int> { 1, 3 }, 20), new PasRuchu(2, 25, 7, 1, new List <int> { 9, 2 }, new List <int> { 3, 0 }, 20), new PasRuchu(2, 28, 9, 3, new List <int> { 2, 7 }, new List <int> { 0, 1 }, 20), }; sk = new Skrzyzowanie(1, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 6, 0, new List <int> { 5, 1 }, new List <int> { 1, 3 }, 20), new PasRuchu(2, 27, 5, 1, new List <int> { 1, 6 }, new List <int> { 3, 0 }, 20), new PasRuchu(2, 28, 1, 3, new List <int> { 6, 5 }, new List <int> { 0, 1 }, 20), }; sk = new Skrzyzowanie(7, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 4, 0, new List <int> { 9, 7 }, new List <int> { 1, 3 }, 20), new PasRuchu(2, 27, 9, 1, new List <int> { 7, 4 }, new List <int> { 3, 0 }, 20), new PasRuchu(2, 25, 7, 3, new List <int> { 4, 9 }, new List <int> { 0, 1 }, 20), }; sk = new Skrzyzowanie(5, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 8, 0, new List <int> { 1, 5 }, new List <int> { 1, 3 }, 20), new PasRuchu(2, 27, 1, 1, new List <int> { 5, 8 }, new List <int> { 3, 0 }, 20), new PasRuchu(2, 28, 5, 3, new List <int> { 8, 1 }, new List <int> { 0, 1 }, 20), }; sk = new Skrzyzowanie(9, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 32, 1, 0, new List <int> { 8, 3, 6 }, new List <int> { 1, 2, 3 }, 20), new PasRuchu(2, 33, 8, 1, new List <int> { 3, 6, 1 }, new List <int> { 2, 3, 0 }, 20), new PasRuchu(1, 30, 3, 3, new List <int> { 6, 1, 8 }, new List <int> { 3, 0, 1 }, 20), new PasRuchu(2, 27, 6, 3, new List <int> { 1, 8, 3 }, new List <int> { 0, 1, 2 }, 20), }; sk = new Skrzyzowanie(2, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 31, 2, 0, new List <int> { 8, 4, 6 }, new List <int> { 1, 2, 3 }, 20), new PasRuchu(1, 33, 8, 1, new List <int> { 4, 6, 2 }, new List <int> { 2, 3, 0 }, 20), new PasRuchu(1, 32, 4, 3, new List <int> { 6, 2, 8 }, new List <int> { 3, 0, 1 }, 20), new PasRuchu(1, 29, 6, 3, new List <int> { 2, 8, 4 }, new List <int> { 0, 1, 2 }, 20), }; sk = new Skrzyzowanie(3, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 3, 0, new List <int> { 8, 5, 6 }, new List <int> { 1, 2, 3 }, 20), new PasRuchu(2, 27, 8, 1, new List <int> { 5, 6, 3 }, new List <int> { 2, 3, 0 }, 20), new PasRuchu(1, 30, 5, 3, new List <int> { 6, 3, 8 }, new List <int> { 3, 0, 1 }, 20), new PasRuchu(2, 25, 6, 3, new List <int> { 3, 8, 5 }, new List <int> { 0, 1, 2 }, 20), }; sk = new Skrzyzowanie(4, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 3, 0, new List <int> { 4, 7, 2 }, new List <int> { 1, 2, 3 }, 20), new PasRuchu(2, 15, 4, 1, new List <int> { 7, 2, 3 }, new List <int> { 2, 3, 0 }, 20), new PasRuchu(1, 25, 7, 3, new List <int> { 2, 3, 4 }, new List <int> { 3, 0, 1 }, 20), new PasRuchu(2, 31, 2, 3, new List <int> { 3, 4, 7 }, new List <int> { 0, 1, 2 }, 20), }; sk = new Skrzyzowanie(6, psy, sw, sr, sr); DodajSkrzyzowanie(sk); sr = new SchematRuchu(new List <int> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 }); ss = new SchematSwiatel(new List <int> { 0, 1, 2, 3, 4, 5 }, new List <int> { 20, 20, 20, 20, 20, 20 }); sw = new Swiatla(ss); //ps = new PasRuchu(1, 30, 2, new List<int> { }, new List<int> { }, 20); psy = new List <PasRuchu> { new PasRuchu(1, 30, 9, 0, new List <int> { 4, 3, 2 }, new List <int> { 1, 2, 3 }, 20), new PasRuchu(2, 31, 4, 1, new List <int> { 3, 2, 9 }, new List <int> { 2, 3, 0 }, 20), new PasRuchu(1, 37, 3, 3, new List <int> { 2, 9, 4 }, new List <int> { 3, 0, 1 }, 20), new PasRuchu(2, 15, 2, 3, new List <int> { 9, 4, 3 }, new List <int> { 0, 1, 2 }, 20), }; sk = new Skrzyzowanie(8, psy, sw, sr, sr); DodajSkrzyzowanie(sk); }