unit body;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, uBodyDLL, CPort, CPortCtl;
type
TbodyFrm =
class(TForm)
startBtn: TButton;
stopBtn: TButton;
Memo1: TMemo;
Panel1: TPanel;
ComPort1: TComPort;
Button1: TButton;
ComDataPacket1: TComDataPacket;
procedure ComDataPacket1Packet(Sender: TObject;
const Str:
string);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure stopBtnClick(Sender: TObject);
procedure startBtnClick(Sender: TObject);
private
{ Private-Deklarationen }
start : boolean;
online : boolean;
public
{ Public-Deklarationen }
dir :
string;
end;
var
bodyFrm: TbodyFrm;
implementation
{$R *.dfm}
procedure TbodyFrm.startBtnClick(Sender: TObject);
begin
startOnlineMode(comPort1);
//sendet den Start-string über die Schnittstelle - klappt einwandfrei
online := true;
end;
procedure TbodyFrm.stopBtnClick(Sender: TObject);
begin
stopOnlineMode(comPort1);
//sendet #13 über die Schnittstelle - klappt einwandfrei
online := false;
end;
procedure TbodyFrm.Button1Click(Sender: TObject);
begin
comPort1.WriteStr('
V'+#13);
//Versionsinfos vom Gerät anfordern
end;
procedure TbodyFrm.ComDataPacket1Packet(Sender: TObject;
const Str:
string);
begin
memo1.Lines.Add(str)
end;
procedure TbodyFrm.FormActivate(Sender: TObject);
begin
if start
then
begin
dir := ExtractFilePath(Application.ExeName);
comPort1.Open;
start := false;
end;
end;
procedure TbodyFrm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if online
then
stopBtn.Click;
comPort1.Close;
action := caFree;
end;
procedure TbodyFrm.FormCreate(Sender: TObject);
begin
start := true;
end;
end.