Beispiel #1
0
 /// <summary>
 /// Copies an NmeaSentence
 /// </summary>
 /// <param name="sentence">The NmeaSentence to copy</param>
 public NmeaSentence(NmeaSentence sentence)
 {
     this.Sentence = sentence.Sentence;
     this.Valid = sentence.Valid;
     this.TalkerId = sentence.TalkerId;
     this.SentenceId = sentence.SentenceId;
     this.HasChecksum = sentence.HasChecksum;
     this.Checksum = sentence.Checksum;
     this.Fields = sentence.Fields;
     this.FieldCount = sentence.FieldCount;
 }
        /// <summary>
        /// Use the factory assigned to the id of the given sentence to construct a 
        /// concrete implementation of the NmeaSentence class. If no factory is assigned
        /// to the sentence id, then the sentence is unknown, and the NmeaUnknownFactory
        /// is used to just return the given sentence
        /// </summary>
        /// <param name="sentence">A generic NmeaSentence to create a concrete implementation
        /// of NmeaSentence for</param>
        /// <returns>A concrete implementation of NmeaSentence, if the sentence is supported,
        /// otherwise the given sentence is returned.</returns>
        public static NmeaSentence CreateConcreteSentence(NmeaSentence sentence)
        {
            if (sentence == null)
            {
                return null;
            }

            string sentendId = sentence.SentenceId;
            NmeaSentenceFactory factory = GetFactory(sentence);
            return factory.Create(sentence);
        }
Beispiel #3
0
        public NmeaGLL(NmeaSentence sentence)
            : base(sentence)
        {
            string lat = sentence.Fields[0];
            string latDir = sentence.Fields[1]; // n or s
            string lng = sentence.Fields[2];
            string lngDir = sentence.Fields[3]; // e or w

            string utc = sentence.Fields[4];
            string status = sentence.Fields[5];

            this.Coordinates = new LatLng(lat, latDir, lng, lngDir, status);
        }
 public override NmeaSentence Create(NmeaSentence sentence)
 {
     return new NmeaGLL(sentence);
 }
 public override NmeaSentence Create(NmeaSentence sentence)
 {
     return sentence;
 }
 /// <summary>
 /// Deriving NmeaSentenceFactory classes must implement this method to 
 /// create the concrete class from the generic class
 /// </summary>
 /// <param name="sentence">The generic NmeaSentect to create a concrete class for</param>
 /// <returns>The concrete NmeaSentence class</returns>
 public abstract NmeaSentence Create(NmeaSentence sentence);
        /// <summary>
        /// Get the NmeaSentenceFactory that can create concrete NmeaSentence classes
        /// from the given generic NmeaSentence.
        /// </summary>
        /// <param name="sentence">The generic NmeaSentence class to create a concrete class from</param>
        /// <returns>The NmeaSentenceFactory that can create concrete classes from the given
        /// generic NmeaSentence</returns>
        public static NmeaSentenceFactory GetFactory(NmeaSentence sentence)
        {
            if (sentence == null)
            {
                return null;
            }

            if (string.IsNullOrEmpty(sentence.SentenceId))
            {
                return _unknownFactory;
            }

            if (_factories.ContainsKey(sentence.SentenceId))
            {
                return _factories[sentence.SentenceId];
            }
            else
            {
                return _unknownFactory;
            }
        }
Beispiel #8
0
 private void _parser_NmeaSentenceReceived(NmeaSentence sentence)
 {
     NmeaGLL gll = sentence as NmeaGLL;
     if (gll != null)
     {
         CurrentGpsPosition.Value = new LatLng(gll.Coordinates);
         Console.WriteLine("GLL: Lat {0}, Lng {1}", gll.Coordinates.Latitude, gll.Coordinates.Longitude);
     }
 }