Exemplo n.º 1
0
        public void ProcessGPSFix(IGPSFix fix)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            if (engineMutex.WaitOne())
            {
                try
                {
                    if (engine != null)
                    {
                        engine.NewGPSFix(fix);
                        outputThread.ThreadEvent.Set();
                    }
                }
                finally
                {
                    engineMutex.ReleaseMutex();
                }
            }
            else
            {
                application.LogMessage(this, "Failed to lock protocol engine mutex");
            }
        }
Exemplo n.º 2
0
 public void ProcessGPSFix(IGPSFix fix)
 {
     // Not used in a provider.
     if (disposed)
     {
         throw new ObjectDisposedException(GetType().Name);
     }
 }
        public void NewGPSFix(IGPSFix gpsFix)
        {
            if (sendPVTData)
            {
                // Calculate the fix time in Garmin format.
                const long gpsDelta = 627666624000000000;
                double     gpsDays  = (double)(gpsFix.UTCFixTime.Ticks - gpsDelta) / 864000000000;            // Fractional days since 31/12/1989 00:00:00 UTC
                Int32      wn_days  = (Int32)(gpsDays / 7) * 7;
                double     tow      = (gpsDays - wn_days) * 86400;

                // Determine the Garmin fix type.
                FixTypes fixType = FixTypes.Invalid;
                switch (gpsFix.FixType)
                {
                case GPSFixTypes.Fix2D:
                    fixType = gpsFix.IsDifferential ? FixTypes.Diff2D : FixTypes.Fix2D;
                    break;

                case GPSFixTypes.Fix3D:
                    fixType = gpsFix.IsDifferential ? FixTypes.Diff3D : FixTypes.Fix3D;
                    break;
                }

                // Build the PVT packet.
                pvtPacket = BuildPVTDataPacket((float)gpsFix.AltitudeAboveMSL + (float)gpsFix.MSLAltitudeAboveWGS84,
                                               (float)gpsFix.EPE, (float)gpsFix.EPH, (float)gpsFix.EPV, (Int16)fixType, tow,
                                               gpsFix.LatitudeRadians, gpsFix.LongitudeRadians,
                                               (float)gpsFix.SpeedEast, (float)gpsFix.SpeedNorth, (float)gpsFix.SpeedUp,
                                               -(float)gpsFix.MSLAltitudeAboveWGS84, 0, wn_days);

                // If we are idle, send the packet immediately. Otherwise save it for later.
                if (protocolState == ProtocolState.Idle)
                {
                    SendPacket(pvtPacket);
                    pvtPacket = null;
                }
            }
        }
Exemplo n.º 4
0
        private void in_port_Read(IPort sender, byte[] data)
        {
            engine.ProcessReceivedData(data);
            IGPSFix fix = engine.MostRecentGPSFix;

            IGPSSatelliteVehicle[] vehicles = engine.MostRecentSatelliteData;
            if ((fix != null) && (NewGPSFix != null))
            {
                NewGPSFix(this, fix);
            }
            if ((vehicles != null) && (NewGPSSatelliteData != null))
            {
                NewGPSSatelliteData(this, vehicles);
            }
            if (out_port != null)
            {
                out_port.Write(data);
            }
            if (log_input)
            {
                application.LogMessage(this, Encoding.ASCII.GetString(data, 0, data.Length));
            }
        }
Exemplo n.º 5
0
		private void NewGPSFix()
		{
			IGPSFix fix = null;
			if (newFixMutex.WaitOne())
			{
				fix = newFix;
				newFix = null;
				newFixMutex.ReleaseMutex();
			}
			if (fix != null)
			{
				for (int i = 0; i < activeExtensions.Length; i++)
				{
					try
					{
						activeExtensions[i].Extension.ProcessGPSFix(fix);
					}
					catch (Exception ex)
					{
						((IApplication)this).LogMessage(activeExtensions[i].Extension, ex.Message);
					}
				}
			}
		}
Exemplo n.º 6
0
		private void Extension_NewGPSFix(IExtension sender, IGPSFix fix)
		{
			if (newFixMutex.WaitOne())
			{
				newFix = fix;
				newFixMutex.ReleaseMutex();
				PostMessage(WM_GPSFIX);
			}
		}
		public void ProcessGPSFix(IGPSFix fix)
		{
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);

			if (engineMutex.WaitOne())
			{
				try
				{
					if (engine != null)
					{
						engine.NewGPSFix(fix);
						outputThread.ThreadEvent.Set();
					}
				}
				finally
				{
					engineMutex.ReleaseMutex();
				}
			}
			else
			{
				application.LogMessage(this, "Failed to lock protocol engine mutex");
			}
		}
		public void ProcessGPSFix(IGPSFix fix)
		{
			// TODO:  Add iQueM5InputExtension.ProcessGPSFix implementation
		}
Exemplo n.º 9
0
		public void ProcessGPSFix(IGPSFix fix)
		{
			// Display the fix type.
			string fixTypeText = "";
			switch (fix.FixType) 
			{
				case GPSFixTypes.Invalid:
					fixTypeText = "Invalid";
					break;
				case GPSFixTypes.Fix2D:
					fixTypeText = "2D";
					break;
				case GPSFixTypes.Fix3D:
					fixTypeText = "3D";
					break;
			}
			if (fix.IsDifferential)
				fixTypeText += " Diff";
			labelFixType.Text = fixTypeText;

			// Display the fix time.
			labelDate.Text = fix.UTCFixTime.ToLocalTime().ToShortDateString() + " " +
				fix.UTCFixTime.ToLocalTime().ToLongTimeString();

			// Convert latitude and longitude in degrees to the format ddmm.mmm.
			double displayLat = (int)fix.LatitudeDegrees;
			displayLat = (displayLat + (fix.LatitudeDegrees - displayLat) * 0.6) * 100;
			double displayLon = (int)fix.LongitudeDegrees;
			displayLon = (displayLon + (fix.LongitudeDegrees - displayLon) * 0.6) * 100;

			labelPosition.Text = displayLat.ToString("'N' 00'\u00B0' 00.000\"'\";'S' 00'\u00B0' 00.000\"'\"") +
				(landscapeMode ? "   " : "\n") +
				displayLon.ToString("'E'000'\u00B0' 00.000\"'\";'W'000'\u00B0' 00.000\"'\"");
			labelElevation.Text = fix.AltitudeAboveMSL.ToString("F1") + " m";
			
			// Display the accuracy.
			double accuracy = fix.EPE / 2;
			labelAccuracy.Text = accuracy.ToString("F1") + " m";
			
			// Display the speeds.
			double speed = Math.Sqrt(fix.SpeedEast * fix.SpeedEast +
				fix.SpeedNorth * fix.SpeedNorth);
			labelSpeed.Text = (speed * 3.6).ToString("F1") + " km/h";
			labelVerticalSpeed.Text = fix.SpeedUp.ToString("F1") + " m/s";

			// Display the heading.
			double heading = fix.HeadingDegrees;
			if (heading < 0)
				heading += 360;
			labelHeading.Text = heading.ToString("F0") + "\u00B0";
		}
		public void NewGPSFix(IGPSFix gpsFix)
		{
			if (sendPVTData) 
			{
				// Calculate the fix time in Garmin format.
				const long gpsDelta = 627666624000000000;
				double gpsDays = (double)(gpsFix.UTCFixTime.Ticks - gpsDelta) / 864000000000; // Fractional days since 31/12/1989 00:00:00 UTC
				Int32 wn_days = (Int32)(gpsDays / 7) * 7;
				double tow = (gpsDays - wn_days) * 86400;

				// Determine the Garmin fix type.
				FixTypes fixType = FixTypes.Invalid;
				switch (gpsFix.FixType)
				{
					case GPSFixTypes.Fix2D:
						fixType = gpsFix.IsDifferential ? FixTypes.Diff2D : FixTypes.Fix2D;
						break;
					case GPSFixTypes.Fix3D:
						fixType = gpsFix.IsDifferential ? FixTypes.Diff3D : FixTypes.Fix3D;
						break;
				}

				// Build the PVT packet.
				pvtPacket = BuildPVTDataPacket((float)gpsFix.AltitudeAboveMSL + (float)gpsFix.MSLAltitudeAboveWGS84,
					(float)gpsFix.EPE, (float)gpsFix.EPH, (float)gpsFix.EPV, (Int16)fixType, tow,
					gpsFix.LatitudeRadians, gpsFix.LongitudeRadians,
					(float)gpsFix.SpeedEast, (float)gpsFix.SpeedNorth, (float)gpsFix.SpeedUp,
					-(float)gpsFix.MSLAltitudeAboveWGS84, 0, wn_days);

				// If we are idle, send the packet immediately. Otherwise save it for later.
				if (protocolState == ProtocolState.Idle) 
				{
					SendPacket(pvtPacket);
					pvtPacket = null;
				}
			}
		}
Exemplo n.º 11
0
 public void ProcessGPSFix(IGPSFix fix)
 {
     // TODO:  Add iQueM5InputExtension.ProcessGPSFix implementation
 }
Exemplo n.º 12
0
 public void ProcessGPSFix(IGPSFix fix)
 {
     // Do nothing.
 }
Exemplo n.º 13
0
        public void ProcessGPSFix(IGPSFix fix)
        {
            // Display the fix type.
            string fixTypeText = "";

            switch (fix.FixType)
            {
            case GPSFixTypes.Invalid:
                fixTypeText = "Invalid";
                break;

            case GPSFixTypes.Fix2D:
                fixTypeText = "2D";
                break;

            case GPSFixTypes.Fix3D:
                fixTypeText = "3D";
                break;
            }
            if (fix.IsDifferential)
            {
                fixTypeText += " Diff";
            }
            labelFixType.Text = fixTypeText;

            // Display the fix time.
            labelDate.Text = fix.UTCFixTime.ToLocalTime().ToShortDateString() + " " +
                             fix.UTCFixTime.ToLocalTime().ToLongTimeString();

            // Convert latitude and longitude in degrees to the format ddmm.mmm.
            double displayLat = (int)fix.LatitudeDegrees;

            displayLat = (displayLat + (fix.LatitudeDegrees - displayLat) * 0.6) * 100;
            double displayLon = (int)fix.LongitudeDegrees;

            displayLon = (displayLon + (fix.LongitudeDegrees - displayLon) * 0.6) * 100;

            labelPosition.Text = displayLat.ToString("'N' 00'\u00B0' 00.000\"'\";'S' 00'\u00B0' 00.000\"'\"") +
                                 (landscapeMode ? "   " : "\n") +
                                 displayLon.ToString("'E'000'\u00B0' 00.000\"'\";'W'000'\u00B0' 00.000\"'\"");
            labelElevation.Text = fix.AltitudeAboveMSL.ToString("F1") + " m";

            // Display the accuracy.
            double accuracy = fix.EPE / 2;

            labelAccuracy.Text = accuracy.ToString("F1") + " m";

            // Display the speeds.
            double speed = Math.Sqrt(fix.SpeedEast * fix.SpeedEast +
                                     fix.SpeedNorth * fix.SpeedNorth);

            labelSpeed.Text         = (speed * 3.6).ToString("F1") + " km/h";
            labelVerticalSpeed.Text = fix.SpeedUp.ToString("F1") + " m/s";

            // Display the heading.
            double heading = fix.HeadingDegrees;

            if (heading < 0)
            {
                heading += 360;
            }
            labelHeading.Text = heading.ToString("F0") + "\u00B0";
        }
		public void ProcessGPSFix(IGPSFix fix)
		{
			// Not used in a provider.
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);
		}