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

📄 unit1.~pas

📁 一个GPS接收和数据分析软件,可以接收实际GPS的数据,并在一张地图上显示位置.
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls, XComDrv,Math;

type
  TLineGet=class(TObject)
  private
    Buf:string;
  public
    procedure Init;
    procedure ProcChar(C:Char);
    procedure SendLine;
  end;

  TForm1 = class(TForm)
    Image1: TImage;
    Shape1: TShape;
    Label1: TLabel;
    XModem1: TXModem;
    Memo1: TMemo;
    Button1: TButton;
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure XModem1Data(Sender: TObject; const Received: Cardinal);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  LineGet:tlineget;

implementation

{$R *.dfm}

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
label1.caption:='X='+inttostr(x)+',Y='+inttostr(y);
end;


procedure  processgpsdata(dtuid:string;gpsstr:string);
var  msgid,timestr,status,latitude,ns,longtitude,we,speed,course,datestr:string;
     tmps:string;
     i,j,x,y:integer;
     gpsinfo:string;
begin
   tmps:=gpsstr;

   i:=pos(',',tmps);
   msgid:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));
   if msgid<>'$GPRMC' then exit;

   i:=pos(',',tmps);
   timestr:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   status:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   latitude:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   ns:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   longtitude:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   we:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   speed:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   course:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

   i:=pos(',',tmps);
   datestr:=copy(tmps,1,i-1);
   tmps:=copy(tmps,i+1,length(tmps));

 if status='V' then
 begin
  form1.memo1.text:=form1.memo1.text+'V';
  exit;
 end;

         // AddPhone(strtofloat(longtitude)/100,strtofloat(latitude)/100);
//         x=(经度-103.987418)*8315.8
//y=(30.45466756-纬度)*(8476.061666)
         x:=floor(((strtofloat(longtitude)/100)-103.987418)*8315);
         y:=floor((30.45466756-(strtofloat(latitude)/100))*(8476.061666));
         form1.shape1.Left:=x;
         form1.Shape1.Top:=y;
end;

procedure ProcLine(Buf:string);
begin
 //  memo1.lines.Add('收到GPS定位数据,dtuid='+dtuid+','+'内容:'+gpsstr);
   if pos('$GPRMC',buf)=0 then exit;
   processgpsdata('zsgprs01',buf);
end;

procedure TLineGet.Init;
begin
  Buf:='';
end;

procedure TLineGet.SendLine;
begin
 if length(buf)<=338 then
 begin
   ProcLine(Buf);
 end;
end;

procedure TLineGet.ProcChar(C:Char);
begin
  if C=chr(10) then
  begin
    SendLine;
    Buf:='';
  end
  else
  begin
      if C<>chr(13) then  Buf:=Buf+C;
  end;
end;



procedure TForm1.XModem1Data(Sender: TObject; const Received: Cardinal);
var s:string;
    i:integer;
begin
  xmodem1.ReadString(s,Received);
  i:=1;
  while i<=length(s) do
  begin
    LineGet.ProcChar(s[i]);
    i:=i+1;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  lineget:=tlineget.Create;
  xmodem1.OpenDevice;
end;

end.

⌨️ 快捷键说明

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