0001 function pan1main(varargin)
0002
0003
0004
0005
0006
0007
0008 global LTPDAinvar LTPDAoutvar currentsystem gl
0009
0010
0011 InputObjList='';
0012 UpdateListbox();
0013
0014 scaleX = getappdata(0, 'ltpda_gui_scalefactor');
0015 guiFontSize = round(8*scaleX);
0016
0017 alltimers = timerfindall;
0018 stop(alltimers(2));
0019 set(alltimers(2),'TimerFcn',@ContinuousCheck,'Period',1);
0020 start(alltimers(2));
0021 set(gcf,'NextPlot','new')
0022 set(gcf,'CloseRequestFcn',{@AskConfirm,'close'})
0023
0024
0025
0026 currPanel = varargin{1};
0027 if nargin>1, runSim = varargin{2}; else runSim = 0; end
0028 panelDimens = get(currPanel, 'Position');
0029 backColor = get(currPanel, 'BackgroundColor');
0030
0031 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Units','normalized','Position',[0.0375 0.895 0.075 0.06],'String','Username:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
0032 uicontrol('Parent',currPanel,'BackgroundColor',[0.9,0.9,0.9],'Units','normalized','HorizontalAlignment','center','Position',[0.1187 0.9213 0.1 0.050],'String',getappdata(0,'ltpda_repo_user'),'FontSize',guiFontSize,'FontAngle','italic','Visible','on','Enable','off','Callback',@UserIDCallback,'Style','edit');
0033 uicontrol('Parent',currPanel,'Units','normalized','HorizontalAlignment','center','Position',[0.2375 0.9274 0.15 0.040],'String','Login / Logout','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@LogoutCallback,'Style','pushbutton');
0034
0035 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Units','normalized','Position',[0.5 0.915 0.125 0.040],'String','Current system:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
0036 currsystem = bdroot;
0037 if isempty(currsystem) || isempty(find_system(currsystem,'FindAll','on','Type','Annotation','Tag','ltpda model')), currsystem = 'None'; end
0038 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Units','normalized','Position',[0.6375 0.915 0.1875 0.040],'String',currsystem,'FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','UserData','currsystem','Style','text');
0039
0040
0041 AnalysPanPos = [.0125 .7983 .975 .111];
0042
0043 hanalysisPanel = uipanel('Parent',currPanel,'Title','Analyses Control Panel','BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',AnalysPanPos);
0044 logosize = [40 35]*scaleX;
0045 icon1 = axes('Parent',hanalysisPanel,'Units','normalized','Position',[.01 .05 0.3 0.3]);
0046 iconSize = getpixelposition(icon1); iconSize(3:4) = logosize; setpixelposition(icon1,iconSize);
0047 image(imread('icongraph.jpg'),'Parent',icon1);
0048 axis(icon1,'off');
0049 clear logosize icon1
0050
0051 nbuttons = 3;
0052 buttonWidth = (AnalysPanPos(3)-.0625-.0125*(nbuttons+1))/nbuttons;
0053 buttonPos = [AnalysPanPos(1)+.075 .2 buttonWidth .6];
0054 uicontrol('Parent',hanalysisPanel,'Units','pixels','Units','normalized','Position',buttonPos,'String','New model','TooltipString','Create a new LTPDA Simulink model','HorizontalAlignment','center','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hNewButtonCallback,'Style','pushbutton');
0055 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0056 uicontrol('Parent',hanalysisPanel,'Units','pixels','Units','normalized','Position',buttonPos,'String','Open model','TooltipString','Open an existing LTPDA Simulink model','HorizontalAlignment','center','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hOpenCallback,'Style','pushbutton');
0057 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0058 uicontrol('Parent',hanalysisPanel,'Units','pixels','Units','normalized','Position',buttonPos,'String','Save model','TooltipString','Save the currently selected LTPDA Simulink model','HorizontalAlignment','center','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hSaveCallback,'Style','pushbutton');
0059 clear AnalysPanPos nbuttons buttonWidth buttonPos
0060
0061
0062 DataPanPos = [.015 .1633 .975 .615];
0063 hDataPanel = uipanel('Parent',currPanel,'Title','Data Control Panel','BackgroundColor',[1,1,1],'FontSize',guiFontSize-1,'Units','normalized','Position',DataPanPos);
0064 logosize = [48 39]*scaleX;
0065 icon2 = axes('Parent',hDataPanel,'Units','normalized','Position',[.01 0.81 0.3 0.3]);
0066 iconSize = getpixelposition(icon2); iconSize(3:4) = logosize; setpixelposition(icon2,iconSize);
0067 image(imread('icondata.jpg'),'Parent',icon2);
0068 axis(icon2,'off');
0069 clear logosize icon2
0070
0071 nbuttons = 3;
0072 buttonWidth = (DataPanPos(3)-.0625-.0125*(nbuttons+1))/nbuttons;
0073 buttonPos = [DataPanPos(1)+.075 .9 buttonWidth .08];
0074 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Load','TooltipString','Load data from file','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hLoadDataButtonCallback,'Style','pushbutton');
0075
0076
0077
0078
0079 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0080 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Remove','TooltipString','Clear the selected object from memory','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hRemoveButtonCallback,'Style','pushbutton');
0081 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0082 hExploreButton = uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Explore','TooltipString','Explore the selected objects with the LTPDA Explorer','FontSize',guiFontSize,'Visible','on','Enable','on','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
0083 clear nbuttons buttonWidth buttonPos
0084
0085 nbuttons = 4;
0086 buttonWidth = (DataPanPos(3)-.0625-.012510*(nbuttons+1))/nbuttons;
0087 buttonPos = [DataPanPos(1)+.075 .8 buttonWidth .08];
0088
0089
0090 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Clear all input','TooltipString','Clear from memory the entire list of input objects','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',{@AskConfirm,'clear'},'Style','pushbutton');
0091 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0092 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Export to workspace','TooltipString','Export the selected objects from LTPDA to MATLAB workspace','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hExportButtonCallback,'Style','pushbutton');
0093 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0094 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Save workspace','TooltipString','Save the LTPDA Workspace as .MAT file','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@SaveWorkspaceCallback,'Style','pushbutton');
0095 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
0096 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Load workspace','TooltipString','Load a workspace from a .MAT file','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@LoadWorkspaceCallback,'Style','pushbutton');
0097 clear nbuttons buttonWidth buttonPos
0098
0099
0100 textPos = [.0125 .67 .5 .083];
0101 uicontrol('Parent',hDataPanel,'BackgroundColor',get(hDataPanel,'BackgroundColor'),'HorizontalAlignment','center','Units','normalized','Position',textPos,'String','Input:','FontName','Times New Roman','FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Style','text');
0102 clear textPos
0103
0104 nlists = 2;
0105 listWidth = (DataPanPos(3)-.0125*(nlists+1))/nlists;
0106 listPos = [.0125 .03 listWidth .66];
0107 InputObjList = uicontrol('Parent',hDataPanel,'BackgroundColor',[0.95,0.95,0.95],'HorizontalAlignment','center','Units','normalized','Position',listPos,'String',listInput,'Value',1,'Max',10,'Min',1,'FontSize',guiFontSize,'FontWeight','normal','Visible','on','Enable','on','Callback',@hListObjsCallback,'Tag','InputObjList','Style','listbox');
0108 set(hExploreButton,'UserData',InputObjList);
0109 listPos(1) = listPos(1)+listWidth+.0125;
0110
0111 uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','listbox','HorizontalAlignment', 'left','Fontsize', guiFontSize,'Units','pixels','Units','normalized','Position',listPos,'Tag','infoPanel');
0112 hListObjsCallback(InputObjList,1);
0113 clear DataPanPos nlists listWidth listPos
0114
0115
0116 hExecutionPanel = uipanel('Parent',currPanel,'Title','Execution control','BackgroundColor',[1,1,1],'FontSize',guiFontSize-1,'Units','normalized','Position',[.0125 .0222 .975 .121]);
0117 logosize = [46 40]*scaleX;
0118 icon3 = axes('Parent',hExecutionPanel,'Units','normalized','Position',[.01 .05 0.3 0.3]);
0119 iconSize = getpixelposition(icon3); iconSize(3:4) = logosize; setpixelposition(icon3,iconSize);
0120 image(imread('iconsettings.jpg'),'Parent',icon3);
0121 axis(icon3,'off');
0122 clear logosize icon3
0123
0124 if isempty(getappdata(0,'maintainresults')), setappdata(0,'maintainresults',0); end
0125 uicontrol('Parent',hExecutionPanel,'BackgroundColor',[1 1 1],'HorizontalAlignment','left','Units','normalized','Position',[.1 .166 .3 .5],'Value',getappdata(0,'maintainresults'),'String',' Maintain all results','FontSize',guiFontSize+1,'TooltipString','Enable this if you want to maintain the results from all blocks at the end of the analysis calculation','ForeGroundColor','black','Visible','on','Enable','on','Callback','setappdata(0,''maintainresults'',get(gco,''Value''))','Style','checkbox');
0126 if isempty(getappdata(0,'hidenames')), setappdata(0,'hidenames',0); end
0127 uicontrol('Parent',hExecutionPanel,'BackgroundColor',[1 1 1],'HorizontalAlignment','left','Units','normalized','Position',[.4 0.166 .23 .5],'Value',getappdata(0,'hidenames'),'String',' Hide block names','FontSize',guiFontSize+1,'TooltipString','Enable this to hide blocks names for clarity; this will work only in the parameters panel','ForeGroundColor','black','Visible','on','Enable','on','Callback','setappdata(0,''hidenames'',get(gco,''Value''))','Style','checkbox');
0128
0129 if runSim == 1, StartExec(); end
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 function ContinuousCheck(varargin)
0142
0143
0144
0145 alltimers = timerfindall;
0146 if strcmp(get(alltimers(1),'Running'),'off')
0147 start(alltimers(1))
0148 end
0149
0150 currsys = bdroot;
0151 if ~isempty(currsys) && ~isempty(find_system(currsys,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0152 set(findobj('UserData', 'currsystem'), 'String', currsys)
0153 else
0154 set(findobj('UserData', 'currsystem'), 'String', 'None')
0155 end
0156
0157 end
0158
0159
0160
0161
0162 function LogoutCallback(varargin)
0163
0164
0165 setappdata(0,'ltpda_repo_pass','');
0166 userID = getappdata(0,'ltpda_repo_user');
0167 if isempty(userID), userID = ''; end
0168
0169 [userID passwd] = loginLTPDA(userID,'');
0170 setappdata(0,'ltpda_repo_user',userID)
0171 setappdata(0,'ltpda_repo_pass',passwd)
0172
0173 ltpdagui('Redraw',1);
0174
0175 end
0176
0177
0178
0179 function AskConfirm(varargin)
0180
0181
0182
0183 screenSize = get(0,'ScreenSize');
0184 backColor = [1 1 1];
0185 position = [(screenSize(3)-250)/2,(screenSize(4)-160)/2,250,160];
0186 confirmFig = figure('Position',position,'Name','Please confirm','Tag','ConfirmReset','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
0187
0188 uicontrol('Parent',confirmFig,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-40 position(3) 20],'String','Are you sure?','FontName','Times New Roman','FontSize',13,'FontWeight','normal','Visible','on','Style','text');
0189
0190 dimension = position;
0191 logosize = [77 95];
0192 dimension = [50 , dimension(4)-logosize(2)-50 , logosize];
0193 yesbut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','Yes');
0194 image(imread('buttonyes2.jpg'),'Parent',yesbut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',0); uiresume;','Tag','YesButton');
0195 axis(yesbut,'off');
0196
0197 dimension = position;
0198 logosize = [77 95];
0199 dimension = [127 , dimension(4)-logosize(2)-50 , logosize];
0200 nobut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','No');
0201 image(imread('buttonno2.jpg'),'Parent',nobut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',1); uiresume;','Tag','NoButton');
0202 axis(nobut,'off');
0203
0204 uiwait;
0205
0206 if get(confirmFig,'UserData'), delete(confirmFig); return; end
0207
0208 if strcmp(varargin{3},'close')
0209 delete(confirmFig);
0210 disp('Closing LTPDA GUI...');
0211 delete(timerfindall);
0212 clear global LTPDAinvar LTPDAoutvar;
0213 setappdata(0,'ltpda_repo_user',''); setappdata(0,'ltpda_repo_pass','');
0214 closereq
0215 elseif strcmp(varargin{3},'clear')
0216 delete(confirmFig);
0217 LTPDAinvar={};
0218 set(InputObjList,'Value',1)
0219 set(findobj('Tag', 'infoPanel'), 'String', '')
0220 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
0221 UpdateListbox();
0222 end
0223
0224 end
0225
0226
0227
0228
0229 function hLoadDataButtonCallback(varargin)
0230
0231
0232 filenames = uipickfiles('REFilter','.txt');
0233 if ~isempty(filenames) && ~isnumeric(filenames(1,1))
0234 [x,y]=size(filenames);
0235 for j=1:y
0236 ext = filenames{j}(end-2:end);
0237 if strcmpi(ext,'mat')
0238 varlist = whos('-file',filenames{j});
0239 for k=1:numel(varlist)
0240 newObj = load(filenames{j},varlist(k).name);
0241 newObj = eval(['newObj.',varlist(k).name]);
0242 if isa(newObj,'ltpda_uo')
0243 LTPDAinvar = [LTPDAinvar; {newObj,1} ];
0244 disp(' + 1 Obj added to the global variable LTPDAinvar')
0245 end
0246 end
0247 else
0248 anobject={ao(filenames{j}),1};
0249 LTPDAinvar=[LTPDAinvar;anobject];
0250 disp(' + 1 AO added to the global variable LTPDAinvar')
0251 end
0252 end
0253 UpdateListbox();
0254 end
0255
0256 end
0257
0258
0259
0260 function hRemoveButtonCallback(varargin)
0261
0262
0263 index_selected = get(InputObjList,'Value');
0264 listObjs = get(InputObjList,'String');
0265 if ~strcmp(listObjs,'The memory is empty')
0266 for i=1:numel(index_selected)
0267 objSelect = str2double(strtok(listObjs{index_selected(i),1},'.'));
0268 LTPDAinvar{objSelect,1} = [];
0269 end
0270 UpdateListbox();
0271 end
0272 set(findobj('Tag', 'infoPanel'), 'String', '')
0273
0274 end
0275
0276
0277
0278 function hExportButtonCallback(varargin)
0279
0280
0281 currSelObjs = get(InputObjList,'Value');
0282 listObjs = get(InputObjList,'String');
0283 if ~strcmp(listObjs,'The memory is empty')
0284 selectedObjs = {};
0285 for i=1:numel(currSelObjs)
0286 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0287 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0288 end
0289 if ~isempty(selectedObjs)
0290 for i=1:numel(selectedObjs)
0291 objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
0292 objName = genvarname(objName,evalin('base','who'));
0293 assignin('base', objName, selectedObjs{i});
0294 disp(['Saved to workspace with name ',objName])
0295 end
0296 end
0297 end
0298
0299 end
0300
0301
0302
0303 function hExploreButtonCallback(varargin)
0304
0305
0306 currSelObjs = get(InputObjList,'Value');
0307 listObjs = get(InputObjList,'String');
0308 if ~strcmp(listObjs,'The memory is empty')
0309 selectedObjs = {};
0310 for i=1:numel(currSelObjs)
0311 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0312 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0313 end
0314
0315 if ~isempty(selectedObjs)
0316 ltpda_explorer(selectedObjs);
0317 else
0318 ltpda_explorer(LTPDAinvar);
0319 end
0320
0321 UpdateListbox();
0322 end
0323
0324 end
0325
0326
0327
0328 function SaveWorkspaceCallback(varargin)
0329
0330
0331
0332 try
0333 [FileName,PathName] = uiputfile('*.mat','Save Workspace As');
0334 if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAinvar','LTPDAoutvar'); disp('Workspace saved'); end
0335 catch
0336 end
0337 end
0338
0339
0340
0341 function LoadWorkspaceCallback(varargin)
0342
0343
0344
0345 try
0346 [FileName,PathName] = uigetfile('*.mat','Load Workspace');
0347 temp = load(strcat(PathName,FileName),'LTPDAinvar');
0348 LTPDAinvar = [LTPDAinvar ; temp.LTPDAinvar];
0349 temp = load(strcat(PathName,FileName),'LTPDAoutvar');
0350 LTPDAoutvar = [LTPDAoutvar ; temp.LTPDAoutvar];
0351 disp('Workspace loaded')
0352 clear temp
0353 UpdateListbox()
0354 catch
0355 end
0356 end
0357
0358
0359
0360
0361 function UpdateListbox(varargin)
0362
0363
0364
0365
0366 xx = size(LTPDAinvar,1);
0367 listInput=cell(xx,1);
0368 if xx>0
0369 for j=1:xx
0370 listInput{j,1} = num2str(j);
0371 [rows,columns] = size(LTPDAinvar{j,1});
0372 if (rows>1 && columns==1) || (rows==1 && columns>1), listInput{j,1} = [listInput{j,1}, ' .(Vector ',num2str(rows),'x',num2str(columns),') '];
0373 elseif rows>1 && columns>1, listInput{j,1} = [listInput{j,1}, ' .(Matrix ',num2str(rows),'x',num2str(columns),') '];
0374 end
0375 switch class(LTPDAinvar{j,1})
0376 case 'ao'
0377 anobject = LTPDAinvar{j,1};
0378 aoname = anobject.name;
0379 aocreated = char(anobject.created);
0380 listInput{j,1} = [listInput{j,1}, ' . AO .' , aoname , '__' , aocreated];
0381 case 'plist'
0382 paramNumb = nparams(LTPDAinvar{j,1});
0383 objcreated = char(LTPDAinvar{j,1}.created);
0384 listInput{j,1}=[listInput{j,1}, ' . PLIST .',num2str(paramNumb),' params','__',objcreated];
0385 case 'specwin'
0386 listInput{j,1}=[listInput{j,1}, ' . SPECWIN .','__','no creation time'];
0387 case 'pzmodel'
0388 objcreated = char(LTPDAinvar{j,1}.created);
0389 listInput{j,1}=[listInput{j,1}, ' . PZMODEL .','__',objcreated];
0390 case 'miir'
0391 objcreated = char(LTPDAinvar{j,1}.created);
0392 listInput{j,1}=[listInput{j,1}, ' . MIIR .','__',objcreated];
0393 otherwise
0394 if isa(LTPDAinvar{j,1},'ltpda_uo')
0395 objclass = class(LTPDAinvar{j,1});
0396 if ~isempty(LTPDAinvar{j,1}), listInput{j,1}=[listInput{j,1}, ' . ',objclass]; end
0397 end
0398 end
0399 end
0400 for j=xx:-1:1
0401 if isempty(listInput{j,1})
0402 listInput(j,:)=[];
0403 end
0404 end
0405 else
0406 listInput{1,1}='The memory is empty';
0407 end
0408
0409 InputObjList = findobj('Tag','InputObjList');
0410 if ~isempty(InputObjList)
0411 set(InputObjList,'Value',1)
0412 set(InputObjList,'String',listInput)
0413 end
0414
0415 end
0416
0417
0418
0419 function hListObjsCallback(hObject, varargin)
0420
0421
0422
0423 if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAinvar,1)>0
0424 val = get(hObject, 'Value');
0425 if length(val) == 1
0426 objLines = get(hObject, 'String');
0427 if isempty(objLines) || isempty(LTPDAinvar{str2double(deblank(strtok(objLines{val}))) ,1})
0428 objtxt = '';
0429 else
0430 objnumb = str2double(deblank(strtok(objLines{val})));
0431 objtxt = display(LTPDAinvar{objnumb});
0432 end
0433 else
0434 objtxt = '';
0435 end
0436 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0437 elseif size(LTPDAinvar,1)>0
0438 if strcmp(get(gcf,'SelectionType'),'normal')
0439 val = get(hObject, 'Value');
0440 if length(val) == 1
0441 objLines = get(hObject, 'String');
0442 objnumb = str2double(deblank(strtok(objLines{val})));
0443 try
0444 objtxt = display(LTPDAinvar{objnumb});
0445 catch
0446 objtxt = class(LTPDAinvar{objnumb});
0447 end
0448 else
0449 objtxt = '';
0450 end
0451 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0452 end
0453
0454 if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String')) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0455 set_param(utils.prog.gcbsh,'Selected','off');
0456 newBlkHandle=add_block('ltpda_library/Input/Object from list', strcat(bdroot,'/AO1'),'MakeNameUnique', 'on');
0457 children=get_param(newBlkHandle,'Blocks');
0458 inputblock=strcat(get(newBlkHandle,'Path'),'/',get(newBlkHandle,'Name'),'/',children{1});
0459 val = get(hObject, 'Value');
0460 objLines = get(hObject, 'String');
0461 number = deblank(strtok(objLines{val}));
0462 set_param(inputblock,'Value',number );
0463
0464 objName = LTPDAinvar{str2double(number),1}.name;
0465 if numel(objName)>3 && strcmpi(objName,'none'), objName = class(LTPDAinvar{str2double(number),1}); end
0466 if numel(objName)>20, objName = ['...',LTPDAinvar{str2double(number),1}.name(end-20:end)]; end
0467 set_param(newBlkHandle,'AttributesFormatString',[number,': ',objName]);
0468 set_param(newBlkHandle,'Selected','on');
0469 end
0470 end
0471
0472 end
0473
0474
0475
0476
0477 function hNewButtonCallback(varargin)
0478
0479
0480
0481
0482 hour = datestr(now,13);
0483 hour(3) = hour(4);hour(4)=hour(5);hour(5)=hour(7);hour(6)=hour(8);
0484 currentsystem = strcat(getappdata(0,'ltpda_repo_user'),'_',datestr(now,7),datestr(now,5),datestr(now,11),'_',hour(1:6));
0485 if ~isempty(find_system('Name',currentsystem)), return; end
0486 simulink
0487 new_system(currentsystem)
0488 open_system(currentsystem)
0489
0490 systemHandle = get_param(gcs,'Handle');
0491 evalin('base','load ltpdaSimConfigSet.mat;');
0492 ltpdaSimConfigSet = evalin('base','ltpdaSimConfigSet');
0493 attachConfigSetCopy(systemHandle, ltpdaSimConfigSet);
0494 setActiveConfigSet(systemHandle, 'LTPDA');
0495 detachConfigSet(systemHandle, 'Configuration');
0496 evalin('base','clear ltpdaSimConfigSet;');
0497
0498 set(systemHandle,'Location',[200 100 1100 600]);
0499 set(systemHandle,'Toolbar','OFF');
0500
0501 caption = strcat(gcs,'/1');
0502 add_block('built-in/Note',caption,'Position', [100 0 0 400],'UserData',1);
0503 annotationHandle = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');
0504 caption1 = [' Analysis designed by ',getappdata(0,'ltpda_repo_user')];
0505
0506 caption2 = ['created (UTC): ',char(time)];
0507 caption3 = [' IP: ',char(getHostAddress(java.net.InetAddress.getLocalHost))];
0508 caption4 = [' OS: ',computer];
0509 caption5 = ['MATLAB ver: ',getappdata(0, 'matlab_version')];
0510 caption6 = [' LTPDA ver: ',getappdata(0, 'ltpda_version')];
0511 caption = strvcat(caption1,caption2,caption3,caption4,caption5,caption6);
0512 set_param(annotationHandle, 'HorizontalAlignment','left','Text',caption,'Tag','ltpda model')
0513 set_param(annotationHandle,'ClickFcn','disp(''You''''re not allowed to change this'')')
0514
0515 end
0516
0517
0518
0519 function hSaveCallback(varargin)
0520
0521
0522
0523 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0524 inputBlockHandles = get_param(find_system(bdroot,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0525 for i=1:numel(inputBlockHandles)
0526 children = get_param(inputBlockHandles{i},'Blocks');
0527 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0528 currIndex(i) = str2double(get_param(inputblock,'Value'));
0529 if currIndex(i)~=0
0530 objcommand = string(LTPDAinvar{currIndex(i)});
0531 set_param(inputBlockHandles{i},'Description',objcommand);
0532 end
0533 end
0534
0535 oldName = bdroot;
0536 if ~isempty(oldName) && ~isempty(find_system(oldName,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0537 try
0538 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0539 [fileName,filePath] = uiputfile([oldName,'.mdl'],'Choose destination folder');
0540 fileName = [filePath,fileName];
0541 save_system(oldName,fileName)
0542 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0543 catch
0544 end
0545 end
0546 end
0547
0548 end
0549
0550
0551
0552 function hOpenCallback(varargin)
0553
0554
0555
0556 try
0557 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0558 [fileName,filePath] = uigetfile('.mdl','Choose source file');
0559 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0560 fileName = [filePath,fileName];
0561 open_system(fileName)
0562 simulink
0563
0564
0565 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
0566 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
0567
0568
0569
0570 inputBlockHandles = get_param(find_system(gcs,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0571 for i=1:numel(inputBlockHandles)
0572 objcommand = get_param(inputBlockHandles{i},'Description');
0573 if ~isempty(objcommand)
0574 xx = size(LTPDAinvar,1);
0575 objcommand = ['LTPDAinvar{',num2str(xx+1),',1}=',objcommand,';LTPDAinvar{',num2str(xx+1),',2}=0'];
0576 eval(objcommand);
0577
0578
0579 children = get_param(inputBlockHandles{i},'Blocks');
0580 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0581 set_param(inputblock,'Value',num2str(xx+1))
0582 set_param(inputBlockHandles{i},'AttributesFormatString',num2str(xx+1));
0583 end
0584 end
0585
0586 UpdateListbox()
0587 catch
0588 end
0589
0590
0591 end
0592
0593
0594
0595
0596 function StartExec(varargin)
0597
0598
0599 if isempty(bdroot) || isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model')), return; end
0600
0601 disp('============================')
0602 disp(' Beginning the analysis')
0603 disp('============================')
0604 stop(timerfindall)
0605 button = findobj('Tag','StartButton');
0606 set(button,'CData',imread('startred.jpg'));
0607 drawnow
0608 progressBar();
0609 drawnow
0610 currSystem = bdroot;
0611 allBlocks = find_system(currSystem,'LookUnderMasks','all');
0612 for i=2:numel(allBlocks), set_param(allBlocks{i},'LinkStatus','inactive'); set_param(allBlocks{i},'MaskVariables',''); end
0613 addterms(currSystem)
0614
0615
0616 if ismember('executionList',evalin('base','who')), partialExecution = 1;
0617
0618 else partialExecution = 0;
0619 end
0620
0621
0622 if ~partialExecution
0623 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
0624 end
0625
0626
0627
0628 if size(LTPDAinvar,1)>0, LTPDAinvar(:,2) = {1}; end
0629
0630
0631 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
0632 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729 try
0730
0731
0732
0733
0734
0735 [ttt,xxx,yyy] = sim(currSystem);
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761 close(findobj('Name','LTPDA Progress Bar'))
0762
0763
0764
0765 if ~getappdata(0,'maintainresults')
0766 for i=size(LTPDAinvar,1):-1:1
0767 if LTPDAinvar{i,2}==0
0768 LTPDAinvar(i,:)=[];
0769
0770 ltpda_annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
0771 execHistory = get_param(ltpda_annotation,'UserData');
0772 for xx=1:size(execHistory,1)
0773 for yy=3:size(execHistory,2),
0774 if execHistory{xx,yy} == i, execHistory{xx,yy} = -1; end
0775 if execHistory{xx,yy} > i, execHistory{xx,yy} = execHistory{xx,yy}-1; end
0776 end
0777 if execHistory{xx,1} == i, execHistory{xx,1} = -1; end
0778 if execHistory{xx,1} > i, execHistory{xx,1} = execHistory{xx,1}-1; end
0779 end
0780 set_param(ltpda_annotation,'UserData',execHistory);
0781
0782 end
0783 end
0784 end
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810 UpdateListbox();
0811 button = findobj('Tag','StartButton');
0812 set(button,'CData',imread('startgreen.jpg'));
0813 evalin('base','clear executionList');
0814 disp('============================')
0815 disp(' Analysis concluded')
0816 disp('============================')
0817 start(timerfindall)
0818
0819
0820 catch ME
0821
0822
0823
0824 keepRes = getappdata(0,'maintainresults');
0825 if ~keepRes
0826 for i=size(LTPDAinvar,1):-1:1
0827 if LTPDAinvar{i,2}==0, LTPDAinvar(i,:)=[]; end
0828 end
0829 end
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854 UpdateListbox();
0855 button = findobj('Tag','StartButton');
0856 set(button,'CData',imread('startgreen.jpg'));
0857 start(timerfindall)
0858
0859 rethrow(ME)
0860 end
0861
0862 end
0863
0864
0865
0866
0867 end