/* autogenerated from "macros/Branching/MUX.sci" */ function MUX() { MUX.prototype.define = function MUX() { this.in1 = 2; this.model = scicos_model(); this.model.sim = list(new ScilabString(["multiplex"]), new ScilabDouble([4])); this.model.in = new ScilabDouble(-transpose([1:this.in1])); this.model.out = new ScilabDouble([0]); this.model.ipar = new ScilabDouble([this.in1]); this.model.blocktype = new ScilabString(["c"]); this.model.dep_ut = new ScilabBoolean([true,false]); var exprs = string(this.in1); var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX\",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([.5,2]),this.model,new ScilabString([exprs]),gr_i); return new BasicBlock(this.x); } MUX.prototype.details = function MUX() { return this.x; } MUX.prototype.get = function MUX() { var exprs = this.graphics.exprs; this.set_param_popup_title = "Set MUX block parameters"; var options = { in1:["number of input ports or vector of sizes",this.in1], } return options; } MUX.prototype.set = function MUX() { var exprs = this.graphics.exprs; while (true) { var ok = true; this.in1 = parseFloat(arguments[0]["in1"]); var exprs = [arguments[0]["in1"]]; 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"); throw "user error"; var ok = false; } else { var tmpvar0 = check_io(this.model,this.graphics,-transpose([1:this.in1]),0,[],[]); this.model = tmpvar0[0]; this.graphics = tmpvar0[1]; var ok = tmpvar0[2]; } } 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. "]]); throw "user error"; var ok = false; } else { if (min(this.in1)<0) { var nout = 0; } else { var nout = sum(this.in1); } var tmpvar1 = check_io(this.model,this.graphics,this.in1.slice(),nout,[],[]); this.model = tmpvar1[0]; this.graphics = tmpvar1[1]; var ok = tmpvar1[2]; if (ok) { this.in1 = size(this.in1,"*"); } } } if (ok) { this.graphics.exprs = new ScilabDouble([exprs]); this.model.ipar = new ScilabDouble([this.in1]); this.x.graphics = this.graphics; this.x.model = this.model; break; } } return new BasicBlock(this.x); } MUX.prototype.get_popup_title = function MUX() { return this.set_param_popup_title; } }