易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi中利用MSCOMM控件进行GPS数据采集

1、准备
  GPS(Global Positioning System),即全球定位系统,利用24颗GPS卫星的测距和测时功能进行全球定位,在许多系统中,如机场导航系统,出租车辆管理和调度系统、江河流域的灾害信息管理和预测系统中,GPS得到了广泛的应用。本文利用MSCOMM控件实现了GPS数据的采集,可为信息管理和指挥调度等提供定位数据。
  本文采用GPS的异步串行传送方式,将GARMIN 12C按NMEA-0183协议输出的数据采集到了微机,并将接收到的地理坐标转换成为直角坐标。
  在DELPHI 5.0 IDE中新建一工程,名为GPSReceiver,在主界面上放置四个TEDIT控件,用于显示接收到的地理坐标和转换后的直角坐标,其“name”属性分别为:Editlatitude、Editlongitude、Editxcoord和Editycoord;在四个TEDIT控件下方放置三个按钮,用于数据接收的控制和退出程序,其“Caption”属性分别为“接收”、“断开”和“返回”;在界面上任意位置放置一个Ttimer控件、其属性interval值为“1000”,主要用于每隔一秒接收一次GPS数据;一个TMSCOMM控件。程序运行后的界面如图1(略):
  2、编写代码
  1) 在FORM的implementation部分添加以下声明
var
nn,x,y,sm,n,weidud,jinchad,firstpxl,secondpxl,a,b,longitude,longitudemargin,latitude:double;
weidustr,weidustrcpy,longitudestr1cpy,longitudestrccpy,
weidustr1,weidustr2,jinchastr,jinchastr1,jinchastr2,longitudestr1,
longitudestr11,longitudestr12,longitudestrc,longitudestrc1,longitudestrc2:string;
gpsstrlist:tstringlist;
gpsstr,gpsstrcpy:string;
gpsstrlen:integer;
  2)在FORM的FORMSHOW事件中添加如下代码:
procedure Tmainfrm.FormShow(Sender: TObject);
begin
mscomm1.CommPort:=1; //默认串口1
mscomm1.InBufferSize:=1024;
mscomm1.Settings:='600,n,8,1'; //波特率为600
if not mscomm1.PortOpen then
mscomm1.PortOpen:=true; //打开串口
mscomm1.InBufferCount:=0;
mscomm1.RThreshold:=512;
mscomm1.InputLen:=0;
timer1.Enabled:=false; //关闭定时器
a:=6378245.0; b:=6356863.0; //参考椭球的长短轴
firstpxl:=(a*a-b*b)/a/a; //第一偏心率
secondpxl:=(a*a-b*b)/b/b; //第二偏心率
end;
  3)为定时器Timer1添加OnTimer事件添加如下代码:
procedure Tmainfrm.Timer1Timer(Sender: TObject);


相关文档:

Delphi双向链表类

unit DvsLinkingClass;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs;
type
PRecLinkNode = ^RecLinkNode;
RecLinkNode = record
NodeMsg: String;
Counter: Integer;
Previous: PRecLinkNode;
Next: PRecLinkNode;
end;
TLinkingClass = class
......

Delphi实现透明窗体

unit unitMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2 ......

Delphi关联文件扩展名

unit unitMain;
interface
uses
Registry, shlobj,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TExtForm = class(TForm)
ledExtension: TLabeledEdit;
ledAssocApp: TLabeledEdit;
GetAssocApp: TButton;
AssocTh ......

Delphi 的RTTI机制浅探(续)

http://www.delphibbs.com/delphibbs/dispq.asp?LID=2421470
本文是《Delphi 的RTTI机制浅探》的续篇,上篇地址在:
  http://www.delphibbs.com/delphibbs/dispq.asp?lid=2420610
本文上篇基本上是
RTTI 入门介绍,续篇介绍了所有 TypInfo.pas 中的函数,附加了 Classes.pas、Graphics.pas、Controls.pas
中的 ......

delphi学习 字符串切割问题(split)

最近做一个项目,要用Delphi,以前从未学过,好是费劲啊,哈哈光是字符串切割这个问题就困扰了几个小时,通过查资料终于解决,在这与大家分享一下
Function split(src: pchar; ch: char):TStringList;
// 分割字符串
var
  i: Integer;
  tmp : string;
begin
  Result:=TStringList.Create;
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号