public void LogPosition(ref GPSData p_gpsData)
        {
            bool blnLogPosition = false;


            if (m_swOutputFile != null)
            {
                //T N54.85655 W1.56742 09-OCT-00 12:01:01

                DateTime dtTimeOfEvent = p_gpsData.TimeOfLastFix;

                TimeSpan tsDifference = dtTimeOfEvent.Subtract(m_dtTimeOfLastWrite);

                if (tsDifference.Ticks >= m_lTrackWriterLogFrequency)
                {
                    if ((m_cdLastLoggedPosition.Latitude == 0) ||
                        (m_cdLastLoggedPosition.Longitude == 0))
                    {
                        blnLogPosition = true;
                    }
                    else
                    {
                        // if 2d lock then accuracy -> 10m
                        // else 2.5m?
                        // get distance between two points...

                        if (p_gpsData.FixType == "3D")
                        {
                            m_dbGPSPositionalAccuracy = 0.0025d;                             //2.5 m
                        }
                        else
                        {
                            m_dbGPSPositionalAccuracy = 0.01d;                             //10 m
                        }

                        double dbDistanceBetweenPoints = Coordinate.DistanceBetweenPoints(m_cdLastLoggedPosition, p_gpsData.LatestFixPosition, UnitOfMeasure.Kilometer);

                        if (dbDistanceBetweenPoints > m_dbGPSPositionalAccuracy)
                        {
                            blnLogPosition = true;
                        }
                    }

                    if (blnLogPosition)
                    {
                        string strDate = dtTimeOfEvent.ToString("dd-MMM-yy ") + dtTimeOfEvent.ToString("T");

                        string strOutput = "T " + p_gpsData.LatestFixPosition.GetLatitude(CoordinateFormat.DecimalDegrees) +
                                           " " + p_gpsData.LatestFixPosition.GetLongitude(CoordinateFormat.DecimalDegrees) +
                                           " " + strDate;

                        try
                        {
                            m_swOutputFile.WriteLine(strOutput);
                            m_swOutputFile.Flush();

                            m_dtTimeOfLastWrite    = dtTimeOfEvent;
                            m_cdLastLoggedPosition = p_gpsData.LatestFixPosition;
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine(e.Message);
                            // what to do?
                            RaiseExceptionEvent("Error Occured In GPSTrackFileWriter.GPSCoordUpdateEventHandler(...)", ex);
                        }
                    }
                }
            }

//			Console.WriteLine("{0}" , test.GetLatitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
//			Console.WriteLine("{0}" , test.GetLongitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
//			Console.WriteLine("{0}" ,  test.TimeOfLastGPSFix);
        }
        public void LogPosition(ref GPSData p_gpsData)
        {
            bool blnLogPosition = false;

            if ((m_dbTrack != null) && m_blnLoggingStarted)
            {
                //T N54.85655 W1.56742 09-OCT-00 12:01:01

                DateTime dtTimeOfEvent = p_gpsData.TimeOfLastFix;

                TimeSpan tsDifference =	dtTimeOfEvent.Subtract(m_dtTimeOfLastWrite);

                if (tsDifference.Ticks >= m_lTrackWriterLogFrequency )
                {
                    if ((m_cdLastLoggedPosition.Latitude == 0) ||
                        (m_cdLastLoggedPosition.Longitude == 0))
                    {
                        blnLogPosition = true;
                    }
                    else
                    {
                        // if 2d lock then accuracy -> 10m
                        // else 2.5m?
                        // get distance between two points...

                        if (p_gpsData.FixType == "3D" )
                        {
                            m_dbGPSPositionalAccuracy = 0.0025d; //2.5 m

                        }
                        else
                        {
                            m_dbGPSPositionalAccuracy = 0.01d; //10 m

                        }

                        double dbDistanceBetweenPoints = Coordinate.DistanceBetweenPoints(m_cdLastLoggedPosition,p_gpsData.LatestFixPosition, UnitOfMeasure.Kilometer);

                        if (dbDistanceBetweenPoints > m_dbGPSPositionalAccuracy)
                        {
                            blnLogPosition = true;

                        }
                    }

                    if (blnLogPosition)
                    {

                        GPSTrackInfo newPosition = new GPSTrackInfo(m_trTrackId.GetTrackID(),p_gpsData.LatestFixPosition,dtTimeOfEvent);
                        newPosition.SpeedKPH = p_gpsData.CurrentSpeedKPH;
                        try
                        {
                            m_dbTrack.Set(newPosition);
                            m_dbTrack.Commit();

                            m_dtTimeOfLastWrite =  dtTimeOfEvent;
                            m_cdLastLoggedPosition = p_gpsData.LatestFixPosition;

                        }
                        catch (Exception ex)
                        {
                                    RaiseExceptionEvent("Error Occured In GPSTrackDBWriter.GPSCoordUpdateEventHandler(...)",ex);

                        }
                    }
                }

            }

            //			Console.WriteLine("{0}" , test.GetLatitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
            //			Console.WriteLine("{0}" , test.GetLongitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
            //			Console.WriteLine("{0}" ,  test.TimeOfLastGPSFix);
        }
Esempio n. 3
0
        public void LogPosition(ref GPSData p_gpsData)
        {
            bool blnLogPosition = false;


            if ((m_dbTrack != null) && m_blnLoggingStarted)
            {
                //T N54.85655 W1.56742 09-OCT-00 12:01:01

                DateTime dtTimeOfEvent = p_gpsData.TimeOfLastFix;

                TimeSpan tsDifference = dtTimeOfEvent.Subtract(m_dtTimeOfLastWrite);

                if (tsDifference.Ticks >= m_lTrackWriterLogFrequency)
                {
                    if ((m_cdLastLoggedPosition.Latitude == 0) ||
                        (m_cdLastLoggedPosition.Longitude == 0))
                    {
                        blnLogPosition = true;
                    }
                    else
                    {
                        // if 2d lock then accuracy -> 10m
                        // else 2.5m?
                        // get distance between two points...

                        if (p_gpsData.FixType == "3D")
                        {
                            m_dbGPSPositionalAccuracy = 0.0025d;                             //2.5 m
                        }
                        else
                        {
                            m_dbGPSPositionalAccuracy = 0.01d;                             //10 m
                        }

                        double dbDistanceBetweenPoints = Coordinate.DistanceBetweenPoints(m_cdLastLoggedPosition, p_gpsData.LatestFixPosition, UnitOfMeasure.Kilometer);

                        if (dbDistanceBetweenPoints > m_dbGPSPositionalAccuracy)
                        {
                            blnLogPosition = true;
                        }
                    }

                    if (blnLogPosition)
                    {
                        GPSTrackInfo newPosition = new GPSTrackInfo(m_trTrackId.GetTrackID(), p_gpsData.LatestFixPosition, dtTimeOfEvent);
                        newPosition.SpeedKPH = p_gpsData.CurrentSpeedKPH;
                        try
                        {
                            m_dbTrack.Set(newPosition);
                            m_dbTrack.Commit();

                            m_dtTimeOfLastWrite    = dtTimeOfEvent;
                            m_cdLastLoggedPosition = p_gpsData.LatestFixPosition;
                        }
                        catch (Exception ex)
                        {
                            RaiseExceptionEvent("Error Occured In GPSTrackDBWriter.GPSCoordUpdateEventHandler(...)", ex);
                        }
                    }
                }
            }

//			Console.WriteLine("{0}" , test.GetLatitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
//			Console.WriteLine("{0}" , test.GetLongitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
//			Console.WriteLine("{0}" ,  test.TimeOfLastGPSFix);
        }
Esempio n. 4
0
 public GPSCoordUpdateEventArgs(GPSData p_coCurrentData)
 {
     m_coCurrentGPSData = p_coCurrentData;             //new Coordinate(p_coCurrentPosition);
 }
        public void LogPosition(ref GPSData p_gpsData)
        {
            bool blnLogPosition = false;

            if (m_swOutputFile != null)
            {
                //T N54.85655 W1.56742 09-OCT-00 12:01:01

                DateTime dtTimeOfEvent = p_gpsData.TimeOfLastFix;

                TimeSpan tsDifference =	dtTimeOfEvent.Subtract(m_dtTimeOfLastWrite);

                if (tsDifference.Ticks >= m_lTrackWriterLogFrequency )
                {

                    if ((m_cdLastLoggedPosition.Latitude == 0) ||
                        (m_cdLastLoggedPosition.Longitude == 0))
                    {
                        blnLogPosition = true;
                    }
                    else
                    {
                        // if 2d lock then accuracy -> 10m
                        // else 2.5m?
                        // get distance between two points...

                        if (p_gpsData.FixType == "3D" )
                        {
                            m_dbGPSPositionalAccuracy = 0.0025d; //2.5 m

                        }
                        else
                        {
                            m_dbGPSPositionalAccuracy = 0.01d; //10 m

                        }

                        double dbDistanceBetweenPoints = Coordinate.DistanceBetweenPoints(m_cdLastLoggedPosition,p_gpsData.LatestFixPosition, UnitOfMeasure.Kilometer);

                        if (dbDistanceBetweenPoints > m_dbGPSPositionalAccuracy)
                        {
                            blnLogPosition = true;

                        }
                    }

                    if (blnLogPosition)
                    {

                        string strDate = dtTimeOfEvent.ToString("dd-MMM-yy ") + dtTimeOfEvent.ToString("T");

                        string strOutput = "T "+ p_gpsData.LatestFixPosition.GetLatitude(CoordinateFormat.DecimalDegrees) +
                                              " " +p_gpsData.LatestFixPosition.GetLongitude(CoordinateFormat.DecimalDegrees) +
                                              " " +strDate;

                        try
                        {
                            m_swOutputFile.WriteLine(strOutput);
                            m_swOutputFile.Flush();

                            m_dtTimeOfLastWrite =  dtTimeOfEvent;
                            m_cdLastLoggedPosition = p_gpsData.LatestFixPosition;

                        }
                        catch (Exception ex)
                        {
                    //Console.WriteLine(e.Message);
                    // what to do?
                            RaiseExceptionEvent("Error Occured In GPSTrackFileWriter.GPSCoordUpdateEventHandler(...)",ex);
                        }

                    }
                }

            }

            //			Console.WriteLine("{0}" , test.GetLatitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
            //			Console.WriteLine("{0}" , test.GetLongitude(GPSData.GPSCoordFormat.DegreesMinutesSeconds));
            //			Console.WriteLine("{0}" ,  test.TimeOfLastGPSFix);
        }
Esempio n. 6
0
 public GPSCoordUpdateEventArgs(GPSData p_coCurrentData )
 {
     m_coCurrentGPSData = p_coCurrentData; //new Coordinate(p_coCurrentPosition);
 }