コード例 #1
0
 // this is for landing request  -Jose
 private void btn_landingrequest_Click(object sender, EventArgs e)
 {
     connected = false;
     if (connected == false)
     {
         this.proxy.Connect(this.FlightNumber, this.FuelLevel, this.status);
         this.connected = true;
     }
     try
     {
         this.proxy.LandRequest(this.FlightNumber);
         requestType = "Land";
     }
     catch (Exception)
     {
     }
     this.BeginInvoke((MethodInvoker) delegate
     {
         btn_LandingRequest.Enabled = false;
         Cancel_Request.Enabled     = true;
         //Change in the status
         status         = AStatus.Wait_landing;
         lb_status.Text = statusDict[status];
     });
 }
コード例 #2
0
        private void Take_Off_Request_Click(object sender, EventArgs e)
        {
            connected = false;
            System.Diagnostics.Debug.WriteLine("ENters takeoff handler");
            //connect
            if (connected == false)
            {
                this.proxy.Connect(this.FlightNumber, this.FuelLevel, this.status);
                this.connected = true;
            }

            System.Diagnostics.Debug.WriteLine("ENters try block");
            this.proxy.TakeOffRequest(this.FlightNumber);
            requestType = "TakeOff";

            this.BeginInvoke((MethodInvoker) delegate
            {
                Take_Off_Request.Enabled = false;
                Cancel_Request.Enabled   = true;
            });


            // change in the status
            status = AStatus.Wait_takeoff;
            this.BeginInvoke((MethodInvoker) delegate
            {
                lb_status.Text = statusDict[status];
            });
        }
コード例 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (connected == false)
     {
         this.proxy.Connect(this.FlightNumber, this.FuelLevel, this.status);
         this.connected = true;
     }
     try
     {
         if (status == AStatus.In_air || status == AStatus.In_the_air || status == AStatus.Wait_landing)
         {
             proxy.EmergencyRequest(this.FlightNumber);
             status         = AStatus.Wait_emergency;
             lb_status.Text = statusDict[status];
             requestType    = "Emergency";
         }
         else
         {
             MessageBox.Show("Emergency calls only allowed in air");
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #4
0
        //status parameter not useful anymore apparently
        public void AbortComplete(string flight, AStatus status)
        {
            string label = locatePlane(flight);

            prepareRunway(label);
            lb_message.Text = flight + " has finished the abort action.";
        }
コード例 #5
0
        public void ConnectToServer()
        {
            FuelLevel = dialog.fuel;
            //magic stuff
            status = statusDict.FirstOrDefault(x => x.Value == dialog.status).Key;

            //if (status == AStatus.On_the_ground) {
            //    this.connected = true;
            //    this.proxy.Connect(FlightNumber, FuelLevel, status);
            //}


            lb_status.Text     = statusDict[status];
            lb_fuel.Text       = FuelLevel + " %";
            pb_fuelLevel.Value = FuelLevel;

            if (status == AStatus.In_the_air)
            {
                Take_Off_Request.Visible = false;
            }
            else
            {
                btn_LandingRequest.Visible = false;
            }
            timer1.Start();
            timer2.Start();
        }
コード例 #6
0
ファイル: ATC_Contract.cs プロジェクト: nimeni1/ProCp
        public void AbortComplete(string flight, AStatus status)
        {
            Airplane a = GetAirplane(flight);

            a.Status = status;

            controllerCallback.AbortFinished(flight, status);
        }
コード例 #7
0
ファイル: ATC_Contract.cs プロジェクト: nimeni1/ProCp
 // ----- Methods form IAirplane Interface
 public void Connect(string FlightNumber, int fuel_level, AStatus status)
 {
     this.airplaneCallback = OperationContext.Current.GetCallbackChannel <IAirplaneCallback>();
     this.airplaneCallbacks.Add(this.airplaneCallback);
     airplanes.Add(new Airplane(FlightNumber, fuel_level, status));
     //if it is on land at startup of the application, the docking process is started
     //if (status == AStatus.On_the_ground) LetPilotKnow(FlightNumber, status);
 }
コード例 #8
0
 public void UpdateForTakingOffProcess(string flight, AStatus status, string runwId)
 {
     this.BeginInvoke((MethodInvoker) delegate {
         UpdateListView(flight, status);
         lb_message.Text = flight + ", " + "take off" + " request is sent.";
         //animate(flight, runwId, false);
     });
 }
コード例 #9
0
ファイル: Airplane.cs プロジェクト: nimeni1/ProCp
        //[DataMember]
        //public Point MyProperty { get; set; }


        public Airplane(string flightNumber, int fuelLevel, AStatus status)

        {
            this.FlightNumber = flightNumber;
            this.FuelLevel    = fuelLevel;
            this.Status       = status;

            IdAll  += 1;
            this.Id = IdAll;
        }
コード例 #10
0
ファイル: ATC_Contract.cs プロジェクト: nimeni1/ProCp
 public void UpdateStatusFromController(string flightNumber, AStatus status)
 {
     for (int i = 0; i < airplanes.Count; i++)
     {
         if (airplanes[i].FlightNumber == flightNumber)
         {
             airplanes[i].Status = status;
             indexes.Enqueue(i);
             i = airplanes.Count;
         }
     }
 }
コード例 #11
0
        private void DoAbort(AStatus nextstatus)
        {
            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(1000);
            }

            this.status = nextstatus;
            this.Aborted(nextstatus);
            timerProgress.Stop();
            proxy.AbortComplete(FlightNumber, this.status);
        }
コード例 #12
0
        public void UpdateListView(string flight, AStatus status)
        {
            int i;

            for (i = 0; i < listView_flight.Items.Count; i++)
            {
                if (listView_flight.Items[i].SubItems[0].Text == flight)
                {
                    listView_flight.Items[i].SubItems[2].Text = statusDict[status];
                }
            }
        }
コード例 #13
0
        public void AbortFinished(string flight, AStatus status)
        {
            string runw = this.proxy.GetAirplane(flight).Runway.RunwayID;

            if (status == AStatus.In_air)
            {
                RemoveFromView(flight);
            }
            else
            {
                UpdateListView(flight, status);
            }
            prepareRunway(runw);
            lb_message.Text = flight + " finished abort";
        }
コード例 #14
0
 public void UpdateForTaxi(string flight, AStatus status, string RunwayID, bool success)
 {
     this.BeginInvoke((MethodInvoker) delegate {
         if (success)
         {
             UpdateListView(flight, status);
             taxi(RunwayID);
             attachLabel(flight, RunwayID, false);
         }
         else
         {
             lb_message.Text = "Command not allowed";
         }
     });
 }
コード例 #15
0
 public void UpdateForLandingProcess(string flight, AStatus status, string RunwayId)
 {
     this.BeginInvoke((MethodInvoker) delegate
     {
         //by this point we know the lanidng approval, not the request was successfully send, so we start occupying the runway
         // to show that abort can be performed on this flight
         //and to prevent the user from sending unnecessary approvals to the server thinking runway is free
         bool emerg = false;
         if (status == AStatus.Emergency_landing)
         {
             emerg = true;
         }
         UpdateListView(flight, status);
         lb_message.Text = flight + ", " + "landing approval is sent.";
         taxi(RunwayId); attachLabel(flight, RunwayId, emerg);
     });
 }
コード例 #16
0
        //self-explanatory
        private void Undock_Click(object sender, EventArgs e)
        {
            Take_Off_Request.Enabled = true;
            Take_Off_Request.Visible = true;

            this.Undock.Enabled = false;

            btn_LandingRequest.Visible = false;
            btn_LandingRequest.Enabled = false;
            this.status = AStatus.On_land;
            //if (status == AStatus.On_land)
            //{
            //    this.connected = true;
            //    this.proxy.Connect(FlightNumber, FuelLevel, status);
            //}
            lb_status.Text = statusDict[status];
            //this.proxy.UpdateStatusFromPilot(this.FlightNumber, this.status);
        }
コード例 #17
0
        private void timerProgress_Tick(object sender, EventArgs e)
        {
            if (progressTicks < 2)
            {
                canAbort = true;
            }
            progressTicks = progressTicks + 1;
            if (progressTicks > 2)
            {
                canAbort = false;
                progress = progress + 1;

                if (semafor && progress < 10)
                {
                    proxy.reportProgress(FlightNumber, progress);
                }
                if (progress == 10)
                {
                    //condition to occupy extra for emergency
                    if (this.status == AStatus.Emergency_landing && semafor)
                    {
                        semafor   = false;
                        progress -= 2;
                    }

                    else
                    {
                        timerProgress.Stop();
                        proxy.reportProgress(FlightNumber, 10);
                        if (status == AStatus.Landing || status == AStatus.Emergency_landing)
                        {
                            this.status = AStatus.On_land; timer2.Stop();
                        }
                        if (status == AStatus.Taking_Off)
                        {
                            this.status = AStatus.In_air;
                        }
                        lb_status.Text = statusDict[status];
                        this.AfterAnimation();
                        this.proxy.UpdateStatusFromPilot(this.FlightNumber, this.status);
                    }
                }
            }
        }
コード例 #18
0
        public void RequestConfirm(string RunwayId)
        {
            this.BeginInvoke((MethodInvoker) delegate
            {
                if (btn_LandingRequest.Visible == true || this.status == AStatus.Wait_emergency)
                {
                    System.Diagnostics.Debug.WriteLine("request reached");

                    this.btn_LandingRequest.BackColor = Color.Green;
                    this.btn_LandingRequest.Text      = "Confirmed";
                    this.btn_LandingRequest.Enabled   = false;
                    if (status == AStatus.Wait_emergency)
                    {
                        status = AStatus.Emergency_landing;
                    }
                    else
                    {
                        status = AStatus.Landing;
                    }
                }
                else
                {
                    this.Take_Off_Request.BackColor = Color.Green;
                    this.Take_Off_Request.Text      = "Confirmed";
                    this.Take_Off_Request.Enabled   = false;
                    status         = AStatus.Taking_Off;
                    this.FuelLevel = 100;
                    timer2.Start();
                }

                //setting the process of landing/taking off
                progress      = -1;
                progressTicks = 0;
                semafor       = true;
                timerProgress.Start();


                lb_status.Text = statusDict[status];
                if (status == AStatus.Taking_Off || status == AStatus.Landing)
                {
                    this.Cancel_Request.Enabled = false;
                }
            });
        }
コード例 #19
0
        private void Cancel_Request_Click(object sender, EventArgs e)
        {
            this.BeginInvoke((MethodInvoker) delegate
            {
                this.proxy.CancelRequest(FlightNumber);

                if (btn_LandingRequest.Visible == true)
                {
                    btn_LandingRequest.Enabled = true;
                    status         = AStatus.In_air;
                    lb_status.Text = statusDict[status];
                }
                else
                {
                    Take_Off_Request.Enabled = true;
                    status         = AStatus.On_land;
                    lb_status.Text = statusDict[status];
                }
                Cancel_Request.Enabled = false;
            });
        }
コード例 #20
0
ファイル: ATC_Contract.cs プロジェクト: nimeni1/ProCp
        //the queue may be removable
        public void UpdateStatusFromPilot(string flightNumber, AStatus status)
        {
            AStatus previous = this.GetAirplane(flightNumber).Status;

            for (int i = 0; i < airplanes.Count; i++)
            {
                if (airplanes[i].FlightNumber == flightNumber)
                {
                    airplanes[i].Status = status;

                    //a little case distinction
                    if (status == AStatus.On_land)
                    {
                        //it adds the plane to the list if it was Docked before
                        if (previous == AStatus.Docked)
                        {
                            messageAddToList(flightNumber);
                        }
                        else
                        {
                            messageStandardUpdate(flightNumber);
                        }
                    }
                    if (status == AStatus.In_air)
                    {
                        messageRemove(flightNumber);                 // removes from the List View
                        airplanes.Remove(GetAirplane(flightNumber)); // removes from the List from the server.
                    }
                    if (status == AStatus.Docked)
                    {
                        messageDocked(flightNumber);
                        airplanes.Remove(GetAirplane(flightNumber)); // removes from the List from the server.
                    }

                    i = airplanes.Count;
                }
            }
        }
コード例 #21
0
ファイル: ATC_Contract.cs プロジェクト: nimeni1/ProCp
        //when animation is done, this function is called from the controller
        //it checks if the status is on land
        //and calls a method which waits for a few seconds before calling this method again with status docked
        //the controller is also notified of the docked status
        public void LetPilotKnow(string flight, AStatus status)
        {
            Thread temp;

            foreach (IAirplaneCallback a in airplaneCallbacks)
            {
                if (a.getFlightNr().Equals(flight))
                {
                    a.StatusChangedPilot(flight, status);
                }
            }
            //time to pass till the plane gets docked
            if (status == AStatus.On_land)
            {
                temp = new Thread(() => timePasses(flight));
                temp.Start();
            }
            if (status == AStatus.Docked)
            {
                this.UpdateStatusFromPilot(flight, status);
                this.airplanes.Remove(GetAirplane(flight)); // remove from the list when docked
            }
        }
コード例 #22
0
        public void Aborted(AStatus status)
        {
            //setting the button request landing to be as usual + label
            this.Invoke((MethodInvoker) delegate {
                lb_status.Text = statusDict[status];

                if (status == AStatus.On_land)
                {
                    Take_Off_Request.BackColor = Color.Green;
                    Take_Off_Request.Text      = "Takeoff request";
                    btn_LandingRequest.Visible = false;
                    Take_Off_Request.Visible   = true;
                    Take_Off_Request.Enabled   = true;
                }

                if (status == AStatus.In_air)
                {
                    btn_LandingRequest.BackColor = Color.Green;
                    btn_LandingRequest.Text      = "Land request";
                    btn_LandingRequest.Visible   = true;
                    btn_LandingRequest.Enabled   = true;
                    Take_Off_Request.Visible     = false;
                }
            });



            //I will leave it here for future reference

            //    AStatus nextStatus = AStatus.Null;
            //   if(status == AStatus.Landing)
            //   {
            //       status = AStatus.Abort_landing;
            //       this.btn_request.BackColor = Color.Red;
            //       this.btn_request.Text = statusDict[status];
            //       this.btn_request.Visible = true;
            //       this.btn_request.Enabled = false;
            //       nextStatus = AStatus.In_air;
            //   }
            //   if (status == AStatus.Taking_Off)
            //   {
            //       status = AStatus.Abort_takeoff;
            //       proxy.UpdateStatusFromPilot(this.FlightNumber, status);
            //       this.Take_Off_Request.Visible = true;
            //       this.Take_Off_Request.Enabled = false;
            //       this.Take_Off_Request.BackColor = Color.Red;
            //       this.Take_Off_Request.Text = statusDict[status];
            //       timer2.Stop();
            //       nextStatus = AStatus.On_land;
            //   }
            //    if(status.Equals(AStatus.Taxi_R1)||status.Equals(AStatus.Taxi_R2)||status.Equals(AStatus.Taxi_R3))
            //    {
            //        status = AStatus.Abort_taxi;
            //        this.Take_Off_Request.Visible = true;
            //        this.Take_Off_Request.Enabled = false;
            //        this.Take_Off_Request.BackColor = Color.Red;
            //        this.Take_Off_Request.Text = statusDict[status];
            //        timer2.Stop();
            //        nextStatus = AStatus.On_land;
            //    }

            //    proxy.UpdateStatusFromPilot(this.FlightNumber, status);
            //    DoAbort(nextStatus);
        }
コード例 #23
0
        public void StatusChangedPilot(string flightNumber, AStatus status)
        {
            string previousStatus = lb_status.Text;

            if (this.FlightNumber == flightNumber)
            {
                AStatus nextStatus = AStatus.Null;
                lb_status.Text = statusDict[status];
                this.status    = status;

                //i assume the fuel is 100% at taking off
                if (status == AStatus.Taking_Off)
                {
                    this.FuelLevel = 100;
                    timer2.Start();
                }

                //you cant cancel request while performing an action
                //if (status == "Taking Off" || status == "Landing") this.Cancel_Request.Enabled = false; - moved to requestconfirm


                //UI update


                if (status == AStatus.Abort_landing)
                {
                    //timer2.Start();
                    this.btn_LandingRequest.BackColor = Color.Red;
                    this.btn_LandingRequest.Text      = statusDict[status];
                    this.btn_LandingRequest.Visible   = true;
                    this.btn_LandingRequest.Enabled   = false;
                    nextStatus = AStatus.In_air;
                }
                if (status == AStatus.Abort_takeoff || status == AStatus.Abort_taxi)
                {
                    this.Take_Off_Request.Visible   = true;
                    this.Take_Off_Request.Enabled   = false;
                    this.Take_Off_Request.BackColor = Color.Red;
                    this.Take_Off_Request.Text      = statusDict[status];
                    timer2.Stop();
                    nextStatus = AStatus.On_land;
                }


                if (status == AStatus.On_land)
                {
                    timer2.Stop();
                    this.btn_LandingRequest.BackColor = default(Color);
                    this.btn_LandingRequest.Text      = "Land request";
                    this.btn_LandingRequest.Visible   = false;

                    this.Take_Off_Request.Visible = true;
                    this.Take_Off_Request.Enabled = true;
                }
                if (status == AStatus.In_air)
                {
                    this.Take_Off_Request.BackColor = default(Color);
                    this.Take_Off_Request.Text      = "Take off request";
                    this.Take_Off_Request.Visible   = false;

                    this.btn_LandingRequest.Visible = true;
                    this.btn_LandingRequest.Enabled = true;
                }

                Cancel_Request.Enabled = false;
                if (nextStatus != AStatus.Null)
                {
                    t = new Thread(() => DoAbort(nextStatus));
                    t.Start();
                }

                if (status == AStatus.Docked)
                {
                    this.Take_Off_Request.Enabled   = false;
                    this.Take_Off_Request.BackColor = default(Color);
                    this.Take_Off_Request.Text      = "Take off request";
                    this.btn_LandingRequest.Enabled = false;
                    this.button1.Enabled            = false;
                    this.Cancel_Request.Enabled     = false;
                    this.Undock.Enabled             = true;
                }
            }
        }