Esempio n. 1
0
        //Deal with GPS data from UDP
        private void UDPPortTaskActive(object sender, SendUDPPortArgs args)
        {
            if (args.ThreadEnd != false)                                       //Serial Port Task has not ended .. it shouldnt
            {
                if (args.gpsData != null)                                      //dont process string if its null... will it ever be null?
                {
                    GPSDataProcessing gPSDataString = new GPSDataProcessing(); //create instance of GPS claas
                    gPSDataString.Process(args.gpsData);                       //pass data to class
                }


                NewGPSDataRecieved(args.gpsData);
            }
            else
            {
                UnexpectedThreadEnd(2);
            }
        }
Esempio n. 2
0
        private void NewGPSDataRecieved(string gpsDataLine)// sort it out and send to UI
        {
            bool postLat  = false;
            bool postLon  = false;
            bool postalt  = false;
            bool postQual = false;
            bool postHDOP = false;
            bool postPDOP = false;
            bool postCM   = false;
            bool postKph  = false;
            bool postVDOP = false;


            GPSData           tempGPSData = new GPSData();           //local store from class
            GPSDataProcessing newGPSData  = new GPSDataProcessing(); //send stringto class for processing and store the returned data

            tempGPSData = newGPSData.Process(gpsDataLine);

            if (tempGPSData.Lat != -1)
            {
                currentGPSData.Lat = tempGPSData.Lat; postLat = true;
            }                                                                                  //we have lat
            if (tempGPSData.Lon != -1)
            {
                currentGPSData.Lon = tempGPSData.Lon; postLon = true;
            }                                                                                  //we have lon
            if (tempGPSData.Alt != -1)
            {
                currentGPSData.Alt = tempGPSData.Alt; postalt = true;
            }                                                                                  //we have alt reading
            if (tempGPSData.GpsQuality != -1)
            {
                currentGPSData.GpsQuality = tempGPSData.GpsQuality; postQual = true;
            }                                                                                                        //we have quality
            if (tempGPSData.HDOP != -1)
            {
                currentGPSData.HDOP = tempGPSData.HDOP; postHDOP = true;
            }                                                                                      //we have HDOP
            if (tempGPSData.PDOP != -1)
            {
                currentGPSData.PDOP = tempGPSData.PDOP;  postPDOP = true;
            }                                                                                       //we have PDOP
            if (tempGPSData.SpeedCMs != -1)
            {
                currentGPSData.SpeedCMs = tempGPSData.SpeedCMs;  postCM = true;
            }                                                                                                 //we have speed in cm
            if (tempGPSData.SpeedKph != -1)
            {
                currentGPSData.SpeedKph = tempGPSData.SpeedKph;  postKph = true;
            }                                                                                                  //we have speed in kph
            if (tempGPSData.VDOP != -1)
            {
                currentGPSData.VDOP = tempGPSData.VDOP;  postVDOP = true;
            }                                                                                       //we have VDOP

            Dispatcher.BeginInvoke(new Action(() =>
            {
                //deal with 0 data
                if (postLat & postLon)     //display lat and long
                {
                    textboxLatitude.Text  = tempGPSData.Lat.ToString();
                    textboxLongitude.Text = tempGPSData.Lon.ToString();
                }

                if (postalt)        //post altitude
                {
                    textboxAltitude.Text = tempGPSData.Alt.ToString();
                }

                if (postCM)                       //we will always have Kph if CM
                {
                    if (tempGPSData.SpeedKph < 1) //if we are slower than 1kph
                    {
                        //post cm to screen
                        textBlockSpeed.Text = "Speed (cm/s)";
                        textboxSpeed.Text   = tempGPSData.SpeedCMs.ToString();
                    }
                    else
                    {
                        //post as KPH
                        textBlockSpeed.Text = "Speed (kph)";
                        textboxSpeed.Text   = tempGPSData.SpeedKph.ToString();
                    }
                }
            }), DispatcherPriority.Background);
        }