/* autogenerated from "macros/IntegerOp/LOGIC.sci" */ function LOGIC() { LOGIC.prototype.define = function LOGIC() { this.mat = [[0],[0],[0],[1]]; this.model = scicos_model(); this.model.sim = list(new ScilabString(["logic"]), new ScilabDouble([4])); this.model.in = new ScilabDouble([1],[1]); this.model.in2 = new ScilabDouble([1],[1]); this.model.out = new ScilabDouble([1]); this.model.out2 = new ScilabDouble([1]); this.model.evtin = new ScilabDouble([1]); this.model.intyp = new ScilabDouble([5,5]); this.model.outtyp = new ScilabDouble([5]); this.model.opar = list(new ScilabDouble([int8(this.mat)])); this.model.blocktype = new ScilabString(["c"]); this.model.firing = new ScilabBoolean([false]); this.model.dep_ut = new ScilabBoolean([true,false]); var exprs = [[sci2exp(this.mat)],[sci2exp(0)]]; var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGIC\",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([2,2]),this.model,new ScilabDouble(exprs),gr_i); return new BasicBlock(this.x); } LOGIC.prototype.details = function LOGIC() { return this.x; } LOGIC.prototype.get = function LOGIC() { var exprs = this.graphics.exprs; this.set_param_popup_title = msprintf("Set %s block parameters","LOGIC"); var options = { mat:["Truth Table (matrix of outputs)",this.mat.toString().replace(/,/g," ")], herit:["Accepts Inherited Events (0:No, 1:Yes)",this.herit], } return options; } LOGIC.prototype.set = function LOGIC() { var exprs = this.graphics.exprs; while (true) { var ok = true; this.mat = inverse(arguments[0]["mat"]); this.herit = arguments[0]["herit"]; var exprs = [arguments[0]["mat"], arguments[0]["herit"]]; if (!ok) { break; } var nout = size(this.mat,2); var nin = (log(size(this.mat,1))/log(2)); var u1 = floor(nin); if ((u1!=nin)) { block_parameter_error(msprintf("Wrong size for \'%s\' parameter: %d.","Truth Table",size(this.mat,1)),"Number of rows must be a power of two."); var ok = false; } else if ((find(this.mat.slice()!=0&&this.mat.slice()!=1).length!=0)) { block_parameter_error(msprintf("Wrong value for \'%s\' parameter.","Truth Table"),msprintf("Elements must be in the interval %s.","[0, 1]")); var ok = false; } else if (this.herit<0||this.herit>1) { block_parameter_error(msprintf("Wrong value for \'%s\' parameter: %d.","Accepts Inherited Events",this.herit),msprintf("Must be in the interval %s.","[0, 1]")); var ok = false; } if (ok) { var in1 = [ones(nin,1),ones(nin,1)]; var out = [ones(nout,1),ones(nout,1)]; var it = 5*ones(1,nin); var ot = 5*ones(1,nout); var tmpvar0 = set_io(this.model,this.graphics,list(in1,it),list(out,ot),ones(1-this.herit,1),[]); this.model = tmpvar0[0]; this.graphics = tmpvar0[1]; var ok = tmpvar0[2]; } if (ok) { this.graphics.exprs = new ScilabDouble([exprs]); this.mat = int8(this.mat); this.model.opar = list(new ScilabDouble([this.mat])); this.x.graphics = this.graphics; this.x.model = this.model; break; } } return new BasicBlock(this.x); } LOGIC.prototype.get_popup_title = function LOGIC() { return this.set_param_popup_title; } }