예제 #1
0
        public bool Parse(byte[] bytes)
        {
            string msg = Encoding.Default.GetString(bytes);

            char[] End = "\r\n".ToCharArray();
            if (GPS.Parse(msg.TrimEnd(End)))
            {
                GPSStatus = GPS.Status;
                var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                GPSSecond = (int)GPS.UTCTime.Subtract(epoch).TotalSeconds;
                //GPSSecond = 1470986158 + count;
                //count = count + 1;
                GPSMicSecond = GPS.UTCTime.Subtract(epoch).Milliseconds;;
                if (GPS.Status == 1 || GPS.Status == 2)
                {
                    Long     = GPS.Longitude;
                    Lat      = GPS.Latitude;
                    Height   = GPS.Height;
                    Velocity = GPS.Speed;
                    Heading  = GPS.Heading;
                    SatNum   = GPS.SatNum;
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
 private void ParseGPSString(string strcmd)
 {
     if (GPS.Parse(strcmd))
     {
         Status = "定位数据无效";
     }
     else
     {
         Status = "接收定位数据中……";
     }
 }
예제 #3
0
 public static GpsInfo ParseGps(byte[] buffer)
 {
     if (GPS.Parse(Encoding.Default.GetString(buffer)))
     {
         GpsInfo info = new GpsInfo()
         {
             UTCTime   = GPS.UTCTime,
             Latitude  = GPS.Latitude,
             Longitude = GPS.Longitude
         };
         return(info);
     }
     return(null);
 }