Exemplo n.º 1
0
 public void DriftFail(GPSEventArgs args)
 {
     if (args.SegIdx - _driftSegIdx > 4)
     {
         Main.Instance.PopupMsg("Drift Fail");
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Private method for Firing a serialport timeout event
        /// </summary>
        private void FireTimeOut()
        {
            GPGGA.FixQuality = SharpGPS.NMEA.GPGGA.FixQualityEnum.Invalid;
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.TimeOut;
            _NewGPSFix(this, e);
        }
Exemplo n.º 4
0
        public void Land(GPSEventArgs args)
        {
            float _airTime = Time.time - _takeOffStartTime;

            _airTime       = Mathf.Round(_airTime * 100) / 100;
            _landStartTime = Time.time;
            _landAngVel    = _goVeh.GetComponent <Rigidbody>().angularVelocity.magnitude;
            //Main.Instance.PopupMsg(Mathf.RoundToInt(Angl).ToString());
        }
Exemplo n.º 5
0
    protected virtual void DriftFail()
    {
        _drifting = false;
        GPSEventArgs args = new GPSEventArgs {
            SegIdx = CurrSegIdx
        };

        OnDriftFail(args);
    }
Exemplo n.º 6
0
        /// <summary>
        /// Private method for parsing the GPGLL NMEA sentence
        /// </summary>
        /// <param name="strGLL">GPGLL sentence</param>
        private void ParseGLL(string strGLL)
        {
            GPGLL = new SharpGPS.NMEA.GPGLL(strGLL);
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.GPGLL;
            e.Sentence    = strGLL;
            _NewGPSFix(this, e);
        }
Exemplo n.º 7
0
 protected virtual void DriftRecovery()
 {
     if (OnDriftEnd != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = this.CurrSegIdx
         };
         OnDriftEnd(args);
     }
 }
Exemplo n.º 8
0
 protected virtual void Recovery()
 {
     if (OnRecovery != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = this.CurrSegIdx
         };
         OnRecovery(args);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Private method for parsing the GPGGA NMEA sentence
        /// </summary>
        /// <param name="strGGA">GPGGA sentence</param>
        private void ParseGGA(string strGGA)
        {
            GPGGA = new SharpGPS.NMEA.GPGGA(strGGA);
            //fire the event.
            GPSEventArgs e = new GPSEventArgs();

            e.TypeOfEvent = GPSEventType.GPGGA;
            e.Sentence    = strGGA;
            _NewGPSFix(this, e);
        }
Exemplo n.º 10
0
 protected virtual void TakeOff()
 {
     if (OnTakeOff != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnTakeOff(args);
     }
 }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
 protected virtual void Drift()
 {
     if (OnDrift != null)
     {
         _drifting = true;
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnDrift(args);
     }
 }
Exemplo n.º 13
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);
     }
 }
Exemplo n.º 14
0
        public void DriftEnd(GPSEventArgs args)
        {
            float _driftTime = Time.time - _driftStartTime;
            int   _driftSegs = args.SegIdx - _driftSegIdx;

            pts = _driftSegs / 10;
            if (pts > 0)
            {
                Main.Instance.PopupMsg("Drift Points \n$" + (pts).ToString());
                Race.Current.DriftBonus += pts;
            }
        }
Exemplo n.º 15
0
 protected virtual void Land()
 {
     if (OnLand != null)
     {
         JustLanded       = true;
         AirRecoveryTimer = 0;
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnLand(args);
     }
 }
Exemplo n.º 16
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;
            }
        }
Exemplo n.º 17
0
        public void Recovery(GPSEventArgs args)
        {
            float _airTime = _landStartTime - _takeOffStartTime;

            if (_airTime < 1)
            {
                return;
            }                               //not a real jump
            float _recoveryTime       = Time.time - _landStartTime;
            int   _recoverySegIdx     = args.SegIdx;
            float _recoverySegsPerSec = (float)(_recoverySegIdx - _takeOffSegIdx) / (Time.time - _takeOffStartTime);

            if (_recoverySegsPerSec > 40)
            {
                return;
            }                                           //landed on the wrong bit of road
            //float _spin = _landAngVel; //a good spin is 2.5
            pts = (int)((1 + _landAngVel) * _recoverySegsPerSec / 5);
            if (pts > 0 && pts < 200)
            {
                Race.Current.AirBonus += pts;
                Main.Instance.PopupMsg("Air Points\n$" + pts.ToString(), new Color(0f, 0.7f, 1f));
            }
        }
Exemplo n.º 18
0
 public void Drift(GPSEventArgs args)
 {
     _driftStartTime = Time.time;
     _driftSegIdx    = args.SegIdx;
 }
Exemplo n.º 19
0
        private void ReturnEvent(Object[] arguments)
        {
            GPSEventArgs e = (GPSEventArgs)arguments[0];

            NewGPSFix(this, e);             //Fire event back to main application
        }
Exemplo n.º 20
0
 public void TakeOff(GPSEventArgs args)
 {
     _takeOffStartTime = Time.time;
     _takeOffSegIdx    = args.SegIdx;
 }
Exemplo n.º 21
0
 private void gps_NewData(object sender, GPSEventArgs e)
 {
     Trace.DoTrace(Trace.TraceCategories.WherugoApp, "gps_NewData");
     ScreenHelper.SetValue(m_txt, ScreenHelper.Property.Text, e.Data);
 }
Exemplo n.º 22
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);///
        }
Exemplo n.º 23
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);
 }
Exemplo n.º 24
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);
     }
 }
Exemplo n.º 25
0
 /// <summary>
 /// Private method for parsing the GPGSA NMEA sentence
 /// </summary>
 /// <param name="strGSA">GPGSA sentence</param>
 private void ParseGSA(string strGSA)
 {
     GPGSA = new SharpGPS.NMEA.GPGSA(strGSA);
     //fire the event.
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.GPGSA;
     e.Sentence = strGSA;
     _NewGPSFix(this, e);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Private method for parsing the GPGLL NMEA sentence
 /// </summary>
 /// <param name="strGLL">GPGLL sentence</param>
 private void ParseGLL(string strGLL)
 {
     GPGLL = new SharpGPS.NMEA.GPGLL(strGLL);
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.GPGLL;
     e.Sentence = strGLL;
     _NewGPSFix(this, e);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Private method for Firing a serialport timeout event
 /// </summary>
 private void FireTimeOut()
 {
     GPGGA.FixQuality = SharpGPS.NMEA.GPGGA.FixQualityEnum.Invalid;
     GPSEventArgs e = new GPSEventArgs();
     e.TypeOfEvent = GPSEventType.TimeOut;
     _NewGPSFix(this, e);
 }
Exemplo n.º 28
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);
 }
Exemplo n.º 29
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;
     }
 }
Exemplo n.º 30
0
 public void DriftRecovery(GPSEventArgs args)
 {
     //Not sure if used
     _drifting = false;
     return;
 }