المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : GPS/GSM application



C# Programming
05-08-2009, 12:22 PM
My GPS application can detect not only a Bluetooth GPS receiver but also a GPS/GSM Micro Tracker(it was connected to my application via TCP). I have to send SMS command and it reply back the GPS data(NMEA data - $GPRMC). The problem is that the application can display GPS data($GPGGA) from the Bluetooth GPS receiver but it can't display the data from the gsm machine. Whenever I send sms, I receive back the GPRMC data and I can show it in my textbox but I can't display it on my VE map. The following problem occurs. Thanks in advance. Regards.

http://img172.imagevenue.com/img.php?image=81285_problem2_122_505lo.JPG

The followings are some of my codes.
private void ProcessNMEAData(string data)
{
string[] NMEALine = data.Split('$');
string[] NMEAType;

for (int i = 0; i < NMEALine.Length; i++)
{
NMEAType = NMEALine[i].Split(',');


switch (NMEAType[0])
{
case "GPGGA":
ProcessGPGGA(NMEAType);
break;
case "GPGLL":
break;
case "GPGSA":
break;
case "GPGSV":
break;
case "GPRMC":
ProcessGPRMC(NMEAType);
break;
case "GPVTG":
break;

}

}
}

private void ProcessGPRMC(string[] data)
{

double lat, lon;
double rawLatLong;

rawLatLong = double.Parse(data[3].Replace(":00", ""));
lat = ((int)(rawLatLong / 100)) + ((rawLatLong - (((int)(rawLatLong / 100)) * 100)) / 60);

if (data[4] == "S")
lat *= -1;

rawLatLong = double.Parse(data[5].Replace(":00", ""));
lon = ((int)(rawLatLong / 100)) + ((rawLatLong - (((int)(rawLatLong / 100)) * 100)) / 60);

if (data[6] == "W")
lon *= -1;

if (internetConnected && !loadingFile)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Latitude: {0}
Longitude: {1}
Speed: {2}
", lat, lon, data[7]);
AddPushpin(lat, lon, sb.ToString());
}
else if (loadingFile)
{
object[] param = new object[] { lat, lon };
webBrowser1.Document.InvokeScript("AddPoint", param);
}
}