summaryrefslogtreecommitdiff
path: root/js/Linear/CLR.js
blob: 099c7f269517a7ad7981b910721c35292ecc0f1f (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
97
98
99
100
101
102
103
104
105
106
107
/* autogenerated from "macros/Linear/CLR.sci" */
function CLR() {
    CLR.prototype.define = function CLR() {
        var x0 = 0;
        var A = -1;
        var B = 1;
        var C = 1;
        var D = 0;
        var exprs = [["1"],["1+s"]];
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4]));
        this.model.in = new ScilabDouble([1]);
        this.model.out = new ScilabDouble([1]);
        this.model.state = new ScilabDouble([x0]);
        this.model.rpar = new ScilabDouble([A.slice()],[B.slice()],[C.slice()],[D.slice()]);
        this.model.blocktype = new ScilabString(["c"]);
        this.model.dep_ut = new ScilabBoolean([false,true]);
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLR\",sz(1),sz(2));"]);
        this.x = new standard_define(new ScilabDouble([3,2]),this.model,new ScilabDouble(exprs),gr_i);
        return new BasicBlock(this.x);
    }
    CLR.prototype.details = function CLR() {
        return this.x;
    }
    CLR.prototype.get = function CLR() {
        var exprs = this.graphics.exprs;
        var x0 = this.model.state;
        var rpar = this.model.rpar;
        var ns = prod(size(x0));
        var nin = 1;
        var nout = 1;
        var PREVAR_scicos_context = PREVAR_scicos_context;
        PREVAR_scicos_context.s = %s;
        this.set_param_popup_title = "Set continuous SISO transfer parameters";
        var options = {
            num:["Numerator (s)",this.num],
            den:["Denominator (s)",this.den],
        }
        return options;
    }
    CLR.prototype.set = function CLR() {
        var exprs = this.graphics.exprs;
        var x0 = this.model.state;
        var rpar = this.model.rpar;
        var ns = prod(size(x0));
        var nin = 1;
        var nout = 1;
        var PREVAR_scicos_context = PREVAR_scicos_context;
        PREVAR_scicos_context.s = %s;
        while (true) {
            var ok = true;
            this.num = arguments[0]["num"];
            this.den = arguments[0]["den"];
            var exprs = [arguments[0]["num"], arguments[0]["den"]];
            if (!ok) {
                break;
            }
            if (degree(this.num)>degree(this.den)) {
                message("Transfer function must be proper or strictly proper.");
                throw "user error";
                var ok = false;
            }
            if (ok) {
                var H = cont_frm(this.num,this.den);
                var tmpvar0 = H.slice(2-1,5);
                var A = tmpvar0[0];
                var B = tmpvar0[1];
                var C = tmpvar0[2];
                var D = tmpvar0[3];
                this.graphics.exprs = new ScilabDouble([exprs]);
                var tmpvar1 = size(A);
                var ns1 = tmpvar1[0];
                var ns1 = tmpvar1[1];
                var rpar = [[matrix(A,ns1*ns1,1)],[matrix(B,ns1,1)],[matrix(C,ns1,1)],[D]];
                if (norm(D,1)!=0) {
                    var mmm = [true,true];
                } else {
                    var mmm = [false,true];
                }
                if (or(this.model.dep_ut!=mmm)) {
                    this.model.dep_ut = new ScilabBoolean(mmm);
                }
                if (ns1<=ns) {
                    var x0 = x0.slice(1-1,ns1);
                } else {
                    x0[ns1-1][1-1] = 0;
                }
                this.model.state = new ScilabDouble(x0);
                this.model.rpar = new ScilabDouble(rpar);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
    CLR.prototype.get_popup_title = function CLR() {
        return this.set_param_popup_title;
    }
    CLR.prototype.importset = function CLR() {
        var graphics = this.x.graphics;
        var ary = getData(graphics.exprs);
        this.num = ary[0];
        this.den = ary[1];
    }
    CLR.prototype.getContainer = function CLR() { return new BasicBlock(this.x); }
}