1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) ????-2008 - INRIA
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 load('SCI/modules/scicos/macros/scicos_scicos/lib');
8 options=default_options();
10 blockslib='scs'+['Branching','Events','Misc','Sinks','Threshold','Linear', ...
11 'NonLinear','Sources','Electrical','Hydraulics']+'lib';
16 for blocklib=blockslib
17 B=string(blocklib);Blocs=[Blocs;B(2:$)];
19 Blocs(Blocs=="m_sin")=[];
21 if checkdefine() then bugmes();quit;end
22 if checkinputs() then bugmes();quit;end
23 if checkoutputs() then bugmes();quit;end
24 if checkorigin() then bugmes();quit;end
25 if checkdeput() then bugmes();quit;end
26 if checkfiring() then bugmes();quit;end
27 if check_define_ports() then bugmes();quit;end
28 if check_set_ports() then bugmes();quit;end
34 // Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
36 // - Alan Layec <alan.layec@inria.fr>
40 // This program is free software; you can redistribute it and/or modify
42 // it under the terms of the GNU General Public License as published by
44 // the Free Software Foundation; either version 2 of the License, or
46 // (at your option) any later version.
50 // This program is distributed in the hope that it will be useful,
52 // but WITHOUT ANY WARRANTY; without even the implied warranty of
54 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 // GNU General Public License for more details.
60 // You should have received a copy of the GNU General Public License
62 // along with this program; if not, write to the Free Software
64 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
68 // See the file ../license.txt
73 function [%ok,%1,%2,%3,%4,%5,...
75 %11,%12,%13,%14,%15,...
76 %16,%17,%18,%19,%20]=setvalue(%desc,%lables,%typ,%ini)
77 // To avoid infinite loops in set section of blocks during eval
78 if %scicos_prob==%t then
82 %11,%12,%13,%14,%15,...
83 %16,%17,%18,%19,%20]=(0,0,0,0,...
88 // setvalues - data acquisition, getvalue equivalent without dialog
90 // [%ok,x1,..,x18]=setvalue(desc,labels,typ,ini)
92 // desc : column vector of strings, dialog general comment
93 // labels : n column vector of strings, labels(i) is the label of
94 // the ith required value
95 // typ : list(typ1,dim1,..,typn,dimn)
96 // typi : defines the type of the ith required value
97 // if may have the following values:
98 // 'mat' : stands for matrix of scalars
99 // 'col' : stands for column vector of scalars
100 // 'row' : stands for row vector of scalars
101 // 'vec' : stands for vector of scalars
102 // 'str' : stands for string
103 // 'lis' : stands for list
104 // 'pol' : stands for polynomials
105 // 'r' : stands for rational
106 // dimi : defines the size of the ith required value
108 // - an integer or a 2-vector of integers (-1 stands for
109 // arbitrary dimension)
110 // - an evaluatable character string
111 // ini : n column vector of strings, ini(i) gives the suggested
112 // response for the ith required value
113 // %ok : boolean ,%t if %ok button pressed, %f if cancel button pressed
114 // xi : contains the ith required value if %ok==%t
116 // getvalues function uses ini strings to evaluate required args
117 // with error checking,
119 // All correct scilab syntax may be used as responses, for matrices
120 // and vectors getvalues automatically adds [ ] around the given response
121 // before numerical evaluation
123 // labels=['magnitude';'frequency';'phase '];
124 // [ampl,freq,ph]=setvalue('define sine signal',labels,..
125 // list('vec',1,'vec',1,'vec',1),['0.85';'10^2';'%pi/3'])
130 // 17/01/07 -Alan- - %scicos_context behavior reviewed in accordance to context_evstr macro
131 // - pass int in field of type vec/mat/row/col (F. Nassif's Work)
133 // 05/02/07 -Alan- : update to %20 rhs parameters
136 %nn=prod(size(%lables))
137 if %lhs<>%nn+2&%lhs<>%nn+1 then error(41),end
138 if size(%typ)<>2*%nn then
139 error('typ : list(''type'',[sizes],...)')
141 %1=[];%2=[];%3=[];%4=[];%5=[];
142 %6=[];%7=[];%8=[];%9=[];%10=[];
143 %11=[];%12=[];%13=[];%14=[],%15=[];
144 %16=[];%17=[];%18=[];%19=[],%20=[];
145 if %rhs==3 then %ini=emptystr(%nn,1),end
149 if %str==[] then %ok=%f,break,end
151 %cod=ascii(%str(%kk))
155 %cod(%spe)=%semi*ones(%spe')
156 %str(%kk)=ascii(%cod)
159 [%vv_list,%ierr_vec]=context_evstr(%str,%scicos_context);
164 select part(%typ(2*%kk-1),1:3)
170 //the type of %vv is accepted if it is constant or integer
171 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
172 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
173 [%mmmm,%nnnnn]=size(%vv)
174 %ssss=string(%sz(1))+' x '+string(%sz(2))
175 if %mmmm*%nnnnn==0 then
176 if %sz(1)>=0&%sz(2)>=0&%sz(1)*%sz(2)<>0 then %noooo=%kk,break,end
178 if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
179 if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
186 //the type of %vv is accepted if it is constant or integer
187 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
188 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
190 %nnnnn=prod(size(%vv))
191 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
196 if %ierr<>0 then %noooo=-%kk;break,end
197 if type(%vv)>2 then %noooo=-%kk,break,end
198 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
200 %nnnnn=prod(size(%vv))
201 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
207 //the type of %vv is accepted if it is constant or integer
208 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
209 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
213 %ssss='1 x '+string(%sz(1))
215 [%mmmm,%nnnnn]=size(%vv)
216 if %mmmm<>1 then %noooo=%kk,break,end,
217 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
223 //the type of %vv is accepted if it is constant or integer
224 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
225 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
229 %ssss=string(%sz(1))+' x 1'
231 [%mmmm,%nnnnn]=size(%vv)
232 if %nnnnn<>1 then %noooo=%kk,break,end,
233 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
237 if type(%vv)<>10 then %noooo=-%kk,break,end
238 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
240 %nnnnn=prod(size(%vv))
241 if %sz(1)>=0 then if %nnnnn<>1 then %noooo=%kk,break,end,end
246 if type(%vv)<>15& type(%vv)<>16& type(%vv)<>17 then %noooo=-%kk,break,end
247 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
250 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
255 if type(%vv)<>16 then %noooo=-%kk,break,end
256 if typeof(%vv)<>'rational' then %noooo=-%kk,break,end
257 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
258 [%mmmm,%nnnnn]=size(%vv(2))
259 %ssss=string(%sz(1))+' x '+string(%sz(2))
260 if %mmmm*%nnnnn==0 then
261 if %sz(1)>=0&%sz(2)>=0&%sz(1)*%sz(2)<>0 then %noooo=%kk,break,end
263 if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
264 if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
267 error('Incorrect type :'+%typ(2*%kk-1))
269 execstr('%'+string(%kk)+'=%vv')
273 message(['answer given for '+%lables(%noooo);
274 'has invalid dimension: ';
275 'waiting for dimension '+%ssss])
279 message(['answer given for '+%lables(-%noooo);
280 'has incorrect type :'+ %typ(-2*%noooo-1)])
288 execstr('%'+string(%lhs-1)+'=%str')