0001 function pan7partial(varargin)
0002
0003
0004
0005
0006
0007
0008
0009 scaleX = getappdata(0, 'ltpda_gui_scalefactor');
0010 guiFontSize = round(8*scaleX);
0011
0012 alltimers = timerfindall;
0013 stop(alltimers(2));
0014 set(alltimers(2),'TimerFcn',@ContinuousCheck,'Period',1);
0015 start(alltimers(2));
0016
0017
0018
0019 currPanel = varargin{1};
0020 panelDimens = get(currPanel, 'Position');
0021 backColor = get(currPanel, 'BackgroundColor');
0022
0023
0024 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.17 0.89 0.125 0.040],'String','Current system:','FontName','Times New Roman','FontSize',guiFontSize+4,'FontWeight','normal','Visible','on','Style','text');
0025 currsystem = bdroot;
0026 if isempty(currsystem) || isempty(find_system(currsystem,'FindAll','on','Type','Annotation','Tag','ltpda model')), currsystem = 'None'; end
0027 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.3 0.89 0.1875 0.040],'String',currsystem,'FontName','Times New Roman','FontSize',guiFontSize+4,'FontWeight','bold','Visible','on','UserData','currsystem','Style','text');
0028
0029
0030 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.5 0.89 0.125 0.040],'String','Current block:','FontName','Times New Roman','FontSize',guiFontSize+4,'FontWeight','normal','Visible','on','Style','text');
0031 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[0.62 0.89 0.1875 0.040],'String','','FontName','Times New Roman','FontSize',guiFontSize+4,'FontWeight','bold','Visible','on','UserData','currblock','Style','text');
0032
0033
0034
0035 FirstPanPos = [.0125 .56 .975 .26];
0036 hFirstPanel = uipanel('Parent',currPanel,'BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',FirstPanPos);
0037 logosize = [53 55]*scaleX;
0038 icon1 = axes('Parent',hFirstPanel,'Units','normalized','Position',[.03 .45 0.3 0.3]);
0039 iconSize = getpixelposition(icon1); panelSize = getpixelposition(hFirstPanel); iconSize(3:4) = logosize; iconSize(2)= (panelSize(4)-iconSize(4))/2; setpixelposition(icon1,iconSize);
0040 image(imread('iconpar1.jpg'),'Parent',icon1,'Tag','partial1');
0041 axis(icon1,'off');
0042 clear logosize iconSize panelSize
0043
0044 firstText = sprintf('Execution from the beginning to the current block.\n\nThis option is always possible: are executed only those blocks parent of the current one, and the execution is stopped as soon as the current one is reached.');
0045 uicontrol('Parent',hFirstPanel,'BackgroundColor',backColor,'Units','normalized','HorizontalAlignment','left','Position',[0.15 0.2 0.8 0.6],'String',firstText,'FontSize',guiFontSize,'Visible','on','Style','text','Tag','infotext1');
0046
0047
0048 SecondPanPos = [.0125 .29 .975 .26];
0049 hSecondPanel = uipanel('Parent',currPanel,'BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',SecondPanPos);
0050 logosize = [53 55]*scaleX;
0051 icon2 = axes('Parent',hSecondPanel,'Units','normalized','Position',[.03 .45 0.3 0.3]);
0052 iconSize = getpixelposition(icon2); panelSize = getpixelposition(hFirstPanel); iconSize(3:4) = logosize; iconSize(2)= (panelSize(4)-iconSize(4))/2; setpixelposition(icon2,iconSize);
0053 image(imread('iconpar2.jpg'),'Parent',icon2,'Tag','partial2');
0054 axis(icon2,'off');
0055 clear logosize iconSize panelSize
0056
0057 secondText = sprintf('Execution of the current block only.\n\nThis option is possible only if all the inputs necessary to the currently selected block are available; this means that the model must have already been executed and either all intermediate results are maintained, or just those necessary to the current block.');
0058 uicontrol('Parent',hSecondPanel,'BackgroundColor',backColor,'Units','normalized','HorizontalAlignment','left','Position',[0.15 0.2 0.8 0.6],'String',secondText,'FontSize',guiFontSize,'Visible','on','Style','text','Tag','infotext2');
0059
0060
0061 ThirdPanPos = [.0125 .02 .975 .26];
0062 hThirdPanel = uipanel('Parent',currPanel,'BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',ThirdPanPos);
0063 logosize = [53 55]*scaleX;
0064 icon3 = axes('Parent',hThirdPanel,'Units','normalized','Position',[.03 .45 0.3 0.3]);
0065 iconSize = getpixelposition(icon3); panelSize = getpixelposition(hFirstPanel); iconSize(3:4) = logosize; iconSize(2)= (panelSize(4)-iconSize(4))/2; setpixelposition(icon3,iconSize);
0066 image(imread('iconpar3.jpg'),'Parent',icon3,'Tag','partial3');
0067 axis(icon3,'off');
0068 clear logosize iconSize panelSize
0069
0070 thirdText = sprintf('Execution from the current block to the end.\n\nThis option is possible only if all the inputs necessary to the currently selected block are available; this means that the model must have already been executed and either all intermediate results are maintained, or just those necessary to the current block.\nAfter the current block the execution continues, updating all the following blocks');
0071 uicontrol('Parent',hThirdPanel,'BackgroundColor',backColor,'Units','normalized','HorizontalAlignment','left','Position',[0.15 0.2 0.8 0.6],'String',thirdText,'FontSize',guiFontSize,'Visible','on','Style','text','Tag','infotext3');
0072
0073
0074 UpdatePanel(1);
0075
0076
0077
0078
0079
0080 function ContinuousCheck(varargin)
0081
0082
0083
0084 alltimers = timerfindall;
0085 if strcmp(get(alltimers(1),'Running'),'off')
0086 start(alltimers(1))
0087 end
0088
0089 currsys = bdroot;
0090 oldsys = get(findobj('UserData', 'currsystem'), 'String');
0091 currselection = utils.prog.gcbsh;
0092 if numel(currselection)>1, UpdatePanel(1); return; end
0093 if isempty(currsys) || isempty(currselection), UpdatePanel(1); return; end
0094 currblock = get_param(currselection,'Name');
0095 oldblock = get(findobj('UserData', 'currblock'), 'String');
0096 if strcmp(currsys,oldsys) && strcmp(currblock,oldblock), return; end
0097
0098 if ~isempty(currsys) && ~isempty(find_system(currsys,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0099 currchild = find_system(currselection,'LookUnderMasks','all','BlockType','M-S-Function');
0100 if isempty(currchild) || ~strcmp(get_param(currchild,'FunctionName'),'ltpdasim')
0101
0102 UpdatePanel(2)
0103 return;
0104 else
0105 annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
0106 execHistory = get_param(annotation,'UserData');
0107 if isempty(execHistory)
0108
0109 UpdatePanel(3)
0110 return;
0111 else
0112 blockIndex = -1;
0113 for i=1:size(execHistory,1), if execHistory{i,2}==currselection, blockIndex=i; break; end; end
0114 if blockIndex==-1
0115
0116 UpdatePanel(3)
0117 return;
0118 end
0119 for i=3:size(execHistory,2)
0120 if execHistory{blockIndex,i}==-1
0121
0122 UpdatePanel(3)
0123 return;
0124 end
0125 end
0126
0127 UpdatePanel(4)
0128 end
0129 end
0130 else
0131
0132 UpdatePanel(1)
0133 end
0134
0135 end
0136
0137
0138
0139 function UpdatePanel(varargin)
0140
0141
0142
0143
0144
0145
0146
0147 switch varargin{1}
0148 case 1
0149 set(findobj('UserData', 'currsystem'), 'String', 'None')
0150 set(findobj('UserData', 'currblock'), 'String', '---')
0151 set(findobj('Tag','partial1'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0152 set(findobj('Tag','partial2'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0153 set(findobj('Tag','partial3'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0154 set(findobj('Tag','infotext1'),'ForegroundColor',[.8 .8 .8]);
0155 set(findobj('Tag','infotext2'),'ForegroundColor',[.8 .8 .8]);
0156 set(findobj('Tag','infotext3'),'ForegroundColor',[.8 .8 .8]);
0157 case 2
0158 set(findobj('UserData', 'currsystem'), 'String', bdroot)
0159 set(findobj('UserData', 'currblock'), 'String', 'Not valid')
0160 set(findobj('Tag','partial1'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0161 set(findobj('Tag','partial2'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0162 set(findobj('Tag','partial3'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0163 set(findobj('Tag','infotext1'),'ForegroundColor',[.8 .8 .8]);
0164 set(findobj('Tag','infotext2'),'ForegroundColor',[.8 .8 .8]);
0165 set(findobj('Tag','infotext3'),'ForegroundColor',[.8 .8 .8]);
0166 case 3
0167 set(findobj('UserData', 'currsystem'), 'String', bdroot)
0168 set(findobj('UserData', 'currblock'), 'String', get_param(gcbh,'Name'))
0169 set(findobj('Tag','partial1'),'CData',imread('iconpar1.jpg'),'ButtonDownFcn',@Run1);
0170 set(findobj('Tag','partial2'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0171 set(findobj('Tag','partial3'),'CData',imread('iconpar4.jpg'),'ButtonDownFcn','');
0172 set(findobj('Tag','infotext1'),'ForegroundColor',[0 0 0]);
0173 set(findobj('Tag','infotext2'),'ForegroundColor',[.8 .8 .8]);
0174 set(findobj('Tag','infotext3'),'ForegroundColor',[.8 .8 .8]);
0175 case 4
0176 set(findobj('UserData', 'currsystem'), 'String', bdroot)
0177 set(findobj('UserData', 'currblock'), 'String', get_param(gcbh,'Name'))
0178 set(findobj('Tag','partial1'),'CData',imread('iconpar1.jpg'),'ButtonDownFcn',@Run1);
0179 set(findobj('Tag','partial2'),'CData',imread('iconpar2.jpg'),'ButtonDownFcn',@Run2);
0180 set(findobj('Tag','partial3'),'CData',imread('iconpar3.jpg'),'ButtonDownFcn',@Run3);
0181 set(findobj('Tag','infotext1'),'ForegroundColor',[0 0 0]);
0182 set(findobj('Tag','infotext2'),'ForegroundColor',[0 0 0]);
0183 set(findobj('Tag','infotext3'),'ForegroundColor',[0 0 0]);
0184 end
0185
0186 end
0187
0188
0189
0190 function Run1(varargin)
0191
0192
0193
0194 parentsBlock = unique(utils.prog.findparent(gcbh));
0195 parentsBlock = [parentsBlock ; find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function');];
0196
0197 assignin('base','executionList',parentsBlock);
0198 ltpdagui('redraw',1.1);
0199
0200 end
0201
0202
0203
0204 function Run2(varargin)
0205
0206
0207 assignin('base','executionList',find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function') );
0208 ltpdagui('redraw',1.1);
0209
0210 end
0211
0212
0213
0214 function Run3(varargin)
0215
0216
0217
0218 childrenBlock = unique(utils.prog.findchildren(gcbh));
0219 childrenBlock(:,2) = 0;
0220 while min(childrenBlock(:,2))==0
0221 for i=1:size(childrenBlock,1)
0222 if childrenBlock(i,2)==0
0223 nextGenerationChildren = utils.prog.findchildren(childrenBlock(i,1));
0224 nextGenerationChildren(:,2) = 0;
0225 if nextGenerationChildren(1,1)~=0
0226 childrenBlock = [childrenBlock ; nextGenerationChildren];
0227 end
0228 childrenBlock(i,2) = 1;
0229 end
0230 end
0231 childrenBlock = unique(childrenBlock,'rows');
0232 end
0233 childrenBlock(:,2)=[];
0234 childrenBlock = [gcbh ; childrenBlock];
0235
0236 assignin('base','executionList',childrenBlock);
0237 ltpdagui('redraw',1.1);
0238
0239 end
0240
0241
0242 end