summaryrefslogtreecommitdiff
path: root/js/Linear/DELAYV_f.js
blob: 79cd24be1f0ddd167ea07cd6cf85ed989d23f28c (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
/* autogenerated from "macros/Linear/DELAYV_f.sci" */
function DELAYV_f() {
    DELAYV_f.prototype.define = function DELAYV_f() {
        this.nin = 1;
        z0 = zeros(11,1);
        this.zz0 = z0.slice(1-1,$-1);
        this.T = 1;
        model = scicos_model();
        model.sim = list("delayv",1);
        model.in1 = [[this.nin],[1]];
        model.out = this.nin;
        model.evtin = 1;
        model.evtout = [[1],[1]];
        model.dstate = z0;
        model.rpar = this.T/(size(this.zz0,"*"));
        model.blocktype = "d";
        model.firing = [0,-1];
        model.dep_ut = [true,false];
        exprs = [[string(this.nin)],[strcat(string(z0.slice(1-1,$-1)),";")],[string(this.T)]];
        gr_i = [];
        this.x = standard_define([3,2],model,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 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() {
        this.nin = parseFloat(arguments[0]["nin"])
        this.zz0 = inverse(arguments[0]["zz0"])
        this.T = parseFloat(arguments[0]["T"])
        this.x = arg1;
        graphics = arg1.graphics;
        exprs = graphics.exprs;
        model = arg1.model;
        this.nin = model.in1[1-1];
        z0 = model.dstate;
        this.zz0 = z0.slice(1-1,$-1);
        told = z0[$-1];
        while (true) {
            [ok,this.nin,this.zz0,this.T,exprs] = scicos_getvalue("Set delay parameters",["Number of inputs","Register initial condition","Max delay"],list("vec",1,"vec",-1,"vec",1),exprs);
            if (!ok) {
                break;
            }
            if (size(this.zz0,"*")<2) {
                message("Register length must be at least 2");
                ok = false;
            }
            if (this.T<=0) {
                message("Delay must be positive");
                ok = false;
            }
            if (ok) {
                [model,graphics,ok] = check_io(model,graphics,[[this.nin],[1]],this.nin,1,[[1],[1]]);
            }
            if (ok) {
                graphics.exprs = exprs;
                model.dstate = [[this.zz0.slice()],[told]];
                model.rpar = this.T/(size(this.zz0,"*"));
                this.x.graphics = graphics;
                this.x.model = model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
}