用C#读取GPS数据的基类,适用于wince操作系统[7]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

#region 读取GPS
  private void opengps(string ComPoint)
  {
   ss_port.PortNum = ComPoint;
   ss_port.BaudRate = 4800;
   ss_port.ByteSize = 8;
   ss_port.Parity = 0;
   ss_port.StopBits = 1;
   ss_port.ReadTimeout = 1000;

   try
   {
    if (ss_port.Opened)
    {
     ss_port.Close();
     ss_port.Open();
     timer1.Enabled=true;
    }
    else
    {
     ss_port.Open();//打开串口
     timer1.Enabled=true;
    }
    
   }
   catch
    
   {
//    MessageBox.Show("读取GPS错误!" ,"系统提示");
    
   }
  }
  private void timer1_Tick(object sender, System.EventArgs e)
  {
   
   if (ss_port.Opened)
    gpsread();
   else
    ss_port.Open();//打开串口
  }
  
  private void gpsread()
  {
   byte[] aa=ss_port.Read(512);
   string gpsinfo =System.Text.Encoding.ASCII.GetString(aa,0,aa.Length);
   GetParam.GpsLongitude=ss_port.GetGPS(gpsinfo,"X");
   GetParam.GpsLatitude=ss_port.GetGPS(gpsinfo,"Y");
   GetParam.GpsSpeed=ss_port.GetGPS(gpsinfo,"V");
   GetParam.GpsTime=ss_port.GetGPS(gpsinfo,"T");
   if(GetParam.GpsLongitude=="-1")
    GetParam.GpsState="0";
   if(GetParam.GpsLongitude=="V" && GetParam.GpsLatitude=="V")
    GetParam.GpsState="0";
   if(GetParam.GpsLongitude!="-1" && GetParam.GpsLongitude!="V")
    GetParam.GpsState="1";

本文关键:用C#读取GPS数据的基类,适用于wince操作系统
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top