summaryrefslogtreecommitdiff
path: root/js/Branching/DEMUX.js
blob: 6f9fc54668c4bfd67f85c94aa07819b5ac328b50 (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
/* autogenerated from "macros/Branching/DEMUX.sci" */
function DEMUX() {
    DEMUX.prototype.define = function DEMUX() {
        out = 2;
        model = scicos_model();
        model.sim = list("multiplex",4);
        model.in1 = 0;
        model.out = -transpose([1:out]);
        model.ipar = out;
        model.blocktype = "c";
        model.firing = [];
        model.dep_ut = [true,false];
        exprs = string(out);
        gr_i = [];
        this.x = standard_define([.5,2],model,exprs,gr_i);
        return new BasicBlock(this.x);
    }
    DEMUX.prototype.details = function DEMUX() {
        return this.x;
    }
    DEMUX.prototype.get = function DEMUX() {
    }
    DEMUX.prototype.set = function DEMUX() {
        this.x = arg1;
        graphics = arg1.graphics;
        exprs = graphics.exprs;
        model = arg1.model;
        while (true) {
            [ok,out,exprs] = scicos_getvalue("Set DEMUX block parameters",["number of output ports or vector of sizes"],list("intvec",-1),exprs);
            if (!ok) {
                break;
            }
            if (size(out,"*")==1) {
                if (out<2||out>31) {
                    message("Block must have at least 2 and at most 31 output ports");
                    ok = false;
                } else {
                    [model,graphics,ok] = check_io(model,graphics,0,-transpose([1:out]),[],[]);
                }
            } else {
                if (size(out,"*")<2||or(out==0)||size(out,"*")>31) {
                    message([["Block must have at least 2 and at most 31 output ports"],["size 0 is not allowed"]]);
                    ok = false;
                } else {
                    if (min(out)<0) {
                        nin = 0;
                    } else {
                        nin = sum(out);
                    }
                    [model,graphics,ok] = check_io(model,graphics,nin,out.slice(),[],[]);
                    if (ok) {
                        out = size(out,"*");
                    }
                }
            }
            if (ok) {
                graphics.exprs = exprs;
                model.ipar = out;
                this.x.graphics = graphics;
                this.x.model = model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
}