* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Sources / SampleCLK.sci
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
22 function [x,y,typ]=SampleCLK(job,arg1,arg2)
23     x=[];
24     y=[];
25     typ=[];
26     select job
27     case "set" then
28         x=arg1;
29         graphics=arg1.graphics;
30         model=arg1.model;
31         exprs=graphics.exprs
32         while %t do
33             [ok,frequ,offset,exprs]=scicos_getvalue(..
34             msprintf(_("Set %s block parameters"), "SampleCLK"),..
35             _(["Sample time" ; "Offset"]), list("vec",1,"vec",1),exprs)
36             if ~ok then
37                 break,
38             end
39             if frequ<0 then
40                 message(_("''Sample time'' must be >= 0"));
41                 ok=%f;
42             end
43             if abs(offset) > frequ then
44                 message(_("The |Offset| must be less than the Sample time"));
45                 ok=%f
46             end
47             if ok then
48                 if or(model.rpar(:)<>[frequ;offset]) then
49                     needcompile=4;
50                     y=needcompile,
51                 end
52                 model.rpar=[frequ;offset]
53                 model.evtout=1
54                 model.firing=-1//compatibility
55                 //       aa=max(length(exprs(1)),length(exprs(2)));
56                 //       if aa>1 then
57                 //          graphics.sz=[10*aa 20]
58                 //       else
59                 //          graphics.sz=[20 20]
60                 //       end
61                 graphics.exprs=exprs
62                 x.graphics=graphics
63                 x.model=model
64                 break
65             end
66         end
67         needcompile=resume(needcompile)
68     case "define" then
69         model=scicos_model()
70         model.sim="sampleclk"
71         model.evtout=1
72         model.rpar=[1,0]
73         model.blocktype="d"
74         model.firing=-1
75         model.dep_ut=[%f %f]
76
77         exprs=[sci2exp(1);sci2exp(0)]
78         x=standard_define([2 2],model,exprs," ")
79         //  x.graphics.id="S-CLK"
80     end
81 endfunction
82
83