diff options
-rw-r--r-- | data_structures_correct/BOUNCE.js | 2 | ||||
-rw-r--r-- | data_structures_correct/BOUNCEXY.js | 58 | ||||
-rw-r--r-- | details.js | 72 |
3 files changed, 129 insertions, 3 deletions
diff --git a/data_structures_correct/BOUNCE.js b/data_structures_correct/BOUNCE.js index 5cfafce..4142430 100644 --- a/data_structures_correct/BOUNCE.js +++ b/data_structures_correct/BOUNCE.js @@ -63,6 +63,6 @@ function BOUNCE() { BOUNCE.prototype.details = function BOUNCE() { - return this.x + return this.x; } } diff --git a/data_structures_correct/BOUNCEXY.js b/data_structures_correct/BOUNCEXY.js new file mode 100644 index 0000000..8562594 --- /dev/null +++ b/data_structures_correct/BOUNCEXY.js @@ -0,0 +1,58 @@ +function BOUNCEXY () { + + BOUNCEXY.prototype.define = function BOUNCEXY() { + this.win = -1; + + this.imode = 1; + + this.clrs = [[1],[2]]; + + this.siz = [[1],[1]]; + + this.xmin = -5; + + this.xmax = 5; + + this.ymin = 0; + + this.ymax = 15; + + var model = scicos_model(); + model.sim=list(new ScilabString(["bouncexy"]),new ScilabDouble([4])); + model.in = new ScilabDouble([-1],[-1]); + model.in2 = new ScilabDouble([1],[1]); + model.intyp = new ScilabDouble([1],[1]); + model.evtin = new ScilabDouble([1]); + + + this.z = []; + + for(var i = 0;i<size(this.clrs,"*");i++) + { + this.z[6*(i)+0] = [0]; + this.z[6*(i)+1] = [0]; + this.z[6*(i)+2] = [2*this.siz[i]]; + this.z[6*(i)+3] = [2*this.siz[i]]; + this.z[6*(i)+4] = [0.000]; + this.z[6*(i)+5] = [64.0*360.000]; + + } + + model.dstate=new ScilabDouble(...this.z); + model.rpar=new ScilabDouble([this.xmin],[this.xmax],[this.ymin],[this.ymax]); + model.ipar=new ScilabDouble([this.win],[this.imode],...colon_operator(this.clrs)); + model.blocktype=new ScilabString("d"); + model.firing=new ScilabDouble(); + model.dep_ut=new ScilabBoolean([false,false]); + + var exprs=new ScilabString([sci2exp(this.clrs)],[sci2exp(this.siz)],[sci2exp(this.win)],[sci2exp(1)],[sci2exp(this.xmin)],[sci2exp(this.xmax)],[sci2exp(this.ymin)],[sci2exp(this.ymax)]); + var gr_i=new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCEXY\",sz(1),sz(2));"]); + this.x= new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); + return new BasicBlock(this.x); + } + + BOUNCE.prototype.details = function BOUNCE() { + + return this.x; + } +} @@ -286,6 +286,61 @@ function ScilabDouble() { } } +function ScilabInteger() { + var i = 0, + j = 0; + if (arguments.length) { + var array = arguments; + this.height = array.length; + this.width = array[0].length; + for (i = 0; i < this.height; i++) { + for (j = 0; j < this.width; j++) { + this["data" + i + j] = new data(); + this["data" + i + j].value = array[i][j]; + this["data" + i + j].line = i; + this["data" + i + j].column = j; + } + } + } +} + +function int32() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_int32"; + return int; +} + +function int16() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_int16"; + return int; +} + +function int8() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_int8"; + return int; +} + +function uint32() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_uint32"; + return int; +} + +function uint16() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_uint16"; + return int; +} + +function uint8() { + var int = new ScilabInteger(arguments[0]); + int.intPrecision = "sci_uint8"; + return int; +} + + function data() { this.line; this.column; @@ -309,6 +364,10 @@ function getData() { return dataArray; } +function isEmpty() { + return !getData(arguments[0]).length; +} + function modelica() { var modelica_type = ["modelica", "model", "inputs", "outputs", "parameters"]; this.modelica = new ScilabString(modelica_type); @@ -476,7 +535,12 @@ function BasicBlock() { this.objectsParameters = options.model.opar; this.nbZerosCrossing = options.model.nzcross; this.nmode = options.model.nmode; - this.state = options.model.state; + if(!isEmpty(options.model.state)) { + this.state = options.model.state; + } + if(!isEmpty(options.model.dstate)) { + this.dState = options.model.dstate; + } this.oDState = options.model.odstate; this.equations = options.model.equations; this.blockName = "BasicBlock"; @@ -485,8 +549,12 @@ function BasicBlock() { } function sci2exp(c) { - if (c.length == 0) + if(typeof c.length === "undefined") { + return c.toString(); + } + else if (c.length == 0) { return "[]"; + } else if (c.length == 1) return c.toString(); else { |