summaryrefslogtreecommitdiff
path: root/js/Linear/DELAYV_f.js
blob: 5ddae67d8d3900e063ea3e66074c0c12d2c53373 (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
/* autogenerated from "macros/Linear/DELAYV_f.sci" */
function DELAYV_f() {
    DELAYV_f.prototype.define = function DELAYV_f() {
        this.nin = 1;
        var z0 = zeros(11,1);
        this.zz0 = z0.slice(1-1,$-1);
        this.T = 1;
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["delayv"]), new ScilabDouble([1]));
        this.model.in = new ScilabDouble([this.nin],[1]);
        this.model.out = new ScilabDouble([this.nin]);
        this.model.evtin = new ScilabDouble([1]);
        this.model.evtout = new ScilabDouble([1],[1]);
        this.model.dstate = new ScilabDouble([z0]);
        this.model.rpar = new ScilabDouble([this.T/(size(this.zz0,"*"))]);
        this.model.blocktype = new ScilabString(["d"]);
        this.model.firing = new ScilabDouble([0,-1]);
        this.model.dep_ut = new ScilabBoolean([true,false]);
        var exprs = [[string(this.nin)],[strcat(string(z0.slice(1-1,$-1)),";")],[string(this.T)]];
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DELAYV_f\",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);
    }
    DELAYV_f.prototype.details = function DELAYV_f() {
        return this.x;
    }
    DELAYV_f.prototype.get = function DELAYV_f() {
        var exprs = this.graphics.exprs;
        this.nin = this.model.in[1-1];
        var z0 = this.model.dstate;
        this.zz0 = z0.slice(1-1,$-1);
        var told = z0[$-1];
        this.set_param_popup_title = "Set delay parameters";
        var options = {
            nin:["Number of inputs",this.nin],
            zz0:["Register initial condition",this.zz0],
            T:["Max delay",this.T],
        }
        return options;
    }
    DELAYV_f.prototype.set = function DELAYV_f() {
        var exprs = this.graphics.exprs;
        this.nin = this.model.in[1-1];
        var z0 = this.model.dstate;
        this.zz0 = z0.slice(1-1,$-1);
        var told = z0[$-1];
        while (true) {
            var ok = true;
            this.nin = parseFloat(arguments[0]["nin"]);
            this.zz0 = inverse(arguments[0]["zz0"]);
            this.T = parseFloat(arguments[0]["T"]);
            var exprs = [arguments[0]["nin"], arguments[0]["zz0"], arguments[0]["T"]];
            if (!ok) {
                break;
            }
            if (size(this.zz0,"*")<2) {
                message("Register length must be at least 2");
                throw "user error";
                var ok = false;
            }
            if (this.T<=0) {
                message("Delay must be positive");
                throw "user error";
                var ok = false;
            }
            if (ok) {
                var tmpvar0 = check_io(this.model,this.graphics,[[this.nin],[1]],this.nin,1,[[1],[1]]);
                this.model = tmpvar0[0];
                this.graphics = tmpvar0[1];
                var ok = tmpvar0[2];
            }
            if (ok) {
                this.graphics.exprs = new ScilabDouble([exprs]);
                this.model.dstate = new ScilabDouble([this.zz0.slice()],[told]);
                this.model.rpar = new ScilabDouble([this.T/(size(this.zz0,"*"))]);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
    DELAYV_f.prototype.get_popup_title = function DELAYV_f() {
        return this.set_param_popup_title;
    }
    DELAYV_f.prototype.importset = function DELAYV_f() {
        var graphics = this.x.graphics;
        var ary = getData(graphics.exprs);
        this.nin = ary[0];
        this.zz0 = ary[1];
        this.T = ary[2];
    }
    DELAYV_f.prototype.getContainer = function DELAYV_f() { return new BasicBlock(this.x); }
}