summaryrefslogtreecommitdiff
path: root/js/Branching/MUX_f.js
blob: 8e50d3276d6b9a57a12c266dda0497acce117472 (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
/* autogenerated from "macros/Branching/MUX_f.sci" */
function MUX_f() {
    MUX_f.prototype.define = function MUX_f() {
        this.in = 2;
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["mux"]), new ScilabDouble([1]));
        this.model.in = new ScilabDouble(-transpose([1:this.in]));
        this.model.out = new ScilabDouble([0]);
        this.model.ipar = new ScilabDouble([this.in]);
        this.model.blocktype = new ScilabString(["c"]);
        this.model.dep_ut = new ScilabBoolean([true,false]);
        var exprs = string(this.in);
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX_f\",sz(1),sz(2));"]);
        this.x = new standard_define(new ScilabDouble([0.5,2]),this.model,new ScilabString([exprs]),gr_i);
        return new BasicBlock(this.x);
    }
    MUX_f.prototype.details = function MUX_f() {
        return this.x;
    }
    MUX_f.prototype.get = function MUX_f() {
        var exprs = this.graphics.exprs;
        this.set_param_popup_title = "Set MUX block parameters";
        var options = {
            in:["number of input ports or vector of sizes",this.in],
        }
        return options;
    }
    MUX_f.prototype.set = function MUX_f() {
        var exprs = this.graphics.exprs;
        while (true) {
            var ok = true;
            this.in = parseFloat(arguments[0]["in"]);
            var exprs = [arguments[0]["in"]];
            if (!ok) {
                break;
            }
            if (size(this.in,"*")==1) {
                if (this.in<2||this.in>8) {
                    message("Block must have at least two input ports and at most eight");
                    throw "user error";
                    var ok = false;
                } else {
                    var tmpvar0 = check_io(this.model,this.graphics,-transpose([1:this.in]),0,[],[]);
                    this.model = tmpvar0[0];
                    this.graphics = tmpvar0[1];
                    var ok = tmpvar0[2];
                }
            } else {
                if (size(this.in,"*")<2||size(this.in,"*")>8||or(this.in==0)) {
                    message([["Block must have at least two input ports"],["and at most eight, and size 0 is not allowed. "]]);
                    throw "user error";
                    var ok = false;
                } else {
                    if (min(this.in)<0) {
                        var nout = 0;
                    } else {
                        var nout = sum(this.in);
                    }
                    var tmpvar1 = check_io(this.model,this.graphics,this.in.slice(),nout,[],[]);
                    this.model = tmpvar1[0];
                    this.graphics = tmpvar1[1];
                    var ok = tmpvar1[2];
                    if (ok) {
                        this.in = size(this.in,"*");
                    }
                }
            }
            if (ok) {
                this.graphics.exprs = new ScilabDouble([exprs]);
                this.model.ipar = new ScilabDouble([this.in]);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
    MUX_f.prototype.get_popup_title = function MUX_f() {
        return this.set_param_popup_title;
    }
    MUX_f.prototype.importset = function MUX_f() {
        var graphics = this.x.graphics;
        var ary = getData(graphics.exprs);
        this.in = ary[0];
    }
    MUX_f.prototype.getContainer = function MUX_f() { return new BasicBlock(this.x); }
}