0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function pan1main(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % This is the function for the main panel of the GUI LTPDA, the package of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % data analysis functions developed for the LISA Pathfinder Mission / LISA
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % Technology Package.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % $Id: pan1main.m,v 1.57 2010/08/02 18:30:20 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 global LTPDAinvar LTPDAoutvar currentsystem gl loop selBlocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % Initialize the list of AOs:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 InputObjList=''; % OutputObjList='';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 set(gcf,'NextPlot','new');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 selBlocks = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 scaleX = getappdata(0, 'ltpda_gui_scalefactor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 guiFontSize = round(8*scaleX);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 alltimers = timerfindall;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 stop(alltimers(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 set(alltimers(2),'TimerFcn',@ContinuousCheck,'Period',.5);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 start(alltimers(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 set(gcf,'NextPlot','new')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 set(gcf,'CloseRequestFcn',{@AskConfirm,'close'})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 currPanel = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 if nargin>1, runSim = varargin{2}; else runSim = 0; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 panelDimens = get(currPanel, 'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 backColor = get(currPanel, 'BackgroundColor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 uicontrol('Parent',currPanel,'TooltipString','login/logout','Units','pixels','HorizontalAlignment','center','Position',[60 panelDimens(4)*0.925 40 20],'String','log','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@LogoutCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'TooltipString','username','Units','pixels','HorizontalAlignment','left','Position',[110 panelDimens(4)*0.93 150 15],'String',getappdata(0,'ltpda_repo_user'),'FontSize',guiFontSize+1,'Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 currsystem = bdroot;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 if isempty(currsystem) || isempty(find_system(currsystem,'FindAll','on','Type','Annotation','Tag','ltpda model')), currsystem = 'None'; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 uicontrol('Parent',currPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','pixels','Position',[230 panelDimens(4)*0.93 300 15],'String',['Current system: ',currsystem],'FontSize',guiFontSize+1,'FontWeight','normal','Visible','on','Tag','currsystem','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 AnalysPanPos = [.005 .8 .990 .111];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 hanalysisPanel = uipanel('Parent',currPanel,'Title',' Analyses Control ','BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',AnalysPanPos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 nbuttons = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 buttonWidth = (AnalysPanPos(3)-.01*(nbuttons))/nbuttons;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 buttonPos = [AnalysPanPos(1) .2 buttonWidth .6];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 clear AnalysPanPos nbuttons buttonWidth buttonPos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 DataPanPos = [.005 .1633 .990 .615];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 hDataPanel = uipanel('Parent',currPanel,'Title',' Data Control ','BackgroundColor',backColor,'FontSize',guiFontSize-1,'Units','normalized','Position',DataPanPos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 nbuttons = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 buttonWidth = (DataPanPos(3)-.01*(nbuttons))/nbuttons;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 buttonPos = [DataPanPos(1) .9 buttonWidth .08];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 % 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Create','FontSize',guiFontSize,'Visible','on','Enable','off','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 % uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Edit','FontSize',guiFontSize,'Visible','on','Enable','off','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 uicontrol('Parent',hDataPanel,'Units','normalized','HorizontalAlignment','center','Position',buttonPos,'String','Report','TooltipString','Report','FontSize',guiFontSize,'Visible','on','Enable','on','Callback',@hReportButtonCallback,'Style','pushbutton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 clear nbuttons buttonWidth buttonPos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 nbuttons = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 buttonWidth = (DataPanPos(3)-.01*(nbuttons))/nbuttons;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 buttonPos = [DataPanPos(1) .8 buttonWidth .08];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 buttonPos(1) = buttonPos(1)+buttonWidth+.0125;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 clear nbuttons buttonWidth buttonPos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 nlists = 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 listWidth = (DataPanPos(3)-.01*(nlists))/nlists;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 listPos = [.01 .03 listWidth .7];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 set(hExploreButton,'UserData',InputObjList);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 listPos(1) = listPos(1)+listWidth+.01;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % Info panel:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','listbox','HorizontalAlignment', 'left','Fontsize', guiFontSize,'Units','pixels','Units','normalized','Position',listPos,'Tag','infoPanel');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 hListObjsCallback(InputObjList,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 clear DataPanPos nlists listWidth listPos
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 hExecutionPanel = uipanel('Parent',currPanel,'Title',' Execution control ','BackgroundColor',[1,1,1],'FontSize',guiFontSize-1,'Units','normalized','Position',[.0125 .0222 .975 .121]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 if isempty(getappdata(0,'maintainresults')), setappdata(0,'maintainresults',0); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 uicontrol('Parent',hExecutionPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[.03 .3 .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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 GUIprefs = getappdata(0, 'GUIpreferences');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 if ~isfield(GUIprefs,'CAD'), GUIprefs.CAD = 0; setappdata(0, 'GUIpreferences',GUIprefs); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 uicontrol('Parent',hExecutionPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[.3 .3 .3 .5],'Value',GUIprefs.CAD,'String',' Quick design mode','FontSize',guiFontSize+1,'TooltipString','To enable quick model drawing: each copied block will be replaced by an hollow block and automatically connected','ForeGroundColor','black','Visible','on','Enable','off','Callback','GUIprefs.Copied=0; GUIprefs.CAD=get(gco,''Value'');setappdata(0, ''GUIpreferences'',GUIprefs); if get(gco,''Value''), ltpdagui(''Redraw'',2); end;','Style','checkbox','Tag','enableCheckbox');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 if ~isfield(GUIprefs,'Detach'), GUIprefs.Detach = 0; setappdata(0, 'GUIpreferences',GUIprefs); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 uicontrol('Parent',hExecutionPanel,'BackgroundColor',backColor,'HorizontalAlignment','left','Units','normalized','Position',[.6 .3 .3 .5],'Value',GUIprefs.Detach,'String',' Detach panel','FontSize',guiFontSize+1,'TooltipString','','ForeGroundColor','black','Visible','on','Enable','off','Callback','GUIprefs.Detach=get(gco,''Value'');setappdata(0, ''GUIpreferences'',GUIprefs);try close(findobj(''Tag'',''parampanelFigure'')); catch, end;','Style','checkbox','Tag','enableCheckbox');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 if runSim == 1, StartExec(); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % ============================== FUNCTIONS ===============================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % ========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 function ContinuousCheck(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % This is the function to execute a continuous timer check
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % Keep alive the first timer:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 alltimers = timerfindall;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 if strcmp(get(alltimers(1),'Running'),'off'), start(alltimers(1)); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 currsys = bdroot;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 if ~isempty(currsys) && ~isempty(find_system(currsys,'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 set(findobj('Tag', 'currsystem'), 'String', ['Current system: ',currsys])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 set(findobj('Tag', 'enableCheckbox'), 'enable', 'on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 set(findobj('Tag', 'currsystem'), 'String', 'Current system: None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 set(findobj('Tag', 'enableCheckbox'), 'enable', 'off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 nestBlock = find_system(bdroot,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 if ~isempty(nestBlock), set(findobj('String',' Enable nested loops'),'Value',1); else set(findobj('String',' Enable nested loops'),'Value',0); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 function LogoutCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 % Callback function: run when the user click the "Logout" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 setappdata(0,'ltpda_repo_pass','');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 userID = getappdata(0,'ltpda_repo_user');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 if isempty(userID), userID = ''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 [userID passwd] = utils.mysql.logindlg(userID,'');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 setappdata(0,'ltpda_repo_user',userID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 setappdata(0,'ltpda_repo_pass',passwd)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 ltpdagui('Redraw',1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 function AskConfirm(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 % Whenever the user click the Reset Parameters button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 if strcmp(varargin{3},'close'), set(gcf,'Visible','off'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % Ask for confirmation:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 screenSize = get(0,'ScreenSize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 backColor = [1 1 1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 position = [(screenSize(3)-250)/2,(screenSize(4)-160)/2,250,160];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 confirmFig = figure('Position',position,'Name','Please confirm','Tag','ConfirmReset','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % Text
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 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');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % Button Yes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 dimension = position;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 logosize = [77 95];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 dimension = [50 , dimension(4)-logosize(2)-50 , logosize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 yesbut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','Yes');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 image(imread('buttonyes2.jpg'),'Parent',yesbut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',0); uiresume;','Tag','YesButton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 axis(yesbut,'off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 % Button No
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 dimension = position;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 logosize = [77 95];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 dimension = [127 , dimension(4)-logosize(2)-50 , logosize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 nobut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','No');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 image(imread('buttonno2.jpg'),'Parent',nobut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',1); uiresume;','Tag','NoButton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 axis(nobut,'off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 uiwait;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 if get(confirmFig,'UserData'), delete(confirmFig); set(findobj('Tag','LTPDAGUI'),'Visible','on'); return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 if strcmp(varargin{3},'close')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 delete(confirmFig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 disp('Closing LTPDA GUI...');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 delete(timerfindall);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 clear global LTPDAinvar LTPDAoutvar;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 setappdata(0,'ltpda_repo_user',''); setappdata(0,'ltpda_repo_pass','');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 closereq
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 elseif strcmp(varargin{3},'clear')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 delete(confirmFig);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 LTPDAinvar={};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 set(InputObjList,'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 set(findobj('Tag', 'infoPanel'), 'String', '')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 % %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 % function hLoadDataButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 % % Callback function: run when the user click the "Add data" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % filenames = uipickfiles('REFilter','.txt');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 % if ~isempty(filenames) && ~isnumeric(filenames(1,1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 % y = size(filenames,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 % for j=1:y
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 % ext = filenames{j}(end-2:end);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % if strcmpi(ext,'mat')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % varlist = whos('-file',filenames{j});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 % for k=1:numel(varlist)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 % newObj = load(filenames{j},varlist(k).name); %#ok<NASGU>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 % newObj = eval(['newObj.',varlist(k).name]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 % if isa(newObj,'ltpda_uo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 % LTPDAinvar = [LTPDAinvar; {newObj,1,'From file'} ];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 % disp(' + 1 Obj added to the global variable LTPDAinvar')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 % elseif strcmpi(ext,'xml')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 % newObj = utils.xml.xmlread(xmlread(filenames{j}));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % if isa(newObj,'ltpda_uo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 % LTPDAinvar = [LTPDAinvar; {newObj,1,'From file'} ];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % disp(sprintf(' + 1 %s added to the global variable LTPDAinvar',class(newObj)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 % else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 % try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 % newObj = {ao(filenames{j}),1,'From file'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 % LTPDAinvar = [LTPDAinvar; {newObj,1,'From file'} ];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 % disp(' + 1 AO added to the global variable LTPDAinvar')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 % catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 % disp([' *** Impossible to load file ',filenames{j}])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 % UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 % %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 % %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % function hRemoveButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 % % Callback function: run when the user click the "Remove data" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 % index_selected = get(InputObjList,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 % listObjs = get(InputObjList,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 % if ~strcmp(listObjs,'The memory is empty')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 % for i=1:numel(index_selected)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 % objSelect = str2double(strtok(listObjs{index_selected(i),1},'.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 % LTPDAinvar{objSelect,1} = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 % UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 % set(findobj('Tag', 'infoPanel'), 'String', '')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 % %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 function hExportButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 % Callback function: run when the user click the "Export data" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 currSelObjs = get(InputObjList,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 listObjs = get(InputObjList,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 if ~strcmp(listObjs,'The memory is empty')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 selectedObjs = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 for i=1:numel(currSelObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 if ~isempty(selectedObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 for i=1:numel(selectedObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 objName = genvarname(objName,evalin('base','who'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 assignin('base', objName, selectedObjs{i});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 disp(['Saved to workspace with name ',objName])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 function hExploreButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 % Callback function: run when the user click the "Update list" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 currSelObjs = get(InputObjList,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 listObjs = get(InputObjList,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 if ~strcmp(listObjs,'The memory is empty')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 selectedObjs = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 for i=1:numel(currSelObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 if ~isempty(selectedObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 ltpda_explorer(selectedObjs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 ltpda_explorer(LTPDAinvar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 function hReportButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 % Callback function: run when the user click the "Update list" button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 currSelObjs = get(InputObjList,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 listObjs = get(InputObjList,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 if ~strcmp(listObjs,'The memory is empty')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 selectedObjs = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 for i=1:numel(currSelObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 selectedObjs = [selectedObjs,LTPDAinvar(objSelect,1)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 if ~isempty(selectedObjs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 report(selectedObjs,'dir',[cd,'\Reports']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 ltpda_explorer(LTPDAinvar);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 function SaveWorkspaceCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 % Callback function: run when the user click the "Save all"
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 % button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 [FileName,PathName] = uiputfile('*.mat','Save Workspace As');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAinvar','LTPDAoutvar'); disp('Workspace saved'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 function LoadWorkspaceCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 % Callback function: run when the user click the "Load workspace"
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 [FileName,PathName] = uigetfile('*.mat','Load Workspace');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 temp = load(strcat(PathName,FileName),'LTPDAinvar');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 LTPDAinvar = [LTPDAinvar ; temp.LTPDAinvar];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 temp = load(strcat(PathName,FileName),'LTPDAoutvar');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 LTPDAoutvar = [LTPDAoutvar ; temp.LTPDAoutvar];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 disp('Workspace loaded')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 clear temp
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 UpdateListbox()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 function UpdateListbox(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 % Updates the listboxes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 %==================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 % Update the list of active AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 xx = size(LTPDAinvar,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 listInput=cell(xx,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 if xx>0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 for j=1:xx
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 listInput{j,1} = num2str(j);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 [rows,columns] = size(LTPDAinvar{j,1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 if (rows>1 && columns==1) || (rows==1 && columns>1), listInput{j,1} = [listInput{j,1}, ' .(Vector ',num2str(rows),'x',num2str(columns),') '];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 elseif rows>1 && columns>1, listInput{j,1} = [listInput{j,1}, ' .(Matrix ',num2str(rows),'x',num2str(columns),') '];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 if isempty(LTPDAinvar{j,1}), listInput{j,1} = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 switch class(LTPDAinvar{j,1})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 case 'ao'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 anobject = LTPDAinvar{j,1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 aoname = anobject.name;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 aocreated = char(anobject.created);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 listInput{j,1} = [listInput{j,1}, ' . AO .' , aoname , '__' , aocreated];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 case 'plist'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 paramNumb = nparams(LTPDAinvar{j,1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 objcreated = char(LTPDAinvar{j,1}.created);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 listInput{j,1}=[listInput{j,1}, ' . PLIST .',num2str(paramNumb),' params','__',objcreated];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 case {'pzmodel','miir','mfir'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 objcreated = char(LTPDAinvar{j,1}.created);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 listInput{j,1}=[listInput{j,1}, ' . ',upper(class(LTPDAinvar{j,1})),' .__',objcreated];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 case 'double'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 if numel(LTPDAinvar{j,1})==1, objclass = ' . Scalar .__ ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 elseif size(LTPDAinvar{j,1},1)==1 || size(LTPDAinvar{j,1},2)==1, objclass = ' . Vector .__ ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 else objclass = ' . Matrix .__ ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 listInput{j,1}=[listInput{j,1}, objclass, mat2str(LTPDAinvar{j,1})];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 listInput{j,1}=[listInput{j,1}, ' . ',upper(class(LTPDAinvar{j,1}))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 for j=xx:-1:1, if isempty(listInput{j,1}), listInput(j,:)=[]; end; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 listInput{1,1}='The workspace is empty';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 InputObjList = findobj('Tag','InputObjList');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 if ~isempty(InputObjList)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 set(InputObjList,'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 set(InputObjList,'String',listInput)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 function hListObjsCallback(hObject, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 % This callback is called whenever the user double click upon one of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 % the AOs in use.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAinvar,1)>0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 val = get(hObject, 'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 if length(val) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 objLines = get(hObject, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 selVal = str2double(deblank(strtok(objLines{val})));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 if isempty(objLines) || isempty(LTPDAinvar{selVal ,1}) || (isnumeric(LTPDAinvar{selVal ,1}) && numel(LTPDAinvar{selVal ,1})>1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 objtxt = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 objtxt = display(LTPDAinvar{selVal,1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 objtxt = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 elseif size(LTPDAinvar,1)>0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 if strcmp(get(gcf,'SelectionType'),'normal')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 val = get(hObject, 'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 if length(val) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 objLines = get(hObject, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 objnumb = str2double(deblank(strtok(objLines{val})));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 objtxt = display(LTPDAinvar{objnumb});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 if isa(LTPDAinvar{objnumb},'double') || isa(LTPDAinvar{objnumb},'logical'), objtxt = mat2str(LTPDAinvar{objnumb});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 elseif isa(LTPDAinvar{objnumb},'char'), objtxt = LTPDAinvar{objnumb,1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 else objtxt = class(LTPDAinvar{objnumb});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 if isempty(LTPDAinvar{objnumb,1}), objtxt=''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 objtxt = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String')) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 val = get(hObject, 'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 objLines = get(hObject, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 number = deblank(strtok(objLines{val}));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 if isempty(LTPDAinvar{str2double(number),1}), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 set_param(utils.prog.gcbsh,'Selected','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 newBlkHandle=add_block('ltpda_library/Input/Object from list', strcat(bdroot,'/AO1'),'MakeNameUnique', 'on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 children=get_param(newBlkHandle,'Blocks');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 inputblock=strcat(get(newBlkHandle,'Path'),'/',get(newBlkHandle,'Name'),'/',children{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 set_param(inputblock,'Value',number );
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % Set the MaskDisplay = n� of input:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 set_param(newBlkHandle,'LinkStatus','inactive');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 set_param(newBlkHandle,'MaskDisplay',sprintf('disp(''%s'')',num2str(number)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 % Modify the block annotation:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 objName = LTPDAinvar{str2double(number),1}.name;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 if numel(objName)>3 && strcmpi(objName,'none'), objName = class(LTPDAinvar{str2double(number),1}); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 if numel(objName)>20, objName = ['...',LTPDAinvar{str2double(number),1}.name(end-20:end)]; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 set_param(newBlkHandle,'AttributesFormatString',[number,': ',objName]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 set_param(newBlkHandle,'Selected','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 function hNewButtonCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % Callback function: run when the user click the "New model" button.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 % It starts also the timer associated to the continuous selection check
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 % (this must be changed in order to allow multiple system execution).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 hour = datestr(now,13); % HH:MM:SS
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 hour(3:4) = hour(4:5);hour(5:6)=hour(7:8);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 currentsystem = strcat(genvarname(strrep(getappdata(0,'ltpda_repo_user'),'.','_')),'_',datestr(now,7),datestr(now,5),datestr(now,11),'_',hour(1:6));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 if ~isempty(find_system('Name',currentsystem)), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 simulink
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 new_system(currentsystem)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 open_system(currentsystem)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 systemHandle = get_param(gcs,'Handle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 evalin('base','load ltpdaSimConfigSet.mat;');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 ltpdaSimConfigSet = evalin('base','ltpdaSimConfigSet');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 attachConfigSetCopy(systemHandle, ltpdaSimConfigSet);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 setActiveConfigSet(systemHandle, 'LTPDA');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 detachConfigSet(systemHandle, 'Configuration');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 evalin('base','clear ltpdaSimConfigSet;');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 set(systemHandle,'Location',[200 100 1100 600]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 set(systemHandle,'Toolbar','OFF');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 caption = [gcs,'/1'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 libraryNote = add_block('built-in/Note',caption,'Position', [100 0 0 400]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 guiNote = add_block('built-in/Note',caption,'Position', [100 0 0 430]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 set_param(guiNote,'ClickFcn','ltpdagui(''Redraw'',2); figure(findobj(''Tag'',''LTPDAGUI''))')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 set_param(libraryNote,'ClickFcn','simulink')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 set_param(guiNote,'Text',' GUI ','FontSize',14,'HorizontalAlignment','center','BackgroundColor','[0.686275, 0.686275, 0.847059]','DropShadow','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 set_param(libraryNote,'Text',' Library ','FontSize',14,'HorizontalAlignment','center','BackgroundColor','[0.870588, 0.870588, 0.937255]','DropShadow','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 mainNote = add_block('built-in/Note',caption,'Position', [200 0 0 400],'UserData',1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 caption1 = [' Analysis designed by ',getappdata(0,'ltpda_repo_user')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 caption2 = ['created (UTC): ',char(time)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 caption3 = [' IP: ',char(getHostAddress(java.net.InetAddress.getLocalHost))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 caption4 = [' OS: ',computer];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531 caption5 = ['MATLAB ver: ',getappdata(0, 'matlab_version')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 caption6 = [' LTPDA ver: ',getappdata(0, 'ltpda_version')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 caption = strvcat(caption1,caption2,caption3,caption4,caption5,caption6); %#ok<VCAT>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 set_param(mainNote, 'HorizontalAlignment','left','Text',caption,'Tag','ltpda model')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535 ltpdaClickFcn = 'load_system(''ltpda_library''); blk = add_block(''ltpda_library/Commonly Used Blocks/hollow'', strcat(bdroot,''/func1''),''MakeNameUnique'', ''on''); set(blk,''LinkStatus'',''inactive'',''MaskDisplay'',''disp(''''hollow'''')''); set(utils.prog.find_in_models(blk,''LookUnderMasks'',''all'',''BlockType'',''M-S-Function'',''FunctionName'',''ltpdasim''),''Tag'','''',''Name'',''hollow''); set(blk,''Selected'',''on'');set(find_system(bdroot,''FindAll'',''on'',''Type'',''Annotation'',''Tag'',''ltpda model''),''Selected'',''off''); ltpdagui(''callback'',1,''redraw'',2);';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 set_param(mainNote,'ClickFcn',ltpdaClickFcn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 function hSaveCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 % This callback is called whenever the user click the 'Save' button to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 % store the current model on disk.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 if ~isempty(bdroot) && ~isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 inputBlockHandles = get_param(find_system(bdroot,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 for i=1:numel(inputBlockHandles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 children = get_param(inputBlockHandles{i},'Blocks');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 currIndex(i) = str2double(get_param(inputblock,'Value'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 if currIndex(i)~=0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 objcommand = string(LTPDAinvar{currIndex(i)});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 set_param(inputBlockHandles{i},'Description',objcommand);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 oldName = bdroot;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 if ~isempty(oldName) && ~isempty(find_system(oldName,'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch, end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 [fileName,filePath] = uiputfile([oldName,'.mdl'],'Choose destination folder');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 fileName = [filePath,fileName];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 save_system(oldName,fileName)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 try cd(getappdata(0,'DefaultDataDirectory')); catch, end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 function hOpenCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 % This callback is called whenever the user click the 'Open' button, to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 % retrieve a previously saved model from disk.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 try cd(getappdata(0,'DefaultAnalysesDirectory')); catch, end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 [fileName,filePath] = uigetfile('.mdl','Choose source file');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 try cd(getappdata(0,'DefaultDataDirectory')); catch, end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 fileName = [filePath,fileName];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 open_system(fileName)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585 simulink
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587 % Load the globals into memory:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 % Load the nested loop variable into memory:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 nestBlock = find_system(bdroot,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 if ~isempty(nestBlock), loop = get_param(nestBlock{1},'UserData'); set(findobj('String',' Enable nested loops'),'Value',1); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 % Update the indexes inside 'Object from list':
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 inputBlockHandles = get_param(find_system(gcs,'AncestorBlock','ltpda_library/Input/Object from list'),'handle');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 for i=1:numel(inputBlockHandles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 objcommand = get_param(inputBlockHandles{i},'Description');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 if ~isempty(objcommand)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 xx = size(LTPDAinvar,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 objcommand = ['LTPDAinvar{',num2str(xx+1),',1}=',objcommand,';LTPDAinvar{',num2str(xx+1),',2}=0'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 eval(objcommand);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 % Update the pointer inside the input block and the annotation:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 children = get_param(inputBlockHandles{i},'Blocks');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606 inputblock = strcat(get(inputBlockHandles{i},'Path'),'/',get(inputBlockHandles{i},'Name'),'/',children{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 set_param(inputblock,'Value',num2str(xx+1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 set_param(inputBlockHandles{i},'AttributesFormatString',num2str(xx+1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 UpdateListbox()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622 function StartExec(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 % This callback is called whenever the user click the 'Start' button.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 if isempty(bdroot) || isempty(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model')), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626 button = findobj('Tag','StartButton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 set(button,'CData',imread('startred.jpg'),'ButtonDownFcn','');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629 % Check availability of inputs expected by the model:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630 inputBlocks = find_system(bdroot,'Tag','input');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 missInputs = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632 for nn = 1:numel(inputBlocks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 innerBlocks = get_param(inputBlocks{nn},'Blocks');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634 inputVal = str2double(get_param([inputBlocks{nn},'/',innerBlocks{1}],'Value'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635 if inputVal>size(LTPDAinvar,1) || isempty(LTPDAinvar{inputVal,1}) % one expected input is missing
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 missInputs = [missInputs;{['The block ''',inputBlocks{nn},''' expects input n�',num2str(inputVal)]}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639 if ~isempty(missInputs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 screenSize = get(0,'ScreenSize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641 backColor = [1 1 1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 position = [(screenSize(3)-400)/2,(screenSize(4)-160)/2,400,160];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643 inputMissFig = figure('Position',position,'Name','Input missing','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none','CloseRequestFcn','uiresume; closereq');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644 uicontrol('Parent',inputMissFig,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[50 position(4)-90 position(3)-60 50],'String',{'The model expects an input, but';'none is loaded.'},'FontName','Times New Roman','FontSize',13,'FontWeight','normal','Visible','on','Style','text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 uicontrol('Parent',inputMissFig,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[70 30 310 20],'String',missInputs,'Value',1,'Visible','on','Style','popup')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 logosize = [40 40];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647 nobut = axes('Parent',inputMissFig,'Units','pixels','Position',[10 , position(4)-logosize(2)-60 , logosize],'Tag','No');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648 image(imread('startred.jpg'),'Parent',nobut);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649 axis(nobut,'off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 uiwait;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 set(button,'CData',imread('startgreen.jpg'),'ButtonDownFcn','ltpdagui(''redraw'',1.1);');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655 disp('============================')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 disp(' Beginning the analysis')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 disp('============================')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658 stop(timerfindall)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659 drawnow
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 currSystem = bdroot;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661 allBlocks = find_system(currSystem,'LookUnderMasks','all');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662 for i=2:numel(allBlocks), set_param(allBlocks{i},'LinkStatus','inactive'); set_param(allBlocks{i},'MaskVariables',''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663 addterms(currSystem)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665 % Check if it's a partial execution:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666 if ismember('executionList',evalin('base','who')), partialExecution = 1; else partialExecution = 0; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668 % Clear the previous execution history:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 if ~partialExecution, set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData',''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 % Set all objects present at the startup to be maintained:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672 if size(LTPDAinvar,1)>0, LTPDAinvar(:,2) = {1}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 % Load the globals from the current model:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675 globBlock = find_system(bdroot,'BlockType','SubSystem','Tag','globals');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676 if ~isempty(globBlock), gl = get_param(globBlock{1},'UserData'); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 executionTime = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 nestBlock = find_system(currSystem,'SearchDepth',1,'BlockType','SubSystem','Tag','nestedloops');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681 % Check for nested loops:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682 if ~isempty(nestBlock) && str2double(get_param(nestBlock{1},'Description'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 disp(' Execution in nested loops')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684 disp('============================')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 paramLoop = get_param(nestBlock{1},'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 % To disable unused nested loop parameters:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687 allfuncBlocks = utils.prog.find_in_models(gcs,'LookUnderMasks','all','BlockType','M-S-Function','FunctionName','ltpdasim');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688 paramLoopnumb = size(paramLoop,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 enabledNestedParams = get_param(nestBlock,'MaskDescription');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 if ~isempty(enabledNestedParams{1}), eval(enabledNestedParams{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 else enabledNestedParams = ones(1,paramLoopnumb);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693 usedParamsLoop = zeros(paramLoopnumb,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694 for mmm = 1:paramLoopnumb
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695 for nnn = 1:numel(allfuncBlocks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 if ~isempty(findstr(get_param(get_param(allfuncBlocks{nnn},'parent'),'Description'),paramLoop{mmm,3})), usedParamsLoop(mmm)=1; break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699 for mmm = paramLoopnumb:-1:1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 if ~usedParamsLoop(mmm) || ~enabledNestedParams(mmm)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 % then the mmm-th line in paramLoop must be removed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702 ii = mmm+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703 while ii <= paramLoopnumb && paramLoop{ii,2} > paramLoop{mmm,2}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704 paramLoop{ii,2} = paramLoop{ii,2}-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705 ii = ii+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 if ~usedParamsLoop(mmm), disp(sprintf(' Parameter %s has been ignored for nested loops, being unused.',paramLoop{mmm,3}))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708 else disp(sprintf(' Parameter %s has been ignored for nested loops, being disabled.',paramLoop{mmm,3}))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710 paramLoop(mmm,:) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 usedParamsLoop(mmm) =[];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712 paramLoopnumb = paramLoopnumb-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715 if ~isempty(paramLoop), useNestedLoop = 1; else useNestedLoop =0; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716 else useNestedLoop =0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720 if useNestedLoop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721 % ==================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722 % Execution with nested loops
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
723 % ==================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
724
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
725 % paramLoop has 6 columns:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
726 % n� | order | parameter's name | n� of iterations | range settings | cell arrays of values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
727 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
728 % Example: n� order appearance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
729 % paramLoop={ 1 1 ... x-------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
730 % 2 2 ... .x------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
731 % 3 3 ... ..x-----
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
732 % 4 2 ... .x------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
733 % 5 3 ... ..x-----
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
734 % 6 1 ... x-------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
735
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
736 branches=[];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
737
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
738 for ii=1:paramLoopnumb, if ii==paramLoopnumb || paramLoop{ii+1,2}<=paramLoop{ii,2}, branches=[branches,ii]; end; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
739 % 'branches' contains the ordinal number of those rows which do not have
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
740 % a children row, ie. the following rows have higher order.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
741 % In the example above, branches = [ 3 , 5 , 6 ];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
742
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
743 family={};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
744 numbIter={};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
745 for ii=1:numel(branches)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
746 currOrder=paramLoop{branches(ii),2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
747 family{ii,1} = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
748 numbIter{ii,1} = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
749 for jj=branches(ii):-1:1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
750 if paramLoop{jj,2}==currOrder
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
751 family{ii,currOrder+1} = jj;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
752 family{ii,1} = family{ii,1}+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
753 numbIter{ii,currOrder+1} = paramLoop{jj,4};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
754 numbIter{ii,1} = numbIter{ii,1}*paramLoop{jj,4};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
755 currOrder = paramLoop{jj,2}-1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
756 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
757 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
758 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
759 totalIter = sum(cell2mat(numbIter(:,1)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
760 currIter = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
761 % 'family' contains all the parents information for each branch: the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
762 % first column contains how many parents there are. In the example:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
763 % family = { 3 1 2 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
764 % 3 1 4 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
765 % 1 6 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
766 % Similarly, numbIter contains the number of iteration necessary to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
767 % complete each param. The first column contains the total for each
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
768 % branch/row.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
769 % numbIter = { 40 2 4 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
770 % 36 2 6 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
771 % 10 10 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
772
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
773 for ii=1:numel(branches)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
774 x = family{ii,1}; % x = how many params to change in this branch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
775 status = ones(1,x); % status shows the current step in the loop;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
776 % [2,3,5] means that we've executed the 2nd value for the first param,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
777 % the 3rd for the second param, and the 5th for the third param.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
778
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
779 for iter = 1:numbIter{ii,1}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
780 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
781 % Here goes what must be executed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
782 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
783 currIter = currIter+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
784 disp([' ..... starting loop ',num2str(currIter),', ',num2str(totalIter-currIter),' more to go.'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
785 statusString = ' ***** Executing now with ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
786 setappdata(0,'loopStatus',[totalIter currIter])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
787 progressBar(executionTime);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
788 drawnow
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
789
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
790 for mm=1:size(paramLoop,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
791 if isempty(paramLoop{mm,7}), disp(['*** Error: default value not set for parameter ',paramLoop{mm,3}]); return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
792 eval([paramLoop{mm,3},'=',paramLoop{mm,7},';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
793 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
794 for nn=1:numel(status)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
795 value = paramLoop{family{ii,nn+1},6}{status(nn)};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
796 if ~ischar(value), value = mat2str(value); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
797 eval([paramLoop{family{ii,nn+1},3},'=', value ,';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
798 statusString = [statusString, paramLoop{family{ii,nn+1},3}(6:end) , ' = ' , value ,'; '];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
799 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
800 disp(statusString)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
801 startingTime = now;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
802
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
803 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
804 varargout = sim(currSystem); %#ok<NASGU>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
805 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
806
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
807 executionTime = [executionTime; now-startingTime];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
808
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
809 % Check if the user wants to stop the execution:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
810 lastChar = get(findobj('Name','LTPDA Progress Bar'),'CurrentCharacter');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
811 if ~isempty(lastChar) && strcmp(lastChar,'x'), break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
812
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
813 for jj=x:-1:1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
814 if status(jj)<numbIter{ii,jj+1} % then we still have to complete iterations on i-th row
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
815 status(jj)=status(jj)+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
816 if jj~=x % if we've just increased a line which is not the last one, reset the lower lines
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
817 for kk=jj+1:x
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
818 status(kk)=1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
819 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
820 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
821 break
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
822 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
823 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
824 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
825 end % End of execution with nested loops
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
826 else % Execution without nested loops
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
827 if ~isempty(nestBlock) && ~str2double(get_param(nestBlock{1},'Description'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
828 % Nested loops are set but disabled
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
829 disp('*** Nested loops, while set, are disabled; using default values.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
830 paramLoop = get_param(nestBlock{1},'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
831 for mm=1:size(paramLoop,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
832 if isempty(paramLoop{mm,7}), disp(['*** Error: default value not set for parameter ',paramLoop{mm,3}]); return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
833 % Setting every nested loops variable = default
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
834 eval([paramLoop{mm,3},'=',paramLoop{mm,7},';'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
835 disp([' ',paramLoop{mm,3},' = ',paramLoop{mm,7}])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
836 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
837 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
838 setappdata(0,'loopStatus',[]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
839 progressBar();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
840 drawnow
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
841 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
842 varargout = sim(currSystem); %#ok<NASGU>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
843 % ==============================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
844 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
845
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
846 close(findobj('Name','LTPDA Progress Bar'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
847
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
848 % Remove final results (intermediate were removed during analysis, as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
849 % soon as they became not useful anymore):
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
850 if ~getappdata(0,'maintainresults') % && ~partialExecution
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
851 for i=size(LTPDAinvar,1):-1:1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
852 if LTPDAinvar{i,2}==0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
853 LTPDAinvar(i,:)=[];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
854 % Update the execution history:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
855 ltpda_annotation = find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
856 execHistory = get_param(ltpda_annotation,'UserData');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
857 for paramLoopnumb=1:size(execHistory,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
858 for yy=3:size(execHistory,2),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
859 if execHistory{paramLoopnumb,yy} == i, execHistory{paramLoopnumb,yy} = -1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
860 if execHistory{paramLoopnumb,yy} > i, execHistory{paramLoopnumb,yy} = execHistory{paramLoopnumb,yy}-1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
861 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
862 if execHistory{paramLoopnumb,1} == i, execHistory{paramLoopnumb,1} = -1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
863 if execHistory{paramLoopnumb,1} > i, execHistory{paramLoopnumb,1} = execHistory{paramLoopnumb,1}-1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
864 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
865 set_param(ltpda_annotation,'UserData',execHistory);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
866
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
867 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
868 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
869 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
870
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
871 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
872 set(button,'CData',imread('startgreen.jpg'),'ButtonDownFcn','ltpdagui(''redraw'',1.1);');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
873 evalin('base','clear executionList');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
874 disp('============================')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
875 disp(' Analysis concluded')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
876 disp('============================')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
877 start(timerfindall)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
878
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
879 % ==================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
880 catch ME
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
881 % ==================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
882
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
883 % Remove anyway intermediate results:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
884 keepRes = getappdata(0,'maintainresults');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
885 if ~keepRes, for i=size(LTPDAinvar,1):-1:1, if LTPDAinvar{i,2}==0, LTPDAinvar(i,:)=[]; end; end; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
886
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
887 UpdateListbox();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
888 close(findobj('Name','LTPDA Progress Bar'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
889 set(button,'CData',imread('startgreen.jpg'),'ButtonDownFcn','ltpdagui(''redraw'',1.1);');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
890 evalin('base','clear executionList');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
891 start(timerfindall)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
892
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
893 rethrow(ME)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
894 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
895
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
896 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
897 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
898 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
899
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
900 end |