Esempio n. 1
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;
     }
 }
Esempio n. 2
0
 private void btConnect_Click(object sender, EventArgs e)
 {
     if (ntripStarted)
     {
         try
         {
             if (ntrip != null)
                 ntrip.StopNTRIP();
             foreach (SerialPort port in Coms)
             {
                 port.Stop();
             }
             Coms.Clear();
             ntripStarted = false;
             btConnect.Text = "Connect";
         }
         catch (Exception ex)
         {
             tbRTCM.AppendText(ex.Message + "\n");
         }
     }
     else
     {
         try
         {
             if (ntrip == null)
                 ntrip = new SharpGis.SharpGps.NTRIP.NTRIPClient(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(tbNTRIPServerIP.Text.Trim()), int.Parse(tbNTRIPPort.Text)), tbNTRIPUser.Text, tbNTRIPPasswd.Text);
             ntrip.NTripDataReceived += ntrip_NTripDataReceived;
             foreach (string com in frmNtripSettings.COMs)
             {
                 string[] portrate = com.Split(',');
                 SerialPort port = new SerialPort(portrate[0], int.Parse(portrate[1]));
                 if (port.Port == frmNtripSettings.ReCom)
                     port.NewGPSData += port_NewGPSData;
                 port.Start();
                 Coms.Add(port);
             }
             ntrip.StartNTRIP(cbMountPoints.Text);
             ntripStarted = true;
             btConnect.Text = "Connected";
         }
         catch (Exception ex)
         {
             tbRTCM.AppendText(ex.Message + "\n");
         }
     }
 }
Esempio n. 3
0
 /// <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);
 }
Esempio n. 4
0
 void port_NewGPSData(object sender, SerialPort.GPSEventArgs e)
 {
     if (e.TypeOfEvent == GPSEventType.GPGGA)
     {
         ntrip.MostRecentGGA = e.Sentence;
     }
 }