Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
MIRA / диплом1.doc
Скачиваний:
18
Добавлен:
16.04.2013
Размер:
546.82 Кб
Скачать

Приложение а Подпрограмма визуального отображения.

procedure TMainForm.SpeedButtonModelierenClick(Sender: TObject);

label konets,konets1;

type

OneLine= Record

Segment: string;

Perehod: string;

Ttime: real;

Ddelay: real;

FromPos: String;

FromCount: integer;

ToPos: string;

ToCount:integer;

end;

var

TransitionList:TList;

OneRec,one1rec: OneLine;

POneRec: ^OneLine;

F: TextFile;

S,segm,perehod,inputpos,outpos,timestr,timeunit, delaystr, delayunit: string;

i,j,m,prevpos,tmppos,inputfish, outfish, timme, delay:integer;

enablearr:array[1..15] of boolean;

OldNet:TNetObj;

OldPos:TPosObj;

k,tiime:extended;

sr:TSearchRec;

found,found1,result:integer;

dl:char;

dir,per:string;

begin

ModelNameRequest.ShowModal;

if ModelNameRequest.ModalResult<>mrOk then

begin

// SpeedButtonModelieren.Enabled:=true;

exit;

end;

found1:=1;

dir:='';

for dl:='c' to 'z' do

if findfirst(uppercase(dl+':\microsim\bin'),faAnyFile,sr)=0 then

begin

dir:=dl+':\microsim\bin\';

found1:=0;

break;

end;

SysUtils.FindClose(sr);

AssignFile(F, dir+ModelNameRequest.Edit1.Text+'.log');

Reset(F);

SpeedButtonModelieren.Visible:=false;

SpeedButtonStop.Visible:=true;

DecimalSeparator:='.';

TransitionList:=TList.Create;

breakModelieren:=false;

Readln(F, S);

Readln(F, S);

while not(EOF(F)) do

begin

Readln(F, S);

new(POneRec);

OneRec.segment:=s[1];

delete(S,1,1);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.perehod:=copy(S,1,(pos(' ',s)-prevpos));

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.Ttime:=strtofloat(copy(S,1,pos(' ',s)-prevpos));

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

// timeunit:=copy(S,1,pos(' ',s)-prevpos);

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.Ddelay:=strtofloat(copy(S,1,pos(' ',s)-prevpos));

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

// delayunit:=copy(S,1,pos(' ',s)-prevpos);

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.FromPos:=copy(S,1,pos(' ',s)-prevpos);

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.FromCount:=strtoint(copy(S,1,pos(' ',s)-prevpos));

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.ToPos:=copy(S,1,pos(' ',s)-prevpos);

delete(s,1,pos(' ',s)-prevpos);

prevpos:=pos(' ',s);

while (pos(' ',s)-prevpos)=0 do

begin

tmppos:=pos(' ',s);

delete(S,pos(' ',s),1);

prevpos:=tmppos;

end;

OneRec.ToCount:=strtoint(copy(S,1,length(s))); //last word

delete(s,1,pos(' ',s)-prevpos);

POneRec^:=OneRec;

TransitionList.Add(POneRec);

Application.ProcessMessages;

if breakModelieren then begin

CloseFile(F);

goto konets;

end;

end;

CloseFile(F);

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListPos.Count-1 do

begin

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).NumPoints:=0;

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).ResetCurrent;

end;

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListNet.Count-1 do

TNETObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).resetpassed;

//start points

for i:=0 to TransitionList.Count -1 do

begin

if (OneLine(TransitionList.Items[i]^). Ttime -OneLine(TransitionList.Items[i]^).Ddelay) = 0 then

begin

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListPos.Count-1 do

begin

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).FromPos then

begin

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).setcurrent;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

end;

//====

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListNet.Count-1 do

begin

for m:=i+1 to TransitionList.Count -1 do

begin

if (OneLine(TransitionList.Items[m]^).ToPos)=OneLine(TransitionList.Items[i]^).FromPos then

begin

per:=OneLine(TransitionList.Items[m]^).Perehod;

break;

end;

end;

if TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).Perehod then//per then

begin

TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).setpassed;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

end;

//====

end;

end;

//delay

k:=0;

while k<119999 do

begin

k:=k+1;

application.processmessages;

if breakmodelieren then goto konets;

end;

i:=0;

while i< TransitionList.Count -1 do

begin

k:=0;

while k<OneLine(TransitionList.Items[i]^).Ddelay*29999 do

begin

k:=k+1;

application.processmessages;

if breakmodelieren then goto konets;

end;

tiime:=(OneLine(TransitionList.Items[i]^).Ttime);

StatusLine.SimpleText:='Current modeling time: '+floattostr(tiime);

while (OneLine(TransitionList.Items[i]^).Ttime) = tiime do

begin

k:=0;

while k<99999 do

begin

k:=k+1;

application.processmessages;

if breakmodelieren then goto konets;

end;

application.processmessages;

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListPos.Count-1 do

begin

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).FromPos then

begin

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).TypePos=QPos then

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).removepoint;

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).NumPoints=0 then

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).resetcurrent;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).ToPos then

begin

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).setcurrent;

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).TypePos=QPos then

TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[j]).addpoint;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

end;

for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListNet.Count-1 do

begin

for m:=i+1 to TransitionList.Count -1 do

begin

if (OneLine(TransitionList.Items[m]^).FromPos)=OneLine(TransitionList.Items[i]^).ToPos then

begin

per:=OneLine(TransitionList.Items[m]^).Perehod;

break;

end;

end;

if TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).GetObjectNameNum=per then

begin

TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).setpassed;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

if TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).Perehod then

begin

for m:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListPos.Count-1 do

if TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[m]).GetObjectNameNum=OneLine(TransitionList.Items[i]^).FromPos then

if (TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[m]).TypePos<>QPos) or

(TPosObj((ActiveMDIChild as TChildForm).GraphSegm.ListPos.Items[m]).numpoints=0) then

TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).resetpassed;

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

end;

inc(i);

end;

//

end;

{ for j:=0 to (ActiveMDIChild as TChildForm).GraphSegm.ListNet.Count-1 do

begin

if TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).GetObjectNameNum=perehod then

begin

if OldNet<>nil then OldNet.ResetPassed;

TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).setpassed;

OldNet:=TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]);

(ActiveMDIChild as TChildForm).GraphSegm.paint;

end;

showmessage(TNetObj((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Items[j]).GetObjectNameNum+' '+inttostr((ActiveMDIChild as TChildForm).GraphSegm.ListNet.Count));

end;

// showmessage('#'+segm+'# #'+perehod+'# #'+timestr+'# #'+timeunit+'# #'+delaystr+'# #'+delayunit+'# #'+inputpos+'# #'+inttostr(inputfish)+'# #'+outpos+'# #'+inttostr(outfish)+'#');

}

konets:

TransitionList.free;

if messagedlg('Удалить '+ModelNameRequest.Edit1.Text+'.log?', mtConfirmation,

[mbYEs,mbNo], 0)=mrOk then DeleteFile(pchar(dir+ModelNameRequest.Edit1.Text+'.log'));

SpeedButtonModelieren.Visible:=true;

SpeedButtonStop.Visible:=false;

end;

procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

// if key=VK_ESCAPE then breakModelieren:=true;

end;

procedure TMainForm.SpeedButtonStopClick(Sender: TObject);

begin

breakmodelieren:=true;

end;

2

Дипломный проект Каф. ИПОВС, 1999 г.

Соседние файлы в папке MIRA