logo search
Дипломы2 / Андрей / Чужие дипломы / Диплом1 / диплом

Приложение 4

Листинг тестирующего приложения

{===== Проект " Шлюз ВТК-12 " =======}

{ Тестирующее приложение (эмулятор ИСУМ) }

{ ОАО "Морион" ИТЦ СТ 2003г. }

{ Автор: Бажгин М.С. }

{=========================================}

unit unittest;

interface

uses

Windows, SysUtils, Classes, StdCtrls, Controls, Forms,

shlusobj, ExtCtrls, FileCtrl;

type

TFormMain = class(TForm)

Edit: TEdit;

DirectoryListBox1: TDirectoryListBox;

MemoCfg: TMemo;

ButtonScan: TButton;

DriveComboBox1: TDriveComboBox;

ListBoxIP: TListBox;

ButtonView: TButton;

MemoUnit: TMemo;

procedure ButtonScanClick(Sender: TObject);

procedure DriveComboBox1Change(Sender: TObject);

procedure ButtonViewClick(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

FormMain: TFormMain;

implementation

{$R *.DFM}

//описание интерфейсных функцию шлюза

Function GetGateInfo:PChar; stdcall; external 'gate.dll';

Function GetNEData(index: LongInt; var List: TList):Byte; stdcall; external 'gate.dll';

Procedure GateInit(idGate:word; Path:PChar; var NEList:TStringList); stdcall; external 'gate.dll';

Procedure GateClose; stdcall; external 'gate.dll';

//-------------------------------------------------------------------------

procedure TFormMain.FormCreate(Sender: TObject);

begin

MemoUnit.Lines.Add('Подключенные модули:');

MemoUnit.Lines.Add(' gate.dll - '+GetGateInfo);

end;

//-------------------------------------------------------------------------

procedure TFormMain.ButtonScanClick(Sender: TObject);

var i:longword;

s:string;

tmpList:TStringList;

begin

Edit.Text:='Ждите';

Edit.Update;

s:=DirectoryListBox1.Directory;

if s[length(s)]='\' then s:=copy(s,1,Length(s)-1);

tmpList:=TStringList.Create;

GateInit(1,PChar(s),tmpList);

Edit.Text:='Количество конфигураций: '+IntToStr(tmpList.Count);

ListBoxIP.Items.Clear;

for i:=1 to tmpList.Count do

ListBoxIP.Items.Add(tmpList.strings[i-1]);

end;

//-------------------------------------------------------------------------

procedure Encode(List:TList);

procedure AddMemo(s:string);

begin

FormMain.MemoCfg.Lines.Add(s);

end;

var i:integer;

s:string;

tmpNE:TNE;

tmpCPack:TCPack;

tmpAG: TAG;

tmpTTPBid:TTTPBid;

tmpTTPSink:TTTPSink;

tmpTTPSource:TTTPSource;

tmpLinkEndSource:TLinkEndSource;

tmpLinkEndSink:TLinkEndSink;

tmpCTPSource:TCTPSource;

tmpCTPSink:TCTPSink;

begin

if List.Count=0 then exit;

FormMain.MemoCfg.Visible:=false;

FormMain.MemoCfg.Lines.Clear;

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

begin

case TTop(List[i]).TypeOBJ of

cNE:

begin

tmpNE:=List[i];

AddMemo('NE ID:'+IntToStr(tmpNE.ID)+'; Type:'+tmpNE.TypeNE+'; Name:'+tmpNE.Name+'; Packs:'+IntToStr(tmpNE.numCPacks)+'; AG:'+IntToStr(tmpNE.numAGs)+'; LinkEnd:'+IntToStr(tmpNE.numLinkEnds));

end;

cCPack:

begin

tmpCPack:=List[i];

AddMemo(' CPack ID:'+IntToStr(tmpCPack.ID)+'; Type:'+tmpCPack.TypecPack);

end;

cAG:

begin

tmpAG:=List[i];

AddMemo(' AG ID:'+IntToStr(tmpAG.ID)+'; TTP Count:'+IntToStr(tmpAG.numTTPs));

end;

cTTPBid:

begin

tmpTTPBid:=List[i];

AddMemo(' TTPBid ID:'+IntToStr(tmpTTPBid.ID)+'; Name:'+tmpTTPBid.Name+'; TTPSource_ID:'+IntToStr(tmpTTPBid.TTPSource_ID)+'; TTPSink_ID:'+IntToStr(tmpTTPBid.TTPSink_ID));

end;

cTTPSource:

begin

tmpTTPSource:=List[i];

case tmpTTPSource.SignalID of

e0CI: s:='e0CI';

e1CI: s:='e1CI';

end;

AddMemo(' TTPSource ID:'+IntToStr(tmpTTPSource.ID)+'; Name:'+tmpTTPSource.Name+'; TP_ID:'+IntToStr(tmpTTPSource.tp_id)+'; CPack_ID:'+IntToStr(tmpTTPSource.cPack_id)+'; LE_ID:'+IntToStr(tmpTTPSource.linkend_id)+'; Signal:'+s);

end;

cTTPSink:

begin

tmpTTPSink:=List[i];

case tmpTTPSink.SignalID of

e0CI: s:='e0CI';

e1CI: s:='e1CI';

end;

AddMemo(' TTPSink ID:'+IntToStr(tmpTTPSink.ID)+'; Name:'+tmpTTPSink.Name+'; TP_ID:'+IntToStr(tmpTTPSink.tp_id)+'; CPack_ID:'+IntToStr(tmpTTPSink.cPack_id)+'; LE_ID:'+IntToStr(tmpTTPSink.linkend_id)+'; Signal:'+s);

end;

cLinkEndSource:

begin

tmpLinkEndSource:=List[i];

AddMemo(' LinkEndSource ID:'+IntToStr(tmpLinkEndSource.ID)+'; TP_ID:'+IntToStr(tmpLinkEndSource.TTP_id)+'; CTP Count:'+IntToStr(tmpLinkEndSource.numCTPs));

end;

cLinkEndSink:

begin

tmpLinkEndSink:=List[i];

AddMemo(' LinkEndSink ID:'+IntToStr(tmpLinkEndSink.ID)+'; TP_ID:'+IntToStr(tmpLinkEndSink.TTP_id)+'; CTP Count:'+IntToStr(tmpLinkEndSink.numCTPs));

end;

cCTPSource:

begin

tmpCTPSource:=List[i];

case tmpCTPSource.SignalID of

e0CI: s:='e0CI';

e1CI: s:='e1CI';

end;

AddMemo(' CTPSource ID:'+IntToStr(tmpCTPSource.ID)+'; TP_ID:'+IntToStr(tmpCTPSource.tp_id)+'; CPack_ID:'+IntToStr(tmpCTPSource.cPack_id)+'; Signal:'+s);

end;

cCTPSink:

begin

tmpCTPSink:=List[i];

case tmpCTPSink.SignalID of

e0CI: s:='e0CI';

e1CI: s:='e1CI';

end;

AddMemo(' CTPSink ID:'+IntToStr(tmpCTPSink.ID)+'; TP_ID:'+IntToStr(tmpCTPSink.tp_id)+'; CPack_ID:'+IntToStr(tmpCTPSink.cPack_id)+'; Signal:'+s);

end;

end;

end;

FormMain.MemoCfg.Visible:=true;

end;

//-------------------------------------------------------------------------

procedure TFormMain.ButtonViewClick(Sender: TObject);

var List:TList;

i:integer;

begin

List:=TList.Create;

i:=GetNEData(ListBoxIP.ItemIndex+1,List);

if i=0 then

Encode(List);

Edit.Text:='Код ошибки: '+IntToStr(i);

List.Clear;

List.Free;

end;

end.