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