Esempio n. 1
0
        public IGPSSatelliteVehicle[] GetSatelliteData()
        {
            GPSSatDataType[] iQueSatData = new GPSSatDataType[maxSatellites];
            ushort           err         = GPSGetSatellites(iQueSatData);

            if (err == 0)
            {
                // Work out how many satellites are in view.
                int numSatellitesInView = 0;
                for (int i = 0; i < maxSatellites; i++)
                {
                    if (iQueSatData[i].svid != 255)
                    {
                        numSatellitesInView++;
                    }
                }

                // Construct the satellite data class.
                IGPSSatelliteVehicle[] satelliteVehicles = new IGPSSatelliteVehicle[numSatellitesInView];
                int index = 0;
                for (int i = 0; i < maxSatellites; i++)
                {
                    if (iQueSatData[i].svid != 255)
                    {
                        GPSSatelliteVehicle vehicle = new GPSSatelliteVehicle();
                        vehicle.PRN                        = iQueSatData[i].svid;
                        vehicle.AziumthDegrees             = (int)Math.Round(iQueSatData[i].azimuth * 180 / Math.PI);
                        vehicle.ElevationDegrees           = (int)Math.Round(iQueSatData[i].elevation * 180 / Math.PI);
                        vehicle.SNRdB                      = iQueSatData[i].snr / 100;
                        vehicle.HaveEphemerisData          = (iQueSatData[i].status & gpsSatEphMask) > 0;
                        vehicle.HaveDifferentialCorrection = (iQueSatData[i].status & gpsSatDifMask) > 0;
                        vehicle.UsedInFix                  = (iQueSatData[i].status & gpsSatUsedMask) > 0;
                        vehicle.IsRising                   = (iQueSatData[i].status & gpsSatRisingMask) > 0;
                        satelliteVehicles[index++]         = vehicle;
                    }
                }

                // Return the result.
                return(satelliteVehicles);
            }
            else
            {
                return(null);
            }
        }
        private byte[] BuildSatDataPacket(IGPSSatelliteVehicle[] satelliteVehicles)
        {
            Array.Sort(satelliteVehicles);
            ArrayList members = new ArrayList();

            for (int i = 0; i < 12; i++)
            {
                if (i < satelliteVehicles.Length)
                {
                    IGPSSatelliteVehicle vehicle = satelliteVehicles[i];

                    // Copy the satellite data across.
                    byte status = vehicle.HaveEphemerisData ? satEphMask : (byte)0;
                    status |= vehicle.HaveDifferentialCorrection ? satDifMask : (byte)0;
                    status |= vehicle.UsedInFix ? satUsedMask : (byte)0;
                    status |= vehicle.IsRising ? satRisingMask : (byte)0;

                    // Adjust the SNR so that the supplied satellite SNR window maps
                    // to the Garmin visible SNR range.
                    int snr = (int)Math.Round((double)(vehicle.SNRdB - SatelliteSNRdBMin) /
                                              (SatelliteSNRdBMax - SatelliteSNRdBMin) *
                                              (GarminSNRRangeMax - GarminSNRRangeMin)) +
                              GarminSNRRangeMin;
                    snr = snr < 0 ? 0 : snr;

                    members.Add((byte)vehicle.PRN);
                    members.Add((UInt16)(snr * 100));
                    members.Add((byte)vehicle.ElevationDegrees);
                    members.Add((UInt16)vehicle.AziumthDegrees);
                    members.Add((byte)status);
                }
                else
                {
                    // Use empty values.
                    members.Add((byte)255);
                    members.Add((UInt16)0);
                    members.Add((byte)0);
                    members.Add((UInt16)0);
                    members.Add((byte)0);
                }
            }

            return(BuildPacketFromArray((byte)PacketId.SAT_DATA, members.ToArray()));
        }
Esempio n. 3
0
		private void Extension_NewGPSSatelliteData(IExtension sender, IGPSSatelliteVehicle[] vehicles)
		{
			if (newSatelliteVehiclesMutex.WaitOne())
			{
				newSatelliteVehicles = vehicles;
				newSatelliteVehiclesMutex.ReleaseMutex();
				PostMessage(WM_GPSSAT);
			}
		}
		public void ProcessGPSSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
		{
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);

			if (engineMutex.WaitOne())
			{
				try
				{
					if (engine != null)
					{
						engine.NewSatelliteData(satelliteVehicles);
						outputThread.ThreadEvent.Set();
					}
				}
				finally
				{
					engineMutex.ReleaseMutex();
				}
			}
			else
			{
				application.LogMessage(this, "Failed to lock protocol engine mutex");
			}
		}
Esempio n. 5
0
		public IGPSSatelliteVehicle[] GetSatelliteData()
		{
			GPSSatDataType[] iQueSatData = new GPSSatDataType[maxSatellites];
			ushort err = GPSGetSatellites(iQueSatData);
			if (err == 0)
			{
				// Work out how many satellites are in view.
				int numSatellitesInView = 0;
				for (int i = 0; i < maxSatellites; i++)
					if (iQueSatData[i].svid != 255)
						numSatellitesInView++;

				// Construct the satellite data class.
				IGPSSatelliteVehicle[] satelliteVehicles = new IGPSSatelliteVehicle[numSatellitesInView];
				int index = 0;
				for (int i = 0; i < maxSatellites; i++)
				{
					if (iQueSatData[i].svid != 255)
					{
						GPSSatelliteVehicle vehicle = new GPSSatelliteVehicle();
						vehicle.PRN = iQueSatData[i].svid;
						vehicle.AziumthDegrees = (int)Math.Round(iQueSatData[i].azimuth * 180 / Math.PI);
						vehicle.ElevationDegrees = (int)Math.Round(iQueSatData[i].elevation * 180 / Math.PI);
						vehicle.SNRdB = iQueSatData[i].snr / 100;
						vehicle.HaveEphemerisData = (iQueSatData[i].status & gpsSatEphMask) > 0;
						vehicle.HaveDifferentialCorrection = (iQueSatData[i].status & gpsSatDifMask) > 0;
						vehicle.UsedInFix = (iQueSatData[i].status & gpsSatUsedMask) > 0;
						vehicle.IsRising = (iQueSatData[i].status & gpsSatRisingMask) > 0;
						satelliteVehicles[index++] = vehicle;
					}
				}

				// Return the result.
				return satelliteVehicles;
			}
			else
			{
				return null;
			}
		}
Esempio n. 6
0
		public void ProcessGPSSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
		{
		}
		public void ProcessGPSSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
		{
			// TODO:  Add iQueM5InputExtension.ProcessGPSSatelliteData implementation
		}
		private byte[] BuildSatDataPacket(IGPSSatelliteVehicle[] satelliteVehicles)
		{
			Array.Sort(satelliteVehicles);
			ArrayList members = new ArrayList();
			for (int i = 0; i < 12; i++)
			{
				if (i < satelliteVehicles.Length) 
				{
					IGPSSatelliteVehicle vehicle = satelliteVehicles[i];

					// Copy the satellite data across.
					byte status = vehicle.HaveEphemerisData ? satEphMask : (byte)0;
					status |= vehicle.HaveDifferentialCorrection ? satDifMask : (byte)0;
					status |= vehicle.UsedInFix ? satUsedMask : (byte)0;
					status |= vehicle.IsRising ? satRisingMask : (byte)0;

					// Adjust the SNR so that the supplied satellite SNR window maps
					// to the Garmin visible SNR range.
					int snr = (int)Math.Round((double)(vehicle.SNRdB - SatelliteSNRdBMin) /
						(SatelliteSNRdBMax - SatelliteSNRdBMin) *
						(GarminSNRRangeMax - GarminSNRRangeMin)) +
						GarminSNRRangeMin;
					snr = snr < 0 ? 0 : snr;

					members.Add((byte)vehicle.PRN);
					members.Add((UInt16)(snr * 100));
					members.Add((byte)vehicle.ElevationDegrees);
					members.Add((UInt16)vehicle.AziumthDegrees);
					members.Add((byte)status);
				} 
				else
				{
					// Use empty values.
					members.Add((byte)255);
					members.Add((UInt16)0);
					members.Add((byte)0);
					members.Add((UInt16)0);
					members.Add((byte)0);
				}
			}

			return BuildPacketFromArray((byte)PacketId.SAT_DATA, members.ToArray());
		}
		public void NewSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
		{
			// Build an send a satellite data packet if required.
			if (sendSatData)
			{
				// Build the packet.
				satDataPacket = BuildSatDataPacket(satelliteVehicles);

				// If we are idle, send the packet immediately. Otherwise save it for later.
				if (protocolState == ProtocolState.Idle) 
				{
					SendPacket(satDataPacket);
					satDataPacket = null;
				}
			}
		}
Esempio n. 10
0
        private void Redraw()
        {
            // Create some pens and brushes for later use.
            Pen        blackPen   = new Pen(Color.Black);
            SolidBrush blackBrush = new SolidBrush(Color.Black);
            SolidBrush greyBrush  = new SolidBrush(Color.Gray);
            SolidBrush whiteBrush = new SolidBrush(Color.White);
            SolidBrush greenBrush = new SolidBrush(Color.Green);

            // Create a bitmap for double-buffering purposes.
            Bitmap   bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
            Graphics g      = Graphics.FromImage(bitmap);

            g.FillRectangle(whiteBrush, new Rectangle(0, 0, bitmap.Width, bitmap.Height));

            // Draw the circles.
            g.DrawEllipse(blackPen, satelliteOuterCircleRect);
            g.DrawEllipse(blackPen, satelliteMiddleCircleRect);
            g.FillEllipse(blackBrush, satelliteInnerCircleRect);

            // Draw the cardinal points.
            Font font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);

            DrawText(g, "N", font, blackBrush, satelliteCircleOrigin.X, satelliteOuterCircleRect.Top,
                     HorizontalAlignment.Centre, VerticalAlignment.Top);
            DrawText(g, "S", font, blackBrush, satelliteCircleOrigin.X, satelliteOuterCircleRect.Bottom,
                     HorizontalAlignment.Centre, VerticalAlignment.Bottom);
            DrawText(g, "W", font, blackBrush, satelliteOuterCircleRect.Left + 3, satelliteCircleOrigin.Y,
                     HorizontalAlignment.Left, VerticalAlignment.Centre);
            DrawText(g, "E", font, blackBrush, satelliteOuterCircleRect.Right - 1, satelliteCircleOrigin.Y,
                     HorizontalAlignment.Right, VerticalAlignment.Centre);

            // Draw the signal strength grid.
            for (int snr = (int)sigGraphMin; snr <= sigGraphMax; snr += 10)
            {
                int y = sigGraphRect.Bottom - (int)Math.Round((snr - sigGraphMin) * sigGraphMultiplier);
                g.DrawLine(blackPen, sigGraphRect.Left, y, sigGraphRect.Right, y);
            }

            if (vehicles != null)
            {
                // Draw the satellite vehicle numbers on the azimuth/elevation grid.
                font = new Font(FontFamily.GenericSansSerif, satellitePosFontSize, FontStyle.Bold);
                for (int i = 0; i < vehicles.Length; i++)
                {
                    IGPSSatelliteVehicle vehicle = vehicles[i];
                    double radius = (double)(90 - vehicle.ElevationDegrees) / 90 * satelliteOuterCircleRadius;
                    double angle  = (double)vehicle.AziumthDegrees / 180 * Math.PI;
                    DrawText(g, vehicle.PRN.ToString(), font,
                             vehicle.UsedInFix ? greenBrush : greyBrush,
                             satelliteCircleOrigin.X + radius * Math.Sin(angle),
                             satelliteCircleOrigin.Y - radius * Math.Cos(angle),
                             HorizontalAlignment.Centre, VerticalAlignment.Centre);
                }

                // Draw the signal strength graph bars and labels.
                font = new Font(FontFamily.GenericSansSerif, sigGraphFontSize, FontStyle.Bold);
                for (int i = 0; (i < vehicles.Length) && (i < maxSatellites); i++)
                {
                    IGPSSatelliteVehicle vehicle = vehicles[i];
                    DrawText(g, vehicle.PRN.ToString(), font, blackBrush, sigHorizOffsets[i],
                             sigGraphRect.Bottom, HorizontalAlignment.Centre, VerticalAlignment.Top);

                    int y = sigGraphRect.Bottom - (int)Math.Round((vehicle.SNRdB - sigGraphMin) * sigGraphMultiplier);
                    if (y < sigGraphRect.Top)
                    {
                        y = sigGraphRect.Top;
                    }
                    if (y > sigGraphRect.Bottom)
                    {
                        y = sigGraphRect.Bottom;
                    }

                    Rectangle bar = new Rectangle(sigHorizOffsets[i] - 4, y, 6, sigGraphRect.Bottom - y);
                    g.FillRectangle(vehicle.UsedInFix ? greenBrush : greyBrush, bar);
                    g.DrawRectangle(blackPen, bar);
                }
            }

            // Update the display with the new bitmap.
            pictureBox.Image = bitmap;
        }
		public void ProcessGPSSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
		{
			// Not used in a provider.
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);
		}