Example #1
0
        public void Reset()
        {
            readBuffer = "";

            partialFix             = null;
            partialFixSentenceType = NMEASentenceType.Unknown;
            haveGGA            = false;
            haveRMC            = false;
            lastGGATimestamp   = new DateTime(0);
            lastRMCTimestamp   = new DateTime(0);
            fixTriggerSentence = NMEASentenceType.Unknown;

            savedFix           = null;
            m_MostRecentGPSFix = null;

            gsaData = null;

            partialSatelliteVehicles      = null;
            partialSatelliteVehicleIndex  = 0;
            m_MostRecentSatelliteVehicles = null;

            lastGSVMessageNumber = 0;
        }
		private void ProcessGSA(string[] parts)
		{
			// Check that we have the correct number of parts.
			if (parts.Length != 18)
			{
				CallOnLogEvent("Invalid GSA sentence.");
				return;
			}

			// Record the information from the packet in a new object.
			GSAData newGsaData = new GSAData();
			newGsaData.timeReceived = DateTime.Now;

			// Extract the PDOP leaving it set to 0 if this fails.
			if (! parts[15].Equals(String.Empty))
			{
				double temp = 0;
				if (ParseDouble(parts[15], ref temp))
					newGsaData.PDOP = temp;
			}

			// Extract the HDOP leaving it set to 0 if this fails.
			if (! parts[16].Equals(String.Empty)) 
			{
				double temp = 0;
				if (ParseDouble(parts[16], ref temp))
					newGsaData.HDOP = temp;
			}

			// Extract the VDOP leaving it set to 0 if this fails.
			if (! parts[17].Equals(String.Empty))
			{
				double temp = 0;
				if (ParseDouble(parts[17], ref temp))
					newGsaData.VDOP = temp;
			}

			// Determine the fix type.
			newGsaData.fixType = GPSFixTypes.Invalid;
			switch (parts[2]) 
			{
				case "2":
					newGsaData.fixType = GPSFixTypes.Fix2D;
					break;
				case "3":
					newGsaData.fixType = GPSFixTypes.Fix3D;
					break;
			}

			// Count the number of satellites in the fix.
			int numSatellitesInFix = 0;
			for (int i = 3; i <= 14; i++) 
			{
				if (! parts[i].Equals(String.Empty))
					numSatellitesInFix++;
			}

			// If there were any satellites, record the vehicle IDs.
			newGsaData.satellitesInFix = new int[numSatellitesInFix];
			if (numSatellitesInFix > 0) 
			{
				int offset = 0;
				for (int i = 3; i <= 14; i++) 
				{
					if (! parts[i].Equals(String.Empty)) 
					{
						try 
						{
							newGsaData.satellitesInFix[offset++] = int.Parse(parts[i]);
						}
						catch
						{
							throw new Exception("Invalid satellite vehicle ID: " + parts[i]);
						}
					}
				}
			}
 
			// Make the data available.
			gsaData = newGsaData;
		}
		public void Reset()
		{
			readBuffer = "";

			partialFix = null;
			partialFixSentenceType = NMEASentenceType.Unknown;
			haveGGA = false;
			haveRMC = false;
			lastGGATimestamp = new DateTime(0);
			lastRMCTimestamp = new DateTime(0);
			fixTriggerSentence = NMEASentenceType.Unknown;

			savedFix = null;
			m_MostRecentGPSFix = null;

			gsaData = null;

			partialSatelliteVehicles = null;
			partialSatelliteVehicleIndex = 0;
			m_MostRecentSatelliteVehicles = null;

			lastGSVMessageNumber = 0;
		}
Example #4
0
        private void ProcessGSA(string[] parts)
        {
            // Check that we have the correct number of parts.
            if (parts.Length != 18)
            {
                CallOnLogEvent("Invalid GSA sentence.");
                return;
            }

            // Record the information from the packet in a new object.
            GSAData newGsaData = new GSAData();

            newGsaData.timeReceived = DateTime.Now;

            // Extract the PDOP leaving it set to 0 if this fails.
            if (!parts[15].Equals(String.Empty))
            {
                double temp = 0;
                if (ParseDouble(parts[15], ref temp))
                {
                    newGsaData.PDOP = temp;
                }
            }

            // Extract the HDOP leaving it set to 0 if this fails.
            if (!parts[16].Equals(String.Empty))
            {
                double temp = 0;
                if (ParseDouble(parts[16], ref temp))
                {
                    newGsaData.HDOP = temp;
                }
            }

            // Extract the VDOP leaving it set to 0 if this fails.
            if (!parts[17].Equals(String.Empty))
            {
                double temp = 0;
                if (ParseDouble(parts[17], ref temp))
                {
                    newGsaData.VDOP = temp;
                }
            }

            // Determine the fix type.
            newGsaData.fixType = GPSFixTypes.Invalid;
            switch (parts[2])
            {
            case "2":
                newGsaData.fixType = GPSFixTypes.Fix2D;
                break;

            case "3":
                newGsaData.fixType = GPSFixTypes.Fix3D;
                break;
            }

            // Count the number of satellites in the fix.
            int numSatellitesInFix = 0;

            for (int i = 3; i <= 14; i++)
            {
                if (!parts[i].Equals(String.Empty))
                {
                    numSatellitesInFix++;
                }
            }

            // If there were any satellites, record the vehicle IDs.
            newGsaData.satellitesInFix = new int[numSatellitesInFix];
            if (numSatellitesInFix > 0)
            {
                int offset = 0;
                for (int i = 3; i <= 14; i++)
                {
                    if (!parts[i].Equals(String.Empty))
                    {
                        try
                        {
                            newGsaData.satellitesInFix[offset++] = int.Parse(parts[i]);
                        }
                        catch
                        {
                            throw new Exception("Invalid satellite vehicle ID: " + parts[i]);
                        }
                    }
                }
            }

            // Make the data available.
            gsaData = newGsaData;
        }