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