unit uMain;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, CPort,
Vcl.StdCtrls,
Vcl.ExtCtrls,
Vcl.ComCtrls;
type
TfrmMain =
class(TForm)
Memo1: TMemo;
Button1: TButton;
ProgressBar1: TProgressBar;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
ComPort: TComPort;
ComData1: TComDataPacket;
ComData2: TComDataPacket;
ComData3: TComDataPacket;
ComData4: TComDataPacket;
ComData5: TComDataPacket;
ComData6: TComDataPacket;
ComData7: TComDataPacket;
ComData8: TComDataPacket;
ComData9: TComDataPacket;
ComData10: TComDataPacket;
procedure ComData1Packet(Sender: TObject;
const Str:
string);
procedure ComData2Packet(Sender: TObject;
const Str:
string);
procedure ComData3Packet(Sender: TObject;
const Str:
string);
procedure ComData4Packet(Sender: TObject;
const Str:
string);
procedure ComData5Packet(Sender: TObject;
const Str:
string);
procedure ComData6Packet(Sender: TObject;
const Str:
string);
procedure ComData7Packet(Sender: TObject;
const Str:
string);
procedure ComData8Packet(Sender: TObject;
const Str:
string);
procedure ComData9Packet(Sender: TObject;
const Str:
string);
procedure ComData10Packet(Sender: TObject;
const Str:
string);
end;
var
frmMain: TfrmMain;
Buffer:
PACKED ARRAY[0..9]
OF Byte;
implementation
{$R *.dfm}
procedure TfrmMain.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
ComData1.Free;
ComData2.Free;
ComData3.Free;
ComData4.Free;
ComData5.Free;
ComData6.Free;
ComData7.Free;
ComData8.Free;
ComData9.Free;
ComData10.Free;
ComPort.Close;
ComPort.Free;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
ComPort := TComPort.Create(
Nil);
ComPort.Port := '
COM5';
ComPort.BaudRate := br38400;
ComData1 := TComDataPacket.Create(
Nil);
ComData1.ComPort := ComPort;
ComData1.StartString := '
AD';
ComData1.StopString := #13#10;
ComData1.OnPacket := ComData1Packet;
ComData2 := TComDataPacket.Create(
Nil);
ComData2.ComPort := ComPort;
ComData2.StartString := '
PAUSE';
ComData2.StopString := #13#10;
ComData2.OnPacket := ComData2Packet;
ComData3 := TComDataPacket.Create(
Nil);
ComData3.ComPort := ComPort;
ComData3.StartString := '
ABSTART';
ComData3.StopString := #13#10;
ComData3.OnPacket := ComData3Packet;
ComData4 := TComDataPacket.Create(
Nil);
ComData4.ComPort := ComPort;
ComData4.StartString := '
ABSTOP';
ComData4.StopString := #13#10;
ComData4.OnPacket := ComData4Packet;
ComData5 := TComDataPacket.Create(
Nil);
ComData5.ComPort := ComPort;
ComData5.StartString := '
AUFSTART';
ComData5.StopString := #13#10;
ComData5.OnPacket := ComData5Packet;
ComData6 := TComDataPacket.Create(
Nil);
ComData6.ComPort := ComPort;
ComData6.StartString := '
AUFSTOP';
ComData6.StopString := #13#10;
ComData6.OnPacket := ComData6Packet;
ComData7 := TComDataPacket.Create(
Nil);
ComData7.ComPort := ComPort;
ComData7.StartString := '
SCHNELLSTART';
ComData7.StopString := #13#10;
ComData7.OnPacket := ComData7Packet;
ComData8 := TComDataPacket.Create(
Nil);
ComData8.ComPort := ComPort;
ComData8.StartString := '
SCHNELLSTOP';
ComData8.StopString := #13#10;
ComData8.OnPacket := ComData8Packet;
ComData9 := TComDataPacket.Create(
Nil);
ComData9.ComPort := ComPort;
ComData9.StartString := '
LANGSAMSTART';
ComData9.StopString := #13#10;
ComData9.OnPacket := ComData9Packet;
ComData10 := TComDataPacket.Create(
Nil);
ComData10.ComPort := ComPort;
ComData10.StartString := '
LANGSAMSTOP';
ComData10.StopString := #13#10;
ComData10.OnPacket := ComData10Packet;
ComPort.Open;
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
Buffer[0] := $66;
Buffer[1] := $30;
Buffer[2] := $51;
Buffer[3] := $00;
Buffer[4] := $00;
Buffer[5] := $00;
Buffer[6] := $00;
Buffer[7] := $00;
Buffer[8] := $00;
Buffer[9] := $66;
ComPort.
Write(Buffer, SizeOf(Buffer));
end;
procedure TfrmMain.ComData1Packet(Sender: TObject;
const Str:
string);
begin
Progressbar1.Position := StrToInt(Str);
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData2Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
PAUSE' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData3Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
ABSTART' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData4Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
ABSTOP' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData5Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
AUFSTART' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData6Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
AUFSTOP' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData7Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
SCHNELLSTART' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData8Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
SCHNELLSTOP' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData9Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
LANGSAMSTART' + #13#10;
ComPort.ClearBuffer(True,False);
end;
procedure TfrmMain.ComData10Packet(Sender: TObject;
const Str:
string);
begin
Memo1.Text := Memo1.Text + '
LANGSAMSTOP' + #13#10;
ComPort.ClearBuffer(True,False);
end;
end.