打印本文 打印本文 关闭窗口 关闭窗口
模拟进程调度(delphi写的)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1850  更新时间:2009/4/23 18:26:30  文章录入:mintao  责任编辑:mintao
bs[1].arv:=strtoint(edit2.text );
pcbs[1].svt:=strtoint(edit3.text );
pcbs[1].sttflg:=true;
pcbs[1].fnhflg:=false;
pcbs[2].name:=edit4.text;
pcbs[2].arv:=strtoint(edit5.text );
pcbs[2].svt:=strtoint(edit6.text );
pcbs[2].sttflg:=false;
pcbs[2].fnhflg:=false;
pcbs[3].name:=edit7.text;
pcbs[3].arv:=strtoint(edit8.text );
pcbs[3].svt:=strtoint(edit9.text );
pcbs[3].sttflg:=false;
pcbs[3].fnhflg:=false;
pcbs[4].name:=edit10.text;
pcbs[4].arv:=strtoint(edit11.text );
pcbs[4].svt:=strtoint(edit12.text );
pcbs[4].sttflg:=false;
pcbs[4].fnhflg:=false;
nullflag:=false;
except
nullflag:=true;
showmessage(''''请将数据填完整'''');
end;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
var
m:integer;


begin

if ((flag=true )and (ntp=false)and (nullflag=false)) then
begin//if falg=true then
count:=count+1;

listbox1.Items.Add(inttostr(count));
for m:=1 to 4do
begin //for m:=1 to 5 do
if((pcbs[m].sttflg=true) and (pcbs[m].fnhflg=false))then
begin//if(pcb[m].sttflg=true and pcb[m].fnhflg=false)
if count=pcbs[m].stt+pcbs[m].svt then
begin//if (count=pcbs[m].stt+pcbs[m].svt)then
pcbs[m].fnhflg:=true;
//timer4.Enabled:=false;
pro:=0;

//timer4.Enabled:=true;
listbox1.Items.Add(''''进程:''''+pcbs[m].name+''''完成!!'''');
if m<4 then
begin//if m<4 then
//pcbs[m+1].sttflg:=true;
//pcbs[m+1].stt:=count;
forword:=true;
end;//if m<4 then
pcbs[m].fnt:=count;
pcbs[m].zzsj:=pcbs[m].fnt-pcbs[m].arv;
pcbs[m].dqsj:=pcbs[m].zzsj/(pcbs[m].fnt-pcbs[m].stt);
end;//if (count=pcbs[m].stt+pcbs[m].svt)then
end;//if(pcb[m].sttflg=true and pcb[m].fnhflg=false)
end;//for m:=1 to 5 do

if pcbs[4].fnhflg=true then
begin
ntp:=true;
edit13.Text:=inttostr(pcbs[1].stt);
edit14.Text:=inttostr(pcbs[1].stt+pcbs[1].svt);
edit15.Text:=inttostr(pcbs[1].zzsj);
edit16.Text:=floattostr(pcbs[1].dqsj);
edit17.Text:=inttostr(pcbs[2].stt);
edit18.Text:=inttostr(pcbs[2].stt+pcbs[2].svt);
edit19.Text:=inttostr(pcbs[2].zzsj);
edit20.Text:=floattostr(pcbs[2].dqsj);
edit21.Text:=inttostr(pcbs[3].stt);
edit22.Text:=inttostr(pcbs[3].stt+pcbs[3].svt);
edit23.Text:=inttostr(pcbs[3].zzsj);
edit24.Text:=floattostr(pcbs[3].dqsj);
edit25.Text:=inttostr(pcbs[4].stt);
edit26.Text:=inttostr(pcbs[4].stt+pcbs[4].svt);
edit27.Text:=inttostr(pcbs[4].zzsj);
edit28.Text:=floattostr(pcbs[4].dqsj);
end;
for m:=1 to 4 do
begin
if ((count>=pcbs[m].arv) and (pcbs[m].sttflg=false))  then
if forword=true then
begin
pcbs[m].sttflg:=true;
pcbs[m].stt:=count;
forword:=false;
end;//3and
end;// for m:=1 to 4 do
gauge1.MaxValue:=pcbs[1].svt;
gauge2.MaxValue:=pcbs[2].svt;
gauge3.MaxValue:=pcbs[3].svt;
gauge4.MaxValue:=pcbs[4].svt;
if pcbs[1].sttflg=true and  pcbs[1].fnhflg=false then
begin
//gauge1.Progress:=gauge1.MaxValue:=pcbs[1].svt;
gauge1.Progress:=count-pcbs[1].stt;
end// if pcbs[1].sttflg=true and  pcbs[1].fnhflg=false then
else if pcbs[1].fnhflg=true then
gauge1.Progress:=pcbs[1].svt;
if pcbs[2].sttflg=true and  pcbs[2].fnhflg=false then
begin
gauge2.Progress:=count-pcbs[2].stt;
end// if pcbs[1].sttflg=true and  pcbs[1].fnhflg=false then
else if pcbs[2].fnhflg=true then
gauge2.Progress:=pcbs[2].svt;


if pcbs[3].sttflg=true and  pcbs[3].fnhflg=false then
begin
gauge3.Progress:=count-pcbs[3].stt;
end// if pcbs[1].sttflg=true and  pcbs[1].fnhflg=false then
else if pcbs[3].fnhflg=true then
gauge3.Progress:=pcbs[3].svt;


if pcbs[4].sttflg=true and  pcbs[4].fnhflg=false then
begin
gauge4.Progress:=count-pcbs[4].stt;
end// if pcbs[1].sttflg=true and  pcbs[1].fnhflg=false then
else if pcbs[4].fnhflg=true then
gauge4.Progress:=pcbs[4].svt;
end; //if falg=true then


end;//procedure over

procedure TForm1.Button3Click(Sender: TObject);
begin
form1.Close;
//end.//do over
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
forword:=false;
subtemp:=0;
j:=1;
openflg:=true;
tempid:=1;
fnhnum:=0;
pcbnum:=0;
ntp:=false;
tempok:=false;
flag:=false;
gauge1.Progress:=0;
gauge2.Progress:=0;
gauge3.Progress:=0;
gauge4.Progress:=0;
button2.Enabled:=true;
button1.Enabled:=true;
count:=-1;
pro:=0;
  //pcbnum:integer=1;
writeflg:=0;
flag:=false;
nullflag:=false;
edit1.Text:='''''''';
edit2.Text:='''''''';
edit3.Text:='''''''';
edit4.Text:='''''''';
edit5.Text:='''''''';
edit6.Text:='''''''';
edit7.Text:='''''''';
edit8.Text:='''''''';
edit9.Text:='''''''';
edit10.Text:='''''''';
edit11.Text:='''''''';
edit12.Text:='''''''';
edit13.Text:=''''系统填写'''';
edit14.Text:=''''系统填写'''';


edit15.Text:=''''系统填写'''';
edit16.Text:=''''系统填写'''';
edit17.Text:=''''系统填写'''';
edit18.Text:=''''系统填写'''';
edit19.Text:=''''系统填写'''';
edit20.Text:=''''系统填写'''';
edit21.Text:=''''系统填写'''';
edit22.Text:=''''系统填写'''';
edit23.Text:=''''系统填写'''';
edit24.Text:=''''系统填写'''';
edit25.Text:=''''系统填写'''';
edit26.Text:=''''系统填写'''';
edit27.Text:=''''系统填写'''';
edit28.Text:=''''系统填写'''';
pcbs[1].fnhflg:=false;
pcbs[1].sttflg:=false;
pcbs[2].fnhflg:=false;
pcbs[2].sttflg:=false;
pcbs[3].fnhflg:=false;
pcbs[3].sttflg:=false;
pcbs[4].fnhflg:=false;
pcbs[4].sttflg:=false;
end;


procedure TForm1.Button5Click(Sender: TObject);
begin
form3.show;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
form1.FormStyle:=fsstayontop;
animatewindow(handle,2000,AW_center);
form1.FormStyle:=fsnormal;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
edit1.Text:=''''A'''';
edit2.Text:=''''0'''';
edit3.Text:=''''3'''';
edit4.Text:=''''B'''';
edit5.Text:=''''5'''';
edit6.Text:=''''2'''';
edit7.Text:=''''C'''';
edit8.Text:=''''5'''';
edit9.Text:=''''3'''';
edit10.Text:=''''D'''';
edit11.Text:=''''5'''';
edit12.Text:=''''2'''';
end;

procedure TForm1.Timer4Timer(Sender: TObject);
begin
if ((pcbs[1].arv=count) and  (pcbs[1].sttflg=false))  then
begin
forword:=true;
end;
end;

end.

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls;

type
  TForm2 = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  type

pcb=record
name:string;
arv:integer;
svt:integer;
stt:integer;
fnt:integer;
zzsj:integer;
dqsj:real;
fnhflg:bool;
sttflg:bool;
end;
pcbx=array[1..4]of pcb;

var
  Form2: TForm2;
  pcbs:pcbx;
implementation
uses Unit1;
{$R *.dfm}

end.
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, jpeg, ExtCtrls;

type
  TForm3 = class(TForm)
    RichEdit1: TRichEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

end.

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口