diff options
Diffstat (limited to 'js/Misc/generic_block.js')
-rw-r--r-- | js/Misc/generic_block.js | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/js/Misc/generic_block.js b/js/Misc/generic_block.js index 1d319a0c..4b0fea72 100644 --- a/js/Misc/generic_block.js +++ b/js/Misc/generic_block.js @@ -18,80 +18,81 @@ function generic_block() { model.dep_ut = [true,false]; label = [[function_name],[sci2exp(funtyp)],[sci2exp(model.in1)],[sci2exp(model.out)],[sci2exp(model.evtin)],[sci2exp(model.evtout)],[sci2exp(model.state)],[sci2exp(model.dstate)],[sci2exp(model.rpar)],[sci2exp(model.ipar)],[sci2exp(model.firing)],["y"],["n"]]; gr_i = []; - x = standard_define([2,2],model,label,gr_i); + this.x = standard_define([2,2],model,label,gr_i); } generic_block.prototype.details = function generic_block() { + return this.x; } generic_block.prototype.get = function generic_block() { } generic_block.prototype.set = function generic_block() { - x = arg1; + this.x = arg1; model = arg1.model; graphics = arg1.graphics; label = graphics.exprs; if (size(label,"*")==14) { - label[9-1] = []; -} + label[9-1] = []; + } while (true) { - [ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,auto0,depu,dept,lab] = scicos_getvalue("Set GENERIC block parameters",[["simulation function"],["function type (0,1,2,..)"],["input ports sizes"],["output port sizes"],["input event ports sizes"],["output events ports sizes"],["initial continuous state"],["initial discrete state"],["Real parameters vector"],["Integer parameters vector"],["initial firing vector (<0 for no firing)"],["direct feedthrough (y or n)"],["time dependence (y or n)"]],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec","sum(%6)","str",1,"str",1),label); - if (!ok) { -break; -} - label = lab; - function_name = stripblanks(function_name); - xx = xx.slice(); - z = z.slice(); - rpar = rpar.slice(); - ipar = int(ipar.slice()); - i = int(i.slice()); - o = int(o.slice()); - ci = int(ci.slice()); - co = int(co.slice()); - funtyp = int(funtyp); - if (funtyp<0) { -message("function type cannot be negative"); - ok = false; -} - if ([[ci],[co]]!=[]) { - if (max([[ci],[co]])>1) { -message("vector event links not supported"); - ok = false; -} -} - depu = stripblanks(depu); - if (part(depu,1)=="y") { - depu = true; - } else { - depu = false; -} - dept = stripblanks(dept); - if (part(dept,1)=="y") { - dept = true; - } else { - dept = false; -} - dep_ut = [depu,dept]; - if (ok) { - [model,graphics,ok] = check_io(model,graphics,i,o,ci,co); -} - if (ok) { - if (funtyp==3) { - needcompile = 4; -} - model.sim = list(function_name,funtyp); - model.state = xx; - model.dstate = z; - model.rpar = rpar; - model.ipar = ipar; - model.firing = auto0; - model.dep_ut = dep_ut; - arg1.model = model; - graphics.exprs = label; - arg1.graphics = graphics; - x = arg1; -break; -} -} -needcompile=resume(needcompile) + [ok,function_name,funtyp,i,o,ci,co,xx,z,rpar,ipar,auto0,depu,dept,lab] = scicos_getvalue("Set GENERIC block parameters",[["simulation function"],["function type (0,1,2,..)"],["input ports sizes"],["output port sizes"],["input event ports sizes"],["output events ports sizes"],["initial continuous state"],["initial discrete state"],["Real parameters vector"],["Integer parameters vector"],["initial firing vector (<0 for no firing)"],["direct feedthrough (y or n)"],["time dependence (y or n)"]],list("str",1,"vec",1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec","sum(%6)","str",1,"str",1),label); + if (!ok) { + break; + } + label = lab; + function_name = stripblanks(function_name); + xx = xx.slice(); + z = z.slice(); + rpar = rpar.slice(); + ipar = int(ipar.slice()); + i = int(i.slice()); + o = int(o.slice()); + ci = int(ci.slice()); + co = int(co.slice()); + funtyp = int(funtyp); + if (funtyp<0) { + message("function type cannot be negative"); + ok = false; + } + if ([[ci],[co]]!=[]) { + if (max([[ci],[co]])>1) { + message("vector event links not supported"); + ok = false; + } + } + depu = stripblanks(depu); + if (part(depu,1)=="y") { + depu = true; + } else { + depu = false; + } + dept = stripblanks(dept); + if (part(dept,1)=="y") { + dept = true; + } else { + dept = false; + } + dep_ut = [depu,dept]; + if (ok) { + [model,graphics,ok] = check_io(model,graphics,i,o,ci,co); + } + if (ok) { + if (funtyp==3) { + needcompile = 4; + } + model.sim = list(function_name,funtyp); + model.state = xx; + model.dstate = z; + model.rpar = rpar; + model.ipar = ipar; + model.firing = auto0; + model.dep_ut = dep_ut; + arg1.model = model; + graphics.exprs = label; + arg1.graphics = graphics; + this.x = arg1; + break; + } + } + needcompile=resume(needcompile) } } |