function plotTTstructure(tt,inScale) %plotTTstructure - plots a scenario topology and traffic structure % % Parameter: tt.name name of this topology and traffic scenario % Parameter: tt.topology the topology % Parameter: tt.traffic the traffic pattern % Parameter: inScale flag to indicate if we should draw in % scale or not % % Example(s): % plotTTstructure(ex.tt) will plot a topology and traffic information % % plotTTstructure(ex.tt,1) will plot a topology and traffic information % in a true length scale. While plotTTstructure(ex.tt,0) will modify the % length scale to better fit the text into the window. % % Reference: % FTW's xDSLsimu manual %% =========================================================================== %% =========================================================================== % Copyright (C): % 1998-1999 by Telia Research AB, Lulea, Sweden; % 2000-2009 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : FTW's xDSLsimu % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % : Bo Engstrom (bosse@upzide.com) % : Petr Kadlec (kadlec@ftw.at) % % CVS: $Id: plotTTstructure.m 752 2009-01-02 13:03:52Z tono $ %% =========================================================================== % Change History % 1998-10-19 (ToNo) Created % 1998-11-12 (ToNo) Modified to new parameter setup % 1998-11-26 (ToNo) Changed y axis into meters % 1998-12-22 (ToNo) Added comments % 1999-01-07 (ToNo) Fixed a bug when traffic rows was less than % topology rows % 1999-01-21 (Gil/ToNo) Modified appearance % 1999-08-12 (ToNo) Added support for bridge taps (todo) % 1999-08-15 (DaB) Added bridgetap plot % 2001-06-14 (Bosse) Octave port % 2001-10-18 (ToNo) Fixed problem of comparing a null string with 'C' % 2002-07-02 (Peka) Octave to Matlab port % 2002-07-23 (Peka) Update of the figure setup % 2003-11-03 (ToNo) Lists now use cell arrays for both Octave and Matlab % 2004-08-06 (ToNo) Turned of axes and adjusted some text positions % 2004-10-04 (ToNo) Cleared out some more plotting glitches % 2005-10-27 (ToNo) Cleaned up plotting differences octave/matlab % 2008-10-09 (ToNo) Made use of octave 3.0's matlab compatibility %% =========================================================================== topology=tt.topology; traffic=tt.traffic; if nargin<2, % Flag to indicate if we should draw in scale or not inScale=0; end % added-------- if length(topology{1})>5, b_tap=1; else b_tap=0; end; YQ=20; % Quantization used for Y axis no_segments=length(topology); % Find total and cummulative length deltalength=zeros(1,no_segments); tap_delta=zeros(1,no_segments); for i=1:no_segments; deltalength(i)=topology{i}{1}; % Take care of bridge taps if b_tap, tap_delta(i)=topology{i}{5}; end; end % Adjust if we do not plot in scale newdelta=deltalength; if ~inScale, newdelta(deltalength>500)=(newdelta(deltalength>500)-500)./5 + 500; newdelta(deltalength<200)=200; newdelta(1)=0; end; total_len=sum(newdelta); cum_len=cumsum(newdelta); % Find maximum (bridge) tap length max_tap=max(200,sum(tap_delta)); % Start plotting defFontSize=12; if onMatlab reset(gca); set(gcf,'defaultaxesfontsize',defFontSize); else reset_cga; end set(gcf,'DefaultLineLineWidth',3); %olddefFontSize=get(0,'DefaultTextFontSize'); set(gcf,'defaulttextfontsize',defFontSize); % Set up title etc. title(strrep(tt.name,'_','-')) axis([-0.05*total_len 1.05*total_len -YQ max_tap]); hold on; % Plot base line plot([0,total_len], [0, 0],'b-'); % Draw Nodes for i=1:no_segments; current_pos=cum_len(i); current_ntext=topology{i}{3}; current_ntext=strrep(current_ntext,'_','-'); % If bridge-tap handle it if b_tap, plot([current_pos,current_pos],[0,tap_delta(i)],'r-'); if tap_delta(i)>0, plot(current_pos,tap_delta(i),'ko'); end; end; % Print Node names if ((length(current_ntext)>0)&& ... ~isempty(findstr(current_ntext,'C'))&&(findstr(current_ntext,'C')==1)) % If name starts with C assume cabinet or central office plot(current_pos,0,'go'); h=text(current_pos,YQ/2,current_ntext); set(h,'HorizontalAlignment','center'); set(h,'fontsize', defFontSize+2); else % Make other nodes a small distance from line plot([current_pos,current_pos], [0, YQ/10],'b-'); plot(current_pos,YQ/10,'r*'); h=text(current_pos,YQ/2, current_ntext); set(h,'HorizontalAlignment','left'); set(h,'fontsize', defFontSize+2); end % Print cable names current_ltext=topology{i}{4}; current_ltext=strrep(current_ltext,'_','-'); if i>1, h=text((cum_len(i-1)+cum_len(i))/2,-0.5*YQ,current_ltext); set(h,'HorizontalAlignment','center'); set(h,'fontsize', defFontSize-2); end; end % Draw modems (traffic patterns) no_tpatterns=length(traffic); no_array=zeros(1,length(topology)); % Generate letters (or digits) to help indicate start & stop for traffic nt_count=1; node_mark=cell(1,no_segments); for i=1:no_segments ti3=topology{i}{3}; if strcmp(ti3,'CO') || strcmp(ti3,'CO (e)'), node_mark{i} = 'CO'; elseif strcmp(ti3,'Cab (c)') || strcmp(ti3,'Cab') || strcmp(ti3,'C') node_mark{i} = 'Cab'; elseif strcmp(ti3,'NT (x)') || strcmp(ti3,'Node (x)') node_mark{i} = 'X'; elseif strcmp(ti3,'NT (c)') || strcmp(ti3,'Node (c)') node_mark{i} = 'C'; elseif strcmp(ti3,'NT (r)') node_mark{i} = 'R'; else if length(ti3)>3, node_mark{i} = num2str(nt_count); nt_count = nt_count + 1; else node_mark{i} = ti3; nt_count = nt_count + 1; end; end end % Print text for traffic as "from_node-to_node modem_type no_modems" % at the right position for i=1:no_tpatterns; position = traffic{i}{2}; modem_type = traffic{i}{3}; no_modem = traffic{i}{4}; tx_pos=node_mark{traffic{i}{1}}; rx_pos=node_mark{traffic{i}{2}}; current_ntext=sprintf('%d %s %s->%s',no_modem,modem_type,tx_pos,rx_pos); current_ntext=strrep(current_ntext,'_','-'); text(cum_len(traffic{i}{2}),YQ*(1+i/4), current_ntext,... 'HorizontalAlignment','right'); no_array(position) = no_array(position) + 1; end plot(0,0,'g') axis([-0.05*total_len 1.05*total_len -YQ YQ*(2+i/4)]); axis('off') hold('off');