Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Мирончук Евгений / Lab5 / SHABLON / SHAB1
.PAS unit shab1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Functions, Grids;
type
TForm1 = class(TForm)
Stangrid: TStringGrid;
Label1: TLabel;
DetGrid: TStringGrid;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function sign(a:real):integer;
var
Form1: TForm1;
implementation
uses grt, Fin;
{$R *.DFM}
Function sign(a:real):integer;
begin
if a>=0 then sign:=1
else sign:=-1;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form1.Hide;
Form2.Show;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Form1.Close;
Form2.Close;
Exit;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j,c,m:integer;
stansr:real;
incl:boolean;
Detproceeded:integer;
First:boolean;
maxr:integer;
begin
Stansr:=0;
DetIncl:=0;
DetProceeded:=0;
First:=True;
m:=0;
for j:=1 to StanC do begin
Val(StanGrid.Cells[j,1],Stan[j],C);
end;
for i:=1 to DetC do begin
for j:=1 to StanC do begin
Val(DetGrid.Cells[i,j],Det[i,j],C);
end;
end;
For j:=1 to StanC do StanOst[j]:=Stan[j];
for i:=1 to DetC do begin
for j:=1 to StanC do begin
Det1[i,j]:=det[i,j]/stan[j];
end;
srtrd[i]:=0;
end;
For i:=1 to DetC do begin
For j:=1 to StanC do begin
srtrd[i]:=srtrd[i]+Det1[i,j];
end;
srtrd[i]:=srtrd[i]/StanC;
detrang[i]:=0;
end;
DetIncl:=0;
While Detproceeded<DetC do begin
Stansr:=0;
for j:=1 to StanC do begin
stansr:=Stansr + StanOst[j];
end;
Stansr:=stansr/StanC;
For i:=1 to DetC do begin
For j:=1 to StanC do begin
If ((Stanost[j]>=Stansr) and (Det1[i,j]>=srtrd[i])) or ((Stanost[j]<Stansr) and (Det1[i,j]<srtrd[i])) then begin
if detrang[i]=-1 then detrang[i]:=-1
else detrang[i]:=detrang[i]+1;
end;
end;
end;
m:=1;
maxr:=detrang[1];
for i:=2 to DetC do begin
if Detrang[i]>maxr then begin
maxr:=detrang[i];
m:=i;
end;
end;
stanost1:=stanost;
incl:=True;
If First then For j:=1 to StanC do StanOst1[j]:=1;
For i:=1 to StanC do begin
Stanost1[i]:=stanost1[i]-Det1[m,i];
if (StanOst1[i]<0) and (abs(StanOst1[i])>0.0000001) then incl:=False;
End;
If incl then begin
Detincl:=detincl+1;
Plan[detincl]:=m;
StanOst:=StanOst1;
DetRang[m]:=-1;
m:=0;
First:=False;
end
else DetRang[m]:=-1;
Detproceeded:=Detproceeded+1;
For i:=1 to DetC do if detrang[i]>0 then detrang[i]:=0;
end;
Writeln(Rfile,'Задание');
Writeln(Rfile,'Остаток фонда рабочего времени по группам технологического оборудования');
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ': ');
write(Rfile, InttoStr(Stan[j]));
Writeln(RFile);
end;
Writeln(Rfile);
Writeln(Rfile,'Трудоемкость деталей по видам технологического оборудования');
Write(Rfile,' ');
for j:=1 to DetC do begin
Write(RFile, 'Д.' + InttoStr(j) + ' ');
end;
Writeln(Rfile);
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ' : ');
for i:=1 to DetC do begin
write(Rfile, RealToStr(Det[i,j],5,0));
end;
Writeln(Rfile);
end;
Writeln(RFile);
Writeln(Rfile,'Результаты.');
Writeln(Rfile,'Детали, рекомендуемые к запуску в текущем месяце');
for j:=1 to DetIncl do begin
Writeln(RFile, 'Дет. ' + InttoStr(plan[j]));
end;
Writeln(Rfile);
Writeln(Rfile,'Остаток фонда по группам технологического оборудования');
Writeln(RFile,' Абсол. Относит.');
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ': ');
write(Rfile, RealtoStr((StanOst[j]*Stan[j]), 5, 2) + ' ' + RealtoStr((StanOst[j]), 5, 2));
Writeln(RFile);
end;
Flush(RFile);
CloseFile(Rfile);
With Form3 do begin
ListBox1.Clear;
Sg1.RowCount:=StanC+1;
For i:=1 to DetIncl do begin
Listbox1.Items.Add('Деталь ' + IntToStr(Plan[i]));
end;
for j:=1 to StanC do begin
SG1.Cells[0,j]:='Стан. ' + IntToStr(j);
SG1.Cells[1,j]:=RealtoStr((StanOst[j]*Stan[j]), 5, 2);
SG1.Cells[2,j]:=RealtoStr((StanOst[j]), 5, 2);
end;
SG1.Cells[1,0]:='Абсол';
SG1.Cells[2,0]:='Относ.';
Listbox1.Update;
SG1.Update;
end;
Form1.Hide;
Form3.Show;
End;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Functions, Grids;
type
TForm1 = class(TForm)
Stangrid: TStringGrid;
Label1: TLabel;
DetGrid: TStringGrid;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function sign(a:real):integer;
var
Form1: TForm1;
implementation
uses grt, Fin;
{$R *.DFM}
Function sign(a:real):integer;
begin
if a>=0 then sign:=1
else sign:=-1;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Form1.Hide;
Form2.Show;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Form1.Close;
Form2.Close;
Exit;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j,c,m:integer;
stansr:real;
incl:boolean;
Detproceeded:integer;
First:boolean;
maxr:integer;
begin
Stansr:=0;
DetIncl:=0;
DetProceeded:=0;
First:=True;
m:=0;
for j:=1 to StanC do begin
Val(StanGrid.Cells[j,1],Stan[j],C);
end;
for i:=1 to DetC do begin
for j:=1 to StanC do begin
Val(DetGrid.Cells[i,j],Det[i,j],C);
end;
end;
For j:=1 to StanC do StanOst[j]:=Stan[j];
for i:=1 to DetC do begin
for j:=1 to StanC do begin
Det1[i,j]:=det[i,j]/stan[j];
end;
srtrd[i]:=0;
end;
For i:=1 to DetC do begin
For j:=1 to StanC do begin
srtrd[i]:=srtrd[i]+Det1[i,j];
end;
srtrd[i]:=srtrd[i]/StanC;
detrang[i]:=0;
end;
DetIncl:=0;
While Detproceeded<DetC do begin
Stansr:=0;
for j:=1 to StanC do begin
stansr:=Stansr + StanOst[j];
end;
Stansr:=stansr/StanC;
For i:=1 to DetC do begin
For j:=1 to StanC do begin
If ((Stanost[j]>=Stansr) and (Det1[i,j]>=srtrd[i])) or ((Stanost[j]<Stansr) and (Det1[i,j]<srtrd[i])) then begin
if detrang[i]=-1 then detrang[i]:=-1
else detrang[i]:=detrang[i]+1;
end;
end;
end;
m:=1;
maxr:=detrang[1];
for i:=2 to DetC do begin
if Detrang[i]>maxr then begin
maxr:=detrang[i];
m:=i;
end;
end;
stanost1:=stanost;
incl:=True;
If First then For j:=1 to StanC do StanOst1[j]:=1;
For i:=1 to StanC do begin
Stanost1[i]:=stanost1[i]-Det1[m,i];
if (StanOst1[i]<0) and (abs(StanOst1[i])>0.0000001) then incl:=False;
End;
If incl then begin
Detincl:=detincl+1;
Plan[detincl]:=m;
StanOst:=StanOst1;
DetRang[m]:=-1;
m:=0;
First:=False;
end
else DetRang[m]:=-1;
Detproceeded:=Detproceeded+1;
For i:=1 to DetC do if detrang[i]>0 then detrang[i]:=0;
end;
Writeln(Rfile,'Задание');
Writeln(Rfile,'Остаток фонда рабочего времени по группам технологического оборудования');
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ': ');
write(Rfile, InttoStr(Stan[j]));
Writeln(RFile);
end;
Writeln(Rfile);
Writeln(Rfile,'Трудоемкость деталей по видам технологического оборудования');
Write(Rfile,' ');
for j:=1 to DetC do begin
Write(RFile, 'Д.' + InttoStr(j) + ' ');
end;
Writeln(Rfile);
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ' : ');
for i:=1 to DetC do begin
write(Rfile, RealToStr(Det[i,j],5,0));
end;
Writeln(Rfile);
end;
Writeln(RFile);
Writeln(Rfile,'Результаты.');
Writeln(Rfile,'Детали, рекомендуемые к запуску в текущем месяце');
for j:=1 to DetIncl do begin
Writeln(RFile, 'Дет. ' + InttoStr(plan[j]));
end;
Writeln(Rfile);
Writeln(Rfile,'Остаток фонда по группам технологического оборудования');
Writeln(RFile,' Абсол. Относит.');
for j:=1 to StanC do begin
Write(RFile, 'Станок ' + InttoStr(j) + ': ');
write(Rfile, RealtoStr((StanOst[j]*Stan[j]), 5, 2) + ' ' + RealtoStr((StanOst[j]), 5, 2));
Writeln(RFile);
end;
Flush(RFile);
CloseFile(Rfile);
With Form3 do begin
ListBox1.Clear;
Sg1.RowCount:=StanC+1;
For i:=1 to DetIncl do begin
Listbox1.Items.Add('Деталь ' + IntToStr(Plan[i]));
end;
for j:=1 to StanC do begin
SG1.Cells[0,j]:='Стан. ' + IntToStr(j);
SG1.Cells[1,j]:=RealtoStr((StanOst[j]*Stan[j]), 5, 2);
SG1.Cells[2,j]:=RealtoStr((StanOst[j]), 5, 2);
end;
SG1.Cells[1,0]:='Абсол';
SG1.Cells[2,0]:='Относ.';
Listbox1.Update;
SG1.Update;
end;
Form1.Hide;
Form3.Show;
End;
end.
Соседние файлы в папке SHABLON