예제 #1
0
파일: NMEA.cs 프로젝트: codecore/Functional
            public bool Parse(string nmea_string)
            {
                bool result = false;

                this.NMEAString = nmea_string;

                string raw_string = nmea_string.Substring(0, nmea_string.IndexOf('*'));

                this.CheckSum = nmea_string.Substring(nmea_string.IndexOf('*') + 1);
                string calculated = NMEAHelper.CalculateChecksum(nmea_string);

                this.Checked = (calculated == this.CheckSum);

                string[] field = raw_string.Split(NMEADelimiter);
                this.Time              = NMEAHelper.parseTime(field[INDEX_TIME]);
                this.Longitude         = NMEAHelper.parseLongitude(field[INDEX_LONGITUDE], field[INDEX_LONGITUDE_HEMISPHERE]);
                this.Latitude          = NMEAHelper.parseLatitude(field[INDEX_LATITUDE], field[INDEX_LATITUDE_HEMISPHERE]);
                this.Fix               = NMEAHelper.parseFixQuality(field[INDEX_FIX_QUALITY]);
                this.Satelites         = NMEAHelper.parseInt(field[INDEX_SATLITES]);
                this.HDOP              = NMEAHelper.parseFloat(field[INDEX_HDOP]);
                this.Altitude          = NMEAHelper.parseAltitude(field[INDEX_ALTITUDE], field[INDEX_ALTITUDE_DIMENSIONS]);
                this.Geoid             = NMEAHelper.parseGeoid(field[INDEX_GEOID], field[INDEX_GEOID_DIMENSIONS]);
                this.DGPS_Elapsed_Time = NMEAHelper.parseFloat(field[INDEX_DGPS_UPDATE]);
                this.DGPS_ID           = field[INDEX_DGPS_ID];
                return(result);
            }
예제 #2
0
파일: NMEA.cs 프로젝트: codecore/Functional
            public bool Parse(string nmea_string)
            {
                bool result = false;

                this.NMEAString = nmea_string;

                string raw_string = nmea_string.Substring(0, nmea_string.IndexOf('*'));

                this.CheckSum = nmea_string.Substring(nmea_string.IndexOf('*') + 1);
                string calculated = NMEAHelper.CalculateChecksum(nmea_string);

                this.Checked = (calculated == this.CheckSum);

                string[] field = raw_string.Split(NMEADelimiter);
                this.Time      = NMEAHelper.parseTime(field[INDEX_TIME]);
                this.Valid     = NMEAHelper.parseValid(field[INDEX_VALID]);
                this.Latitude  = NMEAHelper.parseLatitude(field[INDEX_LATITUDE], field[INDEX_LATITUDE_HEMISPHERE]);
                this.Longitude = NMEAHelper.parseLongitude(field[INDEX_LONGITUDE], field[INDEX_LONGITUDE_HEMISPHERE]);

                this.Speed   = NMEAHelper.parseFloat(field[INDEX_SPEED]);
                this.Bearing = NMEAHelper.parseFloat(field[INDEX_BEARING]);
                this.Date    = NMEAHelper.parseDate(field[INDEX_DATE]);

                this.MagneticVariation = NMEAHelper.parseFloat(field[INDEX_MAG_VARI]);
                this.MagneticDeviation = NMEAHelper.parseDeviation(field[INDEX_MAG_DEV]);
                this.Mode = (field.Count() > INDEX_MODE) ? NMEAHelper.parseMode(field[INDEX_MODE]) : ModeIndicator.Data_not_valid;
                return(result);
            }
예제 #3
0
파일: NMEA.cs 프로젝트: codecore/Functional
            public bool Parse(string nmea_string)
            {
                bool result = false;

                this.NMEAString = nmea_string;
                string raw_string = nmea_string.Substring(0, nmea_string.IndexOf('*'));

                this.CheckSum = nmea_string.Substring(nmea_string.IndexOf('*') + 1);
                string calculated = NMEAHelper.CalculateChecksum(nmea_string);

                this.Checked = (calculated == this.CheckSum);

                string[] field = raw_string.Split(NMEADelimiter);
                if (field.Count() >= 9)
                {
                    result = true;
                    if ((String.Empty != (field[TRUE_TRACK])) && (field[T] == "T"))
                    {
                        this.TrueTrackMadeGood = float.Parse(field[TRUE_TRACK]);
                        this.TrueCourseValid   = true;
                    }
                    else
                    {
                        this.TrueCourseValid = false;
                    }
                    if ((String.Empty != (field[MAGNETIC_TRACK])) && (field[M] == "M"))
                    {
                        this.MagneticTrackMadeGood = float.Parse(field[MAGNETIC_TRACK]);
                        this.MagneticCourseValid   = true;
                    }
                    else
                    {
                        this.MagneticCourseValid = false;
                    }

                    if ((String.Empty != (field[KNOTS])) && (field[N] == "N"))
                    {
                        this.Knots      = float.Parse(field[KNOTS]);
                        this.KnotsValid = true;
                    }
                    else
                    {
                        this.KnotsValid = false;
                    }

                    if ((String.Empty != (field[KPH])) && (field[K] == "K"))
                    {
                        this.KilometersPerHour = float.Parse(field[KPH]);
                        this.KPHValid          = true;
                    }
                    else
                    {
                        this.KPHValid = false;
                    }
                }
                return(result);
            }
예제 #4
0
파일: NMEA.cs 프로젝트: codecore/Functional
            public bool Parse(string nmea_string)
            {
                bool result = false;

                this.satelites.Clear();
                this.Count = 0;

                this.NMEAString = nmea_string;

                string raw_string = nmea_string.Substring(0, nmea_string.IndexOf('*'));

                this.CheckSum = nmea_string.Substring(nmea_string.IndexOf('*') + 1);
                string calculated = NMEAHelper.CalculateChecksum(nmea_string);

                this.Checked = (calculated == this.CheckSum);

                string[] field = raw_string.Split(NMEADelimiter);
                this.Selection = NMEAHelper.parseSelection(field[INDEX_SELECTION]);
                this.Fix       = NMEAHelper.parseFixType(field[INDEX_FIXTYPE]);
                bool b = false;

                b          = AddSatelite(this.satelites, field[INDEX_SAT__1]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__2]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__3]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__4]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__5]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__6]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__7]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__8]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT__9]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT_10]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT_11]);
                b          = AddSatelite(this.satelites, field[INDEX_SAT_12]);
                this.Count = this.satelites.Count();
                this.PDOP  = NMEAHelper.parseFloat(field[INDEX_PDOP]);
                this.HDOP  = NMEAHelper.parseFloat(field[INDEX_HDOP]);
                this.VDOP  = NMEAHelper.parseFloat(field[INDEX_VDOP]);


                return(result);
            }
예제 #5
0
파일: NMEA.cs 프로젝트: codecore/Functional
 public bool Parse(string[] nmea_strings)   // requires a set of strings
 {
     this.NMEAStrings = new string[nmea_strings.Count()];
     this.CheckSum    = new string[nmea_strings.Count()];
     this.Checked     = true;
     this.satelites.Clear(); this.Count = 0;
     for (int i = 0; i < nmea_strings.Count(); ++i)
     {
         this.NMEAStrings[i] = nmea_strings[i];
         this.CheckSum[i]    = nmea_strings[i].Substring(nmea_strings[i].IndexOf('*') + 1);
         string calculated = NMEAHelper.CalculateChecksum(nmea_strings[i]);
         this.Checked = this.Checked && (calculated == this.CheckSum[i]);
         string   raw_string = nmea_strings[i].Substring(0, nmea_strings[i].IndexOf('*'));
         string[] field      = raw_string.Split(NMEADelimiter);
         if (field.Count() > 7)
         {
             if (String.Empty != field[PRN_1])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_1], field[ELEVATION_1], field[AZMUTH_1], field[SNR_1]));
                 ++this.Count;
             }
         }
         if (field.Count() > 11)
         {
             if (String.Empty != field[PRN_2])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_2], field[ELEVATION_2], field[AZMUTH_2], field[SNR_2]));
                 ++this.Count;
             }
         }
         if (field.Count() > 15)
         {
             if (String.Empty != field[PRN_3])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_3], field[ELEVATION_3], field[AZMUTH_3], field[SNR_3]));
                 ++this.Count;
             }
         }
         if (field.Count() > 19)
         {
             if (String.Empty != field[PRN_4])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_4], field[ELEVATION_4], field[AZMUTH_4], field[SNR_4]));
                 ++this.Count;
             }
         }
         if (field.Count() > 23)
         {
             if (String.Empty != field[PRN_5])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_5], field[ELEVATION_5], field[AZMUTH_5], field[SNR_5]));
                 ++this.Count;
             }
         }
         if (field.Count() > 27)
         {
             if (String.Empty != field[PRN_6])
             {
                 this.satelites.Add(NMEAHelper.CreateSateleiteView(field[PRN_6], field[ELEVATION_6], field[AZMUTH_6], field[SNR_6]));
                 ++this.Count;
             }
         }
     }
     return(true);
 }