0001 function varargout = pan1main(varargin)
0002
0003
0004
0005
0006
0007
0008 global ltpdaGUIstatus LTPDAinvar LTPDAoutvar currentsystem
0009
0010
0011 InputObjList=''; OutputObjList='';
0012 UpdateListbox();
0013
0014 alltimers = timerfindall;
0015 stop(alltimers(2));
0016 set(alltimers(2),'TimerFcn',@ContinuousCheck,'Period',1);
0017 start(alltimers(2));
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 currPanel = varargin{1};
0030 if nargin>1, runSim = varargin{2}; else runSim = 0; end
0031 panelDimens = get(currPanel, 'Position');
0032 backColor = get(currPanel, 'BackgroundColor');
0033
0034 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[30 panelDimens(4)-52 60 30],'String','Username:','FontName','Times New Roman','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
0035 hUserIDEdit = uicontrol('Parent',currPanel,'BackgroundColor',[0.9,0.9,0.9],'Units','pixels','HorizontalAlignment','center','Position',[95 panelDimens(4)-39 80 25],'String',ltpdaGUIstatus{1,1},'FontSize',8,'FontAngle','italic','Visible','on','Enable','off','Callback',@UserIDCallback,'Style','edit');
0036 uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[190 panelDimens(4)-36 120 20],'String','Login / Logout','FontSize',8,'Visible','on','Enable','on','Callback',@LogoutCallback,'Style','pushbutton');
0037
0038 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[400 panelDimens(4)-42 100 20],'String','Current system:','FontName','Times New Roman','FontSize',9,'FontWeight','normal','Visible','on','Style','text');
0039 currsystem = bdroot;
0040 if isempty(currsystem) || isempty(find_system(currsystem,'FindAll','on','Type','Annotation','Tag','ltpda model')), currsystem = 'None'; end
0041 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[510 panelDimens(4)-42 150 20],'String',currsystem,'FontName','Times New Roman','FontSize',9,'FontWeight','normal','Visible','on','UserData','currsystem','Style','text');
0042
0043
0044 AnalysPanPos = [20 panelDimens(4)-100 panelDimens(3)-40 55];
0045
0046 uipanel('Title','Analyses Control Panel','BackgroundColor',backColor,'FontSize',7,'Units','pixels','Position',AnalysPanPos);
0047
0048 nbuttons = 3;
0049 buttonWidth = (AnalysPanPos(3)-10*(nbuttons+1))/nbuttons;
0050 buttonPos = [AnalysPanPos(1)+10 AnalysPanPos(2)+10 buttonWidth 25];
0051 hNewModelButton = uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','New model','FontSize',8,'Visible','on','Enable','on','Callback',@hNewButtonCallback,'Style','pushbutton');
0052 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0053 hOpenModelButton = uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Open model','FontSize',8,'Visible','on','Enable','on','Callback',@hOpenCallback,'Style','pushbutton');
0054 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0055 hSaveModelButton = uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Save model','FontSize',8,'Visible','on','Enable','on','Callback',@hSaveCallback,'Style','pushbutton');
0056 clear AnalysPanPos nbuttons buttonWidth buttonPos
0057
0058
0059 DataPanPos = [20 panelDimens(4)-415 panelDimens(3)-40 305];
0060 hDataPanel = uipanel(...
0061 'Title','Data Control Panel',...
0062 'BackgroundColor',[1,1,1],...
0063 'FontSize',7,...
0064 'Units','pixels',...
0065 'Position',DataPanPos);
0066 nbuttons = 5;
0067 buttonWidth = (DataPanPos(3)-10*(nbuttons+1))/nbuttons;
0068 buttonPos = [10 DataPanPos(4)-40 buttonWidth 22];
0069 hLoadButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Load','FontSize',8,'Visible','on','Enable','on','Callback',@hLoadDataButtonCallback,'Style','pushbutton');
0070 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0071 hCreateDataButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Create','FontSize',8,'Visible','on','Enable','off','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
0072 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0073 hEditDataButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Edit','FontSize',8,'Visible','on','Enable','off','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
0074 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0075 hRemoveButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Remove','FontSize',8,'Visible','on','Enable','on','Callback',@hRemoveButtonCallback,'Style','pushbutton');
0076 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0077 hExploreButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Explore','FontSize',8,'Visible','on','Enable','on','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
0078 clear nbuttons buttonWidth buttonPos
0079
0080 nbuttons = 4;
0081 buttonWidth = (DataPanPos(3)-10*(nbuttons+1))/nbuttons;
0082 buttonPos = [10 DataPanPos(4)-65 buttonWidth 22];
0083
0084
0085 hExportButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Export to workspace','FontSize',8,'Visible','on','Enable','on','Callback',@hExportButtonCallback,'Style','pushbutton');
0086 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0087 hClearButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Clear input','FontSize',8,'Visible','on','Enable','on','Callback',@hClearButtonCallback,'Style','pushbutton');
0088 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0089 hSaveWorkButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Save workspace','FontSize',8,'Visible','on','Enable','on','Callback',@SaveWorkspaceCallback,'Style','pushbutton');
0090 buttonPos(1) = buttonPos(1)+buttonWidth+10;
0091 hLoadWorkButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Load workspace','FontSize',8,'Visible','on','Enable','on','Callback',@LoadWorkspaceCallback,'Style','pushbutton');
0092 clear nbuttons buttonWidth buttonPos
0093
0094
0095 ntexts = 2;
0096 textWidth = (DataPanPos(3)-10*(ntexts+1))/ntexts;
0097 textPos = [10 DataPanPos(4)-100 textWidth 25];
0098 hListAOText = uicontrol('Parent',hDataPanel,'BackgroundColor',get(hDataPanel,'BackgroundColor'),'HorizontalAlignment','center','Position',textPos,'String','Input:','FontName','Times New Roman','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
0099 clear ntexts textWidth textPos
0100
0101
0102 nlists = 2;
0103 listWidth = (DataPanPos(3)-10*(nlists+1))/nlists;
0104 listPos = [10 DataPanPos(4)-295 listWidth 200];
0105 InputObjList = uicontrol('Parent',hDataPanel,'BackgroundColor',[0.95,0.95,0.95],'HorizontalAlignment','center','Position',listPos,'String',listInput,'Value',1,'Max',10,'Min',1,'FontSize',8,'FontWeight','normal','Visible','on','Enable','on','Callback',@hListObjsCallback,'Tag','InputObjList','Style','listbox');
0106 set(hExploreButton,'UserData',InputObjList);
0107 listPos(1) = listPos(1)+listWidth+10;
0108
0109 uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','listbox','HorizontalAlignment', 'left','Fontsize', 8,'Units','pixels','Position',listPos,'Tag','infoPanel');
0110 hListObjsCallback(InputObjList,1);
0111 clear DataPanPos nlists listWidth listPos
0112
0113
0114 hExecutionPanel = uipanel('Title','Execution control','BackgroundColor',[1,1,1],'FontSize',7,'Units','pixels','Position',[20 panelDimens(4)-485 panelDimens(3)-40 60]);
0115
0116 if isempty(getappdata(0,'maintainresults')), setappdata(0,'maintainresults',0); end
0117 hKeepPrevData = uicontrol('Parent',hExecutionPanel,'BackgroundColor',[1 1 1],'HorizontalAlignment','center','Position',[30 10 180 30],'Value',getappdata(0,'maintainresults'),'String',' Maintain intermediate results','ForeGroundColor','black','Visible','on','Enable','on','Callback',@MaintainResults,'Style','checkbox');
0118
0119
0120
0121
0122
0123
0124
0125
0126 hExecute = axes('Parent',findobj('Name','In GUI we trust'),'Units','pixels','Position',[panelDimens(3)-100 18 36 38]);
0127 image(imread('startgreen.jpg'),'Parent',hExecute,'AlphaData',imread('startalpha.gif'),'ButtonDownFcn',@StartExec,'Tag','StartButton1');
0128 axis(hExecute,'off');
0129
0130 if runSim == 1, StartExec(); end
0131
0132
0133
0134 mOutputArgs{1} = currPanel;
0135 if nargout>0
0136 [varargout{1:nargout}] = mOutputArgs{:};
0137 end
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 function ContinuousCheck(varargin)
0151
0152
0153
0154 alltimers = timerfindall;
0155 if strcmp(get(alltimers(1),'Running'),'off')
0156 start(alltimers(1))
0157 end
0158
0159 currsys = bdroot;
0160 if ~isempty(currsys) && ~isempty(find_system(currsys,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0161 set(findobj('UserData', 'currsystem'), 'String', currsys)
0162 else
0163 set(findobj('UserData', 'currsystem'), 'String', 'None')
0164 end
0165
0166 end
0167
0168
0169
0170
0171 function UserIDCallback(hObject, varargin)
0172
0173
0174 if hObject~=-1
0175 ltpdaGUIstatus{1,1} = genvarname(get(hObject,'String'));
0176 set(hObject,'String',ltpdaGUIstatus{1,1});
0177 end
0178 end
0179
0180
0181
0182 function LogoutCallback(varargin)
0183
0184
0185 setappdata(0,'ltpda_repo_pass','');
0186 userID = getappdata(0,'ltpda_repo_user');
0187 if isempty(userID), userID = ''; end
0188
0189 [userID passwd] = loginLTPDA(userID,'');
0190 ltpdaGUIstatus{1,1} = userID;
0191 setappdata(0,'ltpda_repo_user',userID)
0192 setappdata(0,'ltpda_repo_pass',passwd)
0193
0194 ltpdagui('Redraw',1);
0195
0196 end
0197
0198
0199
0200
0201 function hLoadDataButtonCallback(varargin)
0202
0203
0204 filenames = uipickfiles('REFilter','.txt');
0205 if ~isempty(filenames) && ~isnumeric(filenames(1,1))
0206 [x,y]=size(filenames);
0207 for j=1:y
0208 ext = filenames{j}(numel(filenames{j})-2:numel(filenames{j}));
0209 if strcmpi(ext,'xml')
0210 try
0211 newObj = ltpda_xmlread(xmlread(filenames{j}));
0212 if ltpda_isuserobject(newObj),
0213 LTPDAinvar = [LTPDAinvar; {newObj,1} ];
0214 disp(' + 1 Obj added to the global variable LTPDAinvar')
0215 end
0216 catch end
0217 elseif strcmpi(ext,'mat')
0218 varlist = whos('-file',filenames{j});
0219 for k=1:numel(varlist)
0220 newObj = load(filenames{j},varlist(k).name);
0221 newObj = eval(['newObj.',varlist(k).name]);
0222 if ltpda_isuserobject(newObj),
0223 LTPDAinvar = [LTPDAinvar; {newObj,1} ];
0224 disp(' + 1 Obj added to the global variable LTPDAinvar')
0225 end
0226 end
0227 else
0228 anobject={ao(filenames{j}),1};
0229 LTPDAinvar=[LTPDAinvar;anobject];
0230 disp(' + 1 AO added to the global variable LTPDAinvar')
0231 end
0232 end
0233 UpdateListbox();
0234 end
0235
0236 end
0237
0238
0239
0240 function hRemoveButtonCallback(varargin)
0241
0242
0243 index_selected = get(InputObjList,'Value');
0244 listAOs = get(InputObjList,'String');
0245 if ~strcmp(listAOs,'The memory is empty')
0246 for i=1:numel(index_selected)
0247 objSelect = str2double(strtok(listAOs{index_selected(i),1},'.'));
0248 LTPDAinvar{objSelect,1} = [];
0249 end
0250 UpdateListbox();
0251 end
0252 set(findobj('Tag', 'infoPanel'), 'String', '')
0253
0254 end
0255
0256
0257
0258 function hExportButtonCallback(varargin)
0259
0260
0261 currSelObjs = get(InputObjList,'Value');
0262 listAOs = get(InputObjList,'String');
0263 if ~strcmp(listAOs,'The memory is empty')
0264 selectedObjs = {};
0265 for i=1:numel(currSelObjs)
0266 objSelect = str2double(strtok(listAOs{currSelObjs(i),1},'.'));
0267 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0268 end
0269 if ~isempty(selectedObjs)
0270 for i=1:numel(selectedObjs)
0271 objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
0272 objName = genvarname(objName,evalin('base','who'));
0273 assignin('base', objName, selectedObjs{i});
0274 disp(['Saved to workspace with name ',objName])
0275 end
0276 end
0277 end
0278
0279 end
0280
0281
0282
0283 function hExploreButtonCallback(varargin)
0284
0285
0286 currSelObjs = get(InputObjList,'Value');
0287 listAOs = get(InputObjList,'String');
0288 if ~strcmp(listAOs,'The memory is empty')
0289 selectedObjs = {};
0290 for i=1:numel(currSelObjs)
0291 objSelect = str2double(strtok(listAOs{currSelObjs(i),1},'.'));
0292 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0293 end
0294
0295 if ~isempty(selectedObjs)
0296 ltpda_explorer(selectedObjs);
0297 else
0298 ltpda_explorer(LTPDAinvar);
0299 end
0300
0301 UpdateListbox();
0302 end
0303
0304 end
0305
0306
0307
0308 function hClearButtonCallback(varargin)
0309
0310
0311
0312 LTPDAinvar={};
0313
0314 set(InputObjList,'Value',1)
0315 set(findobj('Tag', 'infoPanel'), 'String', '')
0316 UpdateListbox();
0317
0318 end
0319
0320
0321
0322 function SaveWorkspaceCallback(varargin)
0323
0324
0325
0326 try
0327 [FileName,PathName] = uiputfile('*.mat','Save Workspace As');
0328 if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAinvar','LTPDAoutvar'); disp('Workspace saved'); end
0329 catch
0330 end
0331 end
0332
0333
0334
0335 function LoadWorkspaceCallback(varargin)
0336
0337
0338
0339 try
0340 [FileName,PathName] = uigetfile('*.mat','Load Workspace');
0341 temp = load(strcat(PathName,FileName),'LTPDAinvar');
0342 LTPDAinvar = [LTPDAinvar ; temp.LTPDAinvar];
0343 temp = load(strcat(PathName,FileName),'LTPDAoutvar');
0344 LTPDAoutvar = [LTPDAoutvar ; temp.LTPDAoutvar];
0345 disp('Workspace loaded')
0346 clear temp
0347 UpdateListbox()
0348 catch
0349 end
0350 end
0351
0352
0353
0354
0355 function UpdateListbox(varargin)
0356
0357
0358
0359
0360 xx = size(LTPDAinvar,1);
0361 listInput=cell(xx,1);
0362 if xx>0
0363 for j=1:xx
0364 switch class(LTPDAinvar{j,1})
0365 case 'ao'
0366 anobject = LTPDAinvar{j,1};
0367 aoname = anobject.name;
0368 aocreated = get(get(anobject.provenance, 'created'),'time_str');
0369 listInput{j,1} = [num2str(j) , ' . AO .' , aoname , '__' , aocreated];
0370 case 'plist'
0371 paramNumb = nparams(LTPDAinvar{j,1});
0372 objcreated = get(LTPDAinvar{j,1}.created,'time_str');
0373 listInput{j,1}=[num2str(j),' . PLIST .',num2str(paramNumb),' params','__',objcreated];
0374 case 'specwin'
0375 listInput{j,1}=[num2str(j),' . SPECWIN .','__','no creation time'];
0376 case 'pzmodel'
0377 objcreated = get(LTPDAinvar{j,1}.created,'time_str');
0378 listInput{j,1}=[num2str(j),' . PZMODEL .','__',objcreated];
0379 case 'miir'
0380 objcreated = get(LTPDAinvar{j,1}.created,'time_str');
0381 listInput{j,1}=[num2str(j),' . MIIR .','__',objcreated];
0382 otherwise
0383 if ltpda_isuserobject(LTPDAinvar{j,1})
0384 objclass = class(LTPDAinvar{j,1});
0385 if ~isempty(LTPDAinvar{j,1}), listInput{j,1}=[num2str(j),' . ',objclass]; end
0386 end
0387 end
0388 end
0389 for j=xx:-1:1
0390 if isempty(listInput{j,1})
0391 listInput(j,:)=[];
0392 end
0393 end
0394 else
0395 listInput{1,1}='The memory is empty';
0396 end
0397
0398 InputObjList = findobj('Tag','InputObjList');
0399 if ~isempty(InputObjList)
0400 set(InputObjList,'Value',1)
0401 set(InputObjList,'String',listInput)
0402 end
0403
0404 end
0405
0406
0407
0408 function hListObjsCallback(hObject, varargin)
0409
0410
0411
0412 if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAinvar,1)>0
0413 val = get(hObject, 'Value');
0414 if length(val) == 1
0415 objLines = get(hObject, 'String');
0416 if isempty(objLines)
0417 objtxt = '';
0418 else
0419 objnumb = str2double(deblank(strtok(objLines{val})));
0420 objtxt = display(LTPDAinvar{objnumb});
0421 end
0422 else
0423 objtxt = '';
0424 end
0425 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0426 elseif size(LTPDAinvar,1)>0
0427 if strcmp(get(gcf,'SelectionType'),'normal')
0428 val = get(hObject, 'Value');
0429 if length(val) == 1
0430 objLines = get(hObject, 'String');
0431 objnumb = str2double(deblank(strtok(objLines{val})));
0432 try objtxt = display(LTPDAinvar{objnumb}); catch objtxt = class(LTPDAinvar{objnumb}); end
0433 else
0434 objtxt = '';
0435 end
0436 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0437 end
0438
0439 if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String')) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0440 set_param(gcbsh,'Selected','off');
0441 newBlkHandle=add_block('ltpda_library/Input/Object from list', strcat(bdroot,'/AO1'),'MakeNameUnique', 'on');
0442 children=get_param(newBlkHandle,'Blocks');
0443 inputblock=strcat(get(newBlkHandle,'Path'),'/',get(newBlkHandle,'Name'),'/',children{1});
0444 val = get(hObject, 'Value');
0445 objLines = get(hObject, 'String');
0446 set_param(inputblock,'Value',deblank(strtok(objLines{val})) );
0447
0448 set_param(newBlkHandle,'AttributesFormatString',deblank(strtok(objLines{val})) );
0449 set_param(newBlkHandle,'Selected','on');
0450 end
0451 end
0452
0453 end
0454
0455
0456
0457
0458 function hNewButtonCallback(varargin)
0459
0460
0461
0462
0463 hour = datestr(now,13);
0464 hour(3) = hour(4);hour(4)=hour(5);hour(5)=hour(7);hour(6)=hour(8);
0465 currentsystem = strcat(ltpdaGUIstatus{1,1},'_',datestr(now,7),datestr(now,5),datestr(now,11),'_',hour(1:6));
0466 if ~isempty(find_system('Name',currentsystem)), return; end
0467 simulink
0468 new_system(currentsystem)
0469 open_system(currentsystem)
0470
0471 systemHandle = get_param(gcs,'Handle');
0472 set(systemHandle,'SolverName','VariableStepDiscrete');
0473 set(systemHandle,'StopTime','0.0');
0474 set(systemHandle,'Location',[200 100 1100 600]);
0475 set(systemHandle,'Toolbar','OFF');
0476
0477 caption = strcat(gcs,'/1');
0478 add_block('built-in/Note',caption,'Position', [100 0 0 400],'UserData',1);
0479 annotationHandle = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');
0480 caption1 = [' Analysis designed by ',ltpdaGUIstatus{1,1}];
0481
0482 caption2 = ['created (UTC): ',get(time,'time_str')];
0483 caption3 = [' IP: ',char(getHostAddress(java.net.InetAddress.getLocalHost))];
0484 caption4 = [' OS: ',computer];
0485 caption5 = ['MATLAB ver: ',getappdata(0, 'matlab_version')];
0486 caption6 = [' LTPDA ver: ',getappdata(0, 'ltpda_version')];
0487 caption = strvcat(caption1,caption2,caption3,caption4,caption5,caption6);
0488 set_param(annotationHandle, 'HorizontalAlignment','left','Text',caption,'Tag','ltpda model')
0489 set_param(annotationHandle,'ClickFcn','disp(''You''''re not allowed to change this'')')
0490
0491 end
0492
0493
0494
0495 function hSaveCallback(varargin)
0496
0497
0498
0499 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0500 inputBlockHandles = get_param(find_system(bdroot,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0501 for i=1:numel(inputBlockHandles)
0502 children = get_param(inputBlockHandles{i},'Blocks');
0503 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0504 currIndex(i) = str2double(get_param(inputblock,'Value'));
0505 if currIndex(i)~=0
0506 objcommand = string(LTPDAinvar{currIndex(i)});
0507 set_param(inputBlockHandles{i},'Description',objcommand);
0508 end
0509 end
0510
0511 oldName = bdroot;
0512 if ~isempty(oldName) && ~isempty(find_system(oldName,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0513 try
0514 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0515 [fileName,filePath] = uiputfile([oldName,'.mdl'],'Choose destination folder');
0516 fileName = [filePath,fileName];
0517 save_system(oldName,fileName)
0518 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0519 catch
0520 end
0521 end
0522 end
0523
0524 end
0525
0526
0527
0528 function hOpenCallback(varargin)
0529
0530
0531
0532 try
0533 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0534 [fileName,filePath] = uigetfile('.mdl','Choose source file');
0535 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0536 fileName = [filePath,fileName];
0537 open_system(fileName)
0538
0539 inputBlockHandles = get_param(find_system(gcs,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0540 for i=1:numel(inputBlockHandles)
0541 objcommand = get_param(inputBlockHandles{i},'Description');
0542 if ~isempty(objcommand)
0543 xx = size(LTPDAinvar,1);
0544 objcommand = ['LTPDAinvar{',num2str(xx+1),',1}=',objcommand,';LTPDAinvar{',num2str(xx+1),',2}=0'];
0545 eval(objcommand);
0546
0547
0548 children = get_param(inputBlockHandles{i},'Blocks');
0549 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0550 set_param(inputblock,'Value',num2str(xx+1))
0551 set_param(inputBlockHandles{i},'AttributesFormatString',num2str(xx+1));
0552 end
0553 end
0554
0555 UpdateListbox()
0556 catch
0557 end
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572 end
0573
0574
0575
0576
0577 function MaintainResults(hObject,varargin)
0578
0579
0580 setappdata(0,'maintainresults',get(hObject,'Value'));
0581 end
0582
0583
0584
0585 function StartExec(varargin)
0586
0587
0588 if isempty(bdroot) || isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model')), return; end
0589
0590 disp('============================')
0591 disp(' Beginning the analysis')
0592 disp('============================')
0593 stop(timerfindall)
0594 button = findobj('Tag','StartButton1');
0595 set(button,'CData',imread('startred.jpg'));
0596 button = findobj('Tag','StartButton2');
0597 set(button,'CData',imread('startred.jpg'));
0598 progressBar();
0599 pause(0.1);
0600 currSystem = bdroot;
0601 addterms(currSystem)
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
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 try
0699
0700
0701
0702
0703
0704 [ttt,xxx,yyy] = sim(currSystem);
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
0730 close(findobj('Name','LTPDA Progress Bar'))
0731
0732
0733 keepRes = getappdata(0,'maintainresults');
0734 if ~keepRes
0735 for i=size(LTPDAinvar,1):-1:1
0736 if LTPDAinvar{i,2}==0, LTPDAinvar(i,:)=[]; end
0737 end
0738 end
0739
0740
0741 for i = size(LTPDAinvar,1):-1:1
0742 objLength = numel(LTPDAinvar{i,1});
0743 if objLength > 1 && ltpda_isuserobject(LTPDAinvar{i,1})
0744
0745 if i~=size(LTPDAinvar,1)
0746
0747 for k = (size(LTPDAinvar,1)+objLength-1):-1:(i+objLength)
0748 LTPDAinvar{k,1} = LTPDAinvar{k-objLength+1,1};
0749 LTPDAinvar{k,2} = LTPDAinvar{k-objLength+1,2};
0750 end
0751
0752 for k = i+1:i+objLength-1
0753 LTPDAinvar(k,:) = {[],0};
0754 end
0755 end
0756
0757 for j = objLength:-1:1
0758 LTPDAinvar{i+j-1,1} = LTPDAinvar{i,1}(j);
0759 LTPDAinvar{i+j-1,2} = LTPDAinvar{i,2};
0760 end
0761 end
0762 end
0763 UpdateListbox();
0764 button = findobj('Tag','StartButton1');
0765 set(button,'CData',imread('startgreen.jpg'));
0766 button = findobj('Tag','StartButton2');
0767 set(button,'CData',imread('startgreen.jpg'));
0768 start(timerfindall)
0769
0770
0771 catch
0772
0773
0774
0775 for i = size(LTPDAinvar,1):-1:1
0776 objLength = numel(LTPDAinvar{i,1});
0777 if objLength > 1 && ltpda_isuserobject(LTPDAinvar{i,1})
0778
0779 if i~=size(LTPDAinvar,1)
0780
0781 for k = (size(LTPDAinvar,1)+objLength-1):-1:(i+objLength)
0782 LTPDAinvar{k,1} = LTPDAinvar{k-objLength+1,1};
0783 LTPDAinvar{k,2} = LTPDAinvar{k-objLength+1,2};
0784 end
0785
0786 for k = i+1:i+objLength-1
0787 LTPDAinvar(k,:) = {[],0};
0788 end
0789 end
0790
0791 for j = objLength:-1:1
0792 LTPDAinvar{i+j-1,1} = LTPDAinvar{i,1}(j);
0793 LTPDAinvar{i+j-1,2} = LTPDAinvar{i,2};
0794 end
0795 end
0796 end
0797 UpdateListbox();
0798 button = findobj('Tag','StartButton1');
0799 set(button,'CData',imread('startgreen.jpg'));
0800 button = findobj('Tag','StartButton2');
0801 set(button,'CData',imread('startgreen.jpg'));
0802 start(timerfindall)
0803
0804 rethrow(lasterror)
0805 end
0806
0807 end
0808
0809
0810
0811
0812 end