Esempio n. 1
0
        public void start()
        {
            double d = Double.Parse("34.5");

            latitude = d;

            Thread t1 = new Thread(delegate()
            {
                while (!stop)
                {
                    telnetClient.write("get /position/latitude-deg");
                    //latitude and longitude in different order in Location class
                    location.Longitude = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /position/longitude-deg");
                    location.Latitude = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    NotifyPropertyChanged("Location");
                    telnetClient.write("get /instrumentation/heading-indicator/indicated-heading-deg");
                    heading_deg = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/gps/indicated-vertical-speed");
                    vertical_speed = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/airspeed-indicator/indicated-speed-kt");


                    airspeed = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/gps/indicated-ground-speed-kt");


                    ground_speed = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/attitude-indicator/internal-roll-deg");


                    roll = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/gps/indicated-altitude-ft");


                    altitude = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/attitude-indicator/internal-pitch-deg");


                    pitch = System.Math.Round(Double.Parse(telnetClient.read()), 4);
                    telnetClient.write("get /instrumentation/altimeter/indicated-altitude-ft");
                    altimeter = System.Math.Round(Double.Parse(telnetClient.read()), 4);


                    Thread.Sleep(250);
                }
            });

            t1.SetApartmentState(ApartmentState.STA);
            t1.Start();
            Thread t2 = new Thread(delegate()
            {
                while (!stop)
                {
                    if (commandsQueue.Count != 0)
                    {
                        string s = commandsQueue.Peek();
                        telnetClient.write(s);
                        commandsQueue.Dequeue();
                    }
                }
            });

            t2.SetApartmentState(ApartmentState.STA);
            t2.Start();
        }