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 load('SCI/modules/scicos/macros/scicos_utils/lib');
9 load('SCI/modules/scicos/macros/scicos_menus/lib');
10 if ( ~isdef("scicos_pal") | ~isdef("%scicos_menu") | ..
11 ~isdef("%scicos_short") | ~isdef("%scicos_help") | ..
12 ~isdef("%scicos_display_mode") | ~isdef("modelica_libs") | ..
13 ~isdef("scicos_pal_libs") ) then
14 [scicos_pal, %scicos_menu, %scicos_short, modelica_libs, scicos_pal_libs,...
15 %scicos_lhb_list, %CmenuTypeOneVector, %scicos_gif,%scicos_contrib, ..
16 %scicos_libs, %scicos_with_grid, %scs_wgrid] = initial_scicos_tables();
19 exec('SCI/modules/scicos/tests/unit_tests/scicos_tests.sci');
20 options=default_options();
22 blockslib='scs'+['Branching','Events','Misc','Sinks','Threshold','Linear', ...
23 'NonLinear','Sources','Electrical','Hydraulics']+'lib';
28 for blocklib=blockslib
29 B=string(blocklib);Blocs=[Blocs;B(2:$)];
31 Blocs(Blocs=="m_sin")=[];
33 if checkdefine() then bugmes();quit;end
34 if checkinputs() then bugmes();quit;end
35 if checkoutputs() then bugmes();quit;end
36 if checkorigin() then bugmes();quit;end
37 if checkdeput() then bugmes();quit;end
38 if checkfiring() then bugmes();quit;end
39 if check_define_ports() then bugmes();quit;end
40 if check_set_ports() then bugmes();quit;end
46 // Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
48 // - Alan Layec <alan.layec@inria.fr>
52 // This program is free software; you can redistribute it and/or modify
54 // it under the terms of the GNU General Public License as published by
56 // the Free Software Foundation; either version 2 of the License, or
58 // (at your option) any later version.
62 // This program is distributed in the hope that it will be useful,
64 // but WITHOUT ANY WARRANTY; without even the implied warranty of
66 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68 // GNU General Public License for more details.
72 // You should have received a copy of the GNU General Public License
74 // along with this program; if not, write to the Free Software
76 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
80 // See the file ../license.txt
85 function [%ok,%1,%2,%3,%4,%5,...
87 %11,%12,%13,%14,%15,...
88 %16,%17,%18,%19,%20]=setvalue(%desc,%lables,%typ,%ini)
89 // To avoid infinite loops in set section of blocks during eval
90 if %scicos_prob==%t then
94 %11,%12,%13,%14,%15,...
95 %16,%17,%18,%19,%20]=(0,0,0,0,...
100 // setvalues - data acquisition, getvalue equivalent without dialog
102 // [%ok,x1,..,x18]=setvalue(desc,labels,typ,ini)
104 // desc : column vector of strings, dialog general comment
105 // labels : n column vector of strings, labels(i) is the label of
106 // the ith required value
107 // typ : list(typ1,dim1,..,typn,dimn)
108 // typi : defines the type of the ith required value
109 // if may have the following values:
110 // 'mat' : stands for matrix of scalars
111 // 'col' : stands for column vector of scalars
112 // 'row' : stands for row vector of scalars
113 // 'vec' : stands for vector of scalars
114 // 'str' : stands for string
115 // 'lis' : stands for list
116 // 'pol' : stands for polynomials
117 // 'r' : stands for rational
118 // dimi : defines the size of the ith required value
120 // - an integer or a 2-vector of integers (-1 stands for
121 // arbitrary dimension)
122 // - an evaluatable character string
123 // ini : n column vector of strings, ini(i) gives the suggested
124 // response for the ith required value
125 // %ok : boolean ,%t if %ok button pressed, %f if cancel button pressed
126 // xi : contains the ith required value if %ok==%t
128 // getvalues function uses ini strings to evaluate required args
129 // with error checking,
131 // All correct scilab syntax may be used as responses, for matrices
132 // and vectors getvalues automatically adds [ ] around the given response
133 // before numerical evaluation
135 // labels=['magnitude';'frequency';'phase '];
136 // [ampl,freq,ph]=setvalue('define sine signal',labels,..
137 // list('vec',1,'vec',1,'vec',1),['0.85';'10^2';'%pi/3'])
142 // 17/01/07 -Alan- - %scicos_context behavior reviewed in accordance to context_evstr macro
143 // - pass int in field of type vec/mat/row/col (F. Nassif's Work)
145 // 05/02/07 -Alan- : update to %20 rhs parameters
149 %nn=prod(size(%lables))
150 if %lhs<>%nn+2&%lhs<>%nn+1 then error(41),end
151 if size(%typ)<>2*%nn then
152 error('typ : list(''type'',[sizes],...)')
154 %1=[];%2=[];%3=[];%4=[];%5=[];
155 %6=[];%7=[];%8=[];%9=[];%10=[];
156 %11=[];%12=[];%13=[];%14=[],%15=[];
157 %16=[];%17=[];%18=[];%19=[],%20=[];
158 if %rhs==3 then %ini=emptystr(%nn,1),end
162 if %str==[] then %ok=%f,break,end
164 %cod=ascii(%str(%kk))
168 %cod(%spe)=%semi*ones(%spe')
169 %str(%kk)=ascii(%cod)
172 [%vv_list,%ierr_vec]=context_evstr(%str,%scicos_context,%typ);
177 select part(%typ(2*%kk-1),1:3)
183 //the type of %vv is accepted if it is constant or integer
184 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
185 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
186 [%mmmm,%nnnnn]=size(%vv)
187 %ssss=string(%sz(1))+' x '+string(%sz(2))
188 if %mmmm*%nnnnn==0 then
189 if %sz(1)>=0&%sz(2)>=0&%sz(1)*%sz(2)<>0 then %noooo=%kk,break,end
191 if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
192 if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
199 //the type of %vv is accepted if it is constant or integer
200 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
201 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
203 %nnnnn=prod(size(%vv))
204 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
209 if %ierr<>0 then %noooo=-%kk;break,end
210 if (type(%vv)>2 & type(%vv)<>8) then %noooo=-%kk,break,end
211 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
213 %nnnnn=prod(size(%vv))
214 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
220 //the type of %vv is accepted if it is constant or integer
221 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
222 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
226 %ssss='1 x '+string(%sz(1))
228 [%mmmm,%nnnnn]=size(%vv)
229 if %mmmm<>1 then %noooo=%kk,break,end,
230 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
236 //the type of %vv is accepted if it is constant or integer
237 if and(type(%vv)<>[1 8]) then %nok=-%kk,break,end
238 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
242 %ssss=string(%sz(1))+' x 1'
244 [%mmmm,%nnnnn]=size(%vv)
245 if %nnnnn<>1 then %noooo=%kk,break,end,
246 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
250 if type(%vv)<>10 then %noooo=-%kk,break,end
251 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
253 %nnnnn=prod(size(%vv))
254 if %sz(1)>=0 then if %nnnnn<>1 then %noooo=%kk,break,end,end
259 if type(%vv)<>15& type(%vv)<>16& type(%vv)<>17 then %noooo=-%kk,break,end
260 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
263 if %sz(1)>=0 then if %nnnnn<>%sz(1) then %noooo=%kk,break,end,end
268 if type(%vv)<>16 then %noooo=-%kk,break,end
269 if typeof(%vv)<>'rational' then %noooo=-%kk,break,end
270 %sz=%typ(2*%kk);if type(%sz)==10 then %sz=evstr(%sz),end
271 [%mmmm,%nnnnn]=size(%vv(2))
272 %ssss=string(%sz(1))+' x '+string(%sz(2))
273 if %mmmm*%nnnnn==0 then
274 if %sz(1)>=0&%sz(2)>=0&%sz(1)*%sz(2)<>0 then %noooo=%kk,break,end
276 if %sz(1)>=0 then if %mmmm<>%sz(1) then %noooo=%kk,break,end,end
277 if %sz(2)>=0 then if %nnnnn<>%sz(2) then %noooo=%kk,break,end,end
282 error('Incorrect type :'+%typ(2*%kk-1))
284 execstr('%'+string(%kk)+'=%vv')
288 messagebox(['answer given for '+%lables(%noooo);
289 'has invalid dimension: ';
290 'waiting for dimension '+%ssss],'modal')
294 messagebox(['answer given for '+%lables(-%noooo);
295 'has incorrect type :'+ %typ(-2*%noooo-1)],'modal')
303 execstr('%'+string(%lhs-1)+'=%str')