コード例 #1
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
 public void DriftFail(GPSEventArgs args)
 {
     if (args.SegIdx - _driftSegIdx > 4)
     {
         Main.Instance.PopupMsg("Drift Fail");
     }
 }
コード例 #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);
        }
コード例 #3
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        /// <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);
        }
コード例 #4
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
        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());
        }
コード例 #5
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
    protected virtual void DriftFail()
    {
        _drifting = false;
        GPSEventArgs args = new GPSEventArgs {
            SegIdx = CurrSegIdx
        };

        OnDriftFail(args);
    }
コード例 #6
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        /// <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);
        }
コード例 #7
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
 protected virtual void DriftRecovery()
 {
     if (OnDriftEnd != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = this.CurrSegIdx
         };
         OnDriftEnd(args);
     }
 }
コード例 #8
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
 protected virtual void Recovery()
 {
     if (OnRecovery != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = this.CurrSegIdx
         };
         OnRecovery(args);
     }
 }
コード例 #9
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        /// <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);
        }
コード例 #10
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
 protected virtual void TakeOff()
 {
     if (OnTakeOff != null)
     {
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnTakeOff(args);
     }
 }
コード例 #11
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        /// <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);
        }
コード例 #12
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
 protected virtual void Drift()
 {
     if (OnDrift != null)
     {
         _drifting = true;
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnDrift(args);
     }
 }
コード例 #13
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
 /// <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);
     }
 }
コード例 #14
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
        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;
            }
        }
コード例 #15
0
ファイル: GPS.cs プロジェクト: TheMeanFiddler/RipRally
 protected virtual void Land()
 {
     if (OnLand != null)
     {
         JustLanded       = true;
         AirRecoveryTimer = 0;
         GPSEventArgs args = new GPSEventArgs {
             SegIdx = CurrSegIdx
         };
         OnLand(args);
     }
 }
コード例 #16
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        /// <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;
            }
        }
コード例 #17
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
        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));
            }
        }
コード例 #18
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
 public void Drift(GPSEventArgs args)
 {
     _driftStartTime = Time.time;
     _driftSegIdx    = args.SegIdx;
 }
コード例 #19
0
ファイル: GPSHandler.cs プロジェクト: liukai-tech/SharpGPS
        private void ReturnEvent(Object[] arguments)
        {
            GPSEventArgs e = (GPSEventArgs)arguments[0];

            NewGPSFix(this, e);             //Fire event back to main application
        }
コード例 #20
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
 public void TakeOff(GPSEventArgs args)
 {
     _takeOffStartTime = Time.time;
     _takeOffSegIdx    = args.SegIdx;
 }
コード例 #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);
 }
コード例 #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);///
        }
コード例 #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);
 }
コード例 #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);
     }
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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;
     }
 }
コード例 #30
0
ファイル: Race.cs プロジェクト: TheMeanFiddler/RipRally
 public void DriftRecovery(GPSEventArgs args)
 {
     //Not sure if used
     _drifting = false;
     return;
 }