summaryrefslogtreecommitdiff
path: root/js/Linear/INTEGRAL.js
blob: 89a6d7f5672d7385df4f0104661bfba8555b8acc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* autogenerated from "macros/Linear/INTEGRAL.sci" */
function INTEGRAL() {
    INTEGRAL.prototype.define = function INTEGRAL() {
        this.maxp = 1;
        minp = -1;
        rpar = [];
        this.model = scicos_model();
        this.model.state = new ScilabDouble([0]);
        this.model.sim = list(new ScilabString(["integral_func"]), new ScilabDouble([4]));
        this.model.in1 = new ScilabDouble([1]);
        this.model.out = new ScilabDouble([1]);
        this.model.rpar = rpar;
        this.model.blocktype = new ScilabString(["c"]);
        this.model.dep_ut = [false,true];
        exprs = string([[0],[0],[0],[this.maxp],[minp]]);
        gr_i = [];
        this.x = standard_define([2,2],this.model,exprs,gr_i);
        this.x.graphics.id = "1/s";
        return new BasicBlock(this.x);
    }
    INTEGRAL.prototype.details = function INTEGRAL() {
        return this.x;
    }
    INTEGRAL.prototype.get = function INTEGRAL() {
        var options = {
            x0:["Initial Condition",this.x0],
            reinit:["With re-intialization (1:yes, 0:no)",this.reinit],
            satur:["With saturation (1:yes, 0:no)",this.satur],
            maxp:["Upper limit",this.maxp],
            lowp:["Lower limit",this.lowp],
        }
        return options;
    }
    INTEGRAL.prototype.set = function INTEGRAL() {
        this.x0 = inverse(arguments[0]["x0"])
        this.reinit = parseFloat(arguments[0]["reinit"])
        this.satur = parseFloat(arguments[0]["satur"])
        this.maxp = parseFloat(arguments[0]["maxp"])
        this.lowp = arguments[0]["lowp"]
        this.x = arg1;
        graphics = arg1.graphics;
        exprs = graphics.exprs;
        this.model = arg1.model;
        while (true) {
            [ok,this.x0,this.reinit,this.satur,this.maxp,this.lowp,exprs] = scicos_getvalue("Set Integral block parameters",["Initial Condition","With re-intialization (1:yes, 0:no)","With saturation (1:yes, 0:no)","Upper limit","Lower limit"],list("vec",-1,"vec",1,"vec",1,"vec",-1,"vec",-1),exprs);
            if (!ok) {
                break;
            }
            this.x0 = this.x0.slice();
            this.maxp = this.maxp.slice();
            this.lowp = this.lowp.slice();
            if (this.reinit!=0) {
                this.reinit = 1;
            }
            if (this.satur!=0) {
                this.satur = 1;
                if (size(this.maxp,"*")==1) {
                    this.maxp = this.maxp*ones(this.x0);
                }
                if (size(this.lowp,"*")==1) {
                    this.lowp = this.lowp*ones(this.x0);
                }
                if ((size(this.x0,1)!=size(this.maxp,1)||size(this.x0,1)!=size(this.lowp,1))) {
                    message("x0 and Upper limit and Lower limit must have same size");
                    ok = false;
                } else if (or(this.maxp<=this.lowp)) {
                    message("Upper limits must be > Lower limits");
                    ok = false;
                } else if (or(this.x0>this.maxp)||or(this.x0<this.lowp)) {
                    message("Initial condition x0 should be inside the limits");
                    ok = false;
                } else {
                    rpar = [[this.maxp],[this.lowp]];
                    this.model.nzcross = new ScilabDouble([size(this.x0,1)]);
                    this.model.nmode = new ScilabDouble([size(this.x0,1)]);
                }
            } else {
                rpar = [];
                this.model.nzcross = new ScilabDouble([0]);
                this.model.nmode = new ScilabDouble([0]);
            }
            if (ok) {
                this.model.rpar = rpar;
                this.model.state = this.x0;
                [model,graphics,ok] = check_io(this.model,graphics,size(this.x0,1)*[[1],[ones(this.reinit,1)]],size(this.x0,1),ones(this.reinit,1),[]);
            }
            if (ok) {
                graphics.exprs = exprs;
                this.x.graphics = graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
}