Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a GpsHandler for communication with GPS receiver.
        /// The GpsHandler is used for communication with the GPS device and process information from the GPS revice.
        /// </summary>
        /// <param name="Parent">Parent form which callbacks should be directed to.</param>
        /// <example>
        /// The following example demonstrates how to create an GpsHandler instance that reacts to GPS position events.
        /// <code>
        /// [C#]
        /// public class Form1 : System.Windows.Forms.Form
        /// {
        ///     public static GPSHandler GPS;
        ///     public Form1()
        ///     {
        ///     InitializeComponent();
        ///     //Initialize GPS handler
        ///     GPS = new GPSHandler(this);
        ///     //Hook up GPS data events to a handler
        ///     GPS.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler);
        /// }
        ///
        /// public void ExitApp()
        /// {
        ///     GPS.Dispose();  //Closes serial port and cleans up
        ///     Application.Exit();
        /// }
        ///
        /// private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        /// {
        ///     switch (e.TypeOfEvent)
        ///     {
        ///         case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data
        ///             if(GPS.HasGPSFix) //Is a GPS fix available?
        ///             {
        ///                 lbPosition.Text = GPS.RMC.Longitude.ToString() + "," + GPS.RMC.Latitude.ToString();
        ///                 lbHeading.Text = GPS.RMC.Course.ToString();
        ///                 lbSpeed.Text = GPS.RMC.Speed.ToString() + " mph";
        ///                 lbTimeOfFix.Text = GPS.RMC.TimeOfFix + " - " + GPS.RMC.DateOfFix;
        ///             }
        ///             else
        ///             {
        ///                 lbPosition.Text = "No fix";
        ///                 lbHeading.Text = "N/A";
        ///                 lbSpeed.Text = "N/A";
        ///                 lbTimeOfFix.Text = "N/A";
        ///             }
        ///             break;
        ///     }
        /// }
        ///
        /// private void btnStartGPS_Click(object sender, System.EventArgs e)
        /// {
        ///     if(!GPS.IsPortOpen)
        ///     {
        ///         try
        ///         {
        ///             //Open serial port 1 at 4800baud
        ///             GPS.Start("COM1",4800);
        ///         }
        ///         catch(System.Exception ex)
        ///         {
        ///             MessageBox.Show("An error occured when trying to open port: " + ex.Message);
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        public GPSHandler()
        {
            disposed         = false;
            this._NewGPSFix += new NewGPSFixHandler(this.GPSEventHandler);

            //Link event from GPS receiver to process data function
            GpsPort.NewGPSData += new SharpGps.SerialPort.NewGPSDataHandler(this.GPSDataEventHandler);
            this.GPRMC          = new SharpGps.NMEA.GPRMC();
            this.GPGGA          = new SharpGps.NMEA.GPGGA();
            this.GPGSA          = new SharpGps.NMEA.GPGSA();
            this.GPRMC          = new SharpGps.NMEA.GPRMC();
            this.PGRME          = new SharpGps.NMEA.GPRME();
            this.GPGSV          = new SharpGps.NMEA.GPGSV();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a GpsHandler for communication with GPS receiver.
        /// The GpsHandler is used for communication with the GPS device and process information from the GPS revice.
        /// </summary>
        /// <param name="Parent">Parent form which callbacks should be directed to.</param>
        /// <example>
        /// The following example demonstrates how to create an GpsHandler instance that reacts to GPS position events.
        /// <code>
        /// [C#]
        /// public class Form1 : System.Windows.Forms.Form
        /// {
        ///     public static GPSHandler GPS;
        ///     public Form1()
        ///     {
        ///     InitializeComponent();
        ///     //Initialize GPS handler
        ///     GPS = new GPSHandler(this);
        ///     //Hook up GPS data events to a handler
        ///     GPS.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler);
        /// }
        ///
        /// public void ExitApp()
        /// {
        ///     GPS.Dispose();  //Closes serial port and cleans up
        ///     Application.Exit();
        /// }
        ///
        /// private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        /// {
        ///     switch (e.TypeOfEvent)
        ///     {
        ///         case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data
        ///             if(GPS.HasGPSFix) //Is a GPS fix available?
        ///             {
        ///                 lbPosition.Text = GPS.RMC.Longitude.ToString() + "," + GPS.RMC.Latitude.ToString();
        ///                 lbHeading.Text = GPS.RMC.Course.ToString();
        ///                 lbSpeed.Text = GPS.RMC.Speed.ToString() + " mph";
        ///                 lbTimeOfFix.Text = GPS.RMC.TimeOfFix + " - " + GPS.RMC.DateOfFix;
        ///             }
        ///             else
        ///             {
        ///                 lbPosition.Text = "No fix";
        ///                 lbHeading.Text = "N/A";
        ///                 lbSpeed.Text = "N/A";
        ///                 lbTimeOfFix.Text = "N/A";
        ///             }
        ///             break;
        ///     }
        /// }
        ///
        /// private void btnStartGPS_Click(object sender, System.EventArgs e)
        /// {
        ///     if(!GPS.IsPortOpen)
        ///     {
        ///         try
        ///         {
        ///             //Open serial port 1 at 4800baud
        ///             GPS.Start("COM1",4800);
        ///         }
        ///         catch(System.Exception ex)
        ///         {
        ///             MessageBox.Show("An error occured when trying to open port: " + ex.Message);
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        public GPSHandler(System.Windows.Forms.Control Parent)
        {
            _Parent          = Parent;
            disposed         = false;
            this._NewGPSFix += new NewGPSFixHandler(this.GPSEventHandler);

            //Link event from GPS receiver to process data function
            GpsPort.NewGPSData += new SharpGps.SerialPort.NewGPSDataHandler(this.GPSDataEventHandler);
            this.GPRMC          = new SharpGps.NMEA.GPRMC();
            this.GPGGA          = new SharpGps.NMEA.GPGGA();
            this.GPGSA          = new SharpGps.NMEA.GPGSA();
            this.GPRMC          = new SharpGps.NMEA.GPRMC();
            this.PGRME          = new SharpGps.NMEA.GPRME();
            this.GPGSV          = new SharpGps.NMEA.GPGSV();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a GpsHandler for communication with GPS receiver.
        /// The GpsHandler is used for communication with the GPS device and process information from the GPS revice.
        /// </summary>
        /// <param name="Parent">Parent form which callbacks should be directed to.</param>
        /// <example>
        /// The following example demonstrates how to create an GpsHandler instance that reacts to GPS position events.
        /// <code>
        /// [C#]
        /// public class Form1 : System.Windows.Forms.Form
        /// {
        /// 	public static GPSHandler GPS;
        /// 	public Form1()
        /// 	{
        /// 	InitializeComponent();
        /// 	//Initialize GPS handler
        /// 	GPS = new GPSHandler(this); 
        /// 	//Hook up GPS data events to a handler
        /// 	GPS.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler);
        /// }
        /// 
        /// public void ExitApp()
        /// {
        /// 	GPS.Dispose();  //Closes serial port and cleans up
        /// 	Application.Exit();
        /// }
        /// 
        /// private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        /// {
        /// 	switch (e.TypeOfEvent)
        /// 	{
        /// 		case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data
        /// 			if(GPS.HasGPSFix) //Is a GPS fix available?
        /// 			{
        /// 				lbPosition.Text = GPS.RMC.Longitude.ToString() + "," + GPS.RMC.Latitude.ToString();
        /// 				lbHeading.Text = GPS.RMC.Course.ToString();
        /// 				lbSpeed.Text = GPS.RMC.Speed.ToString() + " mph";
        /// 				lbTimeOfFix.Text = GPS.RMC.TimeOfFix + " - " + GPS.RMC.DateOfFix;
        /// 			}
        /// 			else
        /// 			{
        /// 				lbPosition.Text = "No fix";
        /// 				lbHeading.Text = "N/A";
        /// 				lbSpeed.Text = "N/A";
        /// 				lbTimeOfFix.Text = "N/A";
        /// 			}
        /// 			break;
        /// 	}
        /// }
        /// 
        /// private void btnStartGPS_Click(object sender, System.EventArgs e)
        /// {
        /// 	if(!GPS.IsPortOpen) 
        /// 	{
        /// 		try
        /// 		{
        /// 			//Open serial port 1 at 4800baud               
        /// 			GPS.Start("COM1",4800);
        /// 		}
        /// 		catch(System.Exception ex) 
        /// 		{
        /// 			MessageBox.Show("An error occured when trying to open port: " + ex.Message);
        /// 		}
        /// 	}
        /// }
        /// </code>
        /// </example>
        public GPSHandler(System.Windows.Forms.Control Parent)
        {
            _Parent = Parent;
            disposed = false;
            this._NewGPSFix += new NewGPSFixHandler(this.GPSEventHandler);

            //Link event from GPS receiver to process data function
            GpsPort.NewGPSData += new SharpGps.SerialPort.NewGPSDataHandler(this.GPSDataEventHandler);
            this.GPRMC = new SharpGps.NMEA.GPRMC();
            this.GPGGA = new SharpGps.NMEA.GPGGA();
            this.GPGSA = new SharpGps.NMEA.GPGSA();
            this.GPRMC = new SharpGps.NMEA.GPRMC();
            this.PGRME = new SharpGps.NMEA.GPRME();
            this.GPGSV = new SharpGps.NMEA.GPGSV();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a GpsHandler for communication with GPS receiver.
        /// The GpsHandler is used for communication with the GPS device and process information from the GPS revice.
        /// </summary>
        /// <param name="Parent">Parent form which callbacks should be directed to.</param>
        /// <example>
        /// The following example demonstrates how to create an GpsHandler instance that reacts to GPS position events.
        /// <code>
        /// [C#]
        /// public class Form1 : System.Windows.Forms.Form
        /// {
        /// 	public static GPSHandler GPS;
        /// 	public Form1()
        /// 	{
        /// 	InitializeComponent();
        /// 	//Initialize GPS handler
        /// 	GPS = new GPSHandler(this); 
        /// 	//Hook up GPS data events to a handler
        /// 	GPS.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler);
        /// }
        /// 
        /// public void ExitApp()
        /// {
        /// 	GPS.Dispose();  //Closes serial port and cleans up
        /// 	Application.Exit();
        /// }
        /// 
        /// private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        /// {
        /// 	switch (e.TypeOfEvent)
        /// 	{
        /// 		case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data
        /// 			if(GPS.HasGPSFix) //Is a GPS fix available?
        /// 			{
        /// 				lbPosition.Text = GPS.RMC.Longitude.ToString() + "," + GPS.RMC.Latitude.ToString();
        /// 				lbHeading.Text = GPS.RMC.Course.ToString();
        /// 				lbSpeed.Text = GPS.RMC.Speed.ToString() + " mph";
        /// 				lbTimeOfFix.Text = GPS.RMC.TimeOfFix + " - " + GPS.RMC.DateOfFix;
        /// 			}
        /// 			else
        /// 			{
        /// 				lbPosition.Text = "No fix";
        /// 				lbHeading.Text = "N/A";
        /// 				lbSpeed.Text = "N/A";
        /// 				lbTimeOfFix.Text = "N/A";
        /// 			}
        /// 			break;
        /// 	}
        /// }
        /// 
        /// private void btnStartGPS_Click(object sender, System.EventArgs e)
        /// {
        /// 	if(!GPS.IsPortOpen) 
        /// 	{
        /// 		try
        /// 		{
        /// 			//Open serial port 1 at 4800baud               
        /// 			GPS.Start("COM1",4800);
        /// 		}
        /// 		catch(System.Exception ex) 
        /// 		{
        /// 			MessageBox.Show("An error occured when trying to open port: " + ex.Message);
        /// 		}
        /// 	}
        /// }
        /// </code>
        /// </example>
        public GPSHandler()
        {
            disposed = false;
            this._NewGPSFix += new NewGPSFixHandler(this.GPSEventHandler);

            //Link event from GPS receiver to process data function
            GpsPort.NewGPSData += new SharpGps.SerialPort.NewGPSDataHandler(this.GPSDataEventHandler);
            this.GPRMC = new SharpGps.NMEA.GPRMC();
            this.GPGGA = new SharpGps.NMEA.GPGGA();
            this.GPGSA = new SharpGps.NMEA.GPGSA();
            this.GPRMC = new SharpGps.NMEA.GPRMC();
            this.PGRME = new SharpGps.NMEA.GPRME();
            this.GPGSV = new SharpGps.NMEA.GPGSV();
        }