?? rmc.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 + -