Begin
form1.pb3.Max:=time3+round(random(80)); form1.pb3.Position:=2;
form1.label8.Caption:=inttostr(strtoint(form1.label8.Caption)-1);
form1.indicator2.Position:=form1.indicator2.Position-2;
zanyat3:=true;prov_nak;end;
if (strtoint(form1.label8.caption)>3) and( not(zanyat4)) then
Begin
form1.pb4.Max:=time4+round(random(80)); form1.pb4.Position:=2;
form1.label8.Caption:=inttostr(strtoint(form1.label8.Caption)-1);
form1.indicator2.Position:=form1.indicator2.Position-2;
zanyat4:=true;
prov_nak;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var t:real;
i:integer;
Begin
if (zapusk)and(TotalMessages<500) then
Begin
If not(ustanov)then
Begin
t1:=5+trunc(random(10));
ustanov:=true;
zapusk:=ustanov;
t2:=0;
End
Else
if t2=t1 then
Begin
t:=0;
for i:=1 to 1000 do
Begin
pb_start.Position:=(pb_start.Position+trunc(t));
t:=t+0.01;
end;
add_new(1);
inc(TotalMessages);{количество всех сообщений пришедших в систему}
pb_start.Position:=0;
t2:=0;
ustanov:=false;
End
else inc(t2);
prov_nak;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
Begin
randomize;
label1.Caption:='Ждёт';label2.Caption:='Ждёт';
label3.Caption:='Ждёт';label4.Caption:='Ждёт';
zanyat1:=false;zanyat2:=false;zanyat3:=false;
zanyat4:=false;
brak1:=4;brak2:=8;time1:=40;time2:=60;
time3:=100;time4:=100;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
Begin
If zapusk then begin
if pb1.Position=pb1.max then begin
pb1.Position:=0;zanyat1:=false;
label1.Caption:='Ждёт';
if where_go(1)then add_new(2)
Else
if RepeatMessages<((brak1+brak2)*5) then
Begin
label10.Caption:=inttostr(strtoint(label10.Caption)+1);
inc(RepeatMessages);
End
else add_new(2);
end;
if pb2.Position=pb2.max then
Begin
pb2.Position:=0;zanyat2:=false;label2.Caption:='Ждёт';
if where_go(2)then add_new(2)
Else
if (ripit)and(LostMessages<trunc(RepeatMessages*brak2)/100) then
Begin
p1.Color:=clred;p2.Color:=clred;
p1.Color:=$00400040;p2.Color:=$00400040;
ripit:=false;
inc(LostMessages);
End
Else
if RepeatMessages<((brak1+brak2)*5) then
Begin
label10.Caption:=inttostr(strtoint(label10.Caption)+1);
inc(RepeatMessages);
End
else add_new(2);
end;
if pb3.Position=pb3.max then
begin pb3.Position:=0;zanyat3:=false;label3.Caption:='Ждёт';end;
if pb4.Position=pb4.max then
begin pb4.Position:=0;zanyat4:=false;label4.Caption:='Ждёт';end;
if pb1.Position>0 then
begin pb1.Position:=pb1.Position+7;label1.Caption:='Выполняет';end;
if pb2.Position>0 then
begin pb2.Position:=pb2.Position+7;label2.Caption:='Выполняет';end;
if pb3.Position>0 then
begin pb3.Position:=pb3.Position+7;label3.Caption:='Выполняет';end;
if pb4.Position>0 then
begin pb4.Position:=pb4.Position+7;label4.Caption:='Выполняет';end;
run;
label12.Caption:=inttostr(TotalMessages);
label14.Caption:=inttostr(RepeatMessages);
label16.Caption:=inttostr(LostMessages);
end;
label17.Caption:=timetostr(time);
end;
procedure TForm1.N2Click(Sender: TObject);
Begin
zapusk:=true;
n2.enabled:=false;
n3.enabled:=true;
end;
procedure TForm1.N3Click(Sender: TObject);
Begin
zapusk:=false;
n2.enabled:=true;
n3.enabled:=false;
end;
procedure TForm1.N11Click(Sender: TObject);
Begin
n2.Enabled:=true;
TotalMessages:=0;
LostMessages:=0;
RepeatMessages:=0;
label6.Caption:='0';
label8.Caption:='0';
label10.Caption:='0';
indicator1.Position:=0;
indicator2.Position:=0;
pb1.Position:=0;pb2.Position:=0;
pb3.Position:=0;pb4.Position:=0;
have1:=false;have2:=false;ripit:=false;
zanyat1:=false;zanyat2:=false;
zanyat3:=false;zanyat4:=false;
TotalTime:=0;TotalMessages:=0;
randomize;
end;
procedure TForm1.N9Click(Sender: TObject);
var c:integer;
Begin
c:=application.MessageBox(pchar('Вы уверены в том что хотите завершить работу ???'),pchar('Предупреждение'),4);
if c=6 then halt;
end;
procedure TForm1.Q1Click(Sender: TObject);
Begin
form2.PageControl1.ActivePage:=form2.PageControl1.Pages[0] ;
form2.ShowModal;
end;
procedure TForm1.N5Click(Sender: TObject);
Begin
form2.PageControl1.ActivePage:=form2.PageControl1.Pages[1] ;
form2.ShowModal;
end;
procedure TForm1.N7Click(Sender: TObject);
Begin
form3.PageControl1.ActivePage:=form3.PageControl1.Pages[0];
form3.showmodal;
end;
procedure TForm1.N10Click(Sender: TObject);
Begin
form4.showmodal;
end;
procedure TForm1.N8Click(Sender: TObject);
Begin
form3.PageControl1.ActivePage:=form3.PageControl1.Pages[1];
form3.showmodal;
end;
End.
Модуль 2.
unit Progr2;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, ExtCtrls, ComCtrls;
Type
TForm2 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Image1: TImage;
Image2: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
Private
Public
end;
Var
Form2: TForm2;
Implementation
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
Begin
form2.Close;
end;
End.
Модуль 3.
unit Progr3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls;
type
TForm3 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var Form3: TForm3;
implementation
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin form3.Close;
end;
End.
Дата: 2019-05-28, просмотров: 183.