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