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',.5);
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','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,round(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','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,round(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,round(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','off','Callback','setappdata(0,''maintainresults'',get(gco,''Value''))','Style','checkbox','Tag','enableCheckbox');
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','off','Callback','setappdata(0,''hidenames'',get(gco,''Value''))','Style','checkbox','Tag','enableCheckbox');
0128 if isempty(find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops')), loopstatus = 0; else loopstatus = 1; end
0129 uicontrol('Parent',hExecutionPanel,'BackgroundColor',[1 1 1],'HorizontalAlignment','left','Units','normalized','Position',[.7 0.166 .23 .5],'Value',loopstatus,'String',' Enable nested loops','FontSize',guiFontSize+1,'TooltipString','Enable the execution in nested loops, cycling variable values set by the proper panel','ForeGroundColor','black','Visible','on','Enable','off','Callback',@UpdateNestedLoops,'Style','checkbox','Tag','enableCheckbox');
0130
0131 if runSim == 1, StartExec(); end
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 function ContinuousCheck(varargin)
0144
0145
0146
0147 alltimers = timerfindall;
0148 if strcmp(get(alltimers(1),'Running'),'off')
0149 start(alltimers(1))
0150 end
0151
0152 currsys = bdroot;
0153 if ~isempty(currsys) && ~isempty(find_system(currsys,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0154 set(findobj('UserData', 'currsystem'), 'String', currsys)
0155 set(findobj('Tag', 'enableCheckbox'), 'enable', 'on')
0156 else
0157 set(findobj('UserData', 'currsystem'), 'String', 'None')
0158 set(findobj('Tag', 'enableCheckbox'), 'enable', 'off')
0159 end
0160
0161 end
0162
0163
0164
0165
0166 function LogoutCallback(varargin)
0167
0168
0169 setappdata(0,'ltpda_repo_pass','');
0170 userID = getappdata(0,'ltpda_repo_user');
0171 if isempty(userID), userID = ''; end
0172
0173 [userID passwd] = loginLTPDA(userID,'');
0174 setappdata(0,'ltpda_repo_user',userID)
0175 setappdata(0,'ltpda_repo_pass',passwd)
0176
0177 ltpdagui('Redraw',1);
0178
0179 end
0180
0181
0182
0183 function AskConfirm(varargin)
0184
0185
0186
0187 screenSize = get(0,'ScreenSize');
0188 backColor = [1 1 1];
0189 position = [(screenSize(3)-250)/2,(screenSize(4)-160)/2,250,160];
0190 confirmFig = figure('Position',position,'Name','Please confirm','Tag','ConfirmReset','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
0191
0192 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');
0193
0194 dimension = position;
0195 logosize = [77 95];
0196 dimension = [50 , dimension(4)-logosize(2)-50 , logosize];
0197 yesbut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','Yes');
0198 image(imread('buttonyes2.jpg'),'Parent',yesbut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',0); uiresume;','Tag','YesButton');
0199 axis(yesbut,'off');
0200
0201 dimension = position;
0202 logosize = [77 95];
0203 dimension = [127 , dimension(4)-logosize(2)-50 , logosize];
0204 nobut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','No');
0205 image(imread('buttonno2.jpg'),'Parent',nobut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',1); uiresume;','Tag','NoButton');
0206 axis(nobut,'off');
0207
0208 uiwait;
0209
0210 if get(confirmFig,'UserData'), delete(confirmFig); return; end
0211
0212 if strcmp(varargin{3},'close')
0213 delete(confirmFig);
0214 disp('Closing LTPDA GUI...');
0215 delete(timerfindall);
0216 clear global LTPDAinvar LTPDAoutvar;
0217 setappdata(0,'ltpda_repo_user',''); setappdata(0,'ltpda_repo_pass','');
0218 closereq
0219 elseif strcmp(varargin{3},'clear')
0220 delete(confirmFig);
0221 LTPDAinvar={};
0222 set(InputObjList,'Value',1)
0223 set(findobj('Tag', 'infoPanel'), 'String', '')
0224 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
0225 UpdateListbox();
0226 end
0227
0228 end
0229
0230
0231
0232
0233 function hLoadDataButtonCallback(varargin)
0234
0235
0236 filenames = uipickfiles('REFilter','.txt');
0237 if ~isempty(filenames) && ~isnumeric(filenames(1,1))
0238 [x,y]=size(filenames);
0239 for j=1:y
0240 ext = filenames{j}(end-2:end);
0241 if strcmpi(ext,'mat')
0242 varlist = whos('-file',filenames{j});
0243 for k=1:numel(varlist)
0244 newObj = load(filenames{j},varlist(k).name);
0245 newObj = eval(['newObj.',varlist(k).name]);
0246 if isa(newObj,'ltpda_uo')
0247 LTPDAinvar = [LTPDAinvar; {newObj,1} ];
0248 disp(' + 1 Obj added to the global variable LTPDAinvar')
0249 end
0250 end
0251 else
0252 anobject={ao(filenames{j}),1};
0253 LTPDAinvar=[LTPDAinvar;anobject];
0254 disp(' + 1 AO added to the global variable LTPDAinvar')
0255 end
0256 end
0257 UpdateListbox();
0258 end
0259
0260 end
0261
0262
0263
0264 function hRemoveButtonCallback(varargin)
0265
0266
0267 index_selected = get(InputObjList,'Value');
0268 listObjs = get(InputObjList,'String');
0269 if ~strcmp(listObjs,'The memory is empty')
0270 for i=1:numel(index_selected)
0271 objSelect = str2double(strtok(listObjs{index_selected(i),1},'.'));
0272 LTPDAinvar{objSelect,1} = [];
0273 end
0274 UpdateListbox();
0275 end
0276 set(findobj('Tag', 'infoPanel'), 'String', '')
0277
0278 end
0279
0280
0281
0282 function hExportButtonCallback(varargin)
0283
0284
0285 currSelObjs = get(InputObjList,'Value');
0286 listObjs = get(InputObjList,'String');
0287 if ~strcmp(listObjs,'The memory is empty')
0288 selectedObjs = {};
0289 for i=1:numel(currSelObjs)
0290 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0291 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0292 end
0293 if ~isempty(selectedObjs)
0294 for i=1:numel(selectedObjs)
0295 objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
0296 objName = genvarname(objName,evalin('base','who'));
0297 assignin('base', objName, selectedObjs{i});
0298 disp(['Saved to workspace with name ',objName])
0299 end
0300 end
0301 end
0302
0303 end
0304
0305
0306
0307 function hExploreButtonCallback(varargin)
0308
0309
0310 currSelObjs = get(InputObjList,'Value');
0311 listObjs = get(InputObjList,'String');
0312 if ~strcmp(listObjs,'The memory is empty')
0313 selectedObjs = {};
0314 for i=1:numel(currSelObjs)
0315 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0316 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
0317 end
0318
0319 if ~isempty(selectedObjs)
0320 ltpda_explorer(selectedObjs);
0321 else
0322 ltpda_explorer(LTPDAinvar);
0323 end
0324
0325 UpdateListbox();
0326 end
0327
0328 end
0329
0330
0331
0332 function SaveWorkspaceCallback(varargin)
0333
0334
0335
0336 try
0337 [FileName,PathName] = uiputfile('*.mat','Save Workspace As');
0338 if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAinvar','LTPDAoutvar'); disp('Workspace saved'); end
0339 catch
0340 end
0341 end
0342
0343
0344
0345 function LoadWorkspaceCallback(varargin)
0346
0347
0348
0349 try
0350 [FileName,PathName] = uigetfile('*.mat','Load Workspace');
0351 temp = load(strcat(PathName,FileName),'LTPDAinvar');
0352 LTPDAinvar = [LTPDAinvar ; temp.LTPDAinvar];
0353 temp = load(strcat(PathName,FileName),'LTPDAoutvar');
0354 LTPDAoutvar = [LTPDAoutvar ; temp.LTPDAoutvar];
0355 disp('Workspace loaded')
0356 clear temp
0357 UpdateListbox()
0358 catch
0359 end
0360 end
0361
0362
0363
0364 function UpdateNestedLoops(hObject,varargin)
0365
0366
0367
0368 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0369
0370
0371 status = get(hObject,'Value');
0372 nestBlock = find_system(bdroot,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
0373 try nestBlock = nestBlock{1}; catch end
0374
0375 if status
0376 if isempty(nestBlock)
0377 paramLoop = cell(1,6);
0378 nestBlock = add_block('ltpda_library/Commonly Used Blocks/Globals',[bdroot '/Nested loops']);
0379 annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
0380 position = get_param(annotation,'Position');
0381 set_param(nestBlock,'LinkStatus','inactive','Showname','off','MaskDisplay','disp(''Nested loops'')','Tag','nestedloops','DropShadow','on','Position',[position(1)+20 position(2)-50 position(1)+150 position(2)-30 ])
0382 set_param(nestBlock,'UserData',paramLoop,'UserDataPersistent','on')
0383 ltpdagui('Redraw',8);
0384 end
0385 else
0386 if ~isempty(nestBlock), delete_block(nestBlock); end;
0387 clear paramLoop;
0388 end;
0389
0390 else
0391 disp('*** Warning: the current model is not a valid LTPDA model. Impossible to enable nested loops.');
0392 set(hObject,'Value',0);
0393 end
0394 end
0395
0396
0397
0398
0399 function UpdateListbox(varargin)
0400
0401
0402
0403
0404 xx = size(LTPDAinvar,1);
0405 listInput=cell(xx,1);
0406 if xx>0
0407 for j=1:xx
0408 listInput{j,1} = num2str(j);
0409 [rows,columns] = size(LTPDAinvar{j,1});
0410 if (rows>1 && columns==1) || (rows==1 && columns>1), listInput{j,1} = [listInput{j,1}, ' .(Vector ',num2str(rows),'x',num2str(columns),') '];
0411 elseif rows>1 && columns>1, listInput{j,1} = [listInput{j,1}, ' .(Matrix ',num2str(rows),'x',num2str(columns),') '];
0412 end
0413 switch class(LTPDAinvar{j,1})
0414 case 'ao'
0415 anobject = LTPDAinvar{j,1};
0416 aoname = anobject.name;
0417 aocreated = char(anobject.created);
0418 listInput{j,1} = [listInput{j,1}, ' . AO .' , aoname , '__' , aocreated];
0419 case 'plist'
0420 paramNumb = nparams(LTPDAinvar{j,1});
0421 objcreated = char(LTPDAinvar{j,1}.created);
0422 listInput{j,1}=[listInput{j,1}, ' . PLIST .',num2str(paramNumb),' params','__',objcreated];
0423 case 'specwin'
0424 listInput{j,1}=[listInput{j,1}, ' . SPECWIN .','__','no creation time'];
0425 case 'pzmodel'
0426 objcreated = char(LTPDAinvar{j,1}.created);
0427 listInput{j,1}=[listInput{j,1}, ' . PZMODEL .','__',objcreated];
0428 case 'miir'
0429 objcreated = char(LTPDAinvar{j,1}.created);
0430 listInput{j,1}=[listInput{j,1}, ' . MIIR .','__',objcreated];
0431 otherwise
0432 if isa(LTPDAinvar{j,1},'ltpda_uo')
0433 objclass = class(LTPDAinvar{j,1});
0434 if ~isempty(LTPDAinvar{j,1}), listInput{j,1}=[listInput{j,1}, ' . ',objclass]; end
0435 end
0436 end
0437 end
0438 for j=xx:-1:1
0439 if isempty(listInput{j,1})
0440 listInput(j,:)=[];
0441 end
0442 end
0443 else
0444 listInput{1,1}='The memory is empty';
0445 end
0446
0447 InputObjList = findobj('Tag','InputObjList');
0448 if ~isempty(InputObjList)
0449 set(InputObjList,'Value',1)
0450 set(InputObjList,'String',listInput)
0451 end
0452
0453 end
0454
0455
0456
0457 function hListObjsCallback(hObject, varargin)
0458
0459
0460
0461 if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAinvar,1)>0
0462 val = get(hObject, 'Value');
0463 if length(val) == 1
0464 objLines = get(hObject, 'String');
0465 if isempty(objLines) || isempty(LTPDAinvar{str2double(deblank(strtok(objLines{val}))) ,1})
0466 objtxt = '';
0467 else
0468 objnumb = str2double(deblank(strtok(objLines{val})));
0469 objtxt = display(LTPDAinvar{objnumb});
0470 end
0471 else
0472 objtxt = '';
0473 end
0474 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0475 elseif size(LTPDAinvar,1)>0
0476 if strcmp(get(gcf,'SelectionType'),'normal')
0477 val = get(hObject, 'Value');
0478 if length(val) == 1
0479 objLines = get(hObject, 'String');
0480 objnumb = str2double(deblank(strtok(objLines{val})));
0481 try
0482 objtxt = display(LTPDAinvar{objnumb});
0483 catch
0484 objtxt = class(LTPDAinvar{objnumb});
0485 end
0486 if isempty(LTPDAinvar{objnumb,1}), objtxt=''; end
0487 else
0488 objtxt = '';
0489 end
0490 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0491 end
0492
0493 if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String')) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0494 val = get(hObject, 'Value');
0495 objLines = get(hObject, 'String');
0496 number = deblank(strtok(objLines{val}));
0497 if isempty(LTPDAinvar{str2double(number),1}), return; end
0498 set_param(utils.prog.gcbsh,'Selected','off');
0499 newBlkHandle=add_block('ltpda_library/Input/Object from list', strcat(bdroot,'/AO1'),'MakeNameUnique', 'on');
0500 children=get_param(newBlkHandle,'Blocks');
0501 inputblock=strcat(get(newBlkHandle,'Path'),'/',get(newBlkHandle,'Name'),'/',children{1});
0502 set_param(inputblock,'Value',number );
0503
0504 objName = LTPDAinvar{str2double(number),1}.name;
0505 if numel(objName)>3 && strcmpi(objName,'none'), objName = class(LTPDAinvar{str2double(number),1}); end
0506 if numel(objName)>20, objName = ['...',LTPDAinvar{str2double(number),1}.name(end-20:end)]; end
0507 set_param(newBlkHandle,'AttributesFormatString',[number,': ',objName]);
0508 set_param(newBlkHandle,'Selected','on');
0509 end
0510 end
0511
0512 end
0513
0514
0515
0516
0517 function hNewButtonCallback(varargin)
0518
0519
0520
0521
0522 hour = datestr(now,13);
0523 hour(3) = hour(4);hour(4)=hour(5);hour(5)=hour(7);hour(6)=hour(8);
0524 currentsystem = strcat(getappdata(0,'ltpda_repo_user'),'_',datestr(now,7),datestr(now,5),datestr(now,11),'_',hour(1:6));
0525 if ~isempty(find_system('Name',currentsystem)), return; end
0526 simulink
0527 new_system(currentsystem)
0528 open_system(currentsystem)
0529
0530 systemHandle = get_param(gcs,'Handle');
0531 evalin('base','load ltpdaSimConfigSet.mat;');
0532 ltpdaSimConfigSet = evalin('base','ltpdaSimConfigSet');
0533 attachConfigSetCopy(systemHandle, ltpdaSimConfigSet);
0534 setActiveConfigSet(systemHandle, 'LTPDA');
0535 detachConfigSet(systemHandle, 'Configuration');
0536 evalin('base','clear ltpdaSimConfigSet;');
0537
0538 set(systemHandle,'Location',[200 100 1100 600]);
0539 set(systemHandle,'Toolbar','OFF');
0540
0541 caption = strcat(gcs,'/1');
0542 add_block('built-in/Note',caption,'Position', [100 0 0 400],'UserData',1);
0543 annotationHandle = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');
0544 caption1 = [' Analysis designed by ',getappdata(0,'ltpda_repo_user')];
0545
0546 caption2 = ['created (UTC): ',char(time)];
0547 caption3 = [' IP: ',char(getHostAddress(java.net.InetAddress.getLocalHost))];
0548 caption4 = [' OS: ',computer];
0549 caption5 = ['MATLAB ver: ',getappdata(0, 'matlab_version')];
0550 caption6 = [' LTPDA ver: ',getappdata(0, 'ltpda_version')];
0551 caption = strvcat(caption1,caption2,caption3,caption4,caption5,caption6);
0552 set_param(annotationHandle, 'HorizontalAlignment','left','Text',caption,'Tag','ltpda model')
0553 set_param(annotationHandle,'ClickFcn','disp(''You''''re not allowed to change this'')')
0554
0555 end
0556
0557
0558
0559 function hSaveCallback(varargin)
0560
0561
0562
0563 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0564 inputBlockHandles = get_param(find_system(bdroot,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0565 for i=1:numel(inputBlockHandles)
0566 children = get_param(inputBlockHandles{i},'Blocks');
0567 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0568 currIndex(i) = str2double(get_param(inputblock,'Value'));
0569 if currIndex(i)~=0
0570 objcommand = string(LTPDAinvar{currIndex(i)});
0571 set_param(inputBlockHandles{i},'Description',objcommand);
0572 end
0573 end
0574
0575 oldName = bdroot;
0576 if ~isempty(oldName) && ~isempty(find_system(oldName,'FindAll','on','Type','Annotation','Tag','ltpda model'))
0577 try
0578 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0579 [fileName,filePath] = uiputfile([oldName,'.mdl'],'Choose destination folder');
0580 fileName = [filePath,fileName];
0581 save_system(oldName,fileName)
0582 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0583 catch
0584 end
0585 end
0586 end
0587
0588 end
0589
0590
0591
0592 function hOpenCallback(varargin)
0593
0594
0595
0596 try
0597 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch end
0598 [fileName,filePath] = uigetfile('.mdl','Choose source file');
0599 try cd(getappdata(0,'DefaultDataDirectory')); catch end
0600 fileName = [filePath,fileName];
0601 open_system(fileName)
0602 simulink
0603
0604
0605 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
0606 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
0607
0608
0609
0610 inputBlockHandles = get_param(find_system(gcs,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
0611 for i=1:numel(inputBlockHandles)
0612 objcommand = get_param(inputBlockHandles{i},'Description');
0613 if ~isempty(objcommand)
0614 xx = size(LTPDAinvar,1);
0615 objcommand = ['LTPDAinvar{',num2str(xx+1),',1}=',objcommand,';LTPDAinvar{',num2str(xx+1),',2}=0'];
0616 eval(objcommand);
0617
0618
0619 children = get_param(inputBlockHandles{i},'Blocks');
0620 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
0621 set_param(inputblock,'Value',num2str(xx+1))
0622 set_param(inputBlockHandles{i},'AttributesFormatString',num2str(xx+1));
0623 end
0624 end
0625
0626 UpdateListbox()
0627 catch
0628 end
0629
0630
0631 end
0632
0633
0634
0635
0636 function StartExec(varargin)
0637
0638
0639 if isempty(bdroot) || isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model')), return; end
0640
0641 disp('============================')
0642 disp(' Beginning the analysis')
0643 disp('============================')
0644 stop(timerfindall)
0645 button = findobj('Tag','StartButton');
0646 set(button,'CData',imread('startred.jpg'));
0647 drawnow
0648 progressBar();
0649 drawnow
0650 currSystem = bdroot;
0651 allBlocks = find_system(currSystem,'LookUnderMasks','all');
0652 for i=2:numel(allBlocks), set_param(allBlocks{i},'LinkStatus','inactive'); set_param(allBlocks{i},'MaskVariables',''); end
0653 addterms(currSystem)
0654
0655
0656 if ismember('executionList',evalin('base','who')), partialExecution = 1;
0657
0658 else partialExecution = 0;
0659 end
0660
0661
0662 if ~partialExecution
0663 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
0664 end
0665
0666
0667 if size(LTPDAinvar,1)>0, LTPDAinvar(:,2) = {1}; end
0668
0669
0670 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
0671 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
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
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757 try
0758
0759
0760
0761
0762
0763 [ttt,xxx,yyy] = sim(currSystem);
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789 close(findobj('Name','LTPDA Progress Bar'))
0790
0791
0792
0793 if ~getappdata(0,'maintainresults')
0794 for i=size(LTPDAinvar,1):-1:1
0795 if LTPDAinvar{i,2}==0
0796 LTPDAinvar(i,:)=[];
0797
0798 ltpda_annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
0799 execHistory = get_param(ltpda_annotation,'UserData');
0800 for xx=1:size(execHistory,1)
0801 for yy=3:size(execHistory,2),
0802 if execHistory{xx,yy} == i, execHistory{xx,yy} = -1; end
0803 if execHistory{xx,yy} > i, execHistory{xx,yy} = execHistory{xx,yy}-1; end
0804 end
0805 if execHistory{xx,1} == i, execHistory{xx,1} = -1; end
0806 if execHistory{xx,1} > i, execHistory{xx,1} = execHistory{xx,1}-1; end
0807 end
0808 set_param(ltpda_annotation,'UserData',execHistory);
0809
0810 end
0811 end
0812 end
0813
0814
0815 UpdateListbox();
0816 button = findobj('Tag','StartButton');
0817 set(button,'CData',imread('startgreen.jpg'));
0818 evalin('base','clear executionList');
0819 disp('============================')
0820 disp(' Analysis concluded')
0821 disp('============================')
0822 start(timerfindall)
0823
0824
0825 catch ME
0826
0827
0828
0829 keepRes = getappdata(0,'maintainresults');
0830 if ~keepRes
0831 for i=size(LTPDAinvar,1):-1:1
0832 if LTPDAinvar{i,2}==0, LTPDAinvar(i,:)=[]; end
0833 end
0834 end
0835
0836 UpdateListbox();
0837 close(findobj('Name','LTPDA Progress Bar'))
0838 button = findobj('Tag','StartButton');
0839 set(button,'CData',imread('startgreen.jpg'));
0840 evalin('base','clear executionList');
0841 start(timerfindall)
0842
0843 rethrow(ME)
0844 end
0845
0846 end
0847
0848
0849
0850
0851 end