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-2003 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,v 3.3 2003/11/03 12:33:22 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 % 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 %% =========================================================================== 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=25; % Quantization used for Y axis no_segments=length(topology); %defFontSize=get(0,'DefaultTextFontSize'); defFontSize=10; % 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)); % Set up title etc. graw('set nokey;') if ~inScale, graw('set noxtics;set noytics;set noborder;') if onMatlab axis('on'); set(gca,'xtick',[],'ytick',[]); end end; title(tt.name); axis([-0.05*total_len 1.05*total_len -2*YQ max_tap]); hold on; plot([0,total_len], [0, 0],'b-'); % Plot base line % 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)],'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'); if onMatlab h=text(current_pos,YQ,current_ntext); set(h,'HorizontalAlignment','center'); else text(current_pos,YQ,current_ntext); end else % Make other nodes a small distance from line plot([current_pos,current_pos], [0, YQ/5],'b-'); plot(current_pos,YQ/5,'r*'); if onMatlab h=text(current_pos,YQ, strcat('.',current_ntext)); set(h,'HorizontalAlignment','left'); else text(current_pos,YQ, strcat('.',current_ntext)); end end % Print cable names current_ltext=topology{i}{4}; if i>1, if onMatlab h=text((cum_len(i-1)+cum_len(i))/2,-YQ,current_ltext); set(h,'HorizontalAlignment','center'); else text((cum_len(i-1)+cum_len(i))/2,-YQ,current_ltext); end if ((length(current_ltext) > 12) & onMatlab), set(h,'FontSize', defFontSize-1); end; 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=list; for i=1:no_segments ti3=topology{i}{3}; if strcmp(ti3,'CO') | strcmp(ti3,'CO (e)'), node_mark{i} = 'E'; elseif strcmp(ti3,'Cab (c)') | strcmp(ti3,'Cab') | strcmp(ti3,'C') node_mark{i} = 'C'; 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); if onMatlab h=text(cum_len(traffic{i}{2}),YQ*(2+no_array(position)),... current_ntext); set(h,'HorizontalAlignment','right', 'FontSize', defFontSize-2); else text(cum_len(traffic{i}{2}),YQ*(2+no_array(position)), current_ntext); end no_array(position) = no_array(position) + 1; end plot(0,0,'g') hold('off'); graw('reset;'); if ~onMatlab figure; end