summaryrefslogtreecommitdiff
path: root/js/Misc/CBLOCK4.js
blob: 42697562e30fd77d6b88c2729304d5b2d30fcf6c (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
108
109
110
111
112
113
/* autogenerated from "macros/Misc/CBLOCK4.sci" */
function CBLOCK4() {
    CBLOCK4.prototype.define = function CBLOCK4() {
        funam = "toto";
        model = scicos_model();
        model.sim = list(" ",2004);
        model.in1 = 1;
        model.in2 = 1;
        model.intyp = 1;
        model.out = 1;
        model.out2 = 1;
        model.outtyp = 1;
        model.dep_ut = [true,false];
        label = list([[funam],["n"],[sci2exp([model.in1,model.in2])],[sci2exp(model.intyp)],[sci2exp([model.out,model.out2])],[sci2exp(model.outtyp)],[sci2exp(model.evtin)],[sci2exp(model.evtout)],[sci2exp(model.state)],[sci2exp(model.dstate)],[sci2exp(model.odstate)],[sci2exp(model.rpar)],[sci2exp(model.ipar)],[sci2exp(model.opar)],[sci2exp(model.nmode)],[sci2exp(model.nzcross)],[sci2exp(model.firing)],["y"],["n"]],[]);
        gr_i = [];
        this.x = standard_define([4,2],model,label,gr_i);
        return new BasicBlock(this.x);
    }
    CBLOCK4.prototype.details = function CBLOCK4() {
        return this.x;
    }
    CBLOCK4.prototype.get = function CBLOCK4() {
    }
    CBLOCK4.prototype.set = function CBLOCK4() {
        this.x = arg1;
        model = arg1.model;
        graphics = arg1.graphics;
        label = graphics.exprs;
        while (true) {
            [ok,this.function_name,this.impli,this.in1,this.it,this.out,this.ot,this.ci,this.co,this.xx,this.z,this.oz,this.rpar,this.ipar,this.opar,this.nmode,this.nzcr,this.auto0,this.depu,this.dept,this.lab] = scicos_getvalue("Set C-Block4 block parameters",[["Simulation function"],["Is block implicit? (y,n)"],["Input ports sizes"],["Input ports type"],["Output port sizes"],["Output ports type"],["Input event ports sizes"],["Output events ports sizes"],["Initial continuous state"],["Initial discrete state"],["Initial object state"],["Real parameters vector"],["Integer parameters vector"],["Object parameters list"],["Number of modes"],["Number of zero crossings"],["Initial firing vector (<0 for no firing)"],["Direct feedthrough (y or n)"],["Time dependence (y or n)"]],list("str",1,"str",1,"mat",[-1,2],"vec",-1,"mat",[-1,2],"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"lis",-1,"vec",-1,"vec",-1,"lis",-1,"vec",1,"vec",1,"vec","sum(%8)","str",1,"str",1),label[1-1]);
            if (!ok) {
                break;
            }
            label[1-1] = this.lab;
            funam = stripblanks(this.function_name);
            this.xx = this.xx.slice();
            this.z = this.z.slice();
            this.rpar = this.rpar.slice();
            this.ipar = int(this.ipar.slice());
            nx = size(this.xx,1);
            nz = size(this.z,1);
            this.ci = int(this.ci.slice());
            nevin = size(this.ci,1);
            this.co = int(this.co.slice());
            nevout = size(this.co,1);
            if (part(this.impli,1)=="y") {
                funtyp = 12004;
            } else {
                funtyp = 2004;
            }
            if ([[this.ci],[this.co]]!=[]) {
                if (max([[this.ci],[this.co]])>1) {
                    message("vector event links not supported");
                    ok = false;
                }
            }
            if (ok) {
                this.depu = stripblanks(this.depu);
                if (part(this.depu,1)=="y") {
                    this.depu = true;
                } else {
                    this.depu = false;
                }
                this.dept = stripblanks(this.dept);
                if (part(this.dept,1)=="y") {
                    this.dept = true;
                } else {
                    this.dept = false;
                }
                dep_ut = [this.depu,this.dept];
                if (funam==" ") {
                    break;
                }
                if (model.sim[1-1]!=funam||sign(size(model.state,"*"))!=sign(nx)||sign(size(model.dstate,"*"))!=sign(nz)||model.nzcross!=this.nzcr||sign(size(model.evtout,"*"))!=sign(nevout)) {
                    tt = [];
                }
                tt = label[2-1];
                [model,graphics,ok] = set_io(model,graphics,list(this.in1,this.it),list(this.out,this.ot),this.ci,this.co);
            }
            if (ok) {
                while (true) {
                    [ok,tt,cancel] = this.CC4[funam-1][tt-1];
                    if (!ok) {
                        if (cancel) {
                            break;
                        }
                    } else {
                        model.sim = list(funam,funtyp);
                        model.state = this.xx;
                        model.dstate = this.z;
                        model.odstate = this.oz;
                        model.rpar = this.rpar;
                        model.ipar = this.ipar;
                        model.opar = this.opar;
                        model.firing = this.auto0;
                        model.nzcross = this.nzcr;
                        model.nmode = this.nmode;
                        model.dep_ut = dep_ut;
                        label[2-1] = tt;
                        this.x.model = model;
                        graphics.exprs = label;
                        this.x.graphics = graphics;
                        break;
                    }
                }
                if (ok||cancel) {
                    break;
                }
            }
        }
        return new BasicBlock(this.x);
    }
}