function plotTTstructure(tt,inScale); %plotTTstructure - plots a FSAN 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 shoul.d 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: % FSAN xDSL simulation tool manual %% =========================================================================== %% =========================================================================== % Copyright (C) 1998,99 by Telia Research AB, Lulea, Sweden; All rights reserved. % Project : FSAN duplex model % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % % CVS: $Id: plotTTstructure.m,v 1.12 2000/05/10 09:24:30 tono Exp $ %% =========================================================================== % 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 % toplogy 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 %% =========================================================================== 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 size(topology,2)>5, b_tap=1; else b_tap=0; end; YQ=25; % Quantization used for Y axis no_segments=length(topology(:,1)); defFontSize=get(0,'DefaultTextFontSize'); % Find total and cummulative length for i=1:no_segments; deltalength(i)=topology{i,1}; % Take care of bridge taps if b_tap, tap_delta(i)=topology{i,5}; else tap_delta(i)=0; end; end maxlen=sum(deltalength); % 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)); plot([0,total_len], [0, 0]); % Plot base line % Set up axis and title etc. axis([-0.05*total_len 1.05*total_len -2*YQ max_tap]); if ~inScale, set(gca,'xtick',[],'ytick',[]); end; title(tt.name); hold on; % Draw Nodes for i=1:no_segments; current_pos=cum_len(i); current_ntext=topology{i,3}; % If bridge-tap handle it if b_tap, plot([current_pos,current_pos],[0,tap_delta(i)]); if tap_delta(i)>0, plot(current_pos,tap_delta(i),'ko'); end; end; % Print Node names if ((length(current_ntext)>0) & (current_ntext(1) == 'C')) % If name starts with C assume cabinet or central office plot(current_pos,0,'go'); h=text(current_pos,YQ,current_ntext); set(h,'HorizontalAlignment','center'); else % Make other nodes a small distance from line plot([current_pos,current_pos], [0, YQ/5]); plot(current_pos,YQ/5,'r*'); h=text(current_pos,YQ, strcat('.',current_ntext)); set(h,'HorizontalAlignment','left'); end % Print cable names current_ltext=topology{i,4}; current_ltext=strrep(current_ltext,'_','\_'); % Make '_' print OK if i>1, h=text((cum_len(i-1)+cum_len(i))/2,-YQ,current_ltext); set(h,'HorizontalAlignment','center'); if length(current_ltext) > 12, set(h,'FontSize', defFontSize-1); end; end; end % Draw gui.modems (traffic patterns) no_tpatterns=length(traffic(:,1)); no_array=zeros(1,length(topology(:,1))); % Generate letters (or digits) to help indicate start & stop for traffic nt_count=1; for i=1:no_segments switch topology{i,3} case { 'CO' 'CO (e)' } node_mark(i) = {'E'}; case {'Cab (c)' 'Cab' 'C'} node_mark(i) = {'C'}; case {'NT (x)' 'Node (x)'} node_mark(i) = {'X'}; case {'NT (c)' 'Node (c)'} node_mark(i) = {'C'}; case 'NT (r)' node_mark(i) = {'R'}; otherwise if length(topology{i,3})>3, node_mark(i) = {[num2str(nt_count)]}; nt_count = nt_count + 1; else node_mark(i) = {topology{i,3}}; nt_count = nt_count + 1; end; end end % Print text for traffic as "from_node-to_node modem_type no_gui.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); h=text(cum_len(traffic{i,2}),YQ*(2+no_array(position)),current_ntext); set(h,'HorizontalAlignment','right', 'FontSize', defFontSize-2); no_array(position) = no_array(position) + 1; end hold off;