* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Misc / HYSTHERESIS.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]=HYSTHERESIS(job,arg1,arg2)
23     x=[];
24     y=[];
25     typ=[];
26     select job
27     case "set" then
28         x=arg1;
29         graphics=arg1.graphics;
30         exprs=graphics.exprs
31         model=arg1.model;
32         while %t do
33             [ok,high_lim,low_lim,out_high,out_low,nzz,exprs]=scicos_getvalue(..
34             msprintf(_("Set %s block parameters"), "HYSTERESIS"),..
35             _(["Switch on at";
36                "Switch off at";
37                "Output when on";
38                "Output when off";
39                "Use zero crossing: yes (1), no (0)"]),..
40             list("vec",1,"vec",1,"vec",1,"vec",1,"vec",1),exprs)
41             if ~ok then
42                 break,
43             end
44             if low_lim>high_lim then
45                 message(_("switch on value must be >= switch off value"))
46             else
47                 graphics.exprs=exprs;
48                 model.rpar=[high_lim,low_lim,out_high,out_low]'
49                 if nzz>0 then
50                     nzz=2,
51                 end
52                 model.nzcross=nzz
53                 x.graphics=graphics;
54                 x.model=model
55                 break
56             end
57         end
58     case "define" then
59         in=1
60         ipar=[0] // rule
61         nzz=2
62         rpar=[1;0;1;0]
63
64         model=scicos_model()
65         model.sim=list("hystheresis",4)
66         model.in=in
67         model.out=1
68         model.rpar=rpar
69         model.nzcross=nzz
70         model.nmode=1
71         model.blocktype="c"
72         model.dep_ut=[%t %f]
73
74         exprs=[string(rpar);string(sign(nzz))]
75
76
77         gr_i=[]
78
79         x=standard_define([2 2],model,exprs,gr_i)
80     end
81 endfunction