summaryrefslogtreecommitdiff
path: root/js/Linear/DELAYV_f.js
blob: 1f569d9b7b6cec0766501b1cfa9e87bc31f61de0 (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;
        this.model = scicos_model();
        this.model.sim = list(new ScilabString("delayv"),new ScilabDouble(1));
        this.model.in1 = [[this.nin],[1]];
        this.model.out = new ScilabDouble(this.nin);
        this.model.evtin = new ScilabDouble(1);
        this.model.evtout = [[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 = [0,-1];
        this.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],this.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;
        this.model = arg1.model;
        this.nin = this.model.in1[1-1];
        z0 = this.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(this.model,graphics,[[this.nin],[1]],this.nin,1,[[1],[1]]);
            }
            if (ok) {
                graphics.exprs = exprs;
                this.model.dstate = [[this.zz0.slice()],[told]];
                this.model.rpar = new ScilabDouble(this.T/(size(this.zz0,"*")));
                this.x.graphics = graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
}