DELPHI 脉搏波9808血压计读取测试程序


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SPComm,StrUtils;

type
  TForm1 = class(TForm)
    Comm1: TComm;
    Button1: TButton;
    Memo1: TMemo;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Comm1ReceiveData(Sender: TObject; Buffer: PAnsiChar;
      BufferLength: Word);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  s:tstringlist;
  j:integer;
  function HexToDec(const AHexString: String): Integer;
implementation

{$R *.dfm}
function HexToDec(const AHexString: String): Integer;
begin
Result := StrToInt('$' + AHexString);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
comm1.StartComm;
if comm1.Handle>0 then
showmessage('打开成功')
else
showmessage('打开失败');

end;

procedure TForm1.Button2Click(Sender: TObject);
var
sbuf: array [1..8] of byte;
i:integer;
begin
 sbuf[1]:=byte($CC);
 sbuf[2]:=byte($80);
 sbuf[3]:=byte($03);
 sbuf[4]:=byte($03);
 sbuf[5]:=byte($01);
 sbuf[6]:=byte($01);
 sbuf[7]:=byte($00);
 sbuf[8]:=byte($00);      //异或校验

for i := 1 to 8 do
 if not comm1.WriteCommData(@sbuf[i],1) then
  showmessage('失败'+inttohex(sbuf[i]));
 j:=8;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
sbuf: array [1..8] of byte;
i:integer;
begin
 sbuf[1]:=byte($CC);
 sbuf[2]:=byte($80);
 sbuf[3]:=byte($03);
 sbuf[4]:=byte($03);
 sbuf[5]:=byte($01);
 sbuf[6]:=byte($02);
 sbuf[7]:=byte($00);
 sbuf[8]:=byte($03);      //异或校验

for i := 1 to 8 do
 if not comm1.WriteCommData(@sbuf[i],1) then
  showmessage('失败'+inttohex(sbuf[i]));
 j:=8;
end;

procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: PAnsiChar;
  BufferLength: Word);
var
temp:Ansistring;
i:integer;
begin
temp:=buffer;
if j>0 then
  begin
    j:=j-1;
    exit;
  end;
 for i := 1 to length(temp) do
   begin
       s.Add(inttostr(ord(temp[i])));
       memo1.Text:=memo1.Text+IntTohex(ord(temp[i]))+' ';
    end;

if s.Count=17 then
  begin
    try
    edit1.Text:=s[13];
    edit2.Text:=s[14];
    edit3.Text:=s[15];
    finally
       s.Clear;
    end;
  end
else
  if s[0]<>'170' then
    s.Clear;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 memo1.Text:='';
 s:=tstringlist.Create;
end;

end.






相关阅读 >>

Delphi 如何产生输出一个变形的图形及文字

Delphi 多次改变 richedit.text部份文本的颜色后,出现所有字体都变色的的解决办法

Delphi 掌控pagecontrol中的右上方的左右箭头事件

Delphi 返回程序执行参数的例子

Delphi 上传文件到七牛,纯原生

Delphi xe7 android 实现的在线更新app的一个程序

Delphi startcount() 时间计数器

Delphi 新建文件夹函数

Delphi tms web core 获取url 参数

Delphi 将整数转换为罗马数字

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...