public void Land(Plane plane, LandingRunwayStation runway) { SetPlaneHistory(plane, runway); SetPlaneLandedProp(plane); simulatorService.AttachPlaneToStation(plane, runway); DbUpdate(plane, runway, FlightActionsEnum.Landing); InvokeNotifierAction(plane); simulatorService.TimeToSleep(1500); }
private void LandAfterWaiting(IStation station, Plane plane) { lock (station.Locker) { if (IsFirstWaiterPlane(station, plane)) //check if its thread first time. { simulatorService.RemoveWaiterFromStations(plane, LandingRunways.Cast <IStation>()); //remove plane from station waiters list. LandingRunwayStation rws = station as LandingRunwayStation; Land(plane, rws); LandingWaiters.Remove(plane); Task.Run(() => ContinueMovement(plane, rws)); //Run it in another thread so other threads will execute. } } }
private List <Station> SetStations() { TakeoffRunwayStation tr1 = new TakeoffRunwayStation { Id = 15, NextStations = null, PlaneWaiters = new List <Plane>(), Type = StationType.TakeoffsRunway }; TakeoffRunwayStation tr2 = new TakeoffRunwayStation { Id = 16, NextStations = null, PlaneWaiters = new List <Plane>(), Type = StationType.TakeoffsRunway }; MiddleStation tms1 = new MiddleStation { Id = 13, NextStations = new List <Station> { tr1, tr2 }, PlaneWaiters = new List <Plane>(), Type = StationType.TakeoffMiddle }; MiddleStation tms2 = new MiddleStation { Id = 14, NextStations = new List <Station> { tr1, tr2 }, PlaneWaiters = new List <Plane>(), Type = StationType.TakeoffMiddle }; HangarStation hs1 = new HangarStation { Id = 5, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs2 = new HangarStation { Id = 6, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs3 = new HangarStation { Id = 7, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs4 = new HangarStation { Id = 8, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs5 = new HangarStation { Id = 9, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs6 = new HangarStation { Id = 10, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs7 = new HangarStation { Id = 11, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; HangarStation hs8 = new HangarStation { Id = 12, NextStations = new List <Station> { tms1, tms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.Hangar }; MiddleStation lms1 = new MiddleStation { Id = 3, NextStations = new List <Station> { hs1, hs2, hs3, hs4, hs5, hs6, hs7, hs8 }, PlaneWaiters = new List <Plane>(), Type = StationType.LandingMiddle }; MiddleStation lms2 = new MiddleStation { Id = 4, NextStations = new List <Station> { hs1, hs2, hs3, hs4, hs5, hs6, hs7, hs8 }, PlaneWaiters = new List <Plane>(), Type = StationType.LandingMiddle }; LandingRunwayStation lrs1 = new LandingRunwayStation { Id = 1, NextStations = new List <Station> { lms1, lms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.LandingsRunway }; LandingRunwayStation lrs2 = new LandingRunwayStation { Id = 2, NextStations = new List <Station> { lms1, lms2 }, PlaneWaiters = new List <Plane>(), Type = StationType.LandingsRunway }; List <Station> stations = new List <Station> { lrs1, lrs2, lms1, lms2, hs1, hs2, hs3, hs4, hs5, hs6, hs7, hs8, tms1, tms2, tr1, tr2 }; return(stations); }
private void DbUpdate(Plane plane, LandingRunwayStation station, FlightActionsEnum flightAction) { ILanding flight = simulatorService.CreateFlightByAction(plane, station, flightAction) as ILanding; dbSaveService.AddLanding(flight); }
private void SetPlaneHistory(Plane plane, LandingRunwayStation runway) => simulatorService.SetPlaneEnteredTime(plane, runway);
private bool IsCanLand(out LandingRunwayStation rws) { rws = GetRunwayToLand(); return(rws != null); }
/// <summary> /// Private method looking for available landing runway. /// </summary> /// <returns></returns> private bool IsAvailableRunway(out LandingRunwayStation rws) { rws = default; return((!IsThereLandingWaiter()) && IsCanLand(out rws)); }
private void Land(Plane plane, LandingRunwayStation rws) => landingSimulator.Land(plane, rws);