Example #1
0
        private void Parse_RMC(object[] parameters)
        {
            DateTime tStamp = (DateTime)parameters[0];

            var latitude          = doubleNullChecker(parameters[2]);
            var longitude         = doubleNullChecker(parameters[4]);
            var groundSpeed       = doubleNullChecker(parameters[6]);
            var courseOverGround  = doubleNullChecker(parameters[7]);
            var dateTime          = (DateTime)parameters[8];
            var magneticVariation = doubleNullChecker(parameters[9]);

            bool isValid = (parameters[1].ToString() != "Invalid") &&
                           (!double.IsNaN(latitude)) &&
                           (!double.IsNaN(longitude)) &&
                           (!double.IsNaN(groundSpeed)) &&
                           (!double.IsNaN(courseOverGround)) &&
                           (parameters[11].ToString() != "N");

            if (isValid)
            {
                dateTime.AddHours(tStamp.Hour);
                dateTime.AddMinutes(tStamp.Minute);
                dateTime.AddSeconds(tStamp.Second);
                dateTime.AddMilliseconds(tStamp.Millisecond);
                groundSpeed = NMEAParser.NM2Km(groundSpeed);

                if (parameters[3].ToString() == "South")
                {
                    latitude = -latitude;
                }
                if (parameters[5].ToString() == "West")
                {
                    longitude = -longitude;
                }


                bLatitude.Value  = latitude;
                bLongitude.Value = longitude;

                GeoPoint newPoint = new GeoPoint();
                newPoint.Latitude  = latitude;
                newPoint.Longitude = longitude;

                bLocation.Add(newPoint);

                InvokeUpdateTrack("BOAT GNSS", latitude, longitude);
                InvokeInvalidatePlot();

                InvokeSetEnabled(mainToolStrip, tracksBtn, true);
            }
        }
Example #2
0
        private void ProcessRMC(TalkerIdentifiers talkerID, object[] parameters)
        {
            if (RMCEvent != null)
            {
                try
                {
                    if (parameters[1].ToString() != "Invalid")
                    {
                        var timeFix = (DateTime)parameters[0];

                        var lat  = (double)parameters[2];
                        var latC = (Cardinals)Enum.Parse(typeof(Cardinals), (string)parameters[3]);
                        if (latC == Cardinals.South)
                        {
                            lat = -lat;
                        }

                        var lon  = (double)parameters[4];
                        var lonC = (Cardinals)Enum.Parse(typeof(Cardinals), (string)parameters[5]);
                        if (lonC == Cardinals.West)
                        {
                            lon = -lon;
                        }

                        var groundSpeed      = (double)parameters[6];
                        var courseOverGround = (double)parameters[7];

                        var dateTime = (DateTime)parameters[8];

                        var magneticVariation = doubleNullChecker(parameters[9]);

                        RMCEvent(this, new RMCEventArgs(talkerID, timeFix, lat, lon, NMEAParser.NM2Km(groundSpeed), courseOverGround, magneticVariation));
                    }
                }
                catch
                {
                    //
                }
            }
        }