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 duplex simulation memo, Telia 1998 %% =========================================================================== %% =========================================================================== % Copyright (C) 1998,99 by Telia Research AB, Lulea, Sweden; All rights reserved. % Project : FSAN duplex model % Author(s) : Tomas Nordstrom (Tomas.B.Nordstrom@Telia.se) % : % % CVS: $Id: plotTTstructure.m,v 1.3 1999/03/31 13:31:49 dab 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 %% =========================================================================== topology=tt.topology; traffic=tt.traffic; if nargin<2, % Flag to indicate if we should draw in scale or not inScale=0; end YQ=25; % Quantization used for Y axis no_segments=length(topology(:,1)); % Find total and cummulative length for i=1:no_segments; deltalength(i)=topology{i,1}; 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 (splits and bridge taps to be implemented later) max_tap=200; 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 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,current_ntext); set(h,'HorizontalAlignment','center'); end current_ltext=topology{i,4}; if i>1, h=text((cum_len(i-1)+cum_len(i))/2,-YQ,current_ltext); set(h,'HorizontalAlignment','center'); end; end % Draw 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 node_mark(i) = {[num2str(nt_count)]}; nt_count = nt_count + 1; 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); h=text(cum_len(traffic{i,2}),YQ*(2+no_array(position)),current_ntext); set(h,'HorizontalAlignment','right'); no_array(position) = no_array(position) + 1; end hold off;