summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChhavi22082016-06-21 13:57:17 +0530
committerChhavi22082016-06-21 13:57:17 +0530
commit7f3a9f3fc199f2eb4fb7344c552ffc9d0bec79bb (patch)
tree72d557a47213d0253f6076ca6c4f0d9dab0b733a
parenta57b6134d14cb1d6a5a9a6f88d94e8e8e087df4d (diff)
downloadxcos-on-web-7f3a9f3fc199f2eb4fb7344c552ffc9d0bec79bb.tar.gz
xcos-on-web-7f3a9f3fc199f2eb4fb7344c552ffc9d0bec79bb.tar.bz2
xcos-on-web-7f3a9f3fc199f2eb4fb7344c552ffc9d0bec79bb.zip
Scoping bug fixed
-rw-r--r--details.js679
-rw-r--r--index.html161
2 files changed, 442 insertions, 398 deletions
diff --git a/details.js b/details.js
index ea36d64..6c5e8f8 100644
--- a/details.js
+++ b/details.js
@@ -4,11 +4,6 @@
/*
Authors: Adhitya, Nimish, Chhavi, Saarang
*/
-// This is temporary so that my functions can be used be by blocks - @ASP1234
-var script = document.createElement("script");
-script.src = "dependencies.js";
-document.head.appendChild(script);
-
var count = 1;
function scicos_block() {
@@ -316,42 +311,40 @@ function modelica() {
}
function CONST_m() {
+ CONST_m.prototype.get = function() {
- switch (arguments[0]) {
- case "get":
- var options = {
- vec: ["Constant Value", this.c.toString()]
- };
- return options;
- case "set":
- this.c = [arguments[2]["vec"]];
- var dec = new mxCodec();
- var details = dec.decode(arguments[1]);
- details.realParameters = new ScilabDouble();
- details.exprs = new ScilabString([sci2exp(this.c)]);
- this.x.realParameters = new ScilabDouble();
- this.x.exprs = new ScilabString([sci2exp(this.c)]);
- return details;
- case "define":
- this.c = [1];
- var model = scicos_model();
- model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4]));
- model.in = new ScilabDouble();
- model.out = new ScilabDouble([this.c.length]);
- model.in2 = new ScilabDouble();
- model.out2 = new ScilabDouble([this.c.length]);
- model.rpar = new ScilabDouble(this.c);
- model.opar = list();
- model.blocktype = new ScilabString(["d"]);
- model.dep_ut = new ScilabBoolean([false, false]);
-
- var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]);
- var exprs = new ScilabString([sci2exp(this.c)]);
- this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80
- this.x.graphics.style = new ScilabString(["CONST_m"]);
- return new BasicBlock(this.x);
- case "details":
- return this.x;
+ var options = {
+ vec: ["Constant Value", this.c.toString()]
+ };
+ return options;
+ }
+ CONST_m.prototype.set = function() {
+ this.c = [arguments[1]["vec"]];
+ this.x.realParameters = new ScilabDouble();
+ this.x.exprs = new ScilabString([sci2exp(this.c)]);
+ return new BasicBlock(this.x);
+ }
+ CONST_m.prototype.define = function() {
+ this.c = [1];
+ var model = new scicos_model();
+ model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble();
+ model.out = new ScilabDouble([this.c.length]);
+ model.in2 = new ScilabDouble();
+ model.out2 = new ScilabDouble([this.c.length]);
+ model.rpar = new ScilabDouble(this.c);
+ model.opar = list();
+ model.blocktype = new ScilabString(["d"]);
+ model.dep_ut = new ScilabBoolean([false, false]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]);
+ var exprs = new ScilabString([sci2exp(this.c)]);
+ this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80
+ this.x.graphics.style = new ScilabString(["CONST_m"]);
+ return new BasicBlock(this.x);
+ }
+ CONST_m.prototype.details = function() {
+ return this.x;
}
}
@@ -381,131 +374,131 @@ function ANDLOG_f() {
function ANDBLK() {
- switch (arguments[0]) {
- case "define":
- var andlog = ANDLOG_f("define");
- andlog.graphics.orig = new ScilabDouble([194, 133]);
- andlog.graphics.sz = new ScilabDouble([60, 60]);
- andlog.graphics.flip = new ScilabBoolean([true]);
- andlog.graphics.pout = new ScilabDouble([9]);
- andlog.graphics.pein = new ScilabDouble([4], [11]);
- andlog.model.uid = new ScilabString([count]);
- andlog.doc = list(new ScilabString([count++]));
-
- var input_port1 = CLKIN_f("define");
- input_port1.graphics.orig = new ScilabDouble([149, 287]);
- input_port1.graphics.sz = new ScilabDouble([20, 20]);
- input_port1.graphics.flip = new ScilabBoolean([true]);
- input_port1.graphics.exprs = new ScilabString(["1"]);
- input_port1.graphics.peout = new ScilabDouble([4]);
- input_port1.model.ipar = new ScilabDouble([1]);
- input_port1.model.uid = new ScilabString([count]);
- input_port1.doc = list(new ScilabString([count++]));
-
- var output_port = CLKOUT_f("define");
- output_port.graphics.orig = new ScilabDouble([450, 83]);
- output_port.graphics.sz = new ScilabDouble([20, 20]);
- output_port.graphics.flip = new ScilabBoolean([true]);
- output_port.graphics.exprs = new ScilabString(["1"]);
- output_port.graphics.pein = new ScilabDouble([8]);
- output_port.model.ipar = new ScilabDouble([1]);
- output_port.model.uid = new ScilabString([count]);
- output_port.doc = list(new ScilabString([count++]));
-
- var input_port2 = CLKIN_f("define");
- input_port2.graphics.orig = new ScilabDouble([141, 330]);
- input_port2.graphics.sz = new ScilabDouble([20, 20]);
- input_port2.graphics.flip = new ScilabBoolean([true]);
- input_port2.graphics.exprs = new ScilabString(["2"]);
- input_port2.graphics.peout = new ScilabDouble([6]);
- input_port2.model.ipar = new ScilabDouble([2]);
- input_port2.model.uid = new ScilabString([count]);
- input_port2.doc = list(new ScilabString([count++]));
-
- var ifthel = IFTHEL_f("define");
- ifthel.graphics.orig = new ScilabDouble([331, 137]);
- ifthel.graphics.sz = new ScilabDouble([60, 60]);
- ifthel.graphics.flip = new ScilabBoolean([true]);
- ifthel.graphics.pin = new ScilabDouble([9]);
- ifthel.graphics.pein = new ScilabDouble([12]);
- ifthel.graphics.peout = new ScilabDouble([8], [0]);
- ifthel.model.uid = new ScilabString([count]);
- ifthel.doc = list(new ScilabString([count++]));
-
-
- var split = CLKSPLIT_f("define");
- split.graphics.orig = new ScilabDouble([234, 275.78348]);
- split.graphics.pein = new ScilabDouble([6]);
- split.graphics.peout = new ScilabDouble([11], [12]);
- split.model.uid = new ScilabString([count]);
- split.doc = list(new ScilabString([count++]));
-
- var diagram = scicos_diagram();
- diagram.objs.push(andlog);
- diagram.objs.push(input_port1);
- diagram.objs.push(output_port);
- diagram.objs.push(input_port2);
- diagram.objs.push(ifthel);
- diagram.objs.push(split);
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([169], [214], [214]),
- yy: new ScilabDouble([297], [297], [198.71]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([2, 1, 0]),
- to: new ScilabDouble([1, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([161], [234], [234]),
- yy: new ScilabDouble([340], [340], [275.78]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([4, 1, 0]),
- to: new ScilabDouble([6, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([351], [351], [450]),
- yy: new ScilabDouble([131.29], [93], [93]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([5, 1, 0]),
- to: new ScilabDouble([3, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([262.57], [322.43]),
- yy: new ScilabDouble([163], [167]),
- ct: new ScilabDouble([1, 1]),
- from: new ScilabDouble([1, 1, 0]),
- to: new ScilabDouble([5, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([234], [234]),
- yy: new ScilabDouble([275.78], [198.71]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([6, 1, 0]),
- to: new ScilabDouble([1, 2, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([234], [361], [361]),
- yy: new ScilabDouble([275.78], [275.78], [202.71]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([6, 2, 0]),
- to: new ScilabDouble([5, 1, 1])
- }));
- this.x = scicos_block();
- this.x.gui = new ScilabString(["ANDBLK"]);
- this.x.graphics.sz = new ScilabDouble([2, 2]);
- this.x.graphics.gr_i = new ScilabDouble();
- this.x.graphics.pein = new ScilabDouble([0, 0]);
- this.x.graphics.peout = new ScilabDouble([0]);
- this.x.model.sim = new ScilabString(["csuper"]);
- this.x.model.evtin = new ScilabDouble([1, 1]);
- this.x.model.evtout = new ScilabDouble([1]);
- this.x.model.blocktype = new ScilabString(["h"]);
- this.x.model.firing = new ScilabBoolean([false]);
- this.x.model.dep_ut = new ScilabBoolean([false, false]);
- this.x.model.rpar = diagram;
- return new BasicBlock(this.x);
-
- case "details":
- return this.x;
+ ANDBLK.prototype.define = function() {
+
+ var andlog = ANDLOG_f("define");
+ andlog.graphics.orig = new ScilabDouble([194, 133]);
+ andlog.graphics.sz = new ScilabDouble([60, 60]);
+ andlog.graphics.flip = new ScilabBoolean([true]);
+ andlog.graphics.pout = new ScilabDouble([9]);
+ andlog.graphics.pein = new ScilabDouble([4], [11]);
+ andlog.model.uid = new ScilabString([count]);
+ andlog.doc = list(new ScilabString([count++]));
+
+ var input_port1 = CLKIN_f("define");
+ input_port1.graphics.orig = new ScilabDouble([149, 287]);
+ input_port1.graphics.sz = new ScilabDouble([20, 20]);
+ input_port1.graphics.flip = new ScilabBoolean([true]);
+ input_port1.graphics.exprs = new ScilabString(["1"]);
+ input_port1.graphics.peout = new ScilabDouble([4]);
+ input_port1.model.ipar = new ScilabDouble([1]);
+ input_port1.model.uid = new ScilabString([count]);
+ input_port1.doc = list(new ScilabString([count++]));
+
+ var output_port = CLKOUT_f("define");
+ output_port.graphics.orig = new ScilabDouble([450, 83]);
+ output_port.graphics.sz = new ScilabDouble([20, 20]);
+ output_port.graphics.flip = new ScilabBoolean([true]);
+ output_port.graphics.exprs = new ScilabString(["1"]);
+ output_port.graphics.pein = new ScilabDouble([8]);
+ output_port.model.ipar = new ScilabDouble([1]);
+ output_port.model.uid = new ScilabString([count]);
+ output_port.doc = list(new ScilabString([count++]));
+
+ var input_port2 = CLKIN_f("define");
+ input_port2.graphics.orig = new ScilabDouble([141, 330]);
+ input_port2.graphics.sz = new ScilabDouble([20, 20]);
+ input_port2.graphics.flip = new ScilabBoolean([true]);
+ input_port2.graphics.exprs = new ScilabString(["2"]);
+ input_port2.graphics.peout = new ScilabDouble([6]);
+ input_port2.model.ipar = new ScilabDouble([2]);
+ input_port2.model.uid = new ScilabString([count]);
+ input_port2.doc = list(new ScilabString([count++]));
+
+ var ifthel = IFTHEL_f("define");
+ ifthel.graphics.orig = new ScilabDouble([331, 137]);
+ ifthel.graphics.sz = new ScilabDouble([60, 60]);
+ ifthel.graphics.flip = new ScilabBoolean([true]);
+ ifthel.graphics.pin = new ScilabDouble([9]);
+ ifthel.graphics.pein = new ScilabDouble([12]);
+ ifthel.graphics.peout = new ScilabDouble([8], [0]);
+ ifthel.model.uid = new ScilabString([count]);
+ ifthel.doc = list(new ScilabString([count++]));
+
+
+ var split = CLKSPLIT_f("define");
+ split.graphics.orig = new ScilabDouble([234, 275.78348]);
+ split.graphics.pein = new ScilabDouble([6]);
+ split.graphics.peout = new ScilabDouble([11], [12]);
+ split.model.uid = new ScilabString([count]);
+ split.doc = list(new ScilabString([count++]));
+
+ var diagram = scicos_diagram();
+ diagram.objs.push(andlog);
+ diagram.objs.push(input_port1);
+ diagram.objs.push(output_port);
+ diagram.objs.push(input_port2);
+ diagram.objs.push(ifthel);
+ diagram.objs.push(split);
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([169], [214], [214]),
+ yy: new ScilabDouble([297], [297], [198.71]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([2, 1, 0]),
+ to: new ScilabDouble([1, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([161], [234], [234]),
+ yy: new ScilabDouble([340], [340], [275.78]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([4, 1, 0]),
+ to: new ScilabDouble([6, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([351], [351], [450]),
+ yy: new ScilabDouble([131.29], [93], [93]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([5, 1, 0]),
+ to: new ScilabDouble([3, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([262.57], [322.43]),
+ yy: new ScilabDouble([163], [167]),
+ ct: new ScilabDouble([1, 1]),
+ from: new ScilabDouble([1, 1, 0]),
+ to: new ScilabDouble([5, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([234], [234]),
+ yy: new ScilabDouble([275.78], [198.71]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([6, 1, 0]),
+ to: new ScilabDouble([1, 2, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([234], [361], [361]),
+ yy: new ScilabDouble([275.78], [275.78], [202.71]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([6, 2, 0]),
+ to: new ScilabDouble([5, 1, 1])
+ }));
+ this.x = scicos_block();
+ this.x.gui = new ScilabString(["ANDBLK"]);
+ this.x.graphics.sz = new ScilabDouble([2, 2]);
+ this.x.graphics.gr_i = new ScilabDouble();
+ this.x.graphics.pein = new ScilabDouble([0, 0]);
+ this.x.graphics.peout = new ScilabDouble([0]);
+ this.x.model.sim = new ScilabString(["csuper"]);
+ this.x.model.evtin = new ScilabDouble([1, 1]);
+ this.x.model.evtout = new ScilabDouble([1]);
+ this.x.model.blocktype = new ScilabString(["h"]);
+ this.x.model.firing = new ScilabBoolean([false]);
+ this.x.model.dep_ut = new ScilabBoolean([false, false]);
+ this.x.model.rpar = diagram;
+ return new BasicBlock(this.x);
+ }
+ ANDBLK.prototype.details = function() {
+ return this.x;
}
}
@@ -513,189 +506,190 @@ function ANDBLK() {
function CFSCOPE() {
- switch (arguments[0]) {
- case "define":
- this.win = -1;
- this.wdim = [
- [600],
- [400]
- ];
- this.wpos = [
- [-1],
- [-1]
- ];
- this.clrs = [
- [1],
- [3],
- [5],
- [7],
- [9],
- [11],
- [13],
- [15]
- ];
- this.N = 2;
- this.ymin = -15;
- this.ymax = 15;
- this.per = 30;
- var model = scicos_model();
- model.sim = list(new ScilabString(["cfscope"]), new ScilabDouble([4]));
- model.evtin = new ScilabDouble([1]);
- model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]);
- model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim, [1], [1]);
- model.blocktype = new ScilabString(["c"]);
- model.dep_ut = new ScilabBoolean([true, false]);
- var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [1]);
- var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CFSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8]));
- this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80
- this.x.graphics.style = new ScilabString(["CFSCOPE"]);
- return new BasicBlock(this.x);
- case "details":
- return this.x;
+
+ CFSCOPE.prototype.define = function() {
+ this.win = -1;
+ this.wdim = [
+ [600],
+ [400]
+ ];
+ this.wpos = [
+ [-1],
+ [-1]
+ ];
+ this.clrs = [
+ [1],
+ [3],
+ [5],
+ [7],
+ [9],
+ [11],
+ [13],
+ [15]
+ ];
+ this.N = 2;
+ this.ymin = -15;
+ this.ymax = 15;
+ this.per = 30;
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["cfscope"]), new ScilabDouble([4]));
+ model.evtin = new ScilabDouble([1]);
+ model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]);
+ model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim, [1], [1]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+ var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [1]);
+ var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CFSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8]));
+ this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80
+ this.x.graphics.style = new ScilabString(["CFSCOPE"]);
+ return new BasicBlock(this.x);
+ }
+ CFSCOPE.prototype.details = function() {
+ return this.x;
}
}
function CMSCOPE() {
- switch (arguments[0]) {
- case "define":
- this.win = -1;
- this.in1 = [
- [1],
- [1]
- ];
- this.wdim = [
- [-1],
- [-1]
- ];
- this.wpos = [
- [-1],
- [-1]
- ];
- this.clrs = [
- [1],
- [3],
- [5],
- [7],
- [9],
- [11],
- [13],
- [15]
- ];
- this.N = 20;
- this.ymin = [
- [-1],
- [-5]
- ];
- this.ymax = [
- [1],
- [5]
- ];
- this.per = [
- [30],
- [30]
- ];
- this.yy = [...transpose(this.ymin), ...transpose(this.ymax)];
- this.period = transpose(this.per);
-
-
- var model = scicos_model();
- model.sim = list(new ScilabString(["cmscope"]), new ScilabDouble([4]));
- model.in = new ScilabDouble(...this.in1);
- model.in2 = new ScilabDouble([1], [1]);
- model.intyp = new ScilabDouble([1], [1]);
- model.evtin = new ScilabDouble([1]);
- model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy));
- model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1]);
-
- model.blocktype = new ScilabString(["c"]);
- model.dep_ut = new ScilabBoolean([true, false]);
- var exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]);
- var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CMSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8]));
- this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80
- this.x.graphics.style = new ScilabString(["CMSCOPE"]);
- return new BasicBlock(this.x);
- case "details":
- return this.x;
+ CMSCOPE.prototype.define = function() {
+ this.win = -1;
+ this.in1 = [
+ [1],
+ [1]
+ ];
+ this.wdim = [
+ [-1],
+ [-1]
+ ];
+ this.wpos = [
+ [-1],
+ [-1]
+ ];
+ this.clrs = [
+ [1],
+ [3],
+ [5],
+ [7],
+ [9],
+ [11],
+ [13],
+ [15]
+ ];
+ this.N = 20;
+ this.ymin = [
+ [-1],
+ [-5]
+ ];
+ this.ymax = [
+ [1],
+ [5]
+ ];
+ this.per = [
+ [30],
+ [30]
+ ];
+ this.yy = [...transpose(this.ymin), ...transpose(this.ymax)];
+ this.period = transpose(this.per);
+
+
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["cmscope"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble(...this.in1);
+ model.in2 = new ScilabDouble([1], [1]);
+ model.intyp = new ScilabDouble([1], [1]);
+ model.evtin = new ScilabDouble([1]);
+ model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy));
+ model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1]);
+
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+ var exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]);
+ var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CMSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8]));
+ this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80
+ this.x.graphics.style = new ScilabString(["CMSCOPE"]);
+ return new BasicBlock(this.x);
+ }
+ CMSCOPE.prototype.details = function() {
+ return this.x;
}
}
function CLOCK_c() {
- switch (arguments[0]) {
- case "define":
- var evtdly = EVTDLY_c("define");
- evtdly.graphics.orig = new ScilabDouble([320, 232]);
- evtdly.graphics.sz = new ScilabDouble([40, 40]);
- evtdly.graphics.flip = new ScilabBoolean([true]);
- evtdly.graphics.exprs = new ScilabString(["0.1"], ["0.1"]);
- evtdly.graphics.pein = new ScilabDouble([6]);
- evtdly.graphics.peout = new ScilabDouble([3]);
- evtdly.model.rpar = new ScilabDouble([0.1], [0.1]);
- evtdly.model.firing = new ScilabDouble([0.1]);
-
- evtdly.model.uid = new ScilabString([count]); // changed
- evtdly.doc = list(new ScilabString([count++]));
- evtdly.model.evtin = new ScilabDouble([-1]);
- evtdly.model.evtout = new ScilabDouble([-1]);
- evtdly.graphics.peout = new ScilabDouble([4]);
-
- var output_port = CLKOUT_f("define");
- output_port.graphics.orig = new ScilabDouble([399, 162]);
- output_port.graphics.sz = new ScilabDouble([20, 20]);
- output_port.graphics.flip = new ScilabBoolean([true]);
- output_port.graphics.exprs = new ScilabString(["1"]);
- output_port.graphics.pein = new ScilabDouble([5]);
- output_port.model.ipar = new ScilabDouble([1]);
-
- output_port.model.uid = new ScilabString([count]); // changed
- output_port.doc = list(new ScilabString([count++]));
-
- var split = CLKSPLIT_f("define");
- split.graphics.orig = new ScilabDouble([380.71066, 172]);
- split.graphics.pein = new ScilabDouble([3]);
- split.graphics.peout = new ScilabDouble([5], [6]);
- split.model.uid = new ScilabString([count]);
- split.doc = list(new ScilabString([count++]));
- split.graphics.pein = new ScilabDouble([4]); // changed
-
- var diagram = scicos_diagram();
- diagram.objs.push(output_port);
- diagram.objs.push(evtdly);
- diagram.objs.push(split);
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([340], [340], [380.71]),
- yy: new ScilabDouble([226.29], [172], [172]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([2, 1, 0]),
- to: new ScilabDouble([3, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([380.71], [399]),
- yy: new ScilabDouble([172], [172]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([3, 1, 0]),
- to: new ScilabDouble([1, 1, 1])
- }));
- diagram.objs.push(scicos_link({
- xx: new ScilabDouble([380.71], [380.71], [340], [340]),
- yy: new ScilabDouble([172], [302], [302], [277.71]),
- ct: new ScilabDouble([5, -1]),
- from: new ScilabDouble([3, 2, 0]),
- to: new ScilabDouble([2, 1, 1])
- }));
- this.x = scicos_block();
- this.x.gui = new ScilabString(["CLOCK_c"]);
- this.x.graphics.sz = new ScilabDouble([2, 2]);
- this.x.graphics.gr_i = new ScilabString([]);
- this.x.graphics.peout = new ScilabDouble([0]);
- this.x.model.sim = new ScilabString(["csuper"]);
- this.x.model.evtout = new ScilabDouble([1]);
- this.x.model.blocktype = new ScilabString(["h"]);
- this.x.model.firing = new ScilabBoolean([false]);
- this.x.model.dep_ut = new ScilabBoolean([false, false]);
- this.x.model.rpar = diagram;
- return new BasicBlock(this.x);
- case "details":
- return this.x;
+ CLOCK_c.prototype.define = function() {
+ var evtdly = EVTDLY_c("define");
+ evtdly.graphics.orig = new ScilabDouble([320, 232]);
+ evtdly.graphics.sz = new ScilabDouble([40, 40]);
+ evtdly.graphics.flip = new ScilabBoolean([true]);
+ evtdly.graphics.exprs = new ScilabString(["0.1"], ["0.1"]);
+ evtdly.graphics.pein = new ScilabDouble([6]);
+ evtdly.graphics.peout = new ScilabDouble([3]);
+ evtdly.model.rpar = new ScilabDouble([0.1], [0.1]);
+ evtdly.model.firing = new ScilabDouble([0.1]);
+
+ evtdly.model.uid = new ScilabString([count]); // changed
+ evtdly.doc = list(new ScilabString([count++]));
+ evtdly.model.evtin = new ScilabDouble([-1]);
+ evtdly.model.evtout = new ScilabDouble([-1]);
+ evtdly.graphics.peout = new ScilabDouble([4]);
+
+ var output_port = CLKOUT_f("define");
+ output_port.graphics.orig = new ScilabDouble([399, 162]);
+ output_port.graphics.sz = new ScilabDouble([20, 20]);
+ output_port.graphics.flip = new ScilabBoolean([true]);
+ output_port.graphics.exprs = new ScilabString(["1"]);
+ output_port.graphics.pein = new ScilabDouble([5]);
+ output_port.model.ipar = new ScilabDouble([1]);
+
+ output_port.model.uid = new ScilabString([count]); // changed
+ output_port.doc = list(new ScilabString([count++]));
+
+ var split = CLKSPLIT_f("define");
+ split.graphics.orig = new ScilabDouble([380.71066, 172]);
+ split.graphics.pein = new ScilabDouble([3]);
+ split.graphics.peout = new ScilabDouble([5], [6]);
+ split.model.uid = new ScilabString([count]);
+ split.doc = list(new ScilabString([count++]));
+ split.graphics.pein = new ScilabDouble([4]); // changed
+
+ var diagram = scicos_diagram();
+ diagram.objs.push(output_port);
+ diagram.objs.push(evtdly);
+ diagram.objs.push(split);
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([340], [340], [380.71]),
+ yy: new ScilabDouble([226.29], [172], [172]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([2, 1, 0]),
+ to: new ScilabDouble([3, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([380.71], [399]),
+ yy: new ScilabDouble([172], [172]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([3, 1, 0]),
+ to: new ScilabDouble([1, 1, 1])
+ }));
+ diagram.objs.push(scicos_link({
+ xx: new ScilabDouble([380.71], [380.71], [340], [340]),
+ yy: new ScilabDouble([172], [302], [302], [277.71]),
+ ct: new ScilabDouble([5, -1]),
+ from: new ScilabDouble([3, 2, 0]),
+ to: new ScilabDouble([2, 1, 1])
+ }));
+ this.x = scicos_block();
+ this.x.gui = new ScilabString(["CLOCK_c"]);
+ this.x.graphics.sz = new ScilabDouble([2, 2]);
+ this.x.graphics.gr_i = new ScilabString([]);
+ this.x.graphics.peout = new ScilabDouble([0]);
+ this.x.model.sim = new ScilabString(["csuper"]);
+ this.x.model.evtout = new ScilabDouble([1]);
+ this.x.model.blocktype = new ScilabString(["h"]);
+ this.x.model.firing = new ScilabBoolean([false]);
+ this.x.model.dep_ut = new ScilabBoolean([false, false]);
+ this.x.model.rpar = diagram;
+ return new BasicBlock(this.x);
+ }
+ CLOCK_c.prototype.details = function() {
+ return this.x;
}
}
@@ -880,9 +874,8 @@ function BasicBlock() {
this.realParameters = options.model.rpar;
this.integerParameters = options.model.ipar;
this.objectsParameters = options.model.opar;
- this.nbZerosCrossing = options.model.nzcross;
- this.nmode = options.model.nmode;
- this.state = options.model.state;
+ this.nbZerosCrossing = new ScilabDouble([0]);
+ this.nmode = new ScilabDouble([0]);
this.oDState = list();
this.equations = list(); // Not Known
this.blockName = "BasicBlock";
diff --git a/index.html b/index.html
index 2370315..c2ac40f 100644
--- a/index.html
+++ b/index.html
@@ -14,7 +14,7 @@
<link rel="stylesheet" href="jquery/farbtastic.css" type="text/css" />
<link rel="stylesheet" href="jquery/jquery-ui.css">
- <script type="text/javascript" src="math.js"></script>
+
<script type="text/javascript" src="details.js"></script>
<script type="text/javascript" src="setup.js"></script>
<script type="text/javascript" src="json2.js"></script>
@@ -355,7 +355,8 @@
var text = null;
if (cell.isVertex() == true && cell.isConnectable() == false) {
var name = cell.value.getAttribute('blockElementName');
- var cellvar = window[name]('details');
+ var cellvar = cell.inst.details();
+
// If cell is a block or port
if (cell.source == null && cell.target == null) {
if (cell.connectable) { // Cell is a port
@@ -564,14 +565,29 @@
var textarea = document.createElement('textarea');
textarea.style.width = '400px';
textarea.style.height = '400px';
-
var enc = new mxCodec(mxUtils.createXmlDocument());
+ /*var array=[],key;
+ for (key in diagRoot.model.cells) {
+
+ if(diagRoot.model.cells[key].connectable == false)
+ {
+ array.push(diagRoot.model.cells[key].inst);
+ diagRoot.model.cells[key].inst=null;
+ }
+ }*/
var node = enc.encode(diagRoot);
var str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + mxUtils.getPrettyXml(node);
textarea.value = str;
-
+ /*var j = 0;
+ for (key in diagRoot.model.cells) {
+
+ if(diagRoot.model.cells[key].connectable == false)
+ {
+ diagRoot.model.cells[key].inst=array[j++];
+ }
+ }*/
if (arguments[2] == null) {
showModalWindow(graph, 'XML', textarea, 410, 440);
} else {
@@ -909,7 +925,7 @@
function showPropertiesWindow(graph, cell) {
var name = cell.getAttribute('blockElementName');
- var defaultProperties = window[name]("get");
+ var defaultProperties = cell.inst.get(); //window[name]("get");
/*{
nbr_curves: ["Number of curves", 1],
clrs: ["color (>0) or mark (<0)", [1, 2, 3, 4, 5, 6, 7, 13]],
@@ -993,7 +1009,7 @@
propertiesObject[key] = document.getElementById(key.toString()).value;
}
}
- var details = window[name]("set", cell.value, propertiesObject);
+ var details = cell.inst.set(cell.value, propertiesObject); //window[name]("set",cell.value,propertiesObject);
var enc = new mxCodec();
var node = enc.encode(details);
node.setAttribute('label', getData(details.exprs)[0]);
@@ -1591,6 +1607,7 @@
return wind;
};
+ var flag = 0;
function addSidebarIcon(graph, sidebar, name, image) {
// Function that is executed when the image is dropped on
@@ -1604,42 +1621,89 @@
model.beginUpdate();
try {
var label = getImgHTML(name); // Will not exist for all blocks
- if (name == 'ANDBLK') {
- var details = ANDBLK("define");
+ var details_instance = new window[name]();
+ var details = details_instance.define();
+ var enc = new mxCodec(mxUtils.createXmlDocument());
+ var node = enc.encode(details);
+ node.setAttribute('label', label);
+ var temp = enc.encode(parent);
+ node.setAttribute('parent', temp.getAttribute('id'));
+ var i, arr = [];
+ var Model = details_instance.x.model;
+ var graphics = details_instance.x.graphics;
+ var inputPorts = [],
+ outputPorts = [],
+ controlPorts = [],
+ commandPorts = [];
+ if (Model.in.height != null) {
+ arr = getData(graphics.in_implicit);
+ if (arr.length != 0) {
+ inputPorts = arr;
+ } else {
+ for (i = 0; i < Model.in.height; i++) {
+ inputPorts.push("E");
+ }
+ }
+ }
+ if (Model.out.height != null) {
+ arr = getData(graphics.out_implicit);
+ if (arr.length != 0) {
+ outputPorts = arr;
+ } else {
+ for (i = 0; i < Model.out.height; i++) {
+ outputPorts.push("E");
+ }
+ }
+ }
+ if (Model.evtin.width != null) {
+ for (i = 0; i < Model.evtin.width; i++) {
+ controlPorts.push("CONTROL");
+ }
+ }
+ if (Model.evtout.width != null) {
+ for (i = 0; i < Model.evtout.width; i++) {
+ commandPorts.push("COMMAND");
+ }
+ }
+ v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, name);
+ v1.inst = details_instance;
+ createPorts(graph, v1, inputPorts, controlPorts, outputPorts, commandPorts);
+ /*if (name == 'ANDBLK') {
+ var a = new ANDBLK();
+ var details = a.define();
var enc = new mxCodec(mxUtils.createXmlDocument());
var node = enc.encode(details);
- node.setAttribute('label', label);
+ node.setAttribute('label',label);
var temp = enc.encode(parent);
node.setAttribute('parent', temp.getAttribute('id'));
v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'ANDBLK');
+ v1.inst = a;
+
createPorts(graph, v1, [], ['CONTROL', 'CONTROL'], [], ['COMMAND']);
} else if (name == 'CMSCOPE') {
- var details = CMSCOPE("define");
+ var a = new CMSCOPE();
+ var details = a.define();
var enc = new mxCodec(mxUtils.createXmlDocument());
var node = enc.encode(details);
- node.setAttribute('label', label);
+ node.setAttribute('label',label);
var temp = enc.encode(parent);
node.setAttribute('parent', temp.getAttribute('id'));
v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'CMSCOPE');
+ v1.inst = a;
createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], [], []);
} else if (name == 'CONST_m') {
- var details = CONST_m("define");
+ var a = new CONST_m();
+ var details = a.define();
+ console.log(a);
var enc = new mxCodec(mxUtils.createXmlDocument());
var node = enc.encode(details);
- node.setAttribute('label', "1");
+ console.log(node);
+ node.setAttribute('label',"1");
var temp = enc.encode(parent);
node.setAttribute('parent', temp.getAttribute('id'));
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'CONST_m');
+ v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, "CONST_m");
+ v1.inst = a;
createPorts(graph, v1, [], [], ['EXPLICIT'], []);
- } else if (name == 'AFFICH_m') {
- var details = AFFICH_m("define");
- var enc = new mxCodec(mxUtils.createXmlDocument());
- var node = enc.encode(details);
- node.setAttribute('label', label);
- var temp = enc.encode(parent);
- node.setAttribute('parent', temp.getAttribute('id'));
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'AFFICH_m');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], [], []);
} else if (name == 'CONVERT') {
v1 = graph.insertVertex(parent, null, 'Convert to', x, y, 80, 80, 'CONVERT');
createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
@@ -1708,13 +1772,7 @@
}
// DISCONTINUOUS
else if (name == 'BACKLASH') {
- var details = BACKLASH("define");
- var enc = new mxCodec(mxUtils.createXmlDocument());
- var node = enc.encode(details);
- node.setAttribute('label', label);
- var temp = enc.encode(parent);
- node.setAttribute('parent', temp.getAttribute('id'));
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'BACKLASH');
+ v1 = graph.insertVertex(parent, null, 'Backlash', x, y, 80, 80, 'BACKLASH');
createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
} else if (name == 'DEADBAND') {
v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'DEADBAND');
@@ -1737,14 +1795,7 @@
}
// DISCRETE
else if (name == 'AUTOMAT') {
- var details = AUTOMAT("define");
- var enc = new mxCodec(mxUtils.createXmlDocument());
- var node = enc.encode(details);
- node.setAttribute('label', label);
- var temp = enc.encode(parent);
- node.setAttribute('parent', temp.getAttribute('id'));
-
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'AUTOMAT');
+ v1 = graph.insertVertex(parent, null, 'Automaton<BR>nM=2, nX=1', x, y, 80, 80, 'AUTOMAT');
createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT', 'EXPLICIT'], ['COMMAND']);
} else if (name == 'DELAY_f') {
v1 = graph.insertVertex(parent, null, 'Delay', x, y, 80, 80, 'DELAYV_f');
@@ -1774,24 +1825,30 @@
v1 = graph.insertVertex(parent, null, 'Shift<BR>register', x, y, 80, 80, 'REGISTER');
createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
} else if (name == 'CFSCOPE') {
- var details = CFSCOPE("define");
+ var a = new CFSCOPE();
+ var details = a.define();
+ console.log(a);
var enc = new mxCodec(mxUtils.createXmlDocument());
var node = enc.encode(details);
- node.setAttribute('label', label);
+ node.setAttribute('label',label);
var temp = enc.encode(parent);
node.setAttribute('parent', temp.getAttribute('id'));
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'ANDBLK');
+ v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'CFSCOPE');
+ v1.inst = a;
createPorts(graph, v1, [], ['CONTROL'], [], []);
}
// EVENTS
else if (name == 'CLOCK_c') {
- var details = CLOCK_c("define");
+ var a = new CLOCK_c();
+ var details = a.define();
+ console.log(a);
var enc = new mxCodec(mxUtils.createXmlDocument());
var node = enc.encode(details);
- node.setAttribute('label', label);
+ node.setAttribute('label',label);
var temp = enc.encode(parent);
node.setAttribute('parent', temp.getAttribute('id'));
v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'CLOCK_c');
+ v1.inst = a;
createPorts(graph, v1, [], [], [], ['COMMAND']);
} else if (name == 'SampleCLK') {
v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'SampleCLK');
@@ -1878,12 +1935,7 @@
}
// MATHEMATICAL OPERATIONS
else if (name == 'ABS_VALUE') {
- var details = ABS_VALUE("define");
- var enc = new mxCodec(mxUtils.createXmlDocument());
- var node = enc.encode(details);
- node.setAttribute('label', label);
- var temp = enc.encode(parent);
- v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, 'ABS_VALUE');
+ v1 = graph.insertVertex(parent, null, 'ABS', x, y, 80, 80, 'ABS_VALUE');
createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
} else if (name == 'BIGSOM_f') {
v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'BIGSOM_f');
@@ -1965,7 +2017,7 @@
} else if (name == 'TEXT_f') {
v1 = graph.insertVertex(parent, null, '', x, y, 80, 80, 'TEXT_f');
createPorts(graph, v1, [], [], [], []);
- }
+ }*/
v1.setConnectable(false);
} finally {
model.endUpdate();
@@ -2049,9 +2101,9 @@
port = graph.insertVertex(block, null, 'CommandPort', x, y, 10, 10, 'CommandPort', true);
} else if (portType == 'CONTROL') {
port = graph.insertVertex(block, null, 'ControlPort', x, y, 10, 10, 'ControlPort', true);
- } else if (portType == 'IMPLICIT') {
+ } else if (portType == 'I') {
port = graph.insertVertex(block, null, 'ImplicitInputPort', x, y, 10, 10, 'ImplicitInputPort', true);
- } else if (portType == 'EXPLICIT') {
+ } else if (portType == 'E') {
port = graph.insertVertex(block, null, 'ExplicitInputPort', x, y, 10, 10, 'ExplicitInputPort', true);
}
if (port != null) {
@@ -2070,9 +2122,9 @@
port = graph.insertVertex(block, null, 'CommandPort', x, y, 10, 10, 'CommandPort', true);
} else if (portType == 'CONTROL') {
port = graph.insertVertex(block, null, 'ControlPort', x, y, 10, 10, 'ControlPort', true);
- } else if (portType == 'IMPLICIT') {
+ } else if (portType == 'I') {
port = graph.insertVertex(block, null, 'ImplicitOutputPort', x, y, 10, 10, 'ImplicitOutputPort', true);
- } else if (portType == 'EXPLICIT') {
+ } else if (portType == 'E') {
port = graph.insertVertex(block, null, 'ExplicitOutputPort', x, y, 10, 10, 'ExplicitOutputPort', true);
}
if (port != null) {
@@ -2509,5 +2561,4 @@
});
});
</script>
-
</html>