Exemplo n.º 1
0
 public NTRIPClient(IPEndPoint Server, GPSHandler gpsHandler)
 {
     //Initialization...
     gps = gpsHandler;
     BroadCaster = Server;
     //InitializeSocket();
 }
Exemplo n.º 2
0
 public NTRIPClient(IPEndPoint Server, string strUserName, string strPassword, GPSHandler gpsHandler)
     : this(Server, gpsHandler)
 {
     _username = strUserName;
     _password = strPassword;
     //InitializeSocket();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Extracts a full NMEA string from the data recieved on the serialport, and parses this.
        /// The remaining and unparsed NMEA string is returned.
        /// </summary>
        /// <param name="strNMEA">NMEA ASCII data</param>
        /// <returns>Unparsed NMEA data</returns>
        private string GetNmeaString(string strNMEA)
        {
            strNMEA = strNMEA.Replace("\n", "").Replace("\r", ""); //Remove linefeeds

            int nStart = strNMEA.IndexOf("$");                     //Position of first NMEA data

            if (nStart < 0 || nStart == strNMEA.Length - 2)
            {
                return(strNMEA);
            }

            //This will never pass the last NMEA sentence, before the next one arrives
            //The following should instead stop at the end of the line.
            int nStop = strNMEA.IndexOf("$", nStart + 1);          //Position of next NMEA sentence

            if (nStop > -1)
            {
                string strData;
                strData = strNMEA.Substring(nStart, nStop - nStart).Trim();
                if (strData.StartsWith("$"))
                {
                    HasTimedOut        = false;
                    TimeSinceLastEvent = DateTime.Now.Ticks;
                    if (CheckSentence(strData))
                    {
                        FireEvent(GPSHandler.String2Eventtype(strData), strData);
                    }
                }
                return(strNMEA.Substring(nStop));
            }
            else
            {
                return(strNMEA);
            }
        }
Exemplo n.º 4
0
 public void Emulator()
 {
     NewGPSData += new SharpGPS.SerialPort.NewGPSDataHandler(gpsdatahandler);
     file        = new System.IO.StreamReader(GPSHandler._NMEAInputFile);
     while (file != null)
     {
         if (file.EndOfStream)
         {
             //Start from beginning of file
             file.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
         }
         string line = file.ReadLine();
         SharpGPS.SerialPort.GPSEventArgs e = new SharpGPS.SerialPort.GPSEventArgs();
         e.TypeOfEvent = GPSHandler.String2Eventtype(line);
         e.Sentence    = line;
         NewGPSData(this, e);
         System.Threading.Thread.Sleep(150);
     }
 }