unit ComGPS;
interface
uses CPort, Classes,SysUtils,StdCtrls,Controls,CPortTypes,funktionen,ExtCtrls;
type TComGPS =
class(TComPort)
public
breite:
string;
laenge:
string;
breitengrad:
string;
laengengrad:
string;
uhrzeit:
string;
satelliten:integer;
procedure MakeNew(Sender: TWinControl);
procedure Loeschen;
private
Cache: TMemo;
N:TRxCharEvent;
procedure Lese(Sender: TObject; Count: Integer);
end;
implementation
uses Unit1;
procedure TCOmGPS.MakeNew(Sender: TWinControl);
begin
Cache:=TMemo.Create(Sender);
Cache.parent:=Sender;
Cache.Height:=400;
Cache.Width:=400;
Cache.Visible:=false;
TMethod(N).Data:=Self;
TMethod(N).Code:=@TComGPS.Lese;
OnRxChar:=N;
end;
procedure TComGPS.Loeschen;
begin
try
if connected
then
close;
Cache.free;
Cache:=nil;
except
end;
end;
procedure TComGPS.Lese(Sender: TObject; Count: Integer);
var Str,zeile:
string; i:integer;
begin
ReadStr(Str,count);
Cache.Text:=Cache.Text+Str;
begin
for i:=0
to Cache.Lines.Count-1
do
begin
zeile:=Cache.Lines[i];
if (pos('
$GPGGA',zeile)>0)
and (copy(zeile,40,1)='
1')
then
begin
uhrzeit:=copy(zeile,8,10);
if pos('
S',zeile)>0
then
breite:='
-'+copy(zeile,15,9)
else
breite:=copy(zeile,15,9);
if pos('
E',zeile)>0
then
laenge:=copy(zeile,27,10)
else
laenge:='
-'+copy(zeile,27,10);
laenge:=Stringreplace(laenge,'
.',#44,[]);
breite:=Stringreplace(breite,'
.',#44,[]);
FOrm1.timer1.Enabled:=true;
cache.Clear;
end;
end;
end;
end;
end.