예제 #1
0
파일: GPSHandler.cs 프로젝트: PlumpMath/UAV
        /// <summary>
        /// Private method for parsing the GPGGA NMEA sentence
        /// </summary>
        /// <param name="strGGA">GPGGA sentence</param>
        private void ParseGGA(string strGGA)
        {
            GPGGA = new NMEA.GPGGA(strGGA);
            //fire the event.
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.GPGGA;
            e.Sentence    = strGGA;
            _NewGPSFix(this, e);
        }
예제 #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()
        {
            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();
        }
예제 #3
0
파일: GPSHandler.cs 프로젝트: PlumpMath/UAV
        /// <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();
        }
예제 #4
0
파일: GPSHandler.cs 프로젝트: PlumpMath/UAV
 /// <summary>
 /// Disposes the GpsHandler and if nessesary calls Stop()
 /// </summary>
 public void Dispose()
 {
     if (!disposed)
     {
         Stop();
         GpsPort.Dispose();
         this.GPGGA = null;
         this.GPGLL = null;
         this.GPGSA = null;
         this.GPRMC = null;
         this.PGRME = null;
         GpsPort    = null;
         //this.GPGSV = null;
         disposed = true;
     }
     GC.SuppressFinalize(this);
 }
예제 #5
0
파일: GPSHandler.cs 프로젝트: kevincwq/UAV
 /// <summary>
 /// Private method for parsing the GPGGA NMEA sentence
 /// </summary>
 /// <param name="strGGA">GPGGA sentence</param>
 private void ParseGGA(string strGGA)
 {
     GPGGA = new NMEA.GPGGA(strGGA);
     //fire the event.
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.GPGGA;
     e.Sentence = strGGA;
     _NewGPSFix(this, e);
 }
예제 #6
0
파일: GPSHandler.cs 프로젝트: kevincwq/UAV
 /// <summary>
 /// Disposes the GpsHandler and if nessesary calls Stop()
 /// </summary>
 public void Dispose()
 {
     if (!disposed)
     {
         Stop();
         GpsPort.Dispose();
         this.GPGGA = null;
         this.GPGLL = null;
         this.GPGSA = null;
         this.GPRMC = null;
         this.PGRME = null;
         GpsPort = null;
         //this.GPGSV = null;
         disposed = true;
     }
     GC.SuppressFinalize(this);
 }
예제 #7
0
파일: GPSHandler.cs 프로젝트: kevincwq/UAV
        /// <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();
        }
예제 #8
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();
        }