📄 otworz_plik.m
字号:
sp1=sp1((end-1):end);
end
hopfrom=l((sp(8)+1):(sp1(1)-1)); % hop from without port number
cnode=l((sp(2)+1):(sp(3)-1)); % other node
if event=='+'
hfromother=strcmp(hopfrom, cnode); % c3=c9
if hfromother
event='s';
fwdnode='0'; % -Hd
onode='0'; % -Ms
level=' AGT ';
else % to the queue after receiving c3~=c9
event='r';
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='-1'; %hop from
end
elseif event=='-' % (mac) c3==c9
hfromother=strcmp(hopfrom, cnode); % c3=c9
if hfromother
event='s';
level=' MAC ';
fwdnode='0';
onode='0';
else % forward
event='f';
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='0';
end
elseif event=='d' % drop
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='0';
elseif event=='r' % receive
level=' MAC ';
fwdnode='0';
onode=cnode;
cnode=l((sp(3)+1):(sp(4)-1));
end
if lsp==11
pid=l((sp(11)+1):(end-1));
else
pid=l((sp(11)+1):(sp(12)-1));
end
pid=pid(pid~=13 & pid~=10);
fwrite(fidw,[event, l(sp(1):sp(2)), cnode, level, pid, ...
[l(sp(4):sp(5)), char(zeros(1, 15-(sp(5)-sp(4)))+32)], l((sp(5)+1):sp(6)), ...
onode, 32, hopfrom, l(sp(9):(sp1(2)-1)), 32, fwdnode, l(sp(10):(sp(11)-1)),10], 'char');
end
end
l=fgets(fid);
end
fclose(fidw);
fclose(fid);
TRACEFORMAT=2;
HEX==0;
elseif length(findstr(l, 'mixed13'))
USUNPLIK=0;
fclose('all');
fidw=fopen(strcat(katalog,'temp'), 'wt');
if length(findstr(l, 'hex'))
HEX=1;
end
fprintf(fidw,'tracegraph\n');
fid=fopen(strcat(katalog, plik));
l=fgets(fid);
tint=TSTART~=-1 & TEND~=-1;
while l~=-1
%event, time, CN, AGT_RTR_IFQ_MAC, ID, type, size, ON, hopf, hopto, fwd_node, seq#
event=l(1);
if l(2)==32 & (event=='s' | event=='r' | event=='f' | event=='d') & length(findstr(l, '-Is'))
if tint
t=str2double(wytnij(l,'-t',3,32));
if t<TSTART
continue;
end
if t>TEND
break;
end
end
p=wytnij(l,'-It',4,32);
if HEX==0
lw=[l(1),wytnij(l,'-t',3,32),wytnij(l,'-Ni',4,32),wytnij(l,'-Nl',4,32), ...
wytnij(l,'-Ii',4,32),p,char(zeros(1,15-length(p))+32),wytnij(l,'-Il',4,32),wytnij(l,'-Ms',4,32), ...
wytnij(l,'-Is',4,46),wytnij(l,'-Id',4,46),wytnij(l,'-Hd',4,32)];
else
lw=[l(1),wytnij(l,'-t',3,32),wytnij(l,'-Ni',4,32),wytnij(l,'-Nl',4,32), ...
wytnij(l,'-Ii',4,32),p,char(zeros(1,15-length(p))+32),wytnij(l,'-Il',4,32), 32, num2str(hex2dec(wytnij(l,'-Ms',4,32))), ...
wytnij(l,'-Is',4,46),wytnij(l,'-Id',4,46),wytnij(l,'-Hd',4,32)];
end
if length(findstr(l,'-Pi'))
fwrite(fidw,[lw,wytnij(l,'-Pi',4,32),10],'char');
elseif length(findstr(l,'-Ps'))
fwrite(fidw,[lw,wytnij(l,'-Ps',4,32),10],'char');
else
fwrite(fidw,[lw,' -1',10],'char'); % there's no seq#
end
elseif l(2)==32 & (event=='+' | event=='r' | event=='-' | event=='d') %if wired
sp=findstr(l,32); % searching for a space
lsp=length(sp);
if lsp==11 | lsp==15
if tint
t=str2double(l((sp(1)+1):(sp(2)-1)));
if t<TSTART
continue;
end
if t>TEND
break;
end
end
sp1=findstr(l,':');
if isempty(sp1)
sp1=findstr(l,'.'); % if there is no : find .
sp1=sp1((end-1):end);
end
hopfrom=l((sp(8)+1):(sp1(1)-1)); % hop from without port number
cnode=l((sp(2)+1):(sp(3)-1)); % other node
if event=='+'
hfromother=strcmp(hopfrom, cnode); % c3=c9
if hfromother
event='s';
fwdnode='0'; % -Hd
onode='0'; % -Ms
level=' AGT ';
else % to the queue after receiving c3~=c9
event='r';
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='-1'; %hop from
end
elseif event=='-' % (mac) c3==c9
hfromother=strcmp(hopfrom, cnode); % c3=c9
if hfromother
event='s';
level=' MAC ';
fwdnode='0';
onode='0';
else % forward
event='f';
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='0';
end
elseif event=='d' % drop
level=' RTR ';
fwdnode=l((sp(3)+1):(sp(4)-1));
onode='0';
elseif event=='r' % receive
level=' MAC ';
fwdnode='0';
onode=cnode;
cnode=l((sp(3)+1):(sp(4)-1));
end
if lsp==11
pid=l((sp(11)+1):(end-1));
else
pid=l((sp(11)+1):(sp(12)-1));
end
pid=pid(pid~=13 & pid~=10);
fwrite(fidw,[event, l(sp(1):sp(2)), cnode, level, pid, ...
[l(sp(4):sp(5)), char(zeros(1, 15-(sp(5)-sp(4)))+32)], l((sp(5)+1):sp(6)), ...
onode, 32, hopfrom, l(sp(9):(sp1(2)-1)), 32, fwdnode, l(sp(10):(sp(11)-1)),10], 'char');
end
end
l=fgets(fid);
end
fclose(fidw);
fclose(fid);
TRACEFORMAT=2; % new trace compatible with the second trace format
HEX==0;
else %other trace formats
if AUTOFORMAT==0
if length(findstr(l, 'hex'))
HEX=1;
USUNPLIK=0;
fidw=fopen(strcat(katalog,'temp'), 'wt');
fprintf(fidw,'tracegraph hex\n');
fclose(fidw);
end
fclose('all');
fid=fopen(strcat(katalog, plik));
while l(1)~='r' & l~=-1
l=fgets(fid);
if (l(1)=='+' | l(1)=='-') & l(2)==32
break;
end
end
fclose(fid);
else
fclose(fid);
end
if length(findstr(l,'-t'))
fid=fopen(strcat(katalog, plik));
fidw=fopen(strcat(katalog,'temp'), 'wt');
l=fgets(fid);
tint=TSTART~=-1 & TEND~=-1;
while l~=-1
%event, time, CN, AGT_RTR_IFQ_MAC, ID, type, size, ON, hopf, hopto, fwd_node, seq#
if l(2)==32 & (l(1)=='s' | l(1)=='r' | l(1)=='f' | l(1)=='d') & length(findstr(l, '-Is'))
if tint
t=str2double(wytnij(l,'-t',3,32));
if t<TSTART
continue;
end
if t>TEND
break;
end
end
p=wytnij(l,'-It',4,32);
lw=[l(1),wytnij(l,'-t',3,32),wytnij(l,'-Ni',4,32),wytnij(l,'-Nl',4,32), ...
wytnij(l,'-Ii',4,32),p,char(zeros(1,15-length(p))+32),wytnij(l,'-Il',4,32),wytnij(l,'-Ms',4,32), ...
wytnij(l,'-Is',4,46),wytnij(l,'-Id',4,46),wytnij(l,'-Hd',4,32)];
if length(findstr(l,'-Pi'))
fwrite(fidw,[lw,wytnij(l,'-Pi',4,32),10],'char');
elseif length(findstr(l,'-Ps'))
fwrite(fidw,[lw,wytnij(l,'-Ps',4,32),10],'char');
else
fwrite(fidw,[lw,' -1',10],'char'); % there's no seq#
end
end
l=fgets(fid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -