1//  Scicos
2//
3//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18//
19// See the file ../license.txt
20//
21
22function [x,y,typ]=GEN_SQR(job,arg1,arg2)
23    //Generated from SuperBlock on 8-Feb-2008
24    x=[];
25    y=[];
26    typ=[];
27    select job
28    case "set" then
29        y=needcompile
30        arg1.model.ipar=1;
31        typ=list()
32        graphics=arg1.graphics;
33        exprs=graphics.exprs
34        Btitre = msprintf(_("Set %s block parameters"), "GEN_SQR");
35        Exprs0 = ["Amin" ; "Amax" ; "rule" ; "F"]
36        Bitems=..
37        _(["Minimum Value";
38           "Maximum Value";
39           "Initial Value( 1= Minimum Value 2= Maximum Value)";
40           "Period (s)"])
41        Ss = list("mat",[-1,-1],"mat",[-1,-1],"pol",-1,"pol",-1)
42        scicos_context=struct()
43        x=arg1
44        ok=%f
45        while ~ok do
46            [ok,scicos_context.Amin,scicos_context.Amax,scicos_context.rule,scicos_context.F,exprs]=scicos_getvalue(Btitre,Bitems,Ss,exprs)
47            if ~ok then
48                return;
49            end
50            %scicos_context=scicos_context;
51            sblock=x.model.rpar
52            [%scicos_context,ierr]=script2var(sblock.props.context,%scicos_context)
53            if ierr==0 then
54                [sblock,%w,needcompile2,ok]=do_eval(sblock,list())
55                if ok then
56                    y=max(2,needcompile,needcompile2)
57                    x.graphics.exprs=exprs
58                    x.model.rpar=sblock
59                    break
60                end
61            else
62                message(lasterror())
63                ok=%f
64            end
65        end
66    case "define" then
67        scs_m_1=scicos_diagram(..
68        version="scicos4.2",..
69        props=scicos_params(..
70        wpar=[-176.97473,421.18646,173.61587,524.41503,827,480,0,15,827,480,755,614,1.4],..
71        Title="SuperBlock",..
72        tol=[0.0001,0.000001,1.000D-10,100001,0,0],..
73        tf=100000,..
74        context=["if typeof(Amin)<>typeof(Amax) then error(''Minimum value and Maximum value must have the same type'');end";
75        "if and(rule<>[1;2]) then error(''Initial Value must be 1 (for Min) or 2 (for Max)'');end";
76        "if Amin>Amax then error(''Maximum value must be greater than the Minimum Value'');end";
77        "P=%pi/F";
78        ""],..
79        void1=[],..
80        options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],..
81        list([5,1],[4,1]),[0.8,0.8,0.8]),..
82        void2=[],..
83        void3=[],..
84        doc=list()))
85        scs_m_1.objs(1)=scicos_block(..
86        gui="Counter",..
87        graphics=scicos_graphics(..
88        orig=[18.229901,339.5057],..
89        sz=[60,40],..
90        exprs=["1";"2";"rule"],..
91        pin=[],..
92        pout=8,..
93        pein=16,..
94        peout=[],..
95        gr_i=[],..
96        id="",..
97        in_implicit=[],..
98        out_implicit="E"),..
99        model=scicos_model(..
100        sim=list("counter",4),..
101        in=[],..
102        in2=[],..
103        intyp=1,..
104        out=1,..
105        out2=1,..
106        outtyp=1,..
107        evtin=1,..
108        evtout=[],..
109        state=[],..
110        dstate=0,..
111        odstate=list(),..
112        rpar=[],..
113        ipar=[1;2;1],..
114        opar=list(),..
115        blocktype="c",..
116        firing=[],..
117        dep_ut=[%f,%f],..
118        label="",..
119        nzcross=0,..
120        nmode=0,..
121        equations=list()),..
122        doc=list())
123        scs_m_1.objs(2)=scicos_block(..
124        gui="CONST_m",..
125        graphics=scicos_graphics(..
126        orig=[38.096074,293.82198],..
127        sz=[40,40],..
128        exprs="Amin",..
129        pin=[],..
130        pout=5,..
131        pein=[],..
132        peout=[],..
133        gr_i=[],..
134        id="",..
135        in_implicit=[],..
136        out_implicit="E"),..
137        model=scicos_model(..
138        sim=list("cstblk4_m",4),..
139        in=[],..
140        in2=[],..
141        intyp=1,..
142        out=1,..
143        out2=1,..
144        outtyp=1,..
145        evtin=[],..
146        evtout=[],..
147        state=[],..
148        dstate=[],..
149        odstate=list(),..
150        rpar=[],..
151        ipar=[],..
152        opar=list(-1),..
153        blocktype="d",..
154        firing=[],..
155        dep_ut=[%f,%f],..
156        label="",..
157        nzcross=0,..
158        nmode=0,..
159        equations=list()),..
160        doc=list())
161        scs_m_1.objs(3)=scicos_block(..
162        gui="CONST_m",..
163        graphics=scicos_graphics(..
164        orig=[37.378886,245.02389],..
165        sz=[40,40],..
166        exprs="Amax",..
167        pin=[],..
168        pout=6,..
169        pein=[],..
170        peout=[],..
171        gr_i=[],..
172        id="",..
173        in_implicit=[],..
174        out_implicit="E"),..
175        model=scicos_model(..
176        sim=list("cstblk4_m",4),..
177        in=[],..
178        in2=[],..
179        intyp=1,..
180        out=1,..
181        out2=1,..
182        outtyp=1,..
183        evtin=[],..
184        evtout=[],..
185        state=[],..
186        dstate=[],..
187        odstate=list(),..
188        rpar=[],..
189        ipar=[],..
190        opar=list(1),..
191        blocktype="d",..
192        firing=[],..
193        dep_ut=[%f,%f],..
194        label="",..
195        nzcross=0,..
196        nmode=0,..
197        equations=list()),..
198        doc=list())
199        scs_m_1.objs(4)=scicos_block(..
200        gui="SELECT_m",..
201        graphics=scicos_graphics(..
202        orig=[116.26954,269.42294],..
203        sz=[40,40],..
204        exprs=["-1";"2";"1"],..
205        pin=[5;6],..
206        pout=14,..
207        pein=[9;10],..
208        peout=[],..
209        gr_i=[],..
210        id="",..
211        in_implicit=["E";"E"],..
212        out_implicit="E"),..
213        model=scicos_model(..
214        sim=list("selector_m",4),..
215        in=[-1;-1],..
216        in2=[-2;-2],..
217        intyp=[-1;-1],..
218        out=-1,..
219        out2=-2,..
220        outtyp=-1,..
221        evtin=[1;1],..
222        evtout=[],..
223        state=[],..
224        dstate=1,..
225        odstate=list(),..
226        rpar=[],..
227        ipar=[],..
228        opar=list(),..
229        blocktype="c",..
230        firing=[],..
231        dep_ut=[%t,%f],..
232        label="",..
233        nzcross=0,..
234        nmode=0,..
235        equations=list()),..
236        doc=list())
237        scs_m_1.objs(5)=scicos_link(..
238        xx=[86.667502;107.69811;107.69811],..
239        yy=[313.82198;313.82198;296.0896],..
240        id="drawlink",..
241        thick=[0,0],..
242        ct=[1,1],..
243        from=[2,1,0],..
244        to=[4,1,1])
245        scs_m_1.objs(6)=scicos_link(..
246        xx=[85.950315;107.69811;107.69811],..
247        yy=[265.02389;265.02389;282.75627],..
248        id="drawlink",..
249        thick=[0,0],..
250        ct=[1,1],..
251        from=[3,1,0],..
252        to=[4,2,1])
253        scs_m_1.objs(7)=scicos_block(..
254        gui="ESELECT_f",..
255        graphics=scicos_graphics(..
256        orig=[106.9461,339.7496],..
257        sz=[60,40],..
258        exprs=["2";"0";"0"],..
259        pin=8,..
260        pout=[],..
261        pein=[],..
262        peout=[9;10],..
263        gr_i=[],..
264        id="",..
265        in_implicit="E",..
266        out_implicit=[]),..
267        model=scicos_model(..
268        sim=list("eselect",-2),..
269        in=1,..
270        in2=1,..
271        intyp=-1,..
272        out=[],..
273        out2=[],..
274        outtyp=1,..
275        evtin=[],..
276        evtout=[1;1],..
277        state=[],..
278        dstate=[],..
279        odstate=list(),..
280        rpar=[],..
281        ipar=[],..
282        opar=list(),..
283        blocktype="l",..
284        firing=[-1;-1],..
285        dep_ut=[%t,%f],..
286        label="",..
287        nzcross=0,..
288        nmode=0,..
289        equations=list()),..
290        doc=list())
291        scs_m_1.objs(8)=scicos_link(..
292        xx=[86.80133;98.374671],..
293        yy=[359.5057;359.7496],..
294        id="drawlink",..
295        thick=[0,0],..
296        ct=[1,1],..
297        from=[1,1,0],..
298        to=[7,1,1])
299        scs_m_1.objs(9)=scicos_link(..
300        xx=[126.9461;129.60287],..
301        yy=[334.03532;315.13722],..
302        id="drawlink",..
303        thick=[0,0],..
304        ct=[5,-1],..
305        from=[7,1,0],..
306        to=[4,1,1])
307        scs_m_1.objs(10)=scicos_link(..
308        xx=[146.9461;142.93621],..
309        yy=[334.03532;315.13722],..
310        id="drawlink",..
311        thick=[0,0],..
312        ct=[5,-1],..
313        from=[7,2,0],..
314        to=[4,2,1])
315        scs_m_1.objs(11)=mlist("Deleted")
316        scs_m_1.objs(12)=mlist("Deleted")
317        scs_m_1.objs(13)=scicos_block(..
318        gui="OUT_f",..
319        graphics=scicos_graphics(..
320        orig=[184.40238,278.75198],..
321        sz=[20,20],..
322        exprs="1",..
323        pin=14,..
324        pout=[],..
325        pein=[],..
326        peout=[],..
327        gr_i=[],..
328        id="",..
329        in_implicit="E",..
330        out_implicit=[]),..
331        model=scicos_model(..
332        sim="output",..
333        in=-1,..
334        in2=-2,..
335        intyp=-1,..
336        out=[],..
337        out2=[],..
338        outtyp=1,..
339        evtin=[],..
340        evtout=[],..
341        state=[],..
342        dstate=[],..
343        odstate=list(),..
344        rpar=[],..
345        ipar=1,..
346        opar=list(),..
347        blocktype="c",..
348        firing=[],..
349        dep_ut=[%f,%f],..
350        label="",..
351        nzcross=0,..
352        nmode=0,..
353        equations=list()),..
354        doc=list())
355        scs_m_1.objs(14)=scicos_link(..
356        xx=[164.84097;184.40238],..
357        yy=[289.42294;288.75198],..
358        id="drawlink",..
359        thick=[0,0],..
360        ct=[1,1],..
361        from=[4,1,0],..
362        to=[13,1,1])
363        scs_m_1.objs(15)=scicos_block(..
364        gui="SampleCLK",..
365        graphics=scicos_graphics(..
366        orig=[18.313686,403.57431],..
367        sz=[60,40],..
368        exprs=["F/2";"0"],..
369        pin=[],..
370        pout=[],..
371        pein=[],..
372        peout=16,..
373        gr_i=[],..
374        id="",..
375        in_implicit=[],..
376        out_implicit=[]),..
377        model=scicos_model(..
378        sim="sampleclk",..
379        in=[],..
380        in2=[],..
381        intyp=1,..
382        out=[],..
383        out2=[],..
384        outtyp=1,..
385        evtin=[],..
386        evtout=1,..
387        state=[],..
388        dstate=[],..
389        odstate=list(),..
390        rpar=[1/2;0],..
391        ipar=[],..
392        opar=list(),..
393        blocktype="d",..
394        firing=-1,..
395        dep_ut=[%f,%f],..
396        label="",..
397        nzcross=0,..
398        nmode=0,..
399        equations=list()),..
400        doc=list())
401        scs_m_1.objs(16)=scicos_link(..
402        xx=[48.313686;48.229901],..
403        yy=[403.57431;385.21998],..
404        id="drawlink",..
405        thick=[0,0],..
406        ct=[5,-1],..
407        from=[15,1,0],..
408        to=[1,1,1])
409        model=scicos_model()
410        model.sim="csuper"
411        model.in=[]
412        model.in2=[]
413        model.intyp=1
414        model.out=-1
415        model.out2=-2
416        model.outtyp=-1
417        model.evtin=[]
418        model.evtout=[]
419        model.state=[]
420        model.dstate=[]
421        model.odstate=list()
422        model.rpar=scs_m_1
423        model.ipar=1
424        model.opar=list()
425        model.blocktype="h"
426        model.firing=[]
427        model.dep_ut=[%f,%f]
428        model.label=""
429        model.nzcross=0
430        model.nmode=0
431        model.equations=list()
432        Amin=-1
433        Amax=1
434        rule=1
435        F=1
436        exprs=[..
437        sci2exp(Amin)
438        sci2exp(Amax)
439        sci2exp(rule)
440        sci2exp(F)
441        ]
442        gr_i=[]
443        x=standard_define([3,2],model,exprs,gr_i)
444    end
445endfunction
446
447
448