Exemple #1
0
 public HDTMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, double heading, bool isValid)
 {
     SourceID = sourceID;
     TalkerID = talkerID;
     Heading  = heading;
     IsValid  = isValid;
 }
Exemple #2
0
 public GLLEventArgs(TalkerIdentifiers talkerID, double lat, double lon, DateTime timeFix)
 {
     TalkerID  = talkerID;
     Latitude  = lat;
     Longitude = lon;
     TimeFix   = timeFix;
 }
Exemple #3
0
        private void OnGLLSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GLLSentenceReceived != null)
            {
                double   latitude  = doubleNullChecker(parameters[0]);
                double   longitude = doubleNullChecker(parameters[2]);
                DateTime tStamp    = (DateTime)parameters[4];
                bool     isValid   = (parameters[5].ToString() == "Valid") &&
                                     (!double.IsNaN(latitude)) && latitude.IsValidLatDeg() &&
                                     (!double.IsNaN(longitude)) && longitude.IsValidLonDeg();

                if (isValid)
                {
                    if (parameters[1].ToString() == "S")
                    {
                        latitude = -latitude;
                    }
                    if (parameters[3].ToString() == "W")
                    {
                        longitude = -longitude;
                    }
                }

                GLLSentenceReceived.Rise(this, new GLLMessageEventArgs(sourceID, talkerID, latitude, longitude, tStamp, isValid));
            }
        }
Exemple #4
0
 public MTWMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, double temp, bool isValid)
 {
     SourceID             = sourceID;
     TalkerID             = talkerID;
     MeanWaterTemperature = temp;
     IsValid = isValid;
 }
Exemple #5
0
        private void OnGSASentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GSASentenceReceived != null)
            {
                string fixSelection = parameters[0].ToString();
                string fixType      = parameters[1].ToString();

                List <int> satIDs = new List <int>();

                for (int i = 2; i < 14; i++)
                {
                    int tPRN = intNullChecker(parameters[i]);
                    if (tPRN >= 0)
                    {
                        satIDs.Add(tPRN);
                    }
                }

                double PDOP = doubleNullChecker(parameters[14]);
                double HDOP = doubleNullChecker(parameters[15]);
                double VDOP = doubleNullChecker(parameters[16]);

                bool isValid = (satIDs.Count > 0) && (!double.IsNaN(PDOP)) && (!double.IsNaN(HDOP)) && (!double.IsNaN(VDOP));

                GSASentenceReceived.Rise(this, new GSAMessageEventArgs(sourceID, talkerID, fixSelection, fixType, satIDs, PDOP, HDOP, VDOP, isValid));
            }
        }
Exemple #6
0
        private void ProcessGLL(TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GLLEvent != null)
            {
                try
                {
                    if (parameters[5].ToString() != "Invalid")
                    {
                        var timeFix = (DateTime)parameters[4];

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

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

                        GLLEvent(this, new GLLEventArgs(talkerID, lat, lon, timeFix));
                    }
                }
                catch
                {
                    //
                }
            }
        }
Exemple #7
0
 public VTGEventArgs(TalkerIdentifiers talkerID, double trackTrue, double trackMagnetic, double speedKmh)
 {
     TalkerID      = talkerID;
     TrackTrue     = trackTrue;
     TrackMagnetic = TrackMagnetic;
     SpeedKmh      = speedKmh;
 }
Exemple #8
0
 public HDGMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, double mHeading, double mVariation, bool isValid)
 {
     SourceID          = sourceID;
     TalkerID          = talkerID;
     MagneticHeading   = mHeading;
     MagneticVariation = mVariation;
     IsValid           = isValid;
 }
Exemple #9
0
 public VTGMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, double trackTrue, double trackMagnetic, double speedKmh, bool isValid)
 {
     SourceID      = sourceID;
     TalkerID      = talkerID;
     TrackTrue     = trackTrue;
     TrackMagnetic = TrackMagnetic;
     SpeedKmh      = speedKmh;
     IsValid       = isValid;
 }
Exemple #10
0
 public GLLMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, double latitude, double longitude, DateTime tStamp, bool isValid)
 {
     SourceID  = sourceID;
     TalkerID  = talkerID;
     Latitude  = latitude;
     Longitude = longitude;
     TimeStamp = tStamp;
     IsValid   = isValid;
 }
Exemple #11
0
 private void OnMTWSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
 {
     if (MTWSentenceReceived != null)
     {
         double temp    = doubleNullChecker(parameters[0]);
         bool   isValid = !double.IsNaN(temp);
         MTWSentenceReceived.Rise(this, new MTWMessageEventArgs(sourceID, talkerID, temp, isValid));
     }
 }
Exemple #12
0
 public RMCEventArgs(TalkerIdentifiers talkerID, DateTime timeFix, double lat, double lon, double speedKmh, double trackTrue, double mVar)
 {
     TalkerID          = talkerID;
     TimeFix           = timeFix;
     Latitude          = lat;
     Longitude         = lon;
     SpeedKmh          = speedKmh;
     TrackTrue         = trackTrue;
     MagneticVariation = mVar;
 }
Exemple #13
0
        private void OnHDTSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            // $GPHDT,253.423,T*34
            if (HDTSentenceReceived != null)
            {
                double heading = doubleNullChecker(parameters[0]);
                bool   isValid = !double.IsNaN(heading);

                HDTSentenceReceived.Rise(this, new HDTMessageEventArgs(sourceID, talkerID, heading, isValid));
            }
        }
Exemple #14
0
 public GSAMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, string fSelection, string fType, List <int> satIDs, double pDOP, double hDOP, double vDOP, bool isValid)
 {
     SourceID          = sourceID;
     TalkerID          = talkerID;
     FixSelection      = fSelection;
     FixType           = fType;
     UsedSatellitesIDs = satIDs.ToArray();
     PDOP    = pDOP;
     HDOP    = hDOP;
     VDOP    = vDOP;
     IsValid = isValid;
 }
Exemple #15
0
 public RMCMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, DateTime timeFix, double lat, double lon, double speedKmh, double trackTrue, double mVar, bool isValid)
 {
     SourceID          = sourceID;
     TalkerID          = talkerID;
     TimeFix           = timeFix;
     Latitude          = lat;
     Longitude         = lon;
     SpeedKmh          = speedKmh;
     TrackTrue         = trackTrue;
     MagneticVariation = mVar;
     IsValid           = isValid;
 }
Exemple #16
0
 public GGAEventArgs(TalkerIdentifiers talkerID, string gpsQualityIndicator, DateTime timeFix, double lat, double lon, int satsInUse, double dohp, double antennaAlt, double gsep, int drs)
 {
     TalkerID                     = talkerID;
     GPSQualityIndicator          = gpsQualityIndicator;
     TimeFix                      = timeFix;
     Latitude                     = lat;
     Longitude                    = lon;
     SatellitesInUse              = satsInUse;
     PrecisionHorizontalDilution  = dohp;
     AntennaAltitude              = antennaAlt;
     GeoidalSeparation            = gsep;
     DifferentianReferenceStation = drs;
 }
Exemple #17
0
        private void OnHDGSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (HDGSentenceReceived != null)
            {
                double magneticHeading   = doubleNullChecker(parameters[0]);
                double magneticVariation = doubleNullChecker(parameters[3]);
                if (double.IsNaN(magneticVariation))
                {
                    magneticVariation = 0.0;
                }

                bool isValid = !double.IsNaN(magneticHeading);

                HDGSentenceReceived.Rise(this, new HDGMessageEventArgs(sourceID, talkerID, magneticHeading, magneticVariation, isValid));
            }
        }
Exemple #18
0
 public GGAMessageEventArgs(int sourceID, TalkerIdentifiers talkerID, DateTime timeStamp,
                            double lat, double lon, string gnssQuality, int satNum, double hdop, double orHeight, double gSep, double dgpsAge, int datumID, bool isValid)
 {
     SourceID             = sourceID;
     TalkerID             = talkerID;
     TimeStamp            = timeStamp;
     Latitude             = lat;
     Longitude            = lon;
     GNSSQualityIndicator = gnssQuality;
     SatellitesInUse      = satNum;
     HDOP = hdop;
     OrthometricHeight = orHeight;
     GeiodSeparation   = gSep;
     DGPSRecordAge     = dgpsAge;
     DatumID           = datumID;
     IsValid           = isValid;
 }
Exemple #19
0
        private void OnVTGSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (VTGSentenceReceived != null)
            {
                var trackTrue     = doubleNullChecker(parameters[0]);
                var trackMagnetic = doubleNullChecker(parameters[2]);
                var speedKnots    = doubleNullChecker(parameters[4]);
                var skUnits       = (string)parameters[5];
                var speedKmh      = doubleNullChecker(parameters[6]);
                var sKmUnits      = (string)parameters[7];

                bool isValid = (!double.IsNaN(trackTrue) || !double.IsNaN(trackMagnetic)) &&
                               !double.IsNaN(speedKnots) &&
                               !double.IsNaN(speedKmh);


                VTGSentenceReceived.Rise(this, new VTGMessageEventArgs(sourceID, talkerID, trackTrue, trackMagnetic, speedKmh, isValid));
            }
        }
Exemple #20
0
        private void ProcessGGA(TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GGAEvent != null)
            {
                var gpsQualityIndicator = (string)parameters[5];
                if (gpsQualityIndicator != "Fix not availible")
                {
                    try
                    {
                        var timeFix                     = (DateTime)parameters[0];
                        var lat                         = doubleNullChecker(parameters[1]);
                        var lon                         = doubleNullChecker(parameters[3]);
                        var satellitesInUse             = intNullChecker(parameters[6]);
                        var precisionHorizontalDilution = doubleNullChecker(parameters[7]);
                        var antennaAltitude             = doubleNullChecker(parameters[8]);
                        var antennaAltitudeUnits        = (string)parameters[9];
                        var geoidalSeparation           = doubleNullChecker(parameters[10]);
                        var geoidalSeparationUnits      = (string)parameters[11];

                        var differentialReferenceStation = intNullChecker(parameters[12]);

                        GGAEvent(this,
                                 new GGAEventArgs(
                                     talkerID,
                                     gpsQualityIndicator,
                                     timeFix,
                                     lat,
                                     lon,
                                     satellitesInUse,
                                     precisionHorizontalDilution,
                                     antennaAltitude,
                                     geoidalSeparation,
                                     differentialReferenceStation));
                    }
                    catch
                    {
                        //
                    }
                }
            }
        }
Exemple #21
0
        private void ProcessGSV(TalkerIdentifiers talkerID, object[] paramters)
        {
            if (GSVEvent != null)
            {
                try
                {
                    List <SatelliteData> satellites = new List <SatelliteData>();

                    int totalMessages        = (int)paramters[0];
                    int currentMessageNumber = (int)paramters[1];

                    int satellitesDataItemsCount = (paramters.Length - 3) / 4;

                    for (int i = 0; i < satellitesDataItemsCount; i++)
                    {
                        satellites.Add(
                            new SatelliteData(
                                intNullChecker(paramters[3 + 4 * i]),
                                intNullChecker(paramters[4 + 4 * i]),
                                intNullChecker(paramters[5 + 4 * i]),
                                intNullChecker(paramters[6 + 4 * i])));
                    }

                    if (currentMessageNumber == 1)
                    {
                        fullSatellitesData = new List <SatelliteData>();
                    }

                    fullSatellitesData.AddRange(satellites.ToArray());

                    if (currentMessageNumber == totalMessages)
                    {
                        GSVEvent(this, new GSVEventArgs(talkerID, fullSatellitesData.ToArray()));
                    }
                }
                catch
                {
                    //
                }
            }
        }
Exemple #22
0
        private void OnRMCSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (RMCSentenceReceived != null)
            {
                DateTime tStamp = parameters[0] == null ? DateTime.MinValue : (DateTime)parameters[0];

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

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

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

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

                RMCSentenceReceived.Rise(this, new RMCMessageEventArgs(sourceID, talkerID, dateTime, latitude, longitude, groundSpeed, courseOverGround, magneticVariation, isValid));
            }
        }
Exemple #23
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
                {
                    //
                }
            }
        }
Exemple #24
0
        private void ProcessVTG(TalkerIdentifiers talkerID, object[] parameters)
        {
            if (VTGEvent != null)
            {
                try
                {
                    var trackTrue     = doubleNullChecker(parameters[0]);
                    var trackMagnetic = doubleNullChecker(parameters[2]);
                    var speedKnots    = doubleNullChecker(parameters[4]);
                    var skUnits       = (string)parameters[5];
                    var speedKmh      = doubleNullChecker(parameters[6]);
                    var sKmUnits      = (string)parameters[7];


                    VTGEvent(this, new VTGEventArgs(talkerID, trackTrue, trackMagnetic, speedKmh));
                }
                catch
                {
                    //
                }
            }
        }
Exemple #25
0
        private void OnGSVSentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GSVSentenceReceived != null)
            {
                List <SatelliteData> satellites = new List <SatelliteData>();

                int totalMessages        = (int)parameters[0];
                int currentMessageNumber = (int)parameters[1];

                int satellitesDataItemsCount = (parameters.Length - 3) / 4;

                for (int i = 0; i < satellitesDataItemsCount; i++)
                {
                    satellites.Add(
                        new SatelliteData(
                            intNullChecker(parameters[3 + 4 * i]),
                            intNullChecker(parameters[4 + 4 * i]),
                            intNullChecker(parameters[5 + 4 * i]),
                            intNullChecker(parameters[6 + 4 * i])));
                }

                if (!fullSatellitesData.ContainsKey(sourceID))
                {
                    fullSatellitesData.Add(sourceID, new List <SatelliteData>());
                }

                if (currentMessageNumber == 1)
                {
                    fullSatellitesData[sourceID] = new List <SatelliteData>();
                }

                fullSatellitesData[sourceID].AddRange(satellites.ToArray());

                if (currentMessageNumber == totalMessages)
                {
                    GSVSentenceReceived.Rise(this, new GSVMessageEventArgs(sourceID, talkerID, fullSatellitesData[sourceID].ToArray()));
                }
            }
        }
Exemple #26
0
        //public void ProcessIncoming(int sourceID, string data)
        //{
        //    if (!buffer_.ContainsKey(sourceID))
        //        buffer_.Add(sourceID, new StringBuilder());

        //    buffer_[sourceID].Append(data);
        //    var temp = buffer_[sourceID].ToString();

        //    int lIndex = temp.LastIndexOf(NMEAParser.SentenceEndDelimiter);
        //    if (lIndex >= 0)
        //    {
        //        buffer_[sourceID].Remove(0, lIndex + 2);
        //        if (lIndex + 2 < temp.Length)
        //            temp = temp.Remove(lIndex + 2);

        //        temp = temp.Trim(new char[] { '\0' });

        //        int startIdx = temp.IndexOf(NMEAParser.SentenceStartDelimiter);
        //        if (startIdx > 0)
        //            temp = temp.Remove(0, startIdx);

        //        var lines = temp.Split(NMEAParser.SentenceEndDelimiter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

        //        for (int i = 0; i < lines.Length; i++)
        //                Parse(sourceID, string.Format("{0}{1}", lines[i], NMEAParser.SentenceEndDelimiter));
        //    }

        //    if (buffer_[sourceID].Length >= ushort.MaxValue)
        //        buffer_[sourceID].Remove(0, short.MaxValue);
        //}

        #endregion

        #region Private

        #region Standard sentence parsers

        private void OnGGASentence(int sourceID, TalkerIdentifiers talkerID, object[] parameters)
        {
            if (GGASentenceReceived != null)
            {
                DateTime tStamp = (DateTime)parameters[0];

                double latitude  = doubleNullChecker(parameters[1]);
                double longitude = doubleNullChecker(parameters[3]);

                string gnssQualityIndicator = parameters[5].ToString();
                int    satellitesInUse      = intNullChecker(parameters[6]);
                double HDOP = doubleNullChecker(parameters[7]);
                double orthometricHeight = doubleNullChecker(parameters[8]);
                // orthometric height units parameters[9]
                double geiodSeparation = doubleNullChecker(parameters[10]);
                // geoid separation units parameters[11]
                double DGPSRecordAge = doubleNullChecker(parameters[12]);
                int    datumID       = intNullChecker(parameters[13]);

                bool isValid = (!double.IsNaN(latitude)) && latitude.IsValidLatDeg() &&
                               (!double.IsNaN(longitude)) && longitude.IsValidLonDeg() &&
                               (!double.IsNaN(HDOP));

                if (isValid)
                {
                    if (parameters[2].ToString() == "S")
                    {
                        latitude = -latitude;
                    }
                    if (parameters[4].ToString() == "W")
                    {
                        longitude = -longitude;
                    }
                }

                GGASentenceReceived.Rise(this, new GGAMessageEventArgs(sourceID, talkerID, tStamp,
                                                                       latitude, longitude, gnssQualityIndicator, satellitesInUse, HDOP, orthometricHeight, geiodSeparation, DGPSRecordAge, datumID, isValid));
            }
        }
Exemple #27
0
 public GSVEventArgs(TalkerIdentifiers taklerID, SatelliteData[] satsData)
 {
     TalkerID       = taklerID;
     SatellitesData = satsData;
 }
Exemple #28
0
 public GSVMessageEventArgs(int sourceID, TalkerIdentifiers taklerID, SatelliteData[] satsData)
 {
     SourceID       = sourceID;
     TalkerID       = taklerID;
     SatellitesData = satsData;
 }