예제 #1
0
        public void Set(ecef_position_s p)
        {
            Time   = new DateTime(1970, 1, 1).AddSeconds(p.time.time).ToString("T");
            HDOP   = p.hdop;
            Ns     = p.ns;
            X      = p.x;
            Y      = p.y;
            Z      = p.z;
            Lat    = p.lat.ToString("f10");
            Lon    = p.lon.ToString("f10");
            Height = p.height.ToString("f10");
            switch (p.stat)
            {
            case 0:
                Stat = "定位不可用";
                break;

            case 1:
                Stat = "单点定位";
                break;

            case 2:
                Stat = "差分定位";
                break;

            case 4:
                Stat = "RTK固定解";
                break;

            case 5:
                Stat = "RTK浮点解";
                break;
            }
        }
예제 #2
0
 public Dictionary <long, ecef_position_s> GetStandard()
 {
     lock (Standard)
     {
         if (Standard.Count == 0)
         {
             using (StreamReader reader = File.OpenText(Location))
             {
                 string line;
                 while ((line = reader.ReadLine()) != null)
                 {
                     if (line.Contains("GGA"))
                     {
                         ecef_position_s p = SolveMethod.SolveGGA(line);
                         Standard[p.time.time] = p;
                     }
                 }
             }
         }
         return(Standard);
     }
 }
예제 #3
0
        private void ReadPort()
        {
            List <int> ret      = new List <int>();
            bool       foundGGA = false;

            // TODO CPU使用率
            while (!CanStop)
            {
                try
                {
                    if (Port.IsOpen)
                    {
                        int b = Port.ReadByte();
                        ret.Add(b);
                        if (ret.Count == 6)
                        {
                            if (ret[0] == 0x24 && ret[3] == 0x47 &&
                                ret[4] == 0x47 && ret[5] == 0x41)
                            {
                                foundGGA = true;
                            }
                            else
                            {
                                ret.RemoveAt(0);
                            }
                        }
                        if (foundGGA)
                        {
                            if (ret[ret.Count - 2] == 0x0D && ret[ret.Count - 1] == 0x0A)
                            {
                                string gga = "";
                                for (int i = 0; i < ret.Count; i++)
                                {
                                    gga += (char)ret[i];
                                }
                                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                                {
                                    if (ReturnIns.Count > 50)
                                    {
                                        ReturnIns.RemoveAt(0);
                                    }
                                    ReturnIns.Add(gga);
                                }));
                                ecef_position_s rev = SolveMethod.SolveGGA(gga);
                                Loc.Set(rev);
                                if (Standard.ContainsKey(rev.time.time))
                                {
                                    ecef_position_s sim = Standard[rev.time.time];
                                    enu_position_s  d   = SolveMethod.hcl_ecef2enu(rev, sim);
                                    AddPoint(EastSeries, d.time.time, d.e);
                                    AddPoint(NorthSeries, d.time.time, d.n);
                                    AddPoint(HeiSeries, d.time.time, d.u);
                                    AddPoint(SatSeries, rev.time.time, rev.ns);
                                }
                                ret.Clear();
                                foundGGA = false;
                            }
                        }
                        if (b != -1 && IsLogging)
                        {
                            LogFile.Write((byte)b);
                            LogFile.Flush();
                        }
                    }
                    Thread.Yield();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }