0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function progressBar(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % Progress bar for the LTPDA GUI.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % This function is called whenever the user starts an analysis by clicking
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % on the 'Start' button in the LTPDA GUI.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % It calculates how many blocks in the current Simulink model are
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % M-S-function blocks calling 'ltpdasim.m', ie. how many LTPDA analysis
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % blocks are present.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % This excludes all 'service' blocks which do not perform any real
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % calculation, such as the input 'Object from list' block or the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % 'Send to output' block: the execution of these blocks is almost immediate
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % and there would be non sense in considering them for the sake of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % 'progress bar'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % Actually, the progress bar do NOT provide an estimate of the remaining
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % time, since this would be impossible to achieve (the time required by
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % every function/block is different and depending on its relative input,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % so there's no way to estimate it). It only shows how many blocks there
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % are, how many have already been executed and how many to go.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % Its primary purpose thus is provide the user with a perception of how the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % analysis is going, and in case which block requires too much time to be
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % executed.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % $Id: progressBar.m,v 1.8 2008/11/06 10:04:36 nicola Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 close(findobj('Name','LTPDA Progress Bar'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 funcBlocks = utils.prog.find_in_models(bdroot,'LookUnderMasks','all','FunctionName','ltpdasim');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 screenSize = get(0,'ScreenSize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 backColor = [0.98 , 0.98 , 0.98];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 loopStatus = getappdata(0,'loopStatus');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 if isempty(loopStatus)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 position = [(screenSize(3)-400)/2,(screenSize(4)-200)/2,400,180];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 progressWind = figure('Position',position,'Name','LTPDA Progress Bar','Tag','LTPDAProgressBar','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 barBackSize = [position(3)-20,14];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 barBackDimension = [(position(3)-barBackSize(1))/2 , (position(4)-barBackSize(2))/2-25 , barBackSize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 progressBack = axes('Parent',progressWind,'Units','pixels','Position',barBackDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 image(imread('progressbarg.jpg'),'Parent',progressBack);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 barSize = [1,14];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 barDimension = [(position(3)-barBackSize(1))/2 , (position(4)-barBackSize(2))/2-25 , barSize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 set(progressBack,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 progressBar = axes('Parent',progressWind,'Units','pixels','Position',barDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 image(imread('progressbar.jpg'),'Parent',progressBar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 set(progressBar,'Tag','progressaxes')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 set(progressBar,'UserData',barBackDimension)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 set(progressBar,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 set(gcf,'NextPlot','new');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 % Total number of blocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-40 position(3) 20],'String',['Total number of blocks to compute: ',num2str(numel(funcBlocks))],'FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Tag','blockstotal','UserData',numel(funcBlocks),'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % Currently executed block
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-85 position(3) 35],'String','','FontName','Arial','FontSize',9,'FontWeight','bold','Visible','on','Tag','currentexec','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % Blocks done
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[10 (position(4)-barBackSize(2))/2-5 60 14],'String','Done: 0','FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Tag','done','UserData',0,'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % Blocks to go
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','right','Position',[position(3)-60-10 (position(4)-barBackSize(2))/2-5 60 14],'String',['To go: ',num2str(numel(funcBlocks))],'FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Tag','togo','UserData',numel(funcBlocks),'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % Press X to stop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 20 position(3) 20],'String','Press X to stop the analysis','FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 else % loop execution
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 position = [(screenSize(3)-400)/2,(screenSize(4)-320)/2,400,300];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 progressWind = figure('Position',position,'Name','LTPDA Progress Bar','Tag','LTPDAProgressBar','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 barBackSize = [position(3)-20,14];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 barBackDimension = [(position(3)-barBackSize(1))/2 , (position(4)-barBackSize(2))/2+35 , barBackSize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 progressBack = axes('Parent',progressWind,'Units','pixels','Position',barBackDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 image(imread('progressbarg.jpg'),'Parent',progressBack);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 barSize = [1,14];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 set(progressBack,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 barDimension = [(position(3)-barBackSize(1))/2 , (position(4)-barBackSize(2))/2+35 , barSize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 progressBar = axes('Parent',progressWind,'Units','pixels','Position',barDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 image(imread('progressbar.jpg'),'Parent',progressBar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 set(progressBar,'Tag','progressaxes')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 set(progressBar,'UserData',barBackDimension)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 set(progressBar,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 barBackDimension(2) = (position(4)-barBackSize(2))/2-60;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 barDimension(2) = (position(4)-barBackSize(2))/2-60;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 progressBack2 = axes('Parent',progressWind,'Units','pixels','Position',barBackDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 image(imread('progressbarg.jpg'),'Parent',progressBack2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 set(progressBack2,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 progressBarLoop = axes('Parent',progressWind,'Units','pixels','Position',barDimension);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 image(imread('progressbarb.jpg'),'Parent',progressBarLoop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 set(progressBarLoop,'Tag','progressaxes2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 set(progressBarLoop,'UserData',barBackDimension)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 axis off;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 set(progressBarLoop,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 set(gcf,'NextPlot','new');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % Total number of blocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-40 position(3) 20],'String',['Total number of blocks to compute: ',num2str(numel(funcBlocks))],'FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Tag','blockstotal','UserData',numel(funcBlocks),'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 % Currently executed block
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-70 position(3) 20],'String','','FontName','Arial','FontSize',9,'FontWeight','bold','Visible','on','Tag','currentexec','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 % Blocks done
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[10 (position(4)-barBackSize(2))/2+50 90 14],'String','Blocks done: 0','FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Tag','done','UserData',0,'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % Blocks to go
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','right','Position',[position(3)-60-10 (position(4)-barBackSize(2))/2+50 60 14],'String',['To go: ',num2str(numel(funcBlocks))],'FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Tag','togo','UserData',numel(funcBlocks),'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % Total number of loops
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 loopStatus = getappdata(0,'loopStatus');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 (position(4)-barBackSize(2))/2-15 position(3) 20],'String',['Total number of loops to compute: ',num2str(loopStatus(1))],'FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % Loops done
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','left','Position',[10 (position(4)-barBackSize(2))/2-45 90 14],'String',['Loops done: ',num2str(loopStatus(2))],'FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % Loops to go
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','right','Position',[position(3)-60-10 (position(4)-barBackSize(2))/2-45 60 14],'String',['To go: ',num2str(loopStatus(1)-loopStatus(2))],'FontName','Arial','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % Press X to stop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 10 position(3) 20],'String','Press X to stop the analysis','FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % Estimated time to completion:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 if nargin>0 && ~isempty(varargin{1})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 executionTime = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 time2go = datestr(mean(executionTime)*(loopStatus(1)-loopStatus(2)+1),'MM:SS');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 time2go = '--:--';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 uicontrol('Parent',progressWind,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 40 position(3) 20],'String',['Estimated time to completion: ',time2go],'FontName','Arial','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 end
|