function uiResults(ex,result,modemno,plottype); %% =========================================================================== %uiResults - Show experiment results in a nice (and interactive) way % % Parameter: ex The experiment setup used for this result % Parameter: result The experiment result structure % Parameter: modemno The current selected modem % % Example(s): % result = evalExperiment; % uiResults(ex,result); % Show results (modem 1 selected) % or: % uiResults(ex,result,modemno); % Starts with modemno selected % % Reference: %% =========================================================================== %% =========================================================================== % Copyright (C): % 1998-2000 by Telia Research AB, Lulea, Sweden; % 2001-2003 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : FTW's xDSLsimu % Author(s) : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % % CVS: $Id: uiResults.m,v 3.3 2003/11/03 12:33:22 tono Exp $ %% =========================================================================== % Change History % 1998-11-09 (DaB) Created % 1998-12-15 (ToNo) Made it menu driven and gui oriented % 1999-01-11 (ToNo) Changed result appearance and allowed instant resizing % 1999-01-14 (ToNo) Working on the str2mat/mat2str & char bug % 1999-01-14 (ToNo) Added plot buttons % 1999-01-20 (ToNo) Added "zoom on" for plot buttons % 1999-02-25 (ToNo) Generlized list (tfplist) handling % 1999-02-26 (ToNo) Added ui for plot type selection % 1999-03-05 (ToNo) Added ui for named hamband % 1999-08-12 (DaB) New struct for efficiencyLoss % 1999-08-19 (DaB) Updated for new tfplan struct % 1999-10-02 (DaB) Rewritten for new ex struct % 1999-10-25 (ToNo) Fixed new way to accesss HAM band flag % 2000-01-12 (DaB) Removed shannon Gap and Effiency box % 2000-04-04 (DaB) fixed margin bug % 2001-07-05 (ToNo) Now we support two-sided colored background noise % 2002-06-05 (StTr) Definition of the resize function needs % to be placed after all uicontrol commands in % order to prevent a self-call of uiSetup.m % caused by uicontrol calls with a 'pos' % parameter (crashes Windows version of Matlab 6.1) % TODO: add box for ADSL eff and two sided bg noise % 2003-11-03 (ToNo) Lists now use cell arrays for both Octave and Matlab %% =========================================================================== global simures; global gui; % Check input if nargin<2, error('Not enough input arguments.'); end if nargin<3, modemno=1; end if nargin<4, plottype = 1; % 1='Linear', 2='Log' end %% =========================================================================== % Set up window set(0,'Units','pixels'); % Define sizes and positions of figures gui.screensize=get(0,'ScreenSize'); gui.swidth=gui.screensize(3); gui.sheight=gui.screensize(4); gui.bdwidth=7; gui.fwidth=gui.swidth/2-gui.bdwidth*5; gui.fwidth=max(gui.fwidth,600); gui.fwidth=min(gui.fwidth,gui.swidth); gui.fheight=max(gui.fwidth,650); gui.fheight=min(gui.fheight,gui.sheight); f2start=gui.bdwidth*4+gui.fwidth; f2start=min(f2start,gui.swidth-gui.fwidth); gui.bottom=gui.sheight-gui.fheight-100; % If we already is a result figure us it, otherwise create a new one if (get(0,'CurrentFigure')>=1), if strcmp(get(gcf,'Tag'),'ResFig'), resultfig=gcf; figpos=get(resultfig,'Position'); gui.fwidth=figpos(3); gui.fheight=figpos(4); f2start=figpos(1); gui.bottom=figpos(2); newfig=0; else resultfig=figure;newfig=1; set(resultfig,'NumberTitle','off','Name','Simulation Result',... 'Position', [f2start gui.bottom gui.fwidth gui.fheight],'Tag','ResFig'); end; else resultfig=figure;newfig=1; set(resultfig,'NumberTitle','off','Name','Simulation Result',... 'Position', [f2start gui.bottom gui.fwidth gui.fheight],'Tag','ResFig'); end; clf; set(resultfig,'Pointer','arrow'); gui.fontSize=get(0,'DefaultTextFontSize'); % Set up window for nice printing set(resultfig,'PaperPositionMode','auto'); gui.uiheight=225; % User interaction area height gui.plotheight=(gui.fheight-gui.uiheight)/2; % Make space for two diagrams gui.plotbd=35; % Coordinates for some of the drawing areas (axes); RECT = [left, gui.bottom, width, height] gui.coordall=[1 1 gui.fwidth gui.fheight]; gui.coordui=[1 gui.fheight-gui.uiheight gui.fwidth gui.uiheight]; gui.coordfm=[gui.plotbd gui.plotheight+gui.plotbd gui.fwidth-gui.plotbd*2 gui.plotheight-gui.plotbd*2]; gui.coordfl=[gui.plotbd gui.plotbd gui.fwidth-gui.plotbd*2 gui.plotheight-gui.plotbd*2]; % Set up drawing areas rallax=axes('Units','pixels','pos',gui.coordall); % The whole window axis('off'); ruiax=axes('Units','pixels','pos',gui.coordui); % User interaction area axis('off'); gui.plotheight=(gui.fheight-gui.uiheight)/2; ltax=axes('Units','pixels','pos',gui.coordfm,'Tag','LTAX');% Area for LT side plot axis('off'); ntax=axes('Units','pixels','pos',gui.coordfl,'Tag','NTAX');% Area for NT side plot axis('off'); %% =========================================================================== % Generate the content plottypes = str2mat('Linear', 'Log'); % Save the window context for use in callbacks simures(resultfig).ex=ex; simures(resultfig).result=result; simures(resultfig).current=modemno; simures(resultfig).plottype=plottype; simures(resultfig).plotstrtype=deblank(plottypes(plottype,:)); current=modemno; % Selected modem n=length(result); % Get the resulting bitrates [bitrate_LT, bitrate_NT margin_LT margin_NT]=calcXDSLresult(ex,result); ratios=bitrate_LT./bitrate_NT; % Show experiment parameters in user interaction area axes(ruiax); fill([0 0 1 1] ,[0 1 1 0],'w'); % Make user interaction area white axis('off'); axes(rallax); gui.delta=20; gui.lheight=gui.fheight; lw=20; gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('Scenario: %s',ex.tt.name); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+2,'FontWeight','bold'); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('Testing: %s',gui.vdslDuplex); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('Noise model: %s',ex.param.NoiseModel); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tfplan=getList(ex.tfplist,gui.vdslDuplex); tmpstr= sprintf('PBO: %s (%gMHz, %gm)',tfplan.PSD.PBO.method,tfplan.PSD.PBO.param.freq./1e6,tfplan.PSD.PBO.param.len); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('SNR max: %.1f',gui.SNRMax); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('Time division: %.1f/%.1f (up/down)',tfplan.timeDivision.up, tfplan.timeDivision.down); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; if gui.tfplan.PSD.HAM.active, tmpstr= sprintf('Using hamband: %s',ex.param.HAMBandName); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); end; gui.lheight=gui.fheight-40; lw=200; text(lw+200, gui.lheight, 'f axis type', 'Units','pixels', 'FontSize', gui.fontSize+1); plotmui=uicontrol('style','popupmenu','string', plottypes, 'value',plottype,... 'units','pixels','pos',[lw+70+200, gui.lheight-10 90 20], ... 'FontSize', gui.fontSize+1, 'BackgroundColor', [1 1 0.9], ... 'callback', 'simures(gcbf).plottype=get(gcbo, ''value'');uiResults(simures(gcbf).ex,simures(gcbf).result,simures(gcbf).current,simures(gcbf).plottype);' ... ); gui.lheight=gui.lheight-gui.delta; if ex.param.frequency.fastrecalc, fcs='Fast calc'; else fcs=''; end; tmpstr= sprintf('f max=%.2f MHz (%s)',max(ex.param.frequency.f)/1e6, fcs); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('VDSL Line Code: %s',gui.lc.name); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); if gui.testVDSL, adslact=getList(ex.param.xDSLlist,'VDSL'); if length(adslact)>0, atfp=getList(ex.tfplist,adslact.used); alc=getList(ex.lclist,atfp.lcname); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('VDSL Eff. loss: %.3f',alc.param.efficiencyLoss); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); end; end; if gui.testADSL, adslact=getList(ex.param.xDSLlist,'ADSL'); if length(adslact)>0, atfp=getList(ex.tfplist,adslact.used); alc=getList(ex.lclist,atfp.lcname); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('ADSL Eff. loss: %.3f',alc.param.efficiencyLoss); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); end; end; % More parameters gui.lheight=gui.fheight-40; lw=400; gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('Background noise LT: %s',ex.param.bgNoise.LT); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('NEXT level: %.1f',ex.param.XTlevel.NEXT); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('FEXT level: %.1f',ex.param.XTlevel.FEXT); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); gui.lheight=gui.lheight-gui.delta; tmpstr= sprintf('3cXT level: %.1f',ex.param.XTlevel.thirdCXT); text(lw, gui.lheight, tmpstr, 'Units','pixels', 'FontSize', gui.fontSize+1); % Buttons gui.lheight=gui.lheight-gui.delta; uicontrol('string','Close', 'Position', [lw gui.lheight-10 60 20],... 'callback','close(gcbf)'); %% =========================================================================== dm=getDM(ex.tt.traffic,ex.param.modemlist); for i=1:n, a=ex.tt.traffic{dm(i)}; a1=a{1}; a2=a{2}; a3=a{3}; b1=ex.tt.topology{a1}; b2=ex.tt.topology{a2}; clables(i)={sprintf('%s %s to %s', a3, b1{3}, b2{3})}; end labels = str2mat(char(clables)); % Draw modem info row axes(ruiax); lpos=((55+10)/gui.uiheight); line([0 1], [lpos lpos],'Color','k'); stepsize=max(100,gui.fwidth/n); for mno=1:n, if mno==current, color='b'; angle='italic'; else color='k'; angle='normal'; end modeminfostr=clables(mno); text(10+(mno-1)*stepsize, 55, modeminfostr, ... 'Units','pixels', ... 'FontSize', gui.fontSize+1,'FontWeight','bold','FontAngle',angle,... 'Color',color); tmpstr= sprintf('Down Rate : %.2f (%.2f )',bitrate_NT(mno),margin_NT(mno)); text(10+(mno-1)*stepsize, 40, tmpstr, ... 'Units','pixels', 'FontSize', gui.fontSize,'Color',color); tmpstr= sprintf('Up Rate : %.2f (%.2f )',bitrate_LT(mno),margin_LT(mno)); text(10+(mno-1)*stepsize, 25, tmpstr, ... 'Units','pixels', 'FontSize', gui.fontSize,'Color',color); tmpstr= sprintf('(Ratio: %.2f)',ratios(mno)); text(10+(mno-1)*stepsize, 10, tmpstr, ... 'Units','pixels', 'FontSize', gui.fontSize-1,'Color',color); end % Modem selection axes(rallax); modempop=uicontrol('style','popupmenu','string', labels, 'value',current,... 'units','pixels','pos',[1, gui.fheight-gui.uiheight-20 200 20], ... 'BackgroundColor', [1 1 0.9], ... 'callback', 'simures(gcbf).current=get(gcbo, ''value'');uiResults(simures(gcbf).ex,simures(gcbf).result,simures(gcbf).current,simures(gcbf).plottype);' ... ); plotstrtype=deblank(plottypes(plottype,:)); % Plot LT side axes(ltax); plotResult(ex,result,current,'LT',plotstrtype); % PlotIT Button for LT uicontrol('string','PlotIt', 'Position', [gui.fwidth-70 ... gui.fheight-gui.uiheight-30 60 20], 'callback', ... 'figure;plotResult(simures(gcbf).ex,simures(gcbf).result,simures(gcbf).current,''LT'',simures(gcbf).plotstrtype);zoom on;') % Plot NT side axes(ntax); plotResult(ex,result,current,'NT',plotstrtype); % PlotIT Button for NT uicontrol('string','PlotIt', 'Position', [gui.fwidth-70 gui.plotheight-30 60 20],... 'callback', ... 'figure;plotResult(simures(gcbf).ex,simures(gcbf).result,simures(gcbf).current,''NT'',simures(gcbf).plotstrtype);zoom on;') axes(rallax); if newfig set(resultfig,'ResizeFcn','uiResults(simures(gcbf).ex,simures(gcbf).result,simures(gcbf).current,simures(gcbf).plottype);'); end