Beispiel #1
0
        /// <summary>
        /// Parse event from GPS thread to parent thread
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">GPSEventArgs</param>
        private void GPSEventHandler(object sender, GPSEventArgs e)
        {
            ControlInvoker controlInvoker;

            controlInvoker = new ControlInvoker(this._Parent);
            controlInvoker.Invoke(new MethodCallInvoker(ReturnEvent), e);               //Send event to parent thread
        }
Beispiel #2
0
        /// <summary>
        /// Fires a NewGPSFix event
        /// </summary>
        /// <param name="type">Type of GPS event (GPGGA, GPGSA, etx...)</param>
        /// <param name="sentence">NMEA Sentence</param>
        private void FireEvent(GPSEventType type, string sentence)
        {
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = type;
            e.Sentence    = sentence;
            NewGPSData(this, e);
        }
Beispiel #3
0
        /// <summary>
        /// Private method for Firing a serialport timeout event
        /// </summary>
        private void FireTimeOut()
        {
            GPGGA.FixQuality = NMEA.GPGGA.FixQualityEnum.Invalid;
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.TimeOut;
            _NewGPSFix(this, e);
        }
Beispiel #4
0
        /// <summary>
        /// Private method for parsing the GPGLL NMEA sentence
        /// </summary>
        /// <param name="strGLL">GPGLL sentence</param>
        private void ParseGLL(string strGLL)
        {
            GPGLL = new NMEA.GPGLL(strGLL);
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.GPGLL;
            e.Sentence    = strGLL;
            _NewGPSFix(this, e);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
        /// <summary>
        /// Private method for parsing the PGRME NMEA sentence
        /// </summary>
        /// <param name="strRME">GPRMC sentence</param>
        private void ParseRME(string strRME)
        {
            this.PGRME = new SharpGps.NMEA.GPRME(strRME);
            //fire the event.
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.PGRME;
            e.Sentence    = strRME;
            _NewGPSFix(this, e);
        }
Beispiel #7
0
 /// <summary>
 /// Private method for parsing the GPGSV NMEA sentence
 /// GPGSV is a bit different, since it if usually made from several NMEA sentences
 /// </summary>
 /// <param name="strGSV">GPGSV sentence</param>
 private void ParseGSV(string strGSV)
 {
     //fire the event if last GSV message.
     if (GPGSV.AddSentence(strGSV))
     {
         GPSEventArgs e = new GPSEventArgs();
         e.TypeOfEvent = GPSEventType.GPGSV;
         e.Sentence    = strGSV;
         _NewGPSFix(this, e);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Method called when a GPS event occured.
        /// This is where we call the methods that parses each kind of NMEA sentence
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GPSDataEventHandler(object sender, SerialPort.GPSEventArgs e)
        {
            switch (e.TypeOfEvent)
            {
            case GPSEventType.GPRMC:
                ParseRMC(e.Sentence);
                break;

            case GPSEventType.GPGGA:
                ParseGGA(e.Sentence);
                break;

            case GPSEventType.GPGLL:
                ParseGLL(e.Sentence);
                break;

            case GPSEventType.GPGSA:
                ParseGSA(e.Sentence);
                break;

            case GPSEventType.GPGSV:
                ParseGSV(e.Sentence);
                break;

            case GPSEventType.PGRME:
                ParseRME(e.Sentence);
                break;

            case GPSEventType.TimeOut:
                FireTimeOut();
                break;

            case GPSEventType.Unknown:
                GPSEventArgs e2 = new GPSEventArgs();
                e2.TypeOfEvent = e.TypeOfEvent;
                e2.Sentence    = e.Sentence;
                _NewGPSFix(this, e2);
                break;

            default: break;
            }
        }
Beispiel #9
0
 /// <summary>
 /// Private method for parsing the GPGSA NMEA sentence
 /// </summary>
 /// <param name="strGSA">GPGSA sentence</param>
 private void ParseGSA(string strGSA)
 {
     GPGSA = new NMEA.GPGSA(strGSA);
     //fire the event.
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.GPGSA;
     e.Sentence = strGSA;
     _NewGPSFix(this, e);
 }
Beispiel #10
0
 /// <summary>
 /// Private method for parsing the GPGLL NMEA sentence
 /// </summary>
 /// <param name="strGLL">GPGLL sentence</param>
 private void ParseGLL(string strGLL)
 {
     GPGLL = new NMEA.GPGLL(strGLL);
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.GPGLL;
     e.Sentence = strGLL;
     _NewGPSFix(this, e);
 }
Beispiel #11
0
 /// <summary>
 /// Parse event from GPS thread to parent thread
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">GPSEventArgs</param>
 private void GPSEventHandler(object sender, GPSEventArgs e)
 {
     ControlInvoker controlInvoker;
     controlInvoker = new ControlInvoker(this._Parent);
     controlInvoker.Invoke (new MethodCallInvoker (ReturnEvent), e); //Send event to parent thread
 }
Beispiel #12
0
 /// <summary>
 /// Method called when a GPS event occured.
 /// This is where we call the methods that parses each kind of NMEA sentence
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GPSDataEventHandler(object sender, SerialPort.GPSEventArgs e)
 {
     switch (e.TypeOfEvent)
     {
         case GPSEventType.GPRMC:
             ParseRMC(e.Sentence);
             break;
         case GPSEventType.GPGGA:
             ParseGGA(e.Sentence);
             break;
         case GPSEventType.GPGLL:
             ParseGLL(e.Sentence);
             break;
         case GPSEventType.GPGSA:
             ParseGSA(e.Sentence);
             break;
         case GPSEventType.GPGSV:
             ParseGSV(e.Sentence);
             break;
         case GPSEventType.PGRME:
             ParseRME(e.Sentence);
             break;
         case GPSEventType.TimeOut:
             FireTimeOut();
             break;
         case GPSEventType.Unknown:
             GPSEventArgs e2 = new GPSEventArgs();
             e2.TypeOfEvent = e.TypeOfEvent;
             e2.Sentence = e.Sentence;
             _NewGPSFix(this, e2);
             break;
         default: break;
     }
 }
Beispiel #13
0
 /// <summary>
 /// Private method for Firing a serialport timeout event
 /// </summary>
 private void FireTimeOut()
 {
     GPGGA.FixQuality = NMEA.GPGGA.FixQualityEnum.Invalid;
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.TimeOut;
     _NewGPSFix(this, e);
 }
Beispiel #14
0
        /// <summary>
        /// Responds to sentence events from GPS receiver
        /// </summary>
        private void GPSEventHandler(object source, GPSEventArgs e)
        {
            switch (e.TypeOfEvent)
            {
                case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data
                    if (GPS.HasGPSFix) //Is a GPS fix available?
                    {
                        //lbRMCPosition.Text = GPS.GPRMC.Position.ToString("#.000000");
                        values["lbRMCPosition"].Value=GPS.GPRMC.Position.ToString("DMS");
                        values["lbRMCPositionLongitude"].Value=GPS.GPRMC.Position.Longitude;
                        values["lbRMCPositionLatitude"].Value= GPS.GPRMC.Position.Latitude;

                        double[] utmpos = TransformToUTM(GPS.GPRMC.Position);
                        values["lbRMCPositionUTM"].Value=utmpos[0].ToString("#.0N ") + utmpos[0].ToString("#.0E") + " (Zone: " + utmpos[2] + ")";
                        values["lbRMCCourse"].Value=GPS.GPRMC.Course.ToString();
                        values["lbRMCSpeed"].Value=GPS.GPRMC.Speed.ToString() + " mph";
                        values["lbRMCTimeOfFix"].Value=GPS.GPRMC.TimeOfFix.ToString("F");
                        values["lbRMCMagneticVariation"].Value=GPS.GPRMC.MagneticVariation.ToString();
                    }
                    else
                    {
                        values["lbRMCCourse"].Value="N/A";
                    values["lbRMCSpeed"].Value = "N/A";
                        values["lbRMCTimeOfFix"].Value = GPS.GPRMC.TimeOfFix.ToString();
                    }
                    break;
                case GPSEventType.GPGGA: //Global Positioning System Fix Data
                    if(GPS.GPGGA.Position!=null)
                    values["lbGGAPosition"].Value = GPS.GPGGA.Position.ToString("DM");
                    else
                    values["lbGGAPosition"].Value="";
                    values["lbGGATimeOfFix"].Value=GPS.GPGGA.TimeOfFix.Hour.ToString() + ":" + GPS.GPGGA.TimeOfFix.Minute.ToString() + ":" + GPS.GPGGA.TimeOfFix.Second.ToString();
                    values["lbGGAFixQuality"].Value=GPS.GPGGA.FixQuality.ToString();
                    values["lbGGANoOfSats"].Value=GPS.GPGGA.NoOfSats.ToString();
                    values["lbGGAAltitude"].Value=GPS.GPGGA.Altitude.ToString();
                    values["lbGGAAltitudeUnit"].Value=GPS.GPGGA.AltitudeUnits;

                    values["lbGGAHDOP"].Value=GPS.GPGGA.Dilution.ToString();
                    values["lbGGAGeoidHeight"].Value=GPS.GPGGA.HeightOfGeoid.ToString();
                    values["lbGGADGPSupdate"].Value=GPS.GPGGA.DGPSUpdate.ToString();
                    values["lbGGADGPSID"].Value=GPS.GPGGA.DGPSStationID;
                    break;
                case GPSEventType.GPGLL: //Geographic position, Latitude and Longitude
                    values["lbGLLPosition"].Value=GPS.GPGLL.Position.ToString();
                values["lbGLLTimeOfSolution"].Value=(GPS.GPGLL.TimeOfSolution.HasValue ? GPS.GPGLL.TimeOfSolution.Value.Hours.ToString() + ":" + GPS.GPGLL.TimeOfSolution.Value.Minutes.ToString() + ":" + GPS.GPGLL.TimeOfSolution.Value.Seconds.ToString() : "");
                    values["lbGLLDataValid"].Value=GPS.GPGLL.DataValid.ToString();
                    break;
                case GPSEventType.GPGSA: //GPS DOP and active satellites
                    if (GPS.GPGSA.Mode == 'A')
                        values["lbGSAMode"].Value="Auto";
                    else if (GPS.GPGSA.Mode == 'M')
                        values["lbGSAMode"].Value="Manual";
                    else values["lbGSAMode"].Value="";
                    values["lbGSAFixMode"].Value=GPS.GPGSA.FixMode.ToString();
                    values["lbGSAPRNs"].Value="";
                    if(GPS.GPGSA.PRNInSolution.Count>0)
                        foreach (string prn in GPS.GPGSA.PRNInSolution)
                            values["lbGSAPRNs"].Value+= prn + " ";
                    else
                        values["lbGSAPRNs"].Value += "none";
                    values["lbGSAPDOP"].Value=GPS.GPGSA.PDOP.ToString() + " (" + DOPtoWord(GPS.GPGSA.PDOP) +")";
                    values["lbGSAHDOP"].Value=GPS.GPGSA.HDOP.ToString() + " (" + DOPtoWord(GPS.GPGSA.HDOP) + ")";
                    values["lbGSAVDOP"].Value=GPS.GPGSA.VDOP.ToString() + " (" + DOPtoWord(GPS.GPGSA.VDOP) + ")";
                    break;
                case GPSEventType.GPGSV: //Satellites in view
                    //if (NMEAtabs.TabPages[NMEAtabs.SelectedIndex].Text == "GPGSV") //Only update this tab when it is active
                    //	DrawGSV();
                    break;
                case GPSEventType.PGRME: //Garmin proprietary sentences.
                    values["lbRMEHorError"].Value=GPS.PGRME.EstHorisontalError.ToString();
                    values["lbRMEVerError"].Value=GPS.PGRME.EstVerticalError.ToString();
                    values["lbRMESphericalError"].Value=GPS.PGRME.EstSphericalError.ToString();
                    break;
                case GPSEventType.TimeOut: //Serialport timeout.
                    /*notification1.Caption = "GPS Serialport timeout";
                    notification1.InitialDuration = 5;
                    notification1.Text = "Check your settings and connection";
                    notification1.Critical = false;
                    notification1.Visible = true;
                     */
                    break;
            }

            /// </param>   if (ValuesChanged != null) ValuesChanged(values);///
        }
Beispiel #15
0
 /// <summary>
 /// Private method for parsing the GPGSV NMEA sentence
 /// GPGSV is a bit different, since it if usually made from several NMEA sentences
 /// </summary>
 /// <param name="strGSV">GPGSV sentence</param>
 private void ParseGSV(string strGSV)
 {
     //fire the event if last GSV message.
     if(GPGSV.AddSentence(strGSV))
     {
         GPSEventArgs e = new GPSEventArgs();
         e.TypeOfEvent = GPSEventType.GPGSV;
         e.Sentence = strGSV;
         _NewGPSFix(this, e);
     }
 }
Beispiel #16
0
        private void ReturnEvent(Object[] arguments)
        {
            GPSEventArgs e = (GPSEventArgs)arguments[0];

            NewGPSFix(this, e);             //Fire event back to main application
        }
Beispiel #17
0
 /// <summary>
 /// Parse event from GPS thread to parent thread
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">GPSEventArgs</param>
 private void GPSEventHandler(object sender, GPSEventArgs e)
 {
     ReturnEvent(e); //Send event to parent thread
 }
Beispiel #18
0
 private void ReturnEvent(GPSEventArgs arguments)
 {
     GPSEventArgs e = arguments;
     NewGPSFix(this, e); //Fire event back to main application
 }
Beispiel #19
0
        private void ReturnEvent(GPSEventArgs arguments)
        {
            GPSEventArgs e = arguments;

            NewGPSFix(this, e);             //Fire event back to main application
        }
Beispiel #20
0
 /// <summary>
 /// Parse event from GPS thread to parent thread
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">GPSEventArgs</param>
 private void GPSEventHandler(object sender, GPSEventArgs e)
 {
     ReturnEvent(e); //Send event to parent thread
 }
Beispiel #21
0
 /// <summary>
 /// Private method for parsing the PGRME NMEA sentence
 /// </summary>
 /// <param name="strRME">GPRMC sentence</param>
 private void ParseRME(string strRME)
 {
     this.PGRME = new SharpGps.NMEA.GPRME(strRME);
     //fire the event.
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.PGRME;
     e.Sentence = strRME;
     _NewGPSFix(this, e);
 }
Beispiel #22
0
 /// <summary>
 /// Fires a NewGPSFix event
 /// </summary>
 /// <param name="type">Type of GPS event (GPGGA, GPGSA, etx...)</param>
 /// <param name="sentence">NMEA Sentence</param>
 private void FireEvent(GPSEventType type, string sentence)
 {
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = type;
     e.Sentence = sentence;
     NewGPSData(this, e);
 }