예제 #1
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);
                }
            }
        }
예제 #2
0
 public virtual void VisitReturnInstruction(ReturnIns @return) => Default(@return);