예제 #1
0
        /// <summary>
        /// Parse VTG verb with this structure:
        ///    VTG,t.t,T,m.m,M,s.s,N,k.k,K,m
        ///    t.t: true heading
        ///    m.m: mag heading
        ///    s.s: speed knots
        ///    k.k: speed k/mh
        /// </summary>
        /// <param name="talkerId"></param>
        /// <param name="words"></param>
        /// <param name="sentence"></param>
        private void ParseCOGandSOG(string talkerId, string[] words, string sentence)
        {
            double cogT;
            double cogM;
            double sog;

            if (words.Length < 6)
            {
                DebugLog.WriteLine("Invalid VTG sentence: " + sentence);
                return;
            }

            try
            {
                cogT = Double.Parse(words[1]);
                if (cogT < 0 || cogT > 360)
                {
                    DebugLog.WriteLine("Invalid heading: " + sentence);
                    return;
                }
                cogM = Double.Parse(words[3]);
                if (cogM < 0 || cogM > 360)
                {
                    DebugLog.WriteLine("Invalid heading: " + sentence);
                    return;
                }
                sog = Double.Parse(words[5]);
            }
            catch
            {
                DebugLog.WriteLine("Invalid VTG sentence: " + sentence);
                return;
            }

            if (COGSOGEvent != null)
            {
                var args = new NmeaCOGSOGEventArgs(cogT, cogM, sog);
                COGSOGEvent(this, args);
            }
        }
예제 #2
0
 void m_nmeaInputPort_CogSogEvent(object sender, NmeaCOGSOGEventArgs args)
 {
     DisplayVariables.SpeedOverGround.Value = args.speedKnots;
 }