⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmc.cs

📁 这是一个gps的数据读写器。大家可以借鉴学习一下。
💻 CS
字号:
using System;
using System.Threading;
using System.Globalization;

namespace BEC
{
	/// <summary>
	/// entity object for RMC sentence
	/// </summary>
	public class RMC
	{
		public RMC(string strSentence)
		{
			this.Read(strSentence);
			
		}

		public decimal UTCTime
		{
			get
			{
              return dUTCTime;

			}
		}
		decimal dUTCTime;

		public bool Status
		{
			get
			{
				return bStatus;

			}

		}
		bool bStatus;

		public decimal Latitude
		{
			get
			{
				return dLatitude;

			}
		}
		decimal dLatitude;

		/// <summary>
		/// Latitude Indicator
		/// </summary>
		public string LatIndicator
		{
			get
			{
				return strLatIndicator;

			}
		
		}
		string strLatIndicator;

		public decimal Longtitude
		{
			get
			{
				return dLongtitude;

			}
		}

		decimal dLongtitude;

		/// <summary>
		/// Lontitude Indicator
		/// </summary>
		public string LongIndicator
		{
			get
			{
				return strLongIndicator;

			}
		
		}
		string strLongIndicator;


		public decimal Speed
		{
			get
			{
				return dSpeed;

			}
		}

		decimal dSpeed;

		public decimal Course
		{
			get
			{
				return dCourse;

			}
		}

		decimal dCourse;

		public DateTime UTCDate
		{
			get
			{
				return dtUTCDate;

			}

		}
		DateTime dtUTCDate;

	

		void Read(string strSentence)
		{
			try
			{
			

				Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
				string strInfo=Thread.CurrentThread.CurrentCulture.ToString();
				if(strSentence.StartsWith("$GPRMC")==true)
				{
					string[] fAttributes =strSentence.Split(',');
					int nAttributes = fAttributes.Length;

					for(int i=0;i<nAttributes;i++)
					{
						string strAttribute = (string)fAttributes[i];
						switch(i)
						{
							/// UTC Time
							case 1: { this.dUTCTime=Convert.ToDecimal(strAttribute); break;}
							// Status
							case 2: 
							{ 
								this.bStatus=(strAttribute=="A")?true:false;
                               break;
							}
							// Latitude
							case 3: { this.dLatitude = Convert.ToDecimal(strAttribute); break;}
							// LatIndicator
							case 4: { this.strLatIndicator =(strAttribute=="S")?"South":"North"; break;}
							// Longtitude
							case 5: { this.dLongtitude=Convert.ToDecimal(strAttribute); break;}
							// Longtitude Indicator
							case 6: { this.strLongIndicator=(strAttribute=="W")?"West":"East"; break;}
							// Speed
							case 7: { this.dSpeed=Convert.ToDecimal(strAttribute); break;}
							// Course
							case 8: { this.dCourse=Convert.ToDecimal(strAttribute); break;}
							// UTCDate
							case 9: { 
								      string strUTCDate=Convert.ToString(strAttribute);
								      int nYear = 2000+Convert.ToInt32(strUTCDate.Substring(4,2));
									  int nMonth = Convert.ToInt32(strUTCDate.Substring(2,2));
								      int nDay = Convert.ToInt32(strUTCDate.Substring(0,2));
								
								      this.dtUTCDate = new DateTime(nYear,nMonth,nDay );
								      break;
							        }
						}

					}

				}

			}
			catch(Exception oException)
			{
				throw oException;

			}
			
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -