diff options
31 files changed, 708 insertions, 172 deletions
diff --git a/blocks/BIGSOM_f.svg b/blocks/BIGSOM_f.svg deleted file mode 100644 index f76cc1c..0000000 --- a/blocks/BIGSOM_f.svg +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg width="40" xmlns="http://www.w3.org/2000/svg" version="1.1" height="40"> - <text y="30" x="14" font-size="30" font-family="serif" fill="black">Σ</text> -</svg> diff --git a/blocks/CEVENTSCOPE.svg b/blocks/CEVENTSCOPE.svg deleted file mode 100644 index a489ba7..0000000 --- a/blocks/CEVENTSCOPE.svg +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg id="svg11300" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="44.822" width="41.062" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <metadata id="metadata39"> - <rdf:RDF> - <cc:Work rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> - </cc:Work> - </rdf:RDF> - </metadata> - <title id="title3289">base scilan</title> - <defs id="defs3"> - <radialGradient id="radialGradient20899" gradientUnits="userSpaceOnUse" cy="32.267" cx="23.994" gradientTransform="matrix(2.2986117,0,0,1.8027614,-75.446386,-24.554065)" r="19.089"> - <stop id="stop2224" stop-color="#5187d6" offset="0"/> - <stop id="stop2227" stop-color="#1e4580" offset="1"/> - </radialGradient> - <linearGradient id="linearGradient2854" y2="24.238" gradientUnits="userSpaceOnUse" x2="12.499" gradientTransform="matrix(0,-5.2061514,2.5688251,0,-79.265723,164.6207)" y1="12.538" x1="8.8208"> - <stop id="stop2182" stop-color="#FFF" offset="0"/> - <stop id="stop2184" stop-color="#FFF" stop-opacity="0" offset="1"/> - </linearGradient> - </defs> - <g id="layer1" transform="translate(-2.8842799e-7,-3.1783548)"> - <g id="layer1-0" transform="matrix(0,0.68137179,-0.68137179,0,39.302853,7.826163)"> - <g id="g9544" transform="translate(-2.0023665,2.2530854)"> - <g id="g9570" transform="translate(0.34662852,-1.7289484)"> - <g id="g28489" transform="translate(2.3098495,0.12996954)"> - <g id="g20882" transform="translate(51.47752,-82.884097)"> - <rect id="rect1314" stroke-linejoin="round" style="stroke-dasharray:none;" transform="matrix(0,-0.99999997,0.99999997,0,-49.042742,89.574337)" fill-rule="evenodd" stroke-dashoffset="0" rx="2.2025" ry="2.2025" height="37.631" width="48.319" stroke="#173562" stroke-linecap="round" stroke-miterlimit="4" y="2.4454" x="-44.453" stroke-width="1.4676" fill="url(#radialGradient20899)"/> - <path id="path28138" stroke-linejoin="round" d="M8.6382,35.758c27.557-0.173,27.904-0.173,27.904-0.173l0.17331-33.97" transform="translate(-49.042742,89.574337)" stroke="#000" stroke-linecap="round" stroke-width="1.46762753px" fill="none"/> - <path id="rect2178" opacity="0.43181817" d="m-45.868,133.4,12.954,0c1.0099-5.0153,1.5849-10.576,1.5849-16.442,0-12.211-2.4433-23.147-6.2788-30.45h-8.2599v46.892z" fill-rule="evenodd" fill="url(#linearGradient2854)"/> - </g> - </g> - </g> - </g> - </g> - </g> - <path id="path2188" stroke-linejoin="round" style="stroke-dasharray:none;" d="m13.665,29.974,4.7566-10.919,5.7799,10.589,6.8184-5.8677,0.06242-4.1123-6.3304,5.6237-6.5406-11.928-6.0101,14.643,1.4637,1.9713z" fill-rule="evenodd" stroke="#8ae234" stroke-linecap="round" stroke-miterlimit="10" stroke-width="0.91817689" fill="#73d216"/> -</svg> diff --git a/blocks/CMSCOPE.svg b/blocks/CMSCOPE.svg deleted file mode 100644 index bd06723..0000000 --- a/blocks/CMSCOPE.svg +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg id="svg11300" xmlns="http://www.w3.org/2000/svg" height="44.822" width="41.062" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title id="title3289">base scilan</title> - <defs id="defs3"> - <radialGradient id="radialGradient20899" gradientUnits="userSpaceOnUse" cy="32.267" cx="23.994" gradientTransform="matrix(2.2986117,0,0,1.8027614,-75.446386,-24.554065)" r="19.089"> - <stop id="stop2224" stop-color="#5187d6" offset="0"/> - <stop id="stop2227" stop-color="#1e4580" offset="1"/> - </radialGradient> - <linearGradient id="linearGradient2854" y2="24.238" gradientUnits="userSpaceOnUse" x2="12.499" gradientTransform="matrix(0,-5.2061514,2.5688251,0,-79.265723,164.6207)" y1="12.538" x1="8.8208"> - <stop id="stop2182" stop-color="#FFF" offset="0"/> - <stop id="stop2184" stop-color="#FFF" stop-opacity="0" offset="1"/> - </linearGradient> - </defs> - <g id="layer1" transform="translate(-2.8842799e-7,-3.1783548)"> - <g id="layer1-0" transform="matrix(0,0.68137179,-0.68137179,0,39.302853,7.826163)"> - <g id="g9544" transform="translate(-2.0023665,2.2530854)"> - <g id="g9570" transform="translate(0.34662852,-1.7289484)"> - <g id="g28489" transform="translate(2.3098495,0.12996954)"> - <g id="g20882" transform="translate(51.47752,-82.884097)"> - <rect id="rect1314" stroke-linejoin="round" style="stroke-dasharray:none;" transform="matrix(0,-0.99999997,0.99999997,0,-49.042742,89.574337)" fill-rule="evenodd" stroke-dashoffset="0" rx="2.2025" ry="2.2025" height="37.631" width="48.319" stroke="#173562" stroke-linecap="round" stroke-miterlimit="4" y="2.4454" x="-44.453" stroke-width="1.4676" fill="url(#radialGradient20899)"/> - <path id="path28138" stroke-linejoin="round" d="M8.6382,35.758c27.557-0.173,27.904-0.173,27.904-0.173l0.17331-33.97" transform="translate(-49.042742,89.574337)" stroke="#000" stroke-linecap="round" stroke-width="1.46762753px" fill="none"/> - <path id="rect2178" opacity="0.43181817" d="m-45.868,133.4,12.954,0c1.0099-5.0153,1.5849-10.576,1.5849-16.442,0-12.211-2.4433-23.147-6.2788-30.45h-8.2599v46.892z" fill-rule="evenodd" fill="url(#linearGradient2854)"/> - <path id="path18808" stroke-linejoin="round" style="stroke-dasharray:none;" d="m-27.782,121.73-0.57149-0.2893-0.56662-0.28848-0.55952-0.28909-0.55222-0.2893-1.0738-0.57777-0.51996-0.2893-0.50637-0.28828-0.49217-0.28929-0.47533-0.28849-0.4597-0.28929-0.44064-0.2893-0.42156-0.28909-0.40027-0.28848-0.37957-0.2893-0.35726-0.28929-0.33372-0.28848-0.30979-0.2893-0.28524-0.28828-0.25927-0.28929-0.2329-0.2893-0.20612-0.28848-0.17913-0.2893-0.15053-0.28909-0.12274-0.28848-0.09433-0.28929-0.06513-0.2893-0.03713-0.28848-0.0071-0.2893,0.0213-0.28909,0.05072-0.28848,0.07932-0.2893,0.10772-0.28929,0.13633-0.28848,0.16473-0.2891,0.19192-0.28929,0.2195-0.28849,0.24568-0.28929,0.27185-0.28929,0.29619-0.28849,0.32175-0.28909,0.34569-0.28929,0.36761-0.28849,0.39073-0.28929,0.41041-0.28909,0.4311-0.28849,0.44936-0.2893,0.46762-0.28929,0.48344-0.28848,0.49927-0.2893,0.51267-0.28828,0.52623-0.28929,0.5372-0.2893,0.54674-0.28929,0.55566-0.28849,0.56338-0.28909,0.56905-0.28848,0.57291-0.28929,0.57616-0.2893,0.57758-0.28848,0.57778-0.2893,0.57696-0.28909,0.57291-0.28848,0.56905-0.2893,0.56337-0.28929,0.55628-0.28849,0.54775-0.2891,0.53721-0.28929,0.52625-0.28848,0.51347-0.2893,0.49927-0.28929,0.48486-0.28849,0.46762-0.28909,0.45017-0.28929,0.43191-0.28849,0.41122-0.28929,0.39073-0.2893,0.36923-0.28827,0.34549-0.2893,0.32257-0.28848,0.29802-0.2893,0.27266-0.28929,0.24649-0.28909,0.22032-0.28849,0.19334-0.28929,0.16473-0.2893,0.13795-0.28848,0.10854-0.28909,0.08075-0.28849,0.05152-0.28929,0.02229-0.28929-0.0065-0.2893-0.03551-0.28849-0.06431-0.28908-0.09352-0.28849-0.12111-0.2893-0.15073-0.28929" stroke="#ef2929" stroke-linecap="round" stroke-miterlimit="4" stroke-width="2.93525505" fill="none"/> - </g> - </g> - </g> - </g> - </g> - </g> -</svg> diff --git a/blocks/INTEGRAL_m.svg b/blocks/INTEGRAL_m.svg deleted file mode 100644 index 6d5a898..0000000 --- a/blocks/INTEGRAL_m.svg +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg id="svg2" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="385" width="240" version="1.0" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <metadata id="metadata7"> - <rdf:RDF> - <cc:Work rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> - </cc:Work> - </rdf:RDF> - </metadata> - <defs id="defs5"></defs> - <path id="path1873" d="M137,156.68c2-28,9.75-78.68,10.25-82.43s3.5-19.75,13.25-31.75,25.75-16.25,25.75-16.25c0.25,0-4,0.75-4,11.5s12.75,18.25,20.75,18.25,22-7,22-19-16.5-19-23-19-17,0-26,3.5-29.38,16.5-37.88,33.5-13.12,37-17.62,67-9.5,77.37-11.5,105.37-11.25,80.5-11.75,84.25-3.5,19.75-13.25,31.75-25.75,16.25-25.75,16.25c-0.25,0,4-0.75,4-11.5s-12.75-18.25-20.75-18.25-22,7-22,19,16.5,19,23,19,17,0,26-3.5,29.375-16.5,37.88-33.5c8.5-17,13.12-37,17.62-67,2.02-13.5,11-85.19,13-107.19z" fill-rule="evenodd" fill="#000"/> -</svg> diff --git a/blocks/LOOKUP_f.svg b/blocks/LOOKUP_f.svg deleted file mode 100644 index a489ba7..0000000 --- a/blocks/LOOKUP_f.svg +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg id="svg11300" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="44.822" width="41.062" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <metadata id="metadata39"> - <rdf:RDF> - <cc:Work rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> - </cc:Work> - </rdf:RDF> - </metadata> - <title id="title3289">base scilan</title> - <defs id="defs3"> - <radialGradient id="radialGradient20899" gradientUnits="userSpaceOnUse" cy="32.267" cx="23.994" gradientTransform="matrix(2.2986117,0,0,1.8027614,-75.446386,-24.554065)" r="19.089"> - <stop id="stop2224" stop-color="#5187d6" offset="0"/> - <stop id="stop2227" stop-color="#1e4580" offset="1"/> - </radialGradient> - <linearGradient id="linearGradient2854" y2="24.238" gradientUnits="userSpaceOnUse" x2="12.499" gradientTransform="matrix(0,-5.2061514,2.5688251,0,-79.265723,164.6207)" y1="12.538" x1="8.8208"> - <stop id="stop2182" stop-color="#FFF" offset="0"/> - <stop id="stop2184" stop-color="#FFF" stop-opacity="0" offset="1"/> - </linearGradient> - </defs> - <g id="layer1" transform="translate(-2.8842799e-7,-3.1783548)"> - <g id="layer1-0" transform="matrix(0,0.68137179,-0.68137179,0,39.302853,7.826163)"> - <g id="g9544" transform="translate(-2.0023665,2.2530854)"> - <g id="g9570" transform="translate(0.34662852,-1.7289484)"> - <g id="g28489" transform="translate(2.3098495,0.12996954)"> - <g id="g20882" transform="translate(51.47752,-82.884097)"> - <rect id="rect1314" stroke-linejoin="round" style="stroke-dasharray:none;" transform="matrix(0,-0.99999997,0.99999997,0,-49.042742,89.574337)" fill-rule="evenodd" stroke-dashoffset="0" rx="2.2025" ry="2.2025" height="37.631" width="48.319" stroke="#173562" stroke-linecap="round" stroke-miterlimit="4" y="2.4454" x="-44.453" stroke-width="1.4676" fill="url(#radialGradient20899)"/> - <path id="path28138" stroke-linejoin="round" d="M8.6382,35.758c27.557-0.173,27.904-0.173,27.904-0.173l0.17331-33.97" transform="translate(-49.042742,89.574337)" stroke="#000" stroke-linecap="round" stroke-width="1.46762753px" fill="none"/> - <path id="rect2178" opacity="0.43181817" d="m-45.868,133.4,12.954,0c1.0099-5.0153,1.5849-10.576,1.5849-16.442,0-12.211-2.4433-23.147-6.2788-30.45h-8.2599v46.892z" fill-rule="evenodd" fill="url(#linearGradient2854)"/> - </g> - </g> - </g> - </g> - </g> - </g> - <path id="path2188" stroke-linejoin="round" style="stroke-dasharray:none;" d="m13.665,29.974,4.7566-10.919,5.7799,10.589,6.8184-5.8677,0.06242-4.1123-6.3304,5.6237-6.5406-11.928-6.0101,14.643,1.4637,1.9713z" fill-rule="evenodd" stroke="#8ae234" stroke-linecap="round" stroke-miterlimit="10" stroke-width="0.91817689" fill="#73d216"/> -</svg> diff --git a/blocks/SELF_SWITCH.svg b/blocks/SELF_SWITCH.svg deleted file mode 100644 index 0344da7..0000000 --- a/blocks/SELF_SWITCH.svg +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg width="40" stroke="#000" xmlns="http://www.w3.org/2000/svg" version="1.1" height="40"> - <g id="base" stroke-linejoin="round" stroke-linecap="round" stroke-width="2px" fill="none"> - <path d="M2,30h9l16-10"/> - <path d="M30,30h8"/> - </g> - <g id="command"> - <polygon fill-opacity="0.1" width="1px" points="18,5,22,5,20,10" fill="#000"/> - <path stroke-width="1px" stroke-dasharray="1,1" d="M20,10v28"/> - </g> -</svg> diff --git a/blocks/SUMMATION.svg b/blocks/SUMMATION.svg deleted file mode 100644 index f76cc1c..0000000 --- a/blocks/SUMMATION.svg +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg width="40" xmlns="http://www.w3.org/2000/svg" version="1.1" height="40"> - <text y="30" x="14" font-size="30" font-family="serif" fill="black">Σ</text> -</svg> diff --git a/blocks/SWITCH2_m.svg b/blocks/SWITCH2_m.svg deleted file mode 100644 index 0344da7..0000000 --- a/blocks/SWITCH2_m.svg +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg width="40" stroke="#000" xmlns="http://www.w3.org/2000/svg" version="1.1" height="40"> - <g id="base" stroke-linejoin="round" stroke-linecap="round" stroke-width="2px" fill="none"> - <path d="M2,30h9l16-10"/> - <path d="M30,30h8"/> - </g> - <g id="command"> - <polygon fill-opacity="0.1" width="1px" points="18,5,22,5,20,10" fill="#000"/> - <path stroke-width="1px" stroke-dasharray="1,1" d="M20,10v28"/> - </g> -</svg> diff --git a/data_structures_correct/DLRADAPT_f.js b/data_structures_correct/DLRADAPT_f.js new file mode 100644 index 0000000..8b68940 --- /dev/null +++ b/data_structures_correct/DLRADAPT_f.js @@ -0,0 +1,32 @@ +function DLRADAPT_f() { + + DLRADAPT_f.prototype.define = function DLRADAPT_f() { + this.p = [[0], [1]]; + this.rn = []; + this.rd = [[math.complex(0.2, 0.8), math.complex(0.2, -0.8)], [math.complex(0.3, 0.7), math.complex(0.3, -0.7)]]; + this.g = [[1], [1]]; + this.last_u = []; + this.last_y = [[0], [0]]; + + var model = scicos_model(); + model.sim = new ScilabString(["dlradp"]); + model.in = new ScilabDouble([1], [1]); + model.out = new ScilabDouble([1]); + model.evtin = new ScilabDouble([1]); + model.dstate = new ScilabDouble(...this.last_y); + model.rpar = new ScilabDouble(...this.p, ...real(colon_operator(this.rd)), ...math.im(colon_operator(this.rd)), ...this.g); + model.ipar = new ScilabDouble([0], [2], [2]); + model.blocktype = new ScilabString(["d"]); + model.firing = new ScilabDouble(); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([sci2exp(this.p)], [sci2exp(this.rn)], [sci2exp(this.rd, 0)], [sci2exp(this.g)], [sci2exp(this.last_u)], [sci2exp(this.last_y)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLRADAPT_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + DLRADAPT_f.prototype.details = function DLRADAPT_f() { + return this.x; + } +} diff --git a/data_structures_correct/MBLOCK.js b/data_structures_correct/MBLOCK.js new file mode 100644 index 0000000..e2b6725 --- /dev/null +++ b/data_structures_correct/MBLOCK.js @@ -0,0 +1,45 @@ +function MBLOCK() { + + MBLOCK.prototype.define = function MBLOCK() { + this.in1 = ["u1"]; + this.intype = ["I"]; + this.out = [["y1"],["y2"]]; + this.outtype = [["I"],["E"]]; + this.param = [["R"],["L"]]; + this.paramv = list(new ScilabDouble([0.1]), new ScilabDouble([0.0001])); + this.pprop = [[0],[0]]; + this.nameF = "generic"; + + var exprs = tlist(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"], new ScilabString(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"]), new ScilabString([sci2exp(this.in1)]), new ScilabString([sci2exp(this.intype)]), new ScilabString([sci2exp(this.out)]), new ScilabString([sci2exp(this.outtype)]), new ScilabString([sci2exp(this.param)]), list(new ScilabString([0.1]), new ScilabString([0.0001])), new ScilabString([sci2exp(this.pprop)]), new ScilabString([this.nameF]), new ScilabDouble()); + + var model = scicos_model(); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false, true]); + model.rpar = []; + + for (var i = 0; i < this.paramv.length; i++) { + model.rpar.push(getData(this.paramv[i])); + } + + model.rpar = new ScilabDouble(...model.rpar); + var mo = modelica(); + mo.model = new ScilabString([this.nameF]); + mo.parameters = list(new ScilabString(...this.param), this.paramv); + model.sim = list(mo.model, new ScilabDouble([30004])); + mo.inputs = new ScilabString(this.in1); + mo.outputs = new ScilabString(...this.out); + model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "r"), 1)); + model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "r"), 1)); + model.equations = mo; + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MBLOCK\",sz(1),sz(2));"]); + + this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); + this.x.graphics.in_implicit = new ScilabString(this.intype); + this.x.graphics.out_implicit = new ScilabString(...this.outtype); + return new BasicBlock(this.x); + } + + MBLOCK.prototype.details = function MBLOCK() { + return this.x; + } +} diff --git a/data_structures_correct/RELATIONALOP.js b/data_structures_correct/RELATIONALOP.js new file mode 100644 index 0000000..100570e --- /dev/null +++ b/data_structures_correct/RELATIONALOP.js @@ -0,0 +1,26 @@ +function RELATIONALOP() { + + RELATIONALOP.prototype.define = function RELATIONALOP() { + this.ipar = 2; + this.label = "<"; + + var model = scicos_model(); + model.sim = list(new ScilabString(["relationalop"]), new ScilabDouble([4])); + model.in = new ScilabDouble([1], [1]); + model.out = new ScilabDouble([1]); + model.ipar = new ScilabDouble([this.ipar]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([this.ipar], [0]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RELATIONALOP\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + this.x.graphics.style = new ScilabString(["fontSize=13;fontStyle=1;displayedLabel=" + label]); + return new BasicBlock(this.x); + } + RELATIONALOP.prototype.details = function RELATIONALOP() { + return this.x; + } +} + diff --git a/data_structures_correct/RICC.js b/data_structures_correct/RICC.js new file mode 100644 index 0000000..5664207 --- /dev/null +++ b/data_structures_correct/RICC.js @@ -0,0 +1,35 @@ +function RICC() { + + RICC.prototype.define = function RICC() { + this.function_name = "ricc_m"; + this.funtyp = 4; + + var model = scicos_model(); + model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); + model.in = new ScilabDouble([-1], [-1], [-1]); + model.in2 = new ScilabDouble([-1], [-1], [-1]); + model.intyp = new ScilabDouble([1, 1, 1]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-1]); + model.outtyp = new ScilabDouble([1]); + model.evtin = new ScilabDouble(); + model.evtout = new ScilabDouble(); + model.state = new ScilabDouble(); + model.dstate = new ScilabDouble(); + model.rpar = new ScilabDouble(); + model.ipar = new ScilabDouble([1], [1]); + model.blocktype = new ScilabString(["c"]); + model.firing = new ScilabDouble(); + model.dep_ut = new ScilabBoolean([true, false]); + + var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RICC\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); + return new BasicBlock(this.x); + } + RICC.prototype.details = function RICC() { + return this.x; + } +} + diff --git a/data_structures_correct/ROOTCOEF.js b/data_structures_correct/ROOTCOEF.js new file mode 100644 index 0000000..96e72c6 --- /dev/null +++ b/data_structures_correct/ROOTCOEF.js @@ -0,0 +1,35 @@ +function ROOTCOEF() { + + ROOTCOEF.prototype.define = function ROOTCOEF() { + this.function_name = "root_coef"; + this.funtyp = 4; + + var model = scicos_model(); + model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([1]); + model.intyp = new ScilabDouble([1]); + model.out = new ScilabDouble([-2]); + model.out2 = new ScilabDouble([1]); + model.outtyp = new ScilabDouble([1]); + model.evtin = new ScilabDouble(); + model.evtout = new ScilabDouble(); + model.state = new ScilabDouble(); + model.dstate = new ScilabDouble(); + model.rpar = new ScilabDouble(); + model.ipar = new ScilabDouble(); + model.blocktype = new ScilabString(["c"]); + model.firing = new ScilabDouble(); + model.dep_ut = new ScilabBoolean([true, false]); + + var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ROOTCOEF\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); + return new BasicBlock(this.x); + } + ROOTCOEF.prototype.details = function ROOTCOEF() { + return this.x; + } +} + diff --git a/data_structures_correct/Resistor.js b/data_structures_correct/Resistor.js new file mode 100644 index 0000000..c8ca7f4 --- /dev/null +++ b/data_structures_correct/Resistor.js @@ -0,0 +1,33 @@ +function Resistor() { + + Resistor.prototype.define = function Resistor() { + this.R = 0.01; + + var model = scicos_model(); + model.rpar = new ScilabDouble([this.R]); + model.sim = new ScilabString(["resistor"]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var mo = modelica(); + mo.model = new ScilabString(["Resistor"]); + mo.inputs = new ScilabString(["p"]); + mo.outputs = new ScilabString(["n"]); + mo.parameters = list(new ScilabString(["R"]), list(new ScilabDouble([this.R]))); + model.equations = mo; + model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); + model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); + + var exprs = new ScilabString([this.R]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Resistor\",sz(1),sz(2));"]); + this.x = standard_define([2, 1], model, exprs, list(gr_i, 0)); + this.x.graphics.in_implicit = new ScilabString(["I"]); + this.x.graphics.out_implicit = new ScilabString(["I"]); + return new BasicBlock(this.x); + } + Resistor.prototype.details = function Resistor() { + return this.x; + } +} + diff --git a/data_structures_correct/SAMPHOLD_m.js b/data_structures_correct/SAMPHOLD_m.js new file mode 100644 index 0000000..7c42b73 --- /dev/null +++ b/data_structures_correct/SAMPHOLD_m.js @@ -0,0 +1,27 @@ +function SAMPHOLD_m() { + + SAMPHOLD_m.prototype.define = function SAMPHOLD_m() { + var model = scicos_model(); + model.sim = list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([1]); + model.outtyp = new ScilabDouble([1]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.evtin = new ScilabDouble([1]); + model.blocktype = new ScilabString(["d"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var label = [sci2exp(1)]; + + var gr_i = ["xstringb(orig(1),orig(2),\"SAMPHOLD_m\",sz(1),sz(2));"]; + this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); + return new BasicBlock(this.x); + + } + + SAMPHOLD_m.prototype.details = function SAMPHOLD_m() { + return this.x; + } +} diff --git a/data_structures_correct/SATURATION.js b/data_structures_correct/SATURATION.js new file mode 100644 index 0000000..99bd3fa --- /dev/null +++ b/data_structures_correct/SATURATION.js @@ -0,0 +1,28 @@ +function SATURATION() { + + SATURATION.prototype.define = function SATURATION() { + this.minp = -1; + this.maxp = 1; + this.rpar = [[this.maxp], [this.minp]]; + + var model = scicos_model(); + model.sim = list(new ScilabString(["satur"]), new ScilabDouble([4])); + model.in = new ScilabDouble([1]); + model.nzcross = new ScilabDouble([2]); + model.nmode = new ScilabDouble([1]); + model.out = new ScilabDouble([1]); + model.rpar = new ScilabDouble(...this.rpar); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([this.maxp], [this.minp], [parseInt(getData(model.nmode)[0])]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SATURATION\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + SATURATION.prototype.details = function SATURATION() { + return this.x; + } +} + diff --git a/data_structures_correct/SAWTOOTH_f.js b/data_structures_correct/SAWTOOTH_f.js new file mode 100644 index 0000000..75a8fec --- /dev/null +++ b/data_structures_correct/SAWTOOTH_f.js @@ -0,0 +1,23 @@ +function SAWTOOTH_f() { + + SAWTOOTH_f.prototype.define = function SAWTOOTH_f() { + + var model = scicos_model(); + model.sim = new ScilabString(["sawtth"]); + model.out = new ScilabDouble([1]); + model.evtin = new ScilabDouble([1]); + model.dstate = new ScilabDouble([0]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false, true]); + + var exprs = new ScilabString([" "]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SAWTOOTH_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + + SAWTOOTH_f.prototype.details = function SAWTOOTH_f() { + return this.x; + } +} diff --git a/data_structures_correct/SCALAR2VECTOR.js b/data_structures_correct/SCALAR2VECTOR.js new file mode 100644 index 0000000..f701a95 --- /dev/null +++ b/data_structures_correct/SCALAR2VECTOR.js @@ -0,0 +1,23 @@ +function SCALAR2VECTOR() { + + SCALAR2VECTOR.prototype.define = function SCALAR2VECTOR() { + this.nout = -1; + + var model = scicos_model(); + model.sim = list(new ScilabString(["scalar2vector"]), new ScilabDouble([4])); + model.out = new ScilabDouble([this.nout]); + model.in = new ScilabDouble([1]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([this.nout]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SCALAR2VECTOR\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + SCALAR2VECTOR.prototype.details = function SCALAR2VECTOR() { + return this.x; + } +} + diff --git a/data_structures_correct/SELECT_m.js b/data_structures_correct/SELECT_m.js new file mode 100644 index 0000000..95583a6 --- /dev/null +++ b/data_structures_correct/SELECT_m.js @@ -0,0 +1,35 @@ +function SELECT_m() { + + SELECT_m.prototype.define = function SELECT_m() { + this.z0 = 1; + this.nin = 2; + + var model = scicos_model(); + model.sim = list(new ScilabString(["selector_m"]), new ScilabDouble([4])); + model.in = new ScilabDouble([-1], [-1]); + model.in2 = new ScilabDouble([-2], [-2]); + model.intyp = new ScilabDouble([1]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.outtyp = new ScilabDouble([1]); + model.evtout = new ScilabDouble(); + model.state = new ScilabDouble(); + model.rpar = new ScilabDouble(); + model.ipar = new ScilabDouble(); + model.firing = new ScilabDouble(); + model.evtin = new ScilabDouble(...ones(this.nin, 1)); + model.dstate = new ScilabDouble([this.z0]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([sci2exp(1)], [sci2exp([this.nin])], [sci2exp([this.z0])]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SELECT_m\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + SELECT_m.prototype.details = function SELECT_m() { + return this.x; + } +} + diff --git a/data_structures_correct/SHIFT.js b/data_structures_correct/SHIFT.js new file mode 100644 index 0000000..a0e9283 --- /dev/null +++ b/data_structures_correct/SHIFT.js @@ -0,0 +1,30 @@ +function SHIFT() { + + SHIFT.prototype.define = function SHIFT() { + this.sgn = [[0],[0]]; + this.OPER = 0; + + var model = scicos_model(); + model.sim = list(new ScilabString(["shift_32_LA"]), new ScilabDouble([4])); + model.in = new ScilabDouble([-1]); + model.out = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.out2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([3]); + model.outtyp = new ScilabDouble([3]); + model.rpar = new ScilabDouble(); + model.ipar = new ScilabDouble(...this.sgn); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)], [sci2exp(0)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SHIFT\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + + SHIFT.prototype.details = function SHIFT() { + return this.x; + } +} diff --git a/data_structures_correct/SIGNUM.js b/data_structures_correct/SIGNUM.js new file mode 100644 index 0000000..1cbac1e --- /dev/null +++ b/data_structures_correct/SIGNUM.js @@ -0,0 +1,25 @@ +function SIGNUM() { + + SIGNUM.prototype.define = function SIGNUM() { + this.nu = -1; + + var model = scicos_model(); + model.sim = list(new ScilabString(["signum"]), new ScilabDouble([4])); + model.in = new ScilabDouble([this.nu]); + model.out = new ScilabDouble([this.nu]); + model.nzcross = new ScilabDouble([this.nu]); + model.nmode = new ScilabDouble([this.nu]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([1]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SIGNUM\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + SIGNUM.prototype.details = function SIGNUM() { + return this.x; + } +} + diff --git a/data_structures_correct/SINBLK_f.js b/data_structures_correct/SINBLK_f.js new file mode 100644 index 0000000..170f5d5 --- /dev/null +++ b/data_structures_correct/SINBLK_f.js @@ -0,0 +1,22 @@ +function SINBLK_f() { + + SINBLK_f.prototype.define = function SINBLK_f() { + + var model = scicos_model(); + model.sim = new ScilabString(["sinblk"]); + model.in = new ScilabDouble([-1]); + model.out = new ScilabDouble([-1]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([" "]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SINBLK_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + SINBLK_f.prototype.details = function SINBLK_f() { + return this.x; + } +} + diff --git a/data_structures_correct/SOM_f.js b/data_structures_correct/SOM_f.js new file mode 100644 index 0000000..2d49214 --- /dev/null +++ b/data_structures_correct/SOM_f.js @@ -0,0 +1,24 @@ +function SOM_f() { + + SOM_f.prototype.define = function SOM_f() { + this.sgn = [[1], [1], [1]]; + + var model = scicos_model(); + model.sim = list(new ScilabString(["sum"]), new ScilabDouble([2])); + model.in = new ScilabDouble([-1], [-1], [-1]); + model.out = new ScilabDouble([-1]); + model.rpar = new ScilabDouble(...this.sgn); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var exprs = new ScilabString([sci2exp(1)], [sci2exp(this.sgn)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SOM_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); + return new BasicBlock(this.x); + } + + SINBLK_f.prototype.details = function SINBLK_f() { + return this.x; + } +} diff --git a/data_structures_correct/SQRT.js b/data_structures_correct/SQRT.js new file mode 100644 index 0000000..f9ddb24 --- /dev/null +++ b/data_structures_correct/SQRT.js @@ -0,0 +1,24 @@ +function SQRT() { + + SQRT.prototype.define = function SQRT() { + var model = scicos_model(); + model.sim = list(new ScilabString(["mat_sqrt"]), new ScilabDouble([4])); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([1]); + model.outtyp = new ScilabDouble([1]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.dep_ut = new ScilabBoolean([true, false]); + + var label = new ScilabString([sci2exp(1)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SQRT\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); + return new BasicBlock(this.x); + } + + SQRT.prototype.details = function SQRT() { + return this.x; + } +} diff --git a/data_structures_correct/SUBMAT.js b/data_structures_correct/SUBMAT.js new file mode 100644 index 0000000..ece918b --- /dev/null +++ b/data_structures_correct/SUBMAT.js @@ -0,0 +1,38 @@ +function SUBMAT() { + + SUBMAT.prototype.define = function SUBMAT() { + var model = scicos_model(); + + this.function_name = new ScilabString(["submat"]); + + this.funtyp = new ScilabDouble([4]); + model.sim = list(this.function_name, this.funtyp); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([1]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.outtyp = new ScilabDouble([1]); + model.evtin = new ScilabDouble(); + model.evtout = new ScilabDouble(); + model.state = new ScilabDouble(); + model.dstate = new ScilabDouble(); + model.rpar = new ScilabDouble(); + model.ipar = new ScilabDouble([1], [1], [1], [1]); + model.blocktype = new ScilabString(["c"]); + model.firing = new ScilabDouble(); + model.dep_ut = new ScilabBoolean([true, false]); + + this.label = new ScilabString([sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUBMAT\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2.5, 2]), model, this.label, gr_i); + + return new BasicBlock(this.x); + + } + SUBMAT.prototype.details = function SUBMAT() { + return this.x; + + } +} diff --git a/data_structures_correct/SUM_f.js b/data_structures_correct/SUM_f.js new file mode 100644 index 0000000..6677eac --- /dev/null +++ b/data_structures_correct/SUM_f.js @@ -0,0 +1,25 @@ +function SUM_f() { + + SUM_f.prototype.define = function SUM_f() { + var model = scicos_model(); + + model.sim = list(new ScilabString(["plusblk"]), new ScilabDouble([2])); + model.in = new ScilabDouble([-1], [-1], [-1]); + model.out = new ScilabDouble([-1]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUM_f\",sz(1),sz(2));"]); + var exprs = new ScilabString(); + + this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); + + return new RoundBlock(this.x); + + } + + SUM_f.prototype.details = function SUM_f() { + return this.x; + + } +} diff --git a/data_structures_correct/SineVoltage.js b/data_structures_correct/SineVoltage.js new file mode 100644 index 0000000..e2bd1e4 --- /dev/null +++ b/data_structures_correct/SineVoltage.js @@ -0,0 +1,38 @@ +function SineVoltage() { + + SineVoltage.prototype.define = function SineVoltage() { + var model = scicos_model(); + model.in = new ScilabDouble([1]); + model.out = new ScilabDouble([1]); + + this.V = 1; + this.ph = 0; + this.frq = 1; + this.offset = 0; + this.start = 0; + + model.rpar = new ScilabDouble([this.V], [this.ph], [this.frq], [this.offset], [this.start]); + model.sim = new ScilabString(["SineVoltage"]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var mo = modelica(); + mo.model = new ScilabString(["SineVoltage"]); + mo.inputs = new ScilabString(["p"]); + mo.outputs = new ScilabString(["n"]); + mo.parameters = list(new ScilabString(["V"], ["phase"], ["freqHz"], ["offset"], ["startTime"]), list(new ScilabDouble([this.V]), new ScilabDouble([this.ph]), new ScilabDouble([this.frq]), new ScilabDouble([this.offset]), new ScilabDouble([this.start]))); + model.equations = mo; + + var exprs = new ScilabString([this.V], [this.ph], [this.frq], [this.offset], [this.start]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SineVoltage\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); + this.x.graphics.in_implicit = new ScilabString(["I"]); + this.x.graphics.out_implicit = new ScilabString(["I"]); + return new BasicBlock(this.x); + } + + SineVoltage.prototype.details = function SineVoltage() { + return this.x; + } +} diff --git a/data_structures_correct/SourceP.js b/data_structures_correct/SourceP.js new file mode 100644 index 0000000..20b9e5a --- /dev/null +++ b/data_structures_correct/SourceP.js @@ -0,0 +1,36 @@ +function SourceP() { + + SourceP.prototype.define = function SourceP() { + var model = scicos_model(); + + this.P0 = 300000; + this.T0 = 290; + this.H0 = 100000; + this.option_temperature = 1; + + model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]); + model.sim = new ScilabString(["Source"]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([true, false]); + + var mo = modelica(); + mo.model = new ScilabString(["Source"]); + mo.inputs = new ScilabDouble(); + mo.outputs = new ScilabString(["C"]); + mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature])); + model.equations = mo; + model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); + model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); + + var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SourceP\",sz(1),sz(2));"]); + this.x = new standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); + this.x.graphics.out_implicit = new ScilabString(["I"]); + return new BasicBlock(this.x); + } + + SourceP.prototype.details = function SourceP() { + return this.x; + } +} diff --git a/dependencies.js b/dependencies.js index c34bf4e..dd2a087 100644 --- a/dependencies.js +++ b/dependencies.js @@ -841,3 +841,47 @@ function _str2code() { } return code; } + +function real() { + var matrix = arguments[0]; + var sz = math.size(matrix); + var res = []; + for (var i = 0; i < sz[0]; i++) { + for (var j = 0; j < sz[1]; j++) { + res.push([math.re(matrix[i][j])]); + } + } + return res; +} + +function imag() { + var matrix = arguments[0]; + var sz = math.size(matrix); + var res = []; + for (var i = 0; i < sz[0]; i++) { + for (var j = 0; j < sz[1]; j++) { + res.push([math.im(matrix[i][j])]); + } + } + return res; +} + +function _check() { + var param = arguments[0]; + if(typeof param == "object") { + var str = param.toString(); + str = str.substring(1, str.length - 1); + str = str.replace(/\B\+/,"+%i*"); + str = str.replace(/\B-/,"-%i*"); + str = param.toString().substring(0,1) + str; + str = str.replace(/ /g,''); + return str; + } + else if(typeof param == "string") { + // needs to be changed later + return param; + } + else { + return param; + } +} @@ -549,31 +549,30 @@ function BasicBlock() { } function sci2exp(c) { - if(c.scilabClass == "ScilabList") { + if (c.scilabClass == "ScilabList") { c = Object.create(c); c.scilabClass = ""; - if(c.length) { + if (c.length) { return "list(" + sci2exp(c) + ")"; - } - else { + } else { return "list()"; } - } - else if(typeof c.length === "undefined") { + } else if (typeof c.length === "undefined") { return c.toString(); - } - else if (c.length == 0) { + } else if (c.length == 0) { return "[]"; - } - else if (c.length == 1) + } else if (c.length == 1) return c.toString(); else { var result = "["; for (var i = 0; i < c.length; i++) { if (typeof c[i].length === 'undefined') { - result += c[i] + ","; + result += _check(c[i]) + ","; } else { - result += c[i][0] + ";"; + for (var j = 0; j < c[i].length - 1; j++) { + result += _check(c[i][j]) + ","; + } + result += _check(c[i][c[i].length - 1]) + ";"; } } result = result.substring(0, result.length - 1); @@ -2183,6 +2183,55 @@ var enc = new mxCodec(mxUtils.createXmlDocument()); var node = enc.encode(details); var temp = enc.encode(parent); + + /* + * @jiteshjha + */ + + // Get the stylesheet for the graph + var stylesheet = graph.getStylesheet(); + + // From the stylesheet, get the style of the particular block + var style = stylesheet.styles[name]; + + /* + * When a particular block is loaded for the first time, + * the image in the style of the block will be a path to the image. + * Set the label in the style property of the block has a html image, + * and set the image in the style property as null + * + * NOTE: Since the image of any block need not be changed for + * for every movement of that block, the image must be + * set only once. + */ + if(style != null && style['image'] != null) { + + // Make label as a image html element + var label = '<img src="' + style['image'] + '" height="80" width="80">'; + + // Set label + style['label'] = label; + + // Set image as null + style['image'] = null; + + // Add the label as a part of node + node.setAttribute('label', label); + } + + /* + * If a particular block with image tag in it's style property + * has been invoked already, the image tag would be null for any + * successive instances of the same block. Hence, set the label + * from the label tag in style which was set when that blockModel + * was invoked on the first time. + */ + if(style!= null && style['label'] != null) { + + // Set label from the label field in the style property + node.setAttribute('label', style['label']); + } + node.setAttribute('parent', temp.getAttribute('id')); var i, arr = []; var blockModel = details_instance.x.model; @@ -2353,13 +2402,6 @@ var root = req.getDocumentElement(); var dec = new mxCodec(root.ownerDocument); dec.decode(root, graph.stylesheet); - - // Set the width and height of image for all blocks to 80 (height) x 80 (width) - var style = new Object(); - style[mxConstants.STYLE_IMAGE_WIDTH] = '80'; - style[mxConstants.STYLE_IMAGE_HEIGHT] = '80'; - style['imageAlign'] = 'center'; - graph.getStylesheet().putDefaultVertexStyle(style); }; </script> <!-- |