Esempio n. 1
0
 private void MangePlanesInAirport(AirportDTO airport)
 {
     //telling planes in airport where to move:
     for (int i = 0; i < airport.Planes.Count; i++)
     {
         PlaneDTO plane = airport.Planes[i];
         //if plane landing
         if (StationsInfoService.IsAttendingToLand(plane.StationId))
         {
             plane.StationId++;
         }
         //if plane on track
         else if (StationsInfoService.IsOnTrack(plane.StationId))
         {
             if (plane.State == PlaneState.Landing)
             {
                 plane.StationId++;
             }
             else//departuring
             {
                 plane.StationId = StationsInfoService.InAir; //tell the plane departure to air
                 //and from the plansOnHold queue:
                 DeparturePlanesOnHold.Dequeue();
             }
         }
         //if attending to park
         else if (StationsInfoService.IsAttendingToPark(plane.StationId))
         {
             //if the parking slots are empty -tell the plane to move there:
             PlaneDTO firstParkingSlot  = airport.Planes.FirstOrDefault(u => u.StationId == StationsInfoService.Parking[0]);
             PlaneDTO secondParkingSlot = airport.Planes.FirstOrDefault(u => u.StationId == StationsInfoService.Parking[1]);
             if (firstParkingSlot == null)
             {
                 plane.StationId = StationsInfoService.Parking[0];
                 //raise event about the parked plane:
                 PlaneParked.Invoke(plane, EventArgs.Empty);
             }
             else if (secondParkingSlot == null)
             {
                 plane.StationId = StationsInfoService.Parking[1];
                 //raise event about the parked plane:
                 PlaneParked.Invoke(plane, EventArgs.Empty);
             }
         }
         else if (StationsInfoService.IsAttendingToDepart(plane.StationId))
         {
             plane.StationId = StationsInfoService.Track;
         }
     }
 }
Esempio n. 2
0
 //bubble the PlaneParked event up to the WCF service,
 private void OnPlaneParked(object sender, EventArgs e)
 {
     PlaneParked.Invoke(sender, e);
 }
Esempio n. 3
0
 public void OnPlaneParked(OnPlaneParkedRequest request)
 {
     //raise event of parked plane (sender = parked plane )
     PlaneParked.Invoke(request.ParkedPlane, EventArgs.Empty);
 }