/* autogenerated from "macros/Linear/GAINBLK.sci" */ function GAINBLK() { GAINBLK.prototype.define = function GAINBLK() { this.gain = 1; in1 = -1; out = -1; in2 = -2; out2 = -2; this.model = scicos_model(); this.model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4])); this.model.in1 = new ScilabDouble([in1]); this.model.out = new ScilabDouble([out]); this.model.in2 = new ScilabDouble([in2]); this.model.out2 = new ScilabDouble([out2]); this.model.rpar = new ScilabDouble([this.gain]); this.model.blocktype = new ScilabString(["c"]); this.model.dep_ut = [true,false]; exprs = [strcat(sci2exp(this.gain))]; gr_i = []; this.x = standard_define([2,2],this.model,exprs,gr_i); return new BasicBlock(this.x); } GAINBLK.prototype.details = function GAINBLK() { return this.x; } GAINBLK.prototype.get = function GAINBLK() { var options = { gain:["Gain",this.gain], over:["Do On Overflow(0=Nothing 1=Saturate 2=Error)",this.over], } return options; } GAINBLK.prototype.set = function GAINBLK() { this.gain = parseFloat(arguments[0]["gain"]) this.over = arguments[0]["over"] this.x = arg1; graphics = arg1.graphics; exprs = graphics.exprs; this.model = arg1.model; if (size(exprs,"*")==1) { exprs = [[exprs],[sci2exp(0)]]; } while (true) { [ok,this.gain,this.over,exprs] = scicos_getvalue("Set gain block parameters",["Gain","Do On Overflow(0=Nothing 1=Saturate 2=Error)"],list("mat",[-1,-1],"vec",1),exprs); if (!ok) { break; } if (this.gain==[]) { message("Gain must have at least one element"); } else { if (typeof(this.gain)=="constant") { if (isreal(this.gain)) { it = 1; ot = 1; this.model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4])); this.model.rpar = this.gain.slice(); this.model.opar = list(); } else { message("type is not supported"); ok = false; } } else { if ((this.over==0)) { if ((typeof(this.gain)=="int32")) { ot = 3; this.model.sim = list(new ScilabString(["gainblk_i32n"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int16")) { ot = 4; this.model.sim = list(new ScilabString(["gainblk_i16n"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int8")) { ot = 5; this.model.sim = list(new ScilabString(["gainblk_i8n"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint32")) { ot = 6; this.model.sim = list(new ScilabString(["gainblk_ui32n"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint16")) { ot = 7; this.model.sim = list(new ScilabString(["gainblk_ui16n"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint8")) { ot = 8; this.model.sim = list(new ScilabString(["gainblk_ui8n"]), new ScilabDouble([4])); } else { message("type is not supported."); ok = false; } } else if ((this.over==1)) { if ((typeof(this.gain)=="int32")) { ot = 3; this.model.sim = list(new ScilabString(["gainblk_i32s"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int16")) { ot = 4; this.model.sim = list(new ScilabString(["gainblk_i16s"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int8")) { ot = 5; this.model.sim = list(new ScilabString(["gainblk_i8s"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint32")) { ot = 6; this.model.sim = list(new ScilabString(["gainblk_ui32s"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint16")) { ot = 7; this.model.sim = list(new ScilabString(["gainblk_ui16s"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint8")) { ot = 8; this.model.sim = list(new ScilabString(["gainblk_ui8s"]), new ScilabDouble([4])); } else { message("type is not supported."); ok = false; } } else if ((this.over==2)) { if ((typeof(this.gain)=="int32")) { ot = 3; this.model.sim = list(new ScilabString(["gainblk_i32e"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int16")) { ot = 4; this.model.sim = list(new ScilabString(["gainblk_i16e"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="int8")) { ot = 5; this.model.sim = list(new ScilabString(["gainblk_i8e"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint32")) { ot = 6; this.model.sim = list(new ScilabString(["gainblk_ui32e"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint16")) { ot = 7; this.model.sim = list(new ScilabString(["gainblk_ui16e"]), new ScilabDouble([4])); } else if ((typeof(this.gain)=="uint8")) { ot = 8; this.model.sim = list(new ScilabString(["gainblk_ui8e"]), new ScilabDouble([4])); } else { message("type is not an integer."); ok = false; } } else { message("Do on Overflow must be 0,1,2"); ok = false; } this.model.rpar = []; this.model.opar = list(this.gain.slice()); } if (ok) { [out,in1] = size(this.gain); if (out*in1!=1) { [this.model,graphics,ok] = set_io(this.model,graphics,list([in1,-1],ot),list([out,-1],ot),[],[]); } else { [this.model,graphics,ok] = set_io(this.model,graphics,list([-1,-2],ot),list([-1,-2],ot),[],[]); } } if (ok) { graphics.exprs = exprs; this.x.graphics = graphics; this.x.model = this.model; break; } } } return new BasicBlock(this.x); } }