Example #1
0
        public Locatoin GetLocation()
        {
            client = new TcpClient();
            client.Connect(ep);
            //client.Connect(ep);
            double        lon, lat;
            StreamWriter  writer;
            StreamReader  reader;
            NetworkStream stream;

            using (stream = client.GetStream())
                using (writer = new StreamWriter(stream))
                    using (reader = new StreamReader(stream)) {
                        writer.Write("get /position/longitude-deg\r\n");
                        writer.Flush();
                        string s = reader.ReadLine();
                        s   = s.Split('=')[1].Split(' ')[1].Split((char)39)[1];
                        lon = double.Parse(s);
                        writer.Write("get /position/latitude-deg\r\n");
                        writer.Flush();
                        s   = reader.ReadLine();
                        lat = double.Parse(s.Split('=')[1].Split(' ')[1].Split((char)39)[1]);
                        stream.Close();
                    }
            //client.Connect(ep);
            //stream.Close();
            Locatoin loc = new Locatoin(lon, lat);

            client.Close();
            return(loc);
        }
Example #2
0
        public Locatoin GetNext()
        {
            switch (state)
            {
            case FactoryState.FROM_FILE:
            {
                return(Read());
            }

            case FactoryState.FROM_SIMULATOR:
            {
                return(simulator.GetLocation());
            }

            case FactoryState.FROM_SIMULATOR_AND_SAVE:
            {
                Locatoin   loc  = simulator.GetLocation();
                FlightInfo info = simulator.GetInfo();
                Write(loc, info);
                return(loc);
            }

            default:
            {
                break;
            }
            }
            return(null);
        }
Example #3
0
 private void Write(Locatoin loc, FlightInfo info)
 {
     writer.WriteLine("{0},{1}", loc, info);
     writer.Flush();
 }