No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail

MatPlanWDM v0.5

by

 

29 Jan 2007 (Updated )

Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

MultiHourAnalysis(varargin)
function varargout = MultiHourAnalysis(varargin)

% MATPLANWDM Application M-file for matplanwdm.fig
%    FIG = matplanwdm2 launch matplanwdm2 GUI.
%    matplanwdm('callback_name', ...) invoke the named callback.

% Last Modified by GUIDE v2.5 14-Jul-2006 18:15:26

if nargin == 0  % LAUNCH GUI
    close all
    clear all
    clc

	fig = openfig(mfilename,'new');

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
	guidata(fig, handles);
    
    
   	if nargout > 0
		varargout{1} = fig;
	end
    
    gui_ini(handles)
    

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

	try
		if (nargout)
			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
		else
			feval(varargin{:}); % FEVAL switchyard
		end
	catch
		disp(lasterr);
	end

end

%set(fig,'Color',get(0,'DefaultUicontrolBackgroundColor'));

%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and 
%| sets objects' callback properties to call them through the FEVAL 
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the 
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback.  You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks.  Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
%
%set(fig,'Color',get(0,'DefaultUicontrolBackgroundColor'));

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% INITIALIZATION FUNCTION
% --------------------------------------------------------------------
% --------------------------------------------------------------------
function gui_ini(handles)

load_global_Multihour;
imageUPCT=imread('upct_logo.jpg','jpg');
axes(handles.axes6);
image(imageUPCT);
axis off
set(handles.men1,'Checked','off');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','on');


%%HEURISTICS MENU BUILDING
h = dir(fullfile(pwd, 'algorithms/staticMHPlanning/*.m'));
priv_h = dir(fullfile(pwd, 'algorithms/private/staticMHPlanning/*.m'));

numberOfPublicHeuristicAlgorithms = length(h);
numberOfPrivateHeuristicAlgorithms = length(priv_h);

MultiHourAlgorithms=cell(numberOfPublicHeuristicAlgorithms+numberOfPrivateHeuristicAlgorithms,1);
MultiHourAlgorithms(1:numberOfPublicHeuristicAlgorithms) = {h.name}';
MultiHourAlgorithms(numberOfPublicHeuristicAlgorithms+1:end) = {priv_h.name}';

numberOfHeuristicAlgorithms=length(MultiHourAlgorithms);
methodsString=cell(numberOfHeuristicAlgorithms+1,1);
methodsString(1)={['Select desired']};
methodsString(2:length(methodsString))=MultiHourAlgorithms;

set(handles.method_popupmenu,'String',methodsString);

%%%%%%%%%%%%%LOAD a XML fille %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=pwd;
s=[s '\data\results\multiHourAnalysis\*.xml'];
c=dir(s);
netStates = struct2cell(c);
numberOfnetStates=length(netStates(1,:));
netStatesString=cell(numberOfnetStates+1,1);
netStatesString(1)={['Select desired']};
netStatesString(2:length(netStatesString))=netStates(1,:);

set(handles.popupmenu12,'String',netStatesString);


% --------------------------------------------------------------------
% --------------------------------------------------------------------
% MENUs
% --------------------------------------------------------------------
% --------------------------------------------------------------------

% *********************************************************************
% *********************************************************************
% MENU 1 - FILE
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Quit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = Quit_Callback(h, eventdata, handles, varargin)

close



% *********************************************************************
% *********************************************************************
% MENU 2 - MODE
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode1 - DESIGN LIGHTPATH LOGICAL NETWORK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = mode1_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','on');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','off');

clear all
close
matplanwdm



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode2 - WHAT IF ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeWhatIf_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','on');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','off');

clear all
close
WhatIfAnalysis



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode3 - MULTIHOUR ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeMultiHour_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','on');
set(handles.men4,'Checked','off');

clear all
close
MultiHourAnalysis

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mode4 - DYNAMIC ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = modeDynamic_Callback(h, eventdata, handles, varargin)

set(handles.men1,'Checked','off');
set(handles.men2,'Checked','off');
set(handles.men3,'Checked','off');
set(handles.men4,'Checked','on');

clear all
close
Dynamic





% *********************************************************************
% *********************************************************************
% MENU 3 - TOOLS
% *********************************************************************
% *********************************************************************


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Traffic Generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = trafficGen_Callback(h, eventdata, handles, varargin)

% load_global_Multihour;%Global variables are loaded 

trafficGenerationFigure=openfig('trafficGeneration.fig','reuse');
dataTrafficGenerationFigure=guihandles(trafficGenerationFigure);
guidata(trafficGenerationFigure,dataTrafficGenerationFigure);

numberOfNodes=0;


% *********************************************************************
% *********************************************************************
% MENU 4 - HELP
% *********************************************************************
% *********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%MatplanWDM HELP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = matplanwdmHelp_Callback(h, eventdata, handles, varargin)

HelpPath =[pwd '\help\matplanwdmHelp.html'];
web(HelpPath,  '-helpbrowser')



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%About
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = about_Callback(h, eventdata, handles, varargin)

openfig('about.fig','new')


% --------------------------------------------------------------------
% --------------------------------------------------------------------
% GENERAL INPUT ARGUMENTS
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%openPhysFile_pushbutton - OPEN PHYS FILE BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = openPhysFile_pushbutton_Callback(h, eventdata, handles, varargin)

load_global_Multihour;%Global variables are loaded

%We open the file to read our 'Physical Topology File (*.phys)'
[filename, pathname] = uigetfile({'*.xml','Physical Topology File'},'Open Physical Topology File','data\physicalTopologies\');
topologyFilename=filename;
fullpathname=[pathname filename];
try
    [metadata, phys] = io_readXML(fullpathname);
    checkPhys(phys)
catch
    lastErrorMsg=lasterr;
    errordlg(lastErrorMsg,'Unexpected Error On Reading/Checking Physical Topology from the XML File!!!','modal');
    return
end

% %We show the loaded file in the edit
physTextReport = physXMLfileTextReport(metadata , phys);
previousText=get(handles.edit6,'String');
topologyReport=vertcat(previousText, {[' ']},{['######### PHYSICAL TOPOLOGY FILE  "',topologyFilename,'"  LOADED ##########']},{[' ']}, physTextReport);                        
set(handles.edit6,'String', topologyReport);

axes(handles.axes1);
hold off
plotTopology(phys.nodesPlaceMatrix,phys.linkTable,0,'',1)
axis('off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%openTraffFile_pushbutton - OPEN TRAFF FILE BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = openTraffFile_pushbutton_Callback(h, eventdata, handles, varargin)

load_global_Multihour;%Global variables are loaded

%We open the file to read our 'Traffic File (*.traff)'
[filename, pathname] = uigetfile({'*.traff','Traffic File (*.traff)'},'Open Traffic File','data\traffics\');
trafficFilename=filename;
fullpathname=[pathname filename];
[traff_trafficMatrixFromFile, errmsg, errorFlag] = IO_readTraffFile(fullpathname);
if errorFlag==-1,
    errordlg(errmsg,'Error On Reading Traff File!!!','modal');
    return
else
    [traffString] = IO_writeTraffString(traff_trafficMatrixFromFile); 
end

% %We show the loaded file in the edit
previousText=get(handles.edit6,'String');
trafficReport=vertcat(previousText, {[' ']},{['############### TRAFFIC FILE  "',trafficFilename,'"  LOADED ##############']},{[' ']}, {traffString});
set(handles.edit6,'String', trafficReport);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%POPUPMENU TO SELECTED METHODS FOR THE ANALYSIS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = method_popupmenu_Callback(h, eventdata, handles, varargin)



% --------------------------------------------------------------------
% --------------------------------------------------------------------
% EXECUTION CONTROLS
% --------------------------------------------------------------------
% --------------------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Start_pushbutton - START BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = Start_pushbutton_Callback(h, eventdata, handles, varargin)

if (get(handles.radiobuttonNewDesign,'Value')==1)
delete(statusbar);
load_global_Multihour;%Global variables are loaded

handles_popupDesign=msgbox('Designing Multhour Virtual Topologies.  Please wait . . .','Virtual Topology Designs in progress','modal');
set(handles.ClearReport_pushbutton,'Enable','off');
set(handles.nodeResources_popupmenu,'Value',1);
set(handles.nodeResources_popupmenu,'Enable','off');
set(handles.text23,'Enable','off');
set(handles.popupmenu16,'Value',1);
set(handles.popupmenu16,'Enable','off');
set(handles.popupmenu17,'Value',1);
set(handles.popupmenu17,'Enable','off');
set(handles.popupmenu18,'Value',1);
set(handles.popupmenu18,'Enable','off');
set(handles.popupmenu19,'Value',1);
set(handles.popupmenu19,'Enable','off');
set(handles.popupmenu20,'Value',1);
set(handles.popupmenu20,'Enable','off');
set(handles.popupmenuTimeSlot,'Value',1);
set(handles.popupmenuTimeSlot,'Enable','off');

%Popup Menu of lightpaths
set(handles.popupmenu13,'Enable','off');
set(handles.popupmenu13,'Value',1);
axes(handles.axes1)
image([]);
axis off

%Popup Menu of flows
set(handles.popupmenu14,'Enable','off');
set(handles.popupmenu14,'Value',1);
axes(handles.axes11)
image([]);
axis off



%We save the traffic matrix loaded by the files.
traff_trafficMatrix=traff_trafficMatrixFromFile;

%CHECK INPUT DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We check that all the input data were entered are correct
if isempty(phys) 
    errordlg('Phys File Not Selected', 'Empty or Bad Input Data','modal');
    return;
elseif isempty(traff_trafficMatrix),
    errordlg('Traff File Not Selected','Empty or Bad Input Data','modal');
    return;
elseif size(phys.nodesPlaceMatrix,1)~=size(traff_trafficMatrix,1),
    errordlg('Phys File and Traff File does not match in the number of nodes','Bad Input Data','modal');
    return;
elseif isempty(phys.nodeTimezone),
    errordlg('Node Timezones Not Selected','Empty or Bad Input Data','modal');
    return;    
elseif get(handles.method_popupmenu,'Value')==1; 
    errordlg('Incorrect Method Selection','Empty or Bad Input Data','modal');
    return;   
else
    numberOfNodes=size(traff_trafficMatrixFromFile,1);
end

%METHOD SELECTED AND ITS PARAMETERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%We catch that the algoritm parameter.
algorithmParameters=get(handles.AlgorithmParameters_edit, 'String');
   
%We capture the selected method
methodSelection=get(handles.method_popupmenu,'Value');
[pathstr,method,ext,versn]=fileparts(MultiHourAlgorithms{methodSelection-1});


%CONSTRUCTION OF THE MULTI-HOUR TRAFFIC MATRICES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%1) Definition of the Activity Function for all the node pairs and for 24
%hours

multiHourTrafficMatrices=zeros(numberOfNodes,numberOfNodes,24);
UTC=0:23;
for i=1:numberOfNodes,
    for j=1:numberOfNodes,
        for t=1:24,
            activity(i,t) = activityFunction(phys.nodeTimezone(i), UTC(t)); 
            activity(j,t) = activityFunction(phys.nodeTimezone(j), UTC(t)); 
            multiHourTrafficMatrices(i,j,t)=traff_trafficMatrix(i,j)*activity(i,t)*activity(j,t);
            
        end 
    end
end

%We compute the netState for each traffic matrix using the selected method
exitMsg=cell(24,1);
exitFlag=zeros(24,1);
sweepOfNetStates=cell(24,1);
sweepOfStatMetrics=cell(24,1);
lightpathsRoutes=cell(24,1);
listOfSerialNumberFlowsPerLp=cell(24,1);

k=0;
try
    tic;
    [exitMsg exitFlag sweepOfNetStates]=feval(method, multiHourTrafficMatrices, phys, algorithmParameters);
    designTime=toc;
    for t=1:24,
        [sweepOfStatMetrics{t},lightpathsRoutes{t},listOfSerialNumberFlowsPerLp{t}] = calculateMetrics(phys, sweepOfNetStates{t});
    end

   close(handles_popupDesign);
    
catch
    close(handles_popupDesign);
    lastErrorMsg=lasterr;
    errordlg(lastErrorMsg,'Unexpected Error in MAnalysis','modal')
    return;
end 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EXIT FLAG FROM DESIGN PROCESS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if exitFlag == 1, errordlg('NO FEASIBLE SOLUTION FOUND!!!','Design Failed','modal'); return; end

%Check netState correct
try
    flag_removeLoops=1;
    flag_checkLpRoutingMatrix=1;
    flag_lossesAllowed=1;
    flag_checkLoops=1;
    [flag_modifiedNetState sweepOfNetStates] = checkNetState_MH(sweepOfNetStates , phys, multiHourTrafficMatrices, flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix, flag_lossesAllowed);
catch
    lastErrorMsg=lasterr;
    errordlg(lastErrorMsg,'Unexpected Error on checking the planned design!!!','modal')
    return;   
end

switch exitFlag,
    case 0,
        [IconData, IconCMap]=imread('OK.bmp');
        msgbox('    OK!!!','Design Successful','custom', IconData, IconCMap,'modal');    
    case 1, 
        errordlg('NO FEASIBLE SOLUTION FOUND!!!','Design Failed','modal')  
        return
    otherwise
        warndlg(exitMsg,'Design Successful Non-Optimal','modal')     
end

%Popup Menu of Statistics
lightpathsMatrixString=cell(7,1);
lightpathsMatrixString={['Select desired'],['Node Routes'],['Link Routes'],...
    ['Number of conversions'],['Distances'],['List of flows'],['Carried Traffic']};
set(handles.popupmenu17,'String', lightpathsMatrixString);

linksMatrixString=cell(3,1);
linksMatrixString={['Select desired'],['Wavelength utilization'],['Routed traffic']};
set(handles.popupmenu18,'String', linksMatrixString);  

nodesMatrixString=cell(3,1);
nodesMatrixString={['Select desired'],['Used Transmitters/Receivers/TWCs'],['Ingress/Egress/Grooming traffic']};
set(handles.popupmenu19,'String', nodesMatrixString);

flowsMatrixString=cell(3,1);
flowsMatrixString={['Select desired'],['Lost traffic'],['Number of virtual hops']};
set(handles.popupmenu20,'String', flowsMatrixString);

set(handles.edit6,'Enable','on');
set(handles.text54,'Enable','on');
set(handles.text55,'Enable','on');
set(handles.text56,'Enable','on');
set(handles.text57,'Enable','on');
set(handles.text58,'Enable','on');
set(handles.ClearReport_pushbutton,'Enable','on');
set(handles.popupmenuTimeSlot,'Enable','on');
set(handles.popupmenu16,'Enable','on');
set(handles.nodeResources_popupmenu,'Enable','on');
set(handles.text23,'Enable','on');
set(handles.pushbutton17,'Enable','on');

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbutton2 - RESET BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)

delete(statusbar);
clear all;
close all;
MultiHourAnalysis;

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% RESULTS REPORT
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ClearReport_pushbutton - Pushbutton to reser the results edit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = ClearReport_pushbutton_Callback(h, eventdata, handles, varargin)

set(handles.edit6,'String','');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%nodeResources_popupmenu - NODE RESOURCES SELECTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
function varargout = nodeResources_popupmenu_Callback(h, eventdata, handles, varargin)

load_global_Multihour;%Global variables are loaded
nodeResourcesSelection=get(handles.nodeResources_popupmenu,'Value')-1;
numberOfNodes=phys.N;
tableOfResourcesPerNode=zeros(numberOfNodes,24);
for t=1:24,
    switch nodeResourcesSelection,
    case 1
        tableOfResourcesPerNode(:,t)=sweepOfStatMetrics{t}.NrUsedTransmittersPerNode';
    case 2
        tableOfResourcesPerNode(:,t)=sweepOfStatMetrics{t}.NrUsedReceiversPerNode';
    case 3
        tableOfResourcesPerNode(:,t)=sweepOfStatMetrics{t}.NrUsedConvertersPerNode';
    case 4
        tableOfResourcesPerNode(:,t) = sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.ingressTraffic';
    case 5
        tableOfResourcesPerNode(:,t) = sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.egressTraffic'; 
    case 6
        tableOfResourcesPerNode(:,t) = sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.groomingTraffic';
    case 7
        tableOfResourcesPerNode(:,t) = sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.ingressTraffic'+...
                                        sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.egressTraffic'+...
                                        sweepOfStatMetrics{t}.ingressEgressGroomingTraffic.groomingTraffic';
    end
end

if(nodeResourcesSelection==1||nodeResourcesSelection==2||nodeResourcesSelection==3)
if (numberOfNodes<7)
    nodeResourcesReport=['Node   X:'];
    for node=1:numberOfNodes
        [nodeString, errmsg] = sprintf('\t%4.0f', node) ;
        nodeResourcesReport=horzcat(nodeResourcesReport,nodeString);
    end
    [totalString, errmsg]=sprintf('\tTotal');
    nodeResourcesReport=[nodeResourcesReport, totalString];
    maxNumber=max(tableOfResourcesPerNode,[],2);
    [maxNumberString, errmsg] = sprintf('\t%4.0f', maxNumber);
    tableOfResourcesPerNode=[tableOfResourcesPerNode maxNumber];
    totalNumberOfUsedResources=sum(tableOfResourcesPerNode,1);
    
    for i=2:25,
        [resourceString, errmsg] = sprintf('\t%4.0f', tableOfResourcesPerNode(:,i-1)) ;
        [totalNumberString, errmsg] = sprintf('\t%4.0f', totalNumberOfUsedResources(i-1));
        if(i<=11) 
            hour=['0', num2str(i-2)]; 
        else
            hour=num2str(i-2);
        end
        nodeResourcesReport=vertcat(nodeResourcesReport,{['Hour ', hour,'h',':', resourceString,totalNumberString]});
    end  
    [totalMaxString, errmsg] = sprintf('\t%4.0f', totalNumberOfUsedResources(end)) ;
    nodeResourcesReport=vertcat(nodeResourcesReport,{['Max     :',maxNumberString, totalMaxString]});
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    auxReport=get(handles.edit6,'String');
    switch nodeResourcesSelection
        case 1
            title=['### Number of  Used Transmitters per node ###'];
        case 2
            title=['### Number of  Used Receivers per node ###'];
        case 3
            title=['### Number of  Used TWCs per node ###'];
    end
    finalReport=vertcat(auxReport,title,nodeResourcesReport, {[''];['']} );
    set(handles.edit6,'String',finalReport);
else
    numberOfReports=ceil(numberOfNodes/7);
    for i=1:numberOfReports
        if (7+(i-1)*7)>numberOfNodes
            numberOfNodesForThisReport=numberOfNodesForThisReport(end)+1:numberOfNodes;
        else
            numberOfNodesForThisReport=(1+(i-1)*7):(7+(i-1)*7);
        end
        nodeResourcesReport=['Node   X: '];
        for node=1:length(numberOfNodesForThisReport)
            [nodeString, errmsg] = sprintf('\t%4.0f', numberOfNodesForThisReport(node)) ;
            nodeResourcesReport=horzcat(nodeResourcesReport,nodeString);
        end
        [totalString, errmsg]=sprintf('\tTotal');
        nodeResourcesReport=[nodeResourcesReport, totalString];
        maxNumber=max(tableOfResourcesPerNode,[],2);

        [maxNumberString, errmsg] = sprintf('\t%4.0f', maxNumber(numberOfNodesForThisReport));
        tableOfResourcesPerNode=[tableOfResourcesPerNode maxNumber];
        totalNumberOfUsedResources=sum(tableOfResourcesPerNode,1);

        for i=2:25,
            [resourceString, errmsg] = sprintf('\t%4.0f', tableOfResourcesPerNode(numberOfNodesForThisReport,i-1)) ;
            [totalNumberString, errmsg] = sprintf('\t%4.0f', totalNumberOfUsedResources(i-1));
            if(i<=11) 
                hour=['0', num2str(i-2)]; 
            else
                hour=num2str(i-2);
            end
            nodeResourcesReport=vertcat(nodeResourcesReport,{['Hour ', hour,'h',':', resourceString,totalNumberString]});
        end  
        [totalMaxString, errmsg] = sprintf('\t%4.0f', totalNumberOfUsedResources(end)) ;
        nodeResourcesReport=vertcat(nodeResourcesReport,{['Max     :',maxNumberString, totalMaxString]});
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        auxReport=get(handles.edit6,'String');
        switch nodeResourcesSelection
            case 1
                title=['### Number of  Used Transmitters per node ###'];
            case 2
                title=['### Number of  Used Receivers per node ###'];
            case 3
                title=['### Number of  Used TWCs per node ###'];
        end
        finalReport=vertcat(auxReport,title,nodeResourcesReport, {[''];['']} );
        set(handles.edit6,'String',finalReport);
    end
end
end
if(nodeResourcesSelection==4||nodeResourcesSelection==5||nodeResourcesSelection==6||nodeResourcesSelection==7)
if (numberOfNodes<7)
    nodeResourcesReport=['Node   X:'];
    for node=1:numberOfNodes
        [nodeString, errmsg] = sprintf('\t%3.0f', node) ;
        nodeResourcesReport=horzcat(nodeResourcesReport,nodeString);
    end
    [totalString, errmsg]=sprintf('\tTotal');
    nodeResourcesReport=[nodeResourcesReport, totalString];
    maxNumber=max(tableOfResourcesPerNode,[],2);
    [maxNumberString, errmsg] = sprintf('\t%7.3f', maxNumber);
    tableOfResourcesPerNode=[tableOfResourcesPerNode maxNumber];
    totalNumberOfUsedResources=sum(tableOfResourcesPerNode,1);
    
    for i=2:25,
        [resourceString, errmsg] = sprintf('\t%7.3f', tableOfResourcesPerNode(:,i-1)) ;
        [totalNumberString, errmsg] = sprintf('\t%7.3f', totalNumberOfUsedResources(i-1));
        if(i<=11) 
            hour=['0', num2str(i-2)]; 
        else
            hour=num2str(i-2);
        end
        nodeResourcesReport=vertcat(nodeResourcesReport,{['Hour ', hour,'h',':', resourceString,totalNumberString]});
    end  
    [totalMaxString, errmsg] = sprintf('\t%7.3f', totalNumberOfUsedResources(end)) ;
    nodeResourcesReport=vertcat(nodeResourcesReport,{['Max     :',maxNumberString, totalMaxString]});
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    auxReport=get(handles.edit6,'String');
    switch nodeResourcesSelection
        case 4
            title=['### Ingress traffic per node (Gbps) ###'];
        case 5
            title=['### Egress traffic per node (Gbps) ###'];
        case 6
            title=['### Grooming traffic per node (Gbps) ###'];
        case 7
            title=['### Total traffic per node (Gbps) ###'];
    end
    finalReport=vertcat(auxReport,title,nodeResourcesReport, {[''];['']} );
    set(handles.edit6,'String',finalReport);
else
    numberOfReports=ceil(numberOfNodes/7);
    for i=1:numberOfReports
        
        if (7+(i-1)*7)>numberOfNodes
            numberOfNodesForThisReport=numberOfNodesForThisReport(end)+1:numberOfNodes;
        else
            numberOfNodesForThisReport=(1+(i-1)*7):(7+(i-1)*7);
        end
        nodeResourcesReport=['Node   X: '];
        for node=1:length(numberOfNodesForThisReport)
            [nodeString, errmsg] = sprintf('\t%3.0f', numberOfNodesForThisReport(node)) ;
            nodeResourcesReport=horzcat(nodeResourcesReport,nodeString);
        end
        [totalString, errmsg]=sprintf('\tTotal');
        nodeResourcesReport=[nodeResourcesReport, totalString];
        maxNumber=max(tableOfResourcesPerNode,[],2);
        [maxNumberString, errmsg] = sprintf('\t%7.3f', maxNumber(numberOfNodesForThisReport));
        tableOfResourcesPerNode=[tableOfResourcesPerNode maxNumber];
        totalNumberOfUsedResources=sum(tableOfResourcesPerNode,1);

        for i=2:25,
            [resourceString, errmsg] = sprintf('\t%7.3f', tableOfResourcesPerNode(numberOfNodesForThisReport,i-1)) ;
            [totalNumberString, errmsg] = sprintf('\t%7.3f', totalNumberOfUsedResources(i-1));
            if(i<=11) 
                hour=['0', num2str(i-2)]; 
            else
                hour=num2str(i-2);
            end
            nodeResourcesReport=vertcat(nodeResourcesReport,{['Hour ', hour,'h',': ', resourceString,totalNumberString]});
        end  
        [totalMaxString, errmsg] = sprintf('\t%7.3f', totalNumberOfUsedResources(end)) ;
        nodeResourcesReport=vertcat(nodeResourcesReport,{['Max     :',maxNumberString, totalMaxString]});
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        auxReport=get(handles.edit6,'String');
        switch nodeResourcesSelection
            case 4
                title=['### Ingress traffic per node (Gbps) ###'];
            case 5
                title=['### Egress traffic per node (Gbps) ###'];
            case 6
                title=['### Grooming traffic per node (Gbps) ###'];
            case 7
                title=['### Total traffic per node (Gbps) ###'];
        end
        finalReport=vertcat(auxReport,title,nodeResourcesReport, {[''];['']} );
        set(handles.edit6,'String',finalReport);
    end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%checkboxLoad - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = checkboxLoad_Callback(h, eventdata, handles, varargin)

selection = get(handles.radiobuttonLoad,'Value');
if selection==1
        set(handles.radiobuttonNewDesign,'Value',0);
        s=pwd;
        s=[s '\data\results\multiHourAnalysis\*.xml'];
        c=dir(s);
        netStates = struct2cell(c);
        numberOfnetStates=length(netStates(1,:));
        netStatesString=cell(numberOfnetStates+1,1);
        netStatesString(1)={['Select desired']};
        netStatesString(2:length(netStatesString))=netStates(1,:);
        set(handles.popupmenu12,'String',netStatesString);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%checkboxNewDesign - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = checkboxNewDesign_Callback(h, eventdata, handles, varargin)

selection = get(handles.radiobuttonNewDesign,'Value');
if selection==1
        set(handles.radiobuttonLoad,'Value',0);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbutton2 - LOAD BUTTON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = pushbuttonLoad_Callback(h, eventdata, handles, varargin)

if(get(handles.radiobuttonLoad,'Value')==1)

load_global_Multihour;

set(handles.edit6,'String',[]);
set(handles.nodeResources_popupmenu,'Value',1);
set(handles.popupmenu16,'Value',1);
set(handles.popupmenu17,'Value',1);
set(handles.popupmenu18,'Value',1);
set(handles.popupmenu19,'Value',1);
set(handles.popupmenu20,'Value',1);
set(handles.popupmenuTimeSlot,'Value',1);


%Popup Menu of lightpaths
set(handles.popupmenu13,'Enable','off');
set(handles.popupmenu13,'Value',1);
axes(handles.axes1)
image([]);
axis off

%Popup Menu of flows
set(handles.popupmenu14,'Enable','off');
set(handles.popupmenu14,'Value',1);
axes(handles.axes11)
image([]);
axis off


s=pwd;
s=[s '\data\results\multiHourAnalysis\*.xml'];
c=dir(s);
netStates = struct2cell(c);
numberOfnetStates=length(netStates(1,:));
netStatesString=cell(numberOfnetStates+1,1);
netStatesString(1)={['Select desired']};
netStatesString(2:length(netStatesString))=netStates(1,:);
net=get(handles.popupmenu12,'Value');
netName=netStatesString(net);
netName=char(netName);
fullpathname=[pwd '\data\results\multiHourAnalysis\' netName];
%We open the file to read our XML file (*.xml)'
%and check the physical topology and the netState read from it.
try
    [metadata, phys, sweepOfNetStates] = io_readXML_MH(fullpathname);
    checkPhys(phys)
    flag_removeLoops=0;
    flag_checkLpRoutingMatrix=1;
    flag_lossesAllowed=1;
    flag_checkLoops=1;
    [flag_modifiedNetState sweepOfNetStates] = checkNetState_MH(sweepOfNetStates , phys, [], flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix, flag_lossesAllowed);
catch
    lastErrorMsg=lasterr;
    errordlg(lastErrorMsg,'Unexpected Error On Reading/Checking the VT Design from the XML File!!!','modal');
    return
end
sweepOfStatMetrics=cell(24,1);
lightpathsRoutes=cell(24,1);
listOfSerialNumberFlowsPerLp=cell(24,1);
for t=1:24,
    [sweepOfStatMetrics{t},lightpathsRoutes{t},listOfSerialNumberFlowsPerLp{t}] = calculateMetrics(phys, sweepOfNetStates{t});
end
%Popup Menu of Statistics
lightpathsMatrixString=cell(7,1);
lightpathsMatrixString={['Select desired'],['Node Routes'],['Link Routes'],...
    ['Number of conversions'],['Distances'],['List of flows'],['Carried Traffic']};
set(handles.popupmenu17,'String', lightpathsMatrixString);

linksMatrixString=cell(3,1);
linksMatrixString={['Select desired'],['Wavelength utilization'],['Routed traffic']};
set(handles.popupmenu18,'String', linksMatrixString);  

nodesMatrixString=cell(3,1);
nodesMatrixString={['Select desired'],['Used Transmitters/Receivers/TWCs'],['Ingress/Egress/Grooming traffic']};
set(handles.popupmenu19,'String', nodesMatrixString);

flowsMatrixString=cell(3,1);
flowsMatrixString={['Select desired'],['Lost traffic'],['Number of virtual hops']};
set(handles.popupmenu20,'String', flowsMatrixString);

set(handles.edit6,'Enable','on');
set(handles.text54,'Enable','on');
set(handles.text55,'Enable','on');
set(handles.text56,'Enable','on');
set(handles.text57,'Enable','on');
set(handles.text58,'Enable','on');
set(handles.ClearReport_pushbutton,'Enable','on');
set(handles.popupmenuTimeSlot,'Enable','on');
set(handles.popupmenu16,'Enable','on');
set(handles.nodeResources_popupmenu,'Enable','on');
set(handles.text23,'Enable','on');
set(handles.pushbutton17,'Enable','on');

%Show Metadata
textReport = designMetadataTextReport(metadata);
set(handles.edit6,'String',[]);
set(handles.edit6,'String',textReport);

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenuTimeSlot 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = popupmenuTimeSlot_Callback(h, eventdata, handles, varargin)

load_global_Multihour;

%Popup Menu of lightpaths
set(handles.popupmenu13,'Enable','off');
set(handles.popupmenu13,'Value',1);
axes(handles.axes1)
image([]);
axis off

%Popup Menu of flows
set(handles.popupmenu14,'Enable','off');
set(handles.popupmenu14,'Value',1);
axes(handles.axes11)
image([]);
axis off

timeSlot=get(handles.popupmenuTimeSlot,'Value')-1;

if timeSlot~=0
    %Popup Menu of lightpaths
    if(isempty(sweepOfNetStates{timeSlot}.lightpathTable)==0)

        lightpathMatrixString=cell(size(sweepOfNetStates{timeSlot}.lightpathTable,1)+1,1);
        lightpathMatrixString(1)={['Lightpaths']};

        for i=2:size(sweepOfNetStates{timeSlot}.lightpathTable,1)+1,
        lightpathMatrixString(i)={['lightpath ', num2str(sweepOfNetStates{timeSlot}.lightpathTable(i-1,1)), ...
            ':  [', num2str(sweepOfNetStates{timeSlot}.lightpathTable(i-1,2)), '-->', num2str(sweepOfNetStates{timeSlot}.lightpathTable(i-1,3)),']' ]};
        end
        set(handles.popupmenu13,'String', lightpathMatrixString);
        axes(handles.axes1);
        topologyTitle='';
        hold off
        plotTopology (phys.nodesPlaceMatrix, phys.linkTable, 0, topologyTitle, 0);

    end

    %Popup Menu of flows
    if(isempty(sweepOfNetStates{timeSlot}.flowTable)==0)

        flowsMatrixString=cell(size(sweepOfNetStates{timeSlot}.flowTable,1)+1,1);
        flowsMatrixString(1)={['Flows']};
        for i=2:size(sweepOfNetStates{timeSlot}.flowTable,1)+1,
        flowsMatrixString(i)={['flow ', num2str(sweepOfNetStates{timeSlot}.flowTable(i-1,1)), ...
            ':  [', num2str(sweepOfNetStates{timeSlot}.flowTable(i-1,2)), '-->', num2str(sweepOfNetStates{timeSlot}.flowTable(i-1,3)),']' ]};
        end
        set(handles.popupmenu14,'String', flowsMatrixString);
        axes(handles.axes11);
        topologyTitle='';
        hold off
        plotTopology (phys.nodesPlaceMatrix, sweepOfNetStates{timeSlot}.lightpathTable(:,2:3), 1, topologyTitle, 0)
    end

    set(handles.popupmenu13,'Enable','on')
    set(handles.popupmenu14,'Enable','on')
end

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% LIGHTPATH AND FLOW RESULTS
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenu13 - LIGHTPATH MENU
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu13_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
%When a lightpath is chosen, its physical route is drawn
lightpathNumber=get(handles.popupmenu13,'Value');
timeSlot=get(handles.popupmenuTimeSlot,'Value')-1;

%cla
axes(handles.axes1);
hold off
if lightpathNumber~=1,
    plotLightpath(phys.nodesPlaceMatrix,phys.linkTable, lightpathNumber-1, sweepOfNetStates{timeSlot}.lightpathRoutingMatrix, '')
else
   plotTopology(phys.nodesPlaceMatrix,phys.linkTable,0,'',1)
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenu14 - FLOW MENU
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu14_Callback(h, eventdata, handles, varargin)

%%Partial flows are drawn
load_global_Multihour;
%When a flow is chosen, its logical route is drawn
flowNumber=get(handles.popupmenu14,'Value');
timeSlot=get(handles.popupmenuTimeSlot,'Value')-1;
axes(handles.axes11);
hold off
title='';

if flowNumber~=1,
    plotTrafficFlow(phys.nodesPlaceMatrix, sweepOfNetStates{timeSlot}.lightpathTable(:,2:3), flowNumber-1, sweepOfNetStates{timeSlot}.flowTable, sweepOfNetStates{timeSlot}.flowRoutingMatrix, title)
else
    plotTopology(phys.nodesPlaceMatrix,sweepOfNetStates{timeSlot}.lightpathTable(:,2:3),1,title,1);
end

if ispc
    set(h,'BackgroundColor','white');
else
    set(h,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenu16 - Per hour report
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu16_Callback(h, eventdata, handles, varargin)

%%Partial flows are drawn
load_global_Multihour;

%CALCULATE NET METRICS 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
timeSlot=get(handles.popupmenu16,'value')-1;
if timeSlot==0
    set(handles.popupmenu17,'Enable','off');
    set(handles.popupmenu18,'Enable','off');
    set(handles.popupmenu19,'Enable','off');
    set(handles.popupmenu20,'Enable','off');
else
    set(handles.popupmenu17,'Enable','on');
    set(handles.popupmenu18,'Enable','on');
    set(handles.popupmenu19,'Enable','on');
    set(handles.popupmenu20,'Enable','on');
end

% --------------------------------------------------------------------
% --------------------------------------------------------------------
% RESULTS REPORT
% --------------------------------------------------------------------
% --------------------------------------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenu9 - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu17_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlot=get(handles.popupmenu16,'value')-1;
lpReportTypeId=get(handles.popupmenu17,'Value');
numberOfLightpaths=size(sweepOfNetStates{timeSlot}.lightpathRoutingMatrix ,1);

switch lpReportTypeId
    case 2, %
        textReport1={['PER LIGHTPATH REPORT: NODE ROUTES'];['----------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Sequence of nodes']};
    case 3, % 
        textReport1={['PER LIGHTPATH REPORT: LINK ROUTES'];['----------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Existing wavelengths'];['Column 6: Sequence of links']};
    case 4, %
        textReport1={['PER LIGHTPATH REPORT: NUMBER OF CONVERSIONS'];['--------------------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Existing wavelengths'];['Column 6:  Number of wavelength conversion']};
    case 5, % 
        textReport1={['PER LIGHTPATH REPORT: DISTANCES'];['--------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Number of physical hops'];['Column 6: Distance']};
    case 6, %
        textReport1={['PER LIGHTPATH REPORT: LIST OF CARRIED FLOW IDS'];['-----------------------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Existing wavelengths'];['Column 6: Flow IDs ']};
    case 7, % 
        textReport1={['PER LIGHTPATH REPORT: CARRIED TRAFFIC'];['--------------------------------------'];['Column 1: Lightpath ID'];['Column 2: Ingress node'];['Column 3: Egress node'];['Column 4: Capacity'];['Column 5: Carried traffic']};
    otherwise
        error ('Not Valid Report Type ID !!!');
end

for lpID=1:numberOfLightpaths
    string1 = sprintf ('%4d %2d %2d %3.1f ' , [sweepOfNetStates{timeSlot}.lightpathTable(lpID,1) sweepOfNetStates{timeSlot}.lightpathTable(lpID,2) sweepOfNetStates{timeSlot}.lightpathTable(lpID,3) phys.lightpathCapacity]);
    switch lpReportTypeId
        case 2,
            for node=lightpathsRoutes{timeSlot}{lpID,1}, 
                string1 = [string1 sprintf('%2d ',[node])];
            end
        case 3,
            for link=lightpathsRoutes{timeSlot}{lpID,2}, 
                string1 = [string1 sprintf('%2d (%2d) ',[link sweepOfNetStates{timeSlot}.lightpathRoutingMatrix(lpID,link)])]; 
            end
        case 4,
            string1 = [string1 sprintf('%2d ',[sweepOfStatMetrics{timeSlot}.NrUsedConvertersPerLP(lpID)])];
        case 5,
            string1 = [string1 sprintf('%2d %2d ',[sweepOfStatMetrics{timeSlot}.NrUsedPhysHops(lpID) sweepOfStatMetrics{timeSlot}.lightpathDistances(lpID)])]; 
        case 6,
            for flowNumber=listOfSerialNumberFlowsPerLp{timeSlot}{lpID},
                string1 = [string1 sprintf('%5d ',[flowNumber])];
            end
        case 7,
            string1 = [string1 sprintf('%2.1f ',[sweepOfStatMetrics{timeSlot}.lightpathFlows(lpID)])]; 
        otherwise
            error ('Not Valid Report Type ID !!!');
    end
    string1={string1};
    textReport1=vertcat(textReport1,string1);
end

textReport1 = vertcat (textReport1 , {[''];['Summary information:'];['--------------------']});

switch lpReportTypeId
    case 2,
        auxTextReport={['Average Virtual Hops: ',num2str(sweepOfStatMetrics{timeSlot}.averVirtualHops)],
            ['Average Distance(km): ', num2str(sweepOfStatMetrics{timeSlot}.averageDistance)]};
        textReport1 =vertcat(textReport1,auxTextReport);
    case 3,
        auxTextReport={['Average Virtual Hops: ',num2str(sweepOfStatMetrics{timeSlot}.averVirtualHops)],
            ['Average Distance(km): ', num2str(sweepOfStatMetrics{timeSlot}.averageDistance)]};
        textReport1 =vertcat(textReport1,auxTextReport);
    case 4,
        auxTextReport={['Average number of used TWCs per lightpath: ',num2str(sweepOfStatMetrics{timeSlot}.averNrUsedConverPerLP)]};
        textReport1 =vertcat(textReport1,auxTextReport);
    case 5,
        auxTextReport={['Average Virtual Hops: ',num2str(sweepOfStatMetrics{timeSlot}.averVirtualHops)],
            ['Average Distance(km): ', num2str(sweepOfStatMetrics{timeSlot}.averageDistance)]};
        textReport1 =vertcat(textReport1,auxTextReport);
    case 6,
        auxTextReport={['Average number of flows in a lightpath: ',num2str(sweepOfStatMetrics{timeSlot}.averNumOfFlowsPerLp)]};
        textReport1 =vertcat(textReport1,auxTextReport);
    case 7,
        auxTextReport={['Network congestion: ',num2str(sweepOfStatMetrics{timeSlot}.networkCongestion)]};
        textReport1 =vertcat(textReport1,auxTextReport);
end

textReport1 = vertcat (textReport1 , {[''];[''];['']});  
textReport=vertcat(get(handles.edit6,'String'),textReport1);
set(handles.edit6,'String',[]);
set(handles.edit6,'String',textReport);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %popupmenu10 -
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu18_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlot=get(handles.popupmenu16,'value')-1;
linkReportTypeId=get(handles.popupmenu18,'Value');
numberOfLinks=phys.M;

switch linkReportTypeId
    case 2, %
        textReport1={['PER LINK REPORT: WAVELENGTH UTILIZATION'];['----------------------------------------'];['Column 1: Link ID'];['Column 2: Origin node'];['Column 3: Destination node'];['Column 4: Distance'];['Column 5: Existing wavelengths'];['Column 6: Used wavelengths']};
    case 3, % 
        textReport1={['PER LINK REPORT: ROUTED TRAFFIC'];['--------------------------------'];['Column 1: Link ID'];['Column 2: Origin node'];['Column 3: Destination node'];['Column 4: Distance'];['Column 5: Routed traffic']};
    otherwise
        error ('Not Link Valid Report Type ID !!!');
end

for linkID=1:numberOfLinks
    string1 = sprintf ('%4d %2d %2d %3d %3d ' , [linkID phys.linkTable(linkID,1) phys.linkTable(linkID,2) phys.lightpathCapacity phys.linkLengthInKm(linkID)]);
    switch linkReportTypeId
        case 2,
            string1 = [string1 sprintf('%3d %3d',[phys.numberWavelengthPerFiber(linkID) sweepOfStatMetrics{timeSlot}.NrUsedWavelengthsPerFiber(linkID)])];
        case 3,
            string1 = [string1 sprintf('%3.1f ',[sweepOfStatMetrics{timeSlot}.linkTraffic(linkID)])]; 
        otherwise
            error ('Not Link Valid Report Type ID !!!');
    end
    string1={string1};
    textReport1=vertcat(textReport1,string1);
end

textReport1 = vertcat (textReport1 , {[''];['Summary information:'];['--------------------']}); 

switch linkReportTypeId
    case 2,
        auxTextReport2={['Average used wavelength per link: ',num2str(sweepOfStatMetrics{timeSlot}.averNrUsedWavelengthsPerFiber)]};
        textReport1 =vertcat(textReport1,auxTextReport2);
    case 3,
        auxTextReport2={['Average routed traffic per link: ',num2str(sweepOfStatMetrics{timeSlot}.averLinkTraffic)]};
        textReport1 =vertcat(textReport1 ,auxTextReport2);
end

textReport1 = vertcat (textReport1 , {[''];[''];['']});  
textReport=vertcat(get(handles.edit6,'String'),textReport1);
set(handles.edit6,'String',[]);
set(handles.edit6,'String',textReport);


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %popupmenu11 - 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu19_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlot=get(handles.popupmenu16,'value')-1;
nodeReportTypeId=get(handles.popupmenu19,'Value');
numberOfNodes=phys.N;

switch nodeReportTypeId
    case 2, %
        textReport1={['PER NODE REPORT: USED TRANSMITTERS/RECEIVERS/TWCS'];['--------------------------------------------------'];['Column 1: Node ID'];['Column 2: Used transmitters'];['Column 3: Used receivers'];['Column 4: Used TWCs']};
    case 3, % 
        textReport1={['PER NODE REPORT: INGRESS/EGRESS/GROOMING TRAFFIC'];['-------------------------------------------------'];['Column 1: Node ID'];['Column 2: Ingress traffic (Gbps)'];['Column 3: Egress traffic (Gbps)'];['Column 4: Grooming traffic (Gbps)']};
    otherwise
        error ('Not Valid Node Report Type ID !!!');
end

for nodeID=1:numberOfNodes
    string1 = sprintf ('%4d ' , [nodeID]);
    switch nodeReportTypeId
        case 2, 
            string1 = [string1 sprintf('%3d %3d %3d ',[sweepOfStatMetrics{timeSlot}.NrUsedTransmittersPerNode(nodeID) sweepOfStatMetrics{timeSlot}.NrUsedReceiversPerNode(nodeID) sweepOfStatMetrics{timeSlot}.NrUsedConvertersPerNode(nodeID)])];
        case 3, 
            string1 = [string1 sprintf('%3.1f %3.1f %3.1f ',[sweepOfStatMetrics{timeSlot}.ingressEgressGroomingTraffic.ingressTraffic(nodeID) sweepOfStatMetrics{timeSlot}.ingressEgressGroomingTraffic.egressTraffic(nodeID) sweepOfStatMetrics{timeSlot}.ingressEgressGroomingTraffic.groomingTraffic(nodeID)])]; 
        otherwise
            error ('Not Valid Node Report Type ID !!!');
    end
    string1={string1};
    textReport1=vertcat(textReport1,string1);
end

switch nodeReportTypeId
    case 2,
        
    case 3,
        textReport1 = vertcat (textReport1 , {[''];['Summary information:'];['--------------------']}); 
        auxTextReport={['Average ingress traffic (Gbps): ',num2str(sweepOfStatMetrics{timeSlot}.averIngressTraffic)],
            ['Average egress traffic (Gbps): ',num2str(sweepOfStatMetrics{timeSlot}.averEgressTraffic)],
            ['Average grooming traffic (Gbps): ',num2str(sweepOfStatMetrics{timeSlot}.averGroomingTraffic)]};
        textReport1 =vertcat(textReport1 ,auxTextReport);
end

textReport1 = vertcat (textReport1 , {[''];[''];['']});  
textReport=vertcat(get(handles.edit6,'String'),textReport1);
set(handles.edit6,'String',[]);
set(handles.edit6,'String',textReport);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%popupmenu12 - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = popupmenu20_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlot=get(handles.popupmenu16,'value')-1;
flowReportTypeId=get(handles.popupmenu20,'Value');
numberOfFlows=size(sweepOfNetStates{timeSlot}.flowRoutingMatrix,1);

switch flowReportTypeId
    case 2, %        
        textReport1={['PER FLOW REPORT: LOST TRAFFIC'];['------------------------------'];['Column 1: Serial number of the flow'];['Column 2: IngressNode'];['Column 3: EgressNode'];['Column 4: Offered traffic (Gbps)'];['Column 5: Lost traffic (Gbps)']};
    case 3, % 
        textReport1={['PER FLOW REPORT: NUMBER OF VIRTUAL HOPS'];['----------------------------------------'];['Column 1: Serial number of the flow'];['Column 2: IngressNode'];['Column 3: EgressNode'];['Column 4: Offered traffic (Gbps)'];['Column 5: Weighted number of hops ']};
    otherwise
        error ('Not Valid Flow Report Type ID !!!');
end

for flowID=1:numberOfFlows
    string1 = sprintf ('%4d %2d %2d %3.1f ' , [sweepOfNetStates{timeSlot}.flowTable(flowID,1) sweepOfNetStates{timeSlot}.flowTable(flowID,2) sweepOfNetStates{timeSlot}.flowTable(flowID,3) sweepOfNetStates{timeSlot}.flowTable(flowID,4)]);
    switch flowReportTypeId
        case 2, 
            string1 = [string1 sprintf('%3.1f ',[sweepOfStatMetrics{timeSlot}.lostTraffic(flowID)])];
        case 3, 
            string1 = [string1 sprintf('%3d ',[sweepOfStatMetrics{timeSlot}.numVirtHopsPerFlow(flowID)])]; 
        otherwise
            error ('Not Valid Flow Report Type ID !!!');
    end
    string1={string1};
    textReport1=vertcat(textReport1,string1);
end

textReport1 = vertcat (textReport1 , {[''];['Summary information:'];['--------------------']}); 

switch flowReportTypeId
    case 2,
        auxTextReport={['Fraction of lost traffic: ',num2str(sweepOfStatMetrics{timeSlot}.fractionOfLostTraffic)]};
        textReport1 =vertcat(textReport1 ,auxTextReport);
    case 3,
        auxTextReport={['Average weighted number of hops: ',num2str(sweepOfStatMetrics{timeSlot}.averNumVirtHopsPerFlow)]};
        textReport1 =vertcat(textReport1 ,auxTextReport);
end

textReport1 = vertcat (textReport1 , {[''];['']});  
textReport=vertcat(get(handles.edit6,'String'),textReport1);
set(handles.edit6,'String',[]);
set(handles.edit6,'String',textReport);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbuttonSaveXML - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = pushbuttonSaveXMLTimeSlot_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlotToSave=get(handles.popupmenuTimeSlot,'Value')-1;

if timeSlotToSave~=0
    metadataFigure=openfig('metadataFigure_MH.fig','reuse');
    dataMetadataFigure=guihandles(metadataFigure);
    guidata(metadataFigure,dataMetadataFigure);
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pushbuttonSaveXML - 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = pushbuttonSaveXML_Callback(h, eventdata, handles, varargin)

load_global_Multihour;
timeSlotToSave=-1;

metadataFigure=openfig('metadataFigure_MH.fig','reuse');
dataMetadataFigure=guihandles(metadataFigure);
guidata(metadataFigure,dataMetadataFigure);

Contact us