0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % SETBLOCKPROPERTIES Sets the specified properties of the specified SSM blocks.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: SETBLOCKPROPERTIES Sets properties of the specified SSM blocks.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % CALL: obj = obj.setBlockProtperties(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % 'FIELD', 'inputs', 'BLOCKS', 'ALL', ... % or a cellstr to indicate the blocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % 'NEW_NAMES', {'names'...}, 'NEW_DESCRIPTIONS');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % blockname may be a double, a string or a cell-array of strings of size 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % newBlockDescription may be a string or a cell-array of strings
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'setBlockProperties')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % VERSION: $Id: setBlockProperties.m,v 1.5 2011/04/08 08:56:23 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 function varargout = setBlockProperties(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 %%% Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 [ssms, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 [pl, invars2, rest] = utils.helper.collect_objects(rest(:), 'plist');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 if ~isempty(rest)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 pl = combine(pl, plist(rest{:}));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 pl = combine(pl, getDefaultPlist());
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 %%% Internal call: Only one object + don't look for a plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 internal = strcmp(varargin{end}, 'internal');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 sys = copy(ssms, nargout);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 %% parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 field = pl.find('field');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 blockIds = pl.find('blocks');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 newDescriptions = pl.find('NEW_DESCRIPTIONS');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 newNames = pl.find('NEW_NAMES');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 if ischar(newDescriptions)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 newDescriptions = {newDescriptions};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 if ischar(newNames)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 newNames = {newNames};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % Some error checking....
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 if isempty(field)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 error('### Please specify the field of the block to modify');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 %% Loop over the input ssm objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 for kk = 1:numel(sys)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 block = sys(kk).(field);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 [pos, logic] = block.findBlockWithNames(blockIds, 'do warning');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 if ~isempty(newDescriptions)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 if numel(newDescriptions) ~= numel(pos)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 error('### Please specify one new description per block');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 for ii=1:numel(pos)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 block(pos(ii)).setBlockDescriptions(newDescriptions{ii});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 if ~isempty(newNames)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 if numel(newNames) ~= numel(pos)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 error('### Please specify one new description per block');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 for ii=1:numel(pos)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 block(pos(ii)).setBlockNames(newNames{ii});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 if ~internal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 % append history step
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 sys(kk).addHistory(getInfo('None'), pl, ssm_invars(kk), sys(kk).hist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 end % End loop over block IDs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 %% Set output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 if nargout == numel(sys)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 for ii = 1:numel(sys)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 varargout{ii} = sys(ii);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 varargout{1} = sys;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 % Local Functions %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
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 % Get Info Object
|
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 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 pl = getDefaultPlist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.helper, '$Id: setBlockProperties.m,v 1.5 2011/04/08 08:56:23 hewitson Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 function plo = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 plo = plist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 % type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 p = param({'field', 'The field being changed'}, {1, {'inputs', 'outputs', 'states'}, paramValue.SINGLE});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 % blocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 p = param({'BLOCKS', 'Identifiers (cellstr of block names or "ALL") of the blocks you want to modify'}, paramValue.EMPTY_CELL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 % descriptions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 p = param({'new_descriptions', 'The new description(s) you want to set to the block(s). Use a cell-array, one entry for each block.'}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 paramValue.EMPTY_CELL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 p = param({'new_names', 'The new names(s) you want to set to the block(s). Use a cell-array, one entry for each block.'}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 paramValue.EMPTY_CELL);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148
|