unit batch_tmc;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, SerialNG, ToolWin, ComCtrls, Menus, Grids;
type
TForm1 =
class(TForm)
SendBtn: TButton;
SerialPortNG1: TSerialPortNG;
OpenDialog1: TOpenDialog;
ListBox2: TListBox;
MainMenu1: TMainMenu;
Datei1: TMenuItem;
MCDateiAuswahl1: TMenuItem;
DatendateiAuswahl1: TMenuItem;
Beenden1: TMenuItem;
Einstellungen1: TMenuItem;
SeriellerPort1: TMenuItem;
Timer1: TTimer;
StatusBar1: TStatusBar;
Memo1: TMemo;
Label3: TLabel;
Label1: TLabel;
Label4: TLabel;
verbleibend: TLabel;
Panel1: TPanel;
Button1: TButton;
Label5: TLabel;
procedure BasicSettingsBtnClick(Sender: TObject);
procedure SendBtnClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Beenden1Click(Sender: TObject);
procedure DatendateiAuswahl1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Dummiload(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
test:
string;
globalcount, rest,i,x : integer;
implementation
uses SerialNGBasic;
{$R *.DFM}
procedure TForm1.BasicSettingsBtnClick(Sender: TObject);
begin
SerialNGBasicDLG.SetDLGData(SerialPortNG1);
if SerialNGBasicDLG.ShowModal = mrOK
then
SerialNGBasicDLG.GetDLGData(SerialPortNG1);
end;
procedure wait (ms:Cardinal);
Var x: Cardinal;
Begin
x:=GetTickCount;
Repeat
Sleep(1000);
Application.ProcessMessages;
Until GetTickCount >= x+ms;
End;
procedure TForm1.SendBtnClick(Sender: TObject);
var SendStr :
String;
i : integer;
begin
i := globalcount;
rest := i;
verbleibend.Caption := inttostr(rest);
SendStr := '
';
sendstr := char(01) + '
V' + char(02) + '
01' + Memo1.Lines[0]+char(03) + char(13);
SerialPortNG1.SendString(SendStr);
if x = 5
then
begin
listbox2.Items.Delete(0);
dec(x);
end;
listbox2.Items[x] := Memo1.Lines[0];
Memo1.Lines.Delete(0);
inc(x);
dec(i);
if i = 0
then showmessage('
Ende der Liste');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SerialPortNG1.Active := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SerialPortNG1.Active := True;
x :=0;
end;
procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.DatendateiAuswahl1Click(Sender: TObject);
var dateiname:
string;
begin
opendialog1.Execute;
dateiname := opendialog1.FileName;
if dateiname ='
'
then exit;
memo1.Clear;
Listbox2.Clear;
memo1.Lines.LoadFromFile(Dateiname);
memo1.
ReadOnly := true ;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
StatusBar1.Panels[0].Text :='
';
StatusBar1.Panels[1].Text := FormatDateTime('
dddd, d mmmm yyyy ',(Now()));
StatusBar1.Panels[2].Text := FormatDateTime('
hh:mm:ss',(Now()));
end;
procedure TForm1.Dummiload(Sender: TObject);
begin
label5.Caption := inttostr(memo1.Lines.Count);
globalcount := memo1.Lines.Count;
end;
end