summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--details.js693
-rw-r--r--finalmodsheet.xsl7
-rw-r--r--index.html836
3 files changed, 638 insertions, 898 deletions
diff --git a/details.js b/details.js
index 8c54590..fee4e32 100644
--- a/details.js
+++ b/details.js
@@ -301,52 +301,59 @@ function getData() {
return dataArray;
}
-function modelica(){
- var model=[];
- var inputs=[];
- var outputs=[];
- var parameters=list([],list());
- var mo=tlist(["modelica","model","inputs","outputs","parameters"],model,inputs,outputs,parameters);
- return mo;
+function modelica() {
+ var model = [];
+ var inputs = [];
+ var outputs = [];
+ var parameters = list([], list());
+ var mo = tlist(["modelica", "model", "inputs", "outputs", "parameters"], model, inputs, outputs, parameters);
+ return mo;
+}
+
+// To add Block name under the instance tag in xml.
+function instance() {
+ this.instance = arguments[0];
+}
+
+function createInstanceTag() {
+ return new instance(arguments[0]);
}
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[0]["vec"]];
+ this.x.model.rpar = new ScilabDouble();
+ this.x.graphics.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;
}
}
@@ -376,131 +383,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;
}
}
@@ -508,189 +515,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;
}
}
@@ -937,4 +945,3 @@ function zeros(n) {
return port;
}
-
diff --git a/finalmodsheet.xsl b/finalmodsheet.xsl
index 56e95b3..8d935dc 100644
--- a/finalmodsheet.xsl
+++ b/finalmodsheet.xsl
@@ -8,6 +8,7 @@ Authors: Maverick & Karma
NOTES:
Look for TAG:Break1!!!
TAG:Break2!!!
+ TAG:Break3!!!
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no" />
@@ -151,6 +152,8 @@ Look for TAG:Break1!!!
</xsl:otherwise>
</xsl:choose>
</xsl:when>
+
+
<xsl:when test="@name">
<xsl:choose>
<xsl:when test="@name='ExplicitLink'">
@@ -2191,4 +2194,6 @@ Look for TAG:Break1!!!
<xsl:apply-templates />
</xsl:element>
</xsl:template>
-</xsl:stylesheet> \ No newline at end of file
+ <!-- To remove the instance variable in generated Xcos-->
+ <xsl:template match="mxCell/instance"/>
+</xsl:stylesheet>
diff --git a/index.html b/index.html
index ebca018..7cc3436 100644
--- a/index.html
+++ b/index.html
@@ -19,7 +19,6 @@
<script type="text/javascript" src="setup.js"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
-
function main(container, outline, toolbar, sidebar, status) {
// Checks if the browser is supported
if (!mxClient.isBrowserSupported()) {
@@ -121,22 +120,22 @@
XSLT transformation.
*/
var cellSource = cell.source;
- while(cellSource.isEdge() == true) {
- cellSource = cellSource.source;
+ while (cellSource.isEdge() == true) {
+ cellSource = cellSource.source;
}
if (cellSource.value == "ExplicitOutputPort" || cellSource.value == "ExplicitInputPort") {
- if(style == null) {
- style = 'ExplicitLink' + ';';
+ if (style == null) {
+ style = 'ExplicitLink' + ';';
}
cell.name = "ExplicitLink";
} else if (cellSource.value == "ImplicitOutputPort" || cellSource.value == "ImplicitInputPort") {
- if(style == null) {
- style = 'ImplicitLink' + ';';
+ if (style == null) {
+ style = 'ImplicitLink' + ';';
}
cell.name = "ImplicitLink";
} else if (cellSource.value == "CommandPort" || cellSource.value == "ControlPort") {
- if(style == null) {
- style = 'CommandControlLink' + ';';
+ if (style == null) {
+ style = 'CommandControlLink' + ';';
}
cell.name = "CommandControlLink";
}
@@ -167,10 +166,10 @@
}, edgeformat);
menu.addItem('Text and Text Font', 'images/edit.png', function() {
- showTextEditWindow(graph, cell);
+ showTextEditWindow(graph, cell);
}, edgeformat);
menu.addItem('Text Color', 'images/edit.png', function() {
- showColorWheel(graph, cell, 'edgeTextColor');
+ showColorWheel(graph, cell, 'edgeTextColor');
}, edgeformat);
} else {
@@ -262,43 +261,36 @@
*/
graph.addEdge = function(edge, parent, source, target, index) {
- var edgeSource = source;
+ var edgeSource = source;
- // If the source of the edge is also an edge, find the port.
- while (edgeSource.isEdge() == true) {
- edgeSource = edgeSource.source;
- }
+ // If the source of the edge is also an edge, find the port.
+ while (edgeSource.isEdge() == true) {
+ edgeSource = edgeSource.source;
+ }
- // If the edge violates any port constraints, return null.
- if(!((edgeSource.getEdgeCount() == 0 && edgeSource.isVertex() &&
- target.getEdgeCount() == 0 && target.isVertex()) ||
- (edgeSource.getEdgeCount() <= 1 && source.isEdge()))) {
- alert("Port is already connected, please select an please select an unconnected port or a valid link");
- }
- else if(edgeSource.value == "ExplicitOutputPort" && target.value != "ExplicitInputPort") {
- alert("Explicit data output port must be connected to explicit data input port");
- }
- else if(edgeSource.value == "ExplicitInputPort" && target.value != "ExplicitOutputPort") {
- alert("Explicit data input port must be connected to explicit data output port");
- }
- else if(edgeSource.value == "ImplicitOutputPort" && target.value != "ImplicitInputPort") {
- alert("Implicit data output port must be connected to implicit data input port");
- }
- else if(edgeSource.value == "ImplicitInputPort" && target.value != "ImplicitOutputPort") {
- alert("Implicit data input port must be connected to implicit data output port");
- }
- else if(edgeSource.value == "CommandPort" && target.value != "ControlPort") {
- alert("Command port must be connected to control port");
- }
- else if(edgeSource.value == "ControlPort" && target.value != "CommandPort") {
- alert("Control port must be connected to command port");
- }
- else {
- // If the edge is legit, return the edge.
- return mxGraph.prototype.addEdge.apply(this, arguments);
- }
+ // If the edge violates any port constraints, return null.
+ if (!((edgeSource.getEdgeCount() == 0 && edgeSource.isVertex() &&
+ target.getEdgeCount() == 0 && target.isVertex()) ||
+ (edgeSource.getEdgeCount() <= 1 && source.isEdge()))) {
+ alert("Port is already connected, please select an please select an unconnected port or a valid link");
+ } else if (edgeSource.value == "ExplicitOutputPort" && target.value != "ExplicitInputPort") {
+ alert("Explicit data output port must be connected to explicit data input port");
+ } else if (edgeSource.value == "ExplicitInputPort" && target.value != "ExplicitOutputPort") {
+ alert("Explicit data input port must be connected to explicit data output port");
+ } else if (edgeSource.value == "ImplicitOutputPort" && target.value != "ImplicitInputPort") {
+ alert("Implicit data output port must be connected to implicit data input port");
+ } else if (edgeSource.value == "ImplicitInputPort" && target.value != "ImplicitOutputPort") {
+ alert("Implicit data input port must be connected to implicit data output port");
+ } else if (edgeSource.value == "CommandPort" && target.value != "ControlPort") {
+ alert("Command port must be connected to control port");
+ } else if (edgeSource.value == "ControlPort" && target.value != "CommandPort") {
+ alert("Control port must be connected to command port");
+ } else {
+ // If the edge is legit, return the edge.
+ return mxGraph.prototype.addEdge.apply(this, arguments);
+ }
- return null;
+ return null;
}
// Shows a "modal" window when double clicking a vertex.
@@ -317,8 +309,8 @@
content.innerHTML = this.convertValueToString(cell);
showModalWindow(this, 'Properties', content, 400, 300);
*/
- if(cell.isVertex() == true) {
- showPropertiesWindow(graph, cell);
+ if (cell.isVertex() == true) {
+ showPropertiesWindow(graph, cell);
}
}
}
@@ -360,55 +352,64 @@
}
graph.getTooltipForCell = function(cell) {
- var text = null;
- if (cell.isVertex() == true && cell.isConnectable() == false) {
- var name = cell.value.getAttribute('blockElementName');
- var cellvar = window[name]('details');
- // If cell is a block or port
- if (cell.source == null && cell.target == null) {
- if (cell.connectable) { // Cell is a port
- // @ToDo: Port Number
- text = 'Style : ' + cell.style + "\n";
- } else { //Cell is a block
- // @ToDo: Block Name, Simulation, Flip, Mirror
- // @ToDo: Number of Input, Output, Control, Command Ports
- var inputport, outputport, controlport, commandport;
- if (cellvar.model.in.height == null)
- inputport = 0;
- else
- inputport = cellvar.model.in.height;
- if (cellvar.model.out.height == null)
- outputport = 0;
- else
- outputport = cellvar.model.out.height;
- if (cellvar.model.evtin.width == null)
- controlport = 0;
- else
- controlport = cellvar.model.evtin.width;
- if (cellvar.model.evtout.width == null)
- commandport = 0;
- else
- commandport = cellvar.model.evtout.width;
- var geometry = cell.getGeometry();
- text = 'Block Name : ' + cell.value.getAttribute('blockElementName') + "\n" +
- 'Simulation : ' + cell.value.getAttribute('simulationFunctionName') + "\n" +
- 'UID : ' + cell.id + "\n" +
- 'Style : ' + cell.style + "\n" +
- 'Flip : ' + getData(cellvar.graphics.flip)[0] + "\n" +
- 'Mirror : false' + "\n" +
- 'Input Ports : ' + inputport + "\n" +
- 'Output Ports : ' + outputport + "\n" +
- 'Control Ports : ' + controlport + "\n" +
- 'Command Ports : ' + commandport + "\n" +
- 'x : ' + geometry.x + "\n" +
- 'y : ' + geometry.y + "\n" +
- 'w : ' + geometry.width + "\n" +
- 'h : ' + geometry.height + "\n";
- }
- }
- }
- return text;
- };
+ var text = null;
+ if (cell.isVertex() == true && cell.isConnectable() == false) {
+ var name = cell.value.getAttribute('blockElementName');
+ var cellvar = cell.blockInstance.instance.details();
+
+ // If cell is a block or ports
+ if (cell.source == null && cell.target == null) {
+ if (cell.connectable) { // Cell is a Port
+ // @ToDo: Port Number
+ text = 'Style : ' + cell.style + "\n";
+ } else { //Cell is a block
+ // @ToDo: Block Name, Simulation, Flip, Mirror
+ // @ToDo: Number of Input, Output, Control, Command Ports
+ var inputPort, outputPort, controlPort, commandPort;
+ if (cellvar.model.in.height == null) {
+ inputPort = 0;
+ }
+ else {
+ inputPort = cellvar.model.in.height;
+ }
+ if (cellvar.model.out.height == null) {
+ outputPort = 0;
+ }
+ else {
+ outputPort = cellvar.model.out.height;
+ }
+ if (cellvar.model.evtin.width == null) {
+ controlPort = 0;
+ }
+ else {
+ controlPort = cellvar.model.evtin.width;
+ }
+ if (cellvar.model.evtout.width == null) {
+ commandPort = 0;
+ }
+ else {
+ commandPort = cellvar.model.evtout.width;
+ }
+ var geometry = cell.getGeometry();
+ text = 'Block Name : ' + cell.value.getAttribute('blockElementName') + "\n" +
+ 'Simulation : ' + cell.value.getAttribute('simulationFunctionName') + "\n" +
+ 'UID : ' + cell.id + "\n" +
+ 'Style : ' + cell.style + "\n" +
+ 'Flip : ' + getData(cellvar.graphics.flip)[0] + "\n" +
+ 'Mirror : false' + "\n" +
+ 'Input Ports : ' + inputPort + "\n" +
+ 'Output Ports : ' + outputPort + "\n" +
+ 'Control Ports : ' + controlPort + "\n" +
+ 'Command Ports : ' + commandPort + "\n" +
+ 'x : ' + geometry.x + "\n" +
+ 'y : ' + geometry.y + "\n" +
+ 'w : ' + geometry.width + "\n" +
+ 'h : ' + geometry.height + "\n";
+ }
+ }
+ }
+ return text;
+ };
// Create XML tags!
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -572,14 +573,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 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 {
@@ -620,9 +636,9 @@
Maverick
Using resultDocument.documentElement to remove an additional tag "<#document>" created by the XSLTProcessor.
*/
- var str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+mxUtils.getPrettyXml(resultDocument.documentElement);
+ var str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" + mxUtils.getPrettyXml(resultDocument.documentElement);
- textarea.value=str.replace(/\n\n/g,"\n");
+ textarea.value = str.replace(/\n\n/g, "\n");
showModalWindow(graph, 'Xcos', textarea, 410, 440);
}
});
@@ -747,30 +763,30 @@
function styleToObject(style) {
- var defaultStyle = style.substring(0, style.indexOf(';'));
- var styleObject = {
- "default" : defaultStyle
- };
- var remainingStyle = style.substring(style.indexOf(';') + 1);
-
- /*
- remainingStyle is the string without the default style.
- For every key:value pair in the string,
- extract the key(string before '=') and the value
- (string before ';'), set the key:value pair into styleObject
- and remainingStyle is set to a string without the key:value pair.
- */
- while(remainingStyle.length > 0) {
- var indexOfKey = remainingStyle.indexOf('=');
- var key = remainingStyle.substring(0, indexOfKey);
- remainingStyle = remainingStyle.substring(indexOfKey + 1);
- var indexOfValue = remainingStyle.indexOf(';');
- var value = remainingStyle.substring(0, indexOfValue);
- styleObject[key] = value;
- remainingStyle = remainingStyle.substring(indexOfValue + 1);
- }
-
- return styleObject;
+ var defaultStyle = style.substring(0, style.indexOf(';'));
+ var styleObject = {
+ "default": defaultStyle
+ };
+ var remainingStyle = style.substring(style.indexOf(';') + 1);
+
+ /*
+ remainingStyle is the string without the default style.
+ For every key:value pair in the string,
+ extract the key(string before '=') and the value
+ (string before ';'), set the key:value pair into styleObject
+ and remainingStyle is set to a string without the key:value pair.
+ */
+ while (remainingStyle.length > 0) {
+ var indexOfKey = remainingStyle.indexOf('=');
+ var key = remainingStyle.substring(0, indexOfKey);
+ remainingStyle = remainingStyle.substring(indexOfKey + 1);
+ var indexOfValue = remainingStyle.indexOf(';');
+ var value = remainingStyle.substring(0, indexOfValue);
+ styleObject[key] = value;
+ remainingStyle = remainingStyle.substring(indexOfValue + 1);
+ }
+
+ return styleObject;
}
/*
@@ -778,16 +794,15 @@
styleToObject(style) converts the object back to the style string.
*/
function objectToStyle(object) {
- var style = "";
- for (var key in object) {
- if(key.toString() == "default") {
- style += object[key] + ';';
- }
- else {
- style += (key + '=' + object[key] + ';');
+ var style = "";
+ for (var key in object) {
+ if (key.toString() == "default") {
+ style += object[key] + ';';
+ } else {
+ style += (key + '=' + object[key] + ';');
+ }
}
- }
- return style;
+ return style;
}
/*
@@ -867,7 +882,7 @@
traverse the array of 'contextValue' and not all the
elements of it.
*/
- for (var i=0;i<contextValue.length;i++) {
+ for (var i = 0; i < contextValue.length; i++) {
displayValue += contextValue[i] + "\n";
}
if (contextValue != "") {
@@ -905,7 +920,7 @@
}
diagRoot.context = contextValues;
- diagRoot.context.scilabClass="String[]";
+ diagRoot.context.scilabClass = "String[]";
handleContext("set", contextValues);
wind.destroy();
};
@@ -918,7 +933,7 @@
function showPropertiesWindow(graph, cell) {
var name = cell.getAttribute('blockElementName');
- var defaultProperties = window[name]("get");
+ var defaultProperties = cell.blockInstance.instance.get(); //window[name]("get");
/*{
nbr_curves: ["Number of curves", 1],
clrs: ["color (>0) or mark (<0)", [1, 2, 3, 4, 5, 6, 7, 13]],
@@ -1002,10 +1017,10 @@
propertiesObject[key] = document.getElementById(key.toString()).value;
}
}
- var details = window[name]("set",cell.value,propertiesObject);
+ var details = cell.blockInstance.instance.set(propertiesObject); //window[name]("set",cell.value,propertiesObject);
var enc = new mxCodec();
var node = enc.encode(details);
- node.setAttribute('label',getData(details.exprs)[0]);
+ node.setAttribute('label', getData(details.exprs)[0]);
cell.value = node;
/*
Maverick
@@ -1050,17 +1065,17 @@
function showTextEditWindow(graph, cell) {
- var fontFamilyList = {
- "Arial" : 0,
- "Dialog" : 1,
- "Verdana" : 2,
- "Times New Roman" : 3
- }
- var defaultProperties = {
- text: ["Text", "text"],
- fontFamily : ["Font Family", fontFamilyList],
- fontSize: ["fontSize", 20]
- };
+ var fontFamilyList = {
+ "Arial": 0,
+ "Dialog": 1,
+ "Verdana": 2,
+ "Times New Roman": 3
+ }
+ var defaultProperties = {
+ text: ["Text", "text"],
+ fontFamily: ["Font Family", fontFamilyList],
+ fontSize: ["fontSize", 20]
+ };
var style = graph.getModel().getStyle(cell);
var styleObject = styleToObject(style);
@@ -1099,38 +1114,37 @@
namelabel.innerHTML = defaultProperties[key][0];
myform.appendChild(namelabel);
- if(key == "fontFamily") {
- //Here we create a "select" element (a drop down list).
- var newList = document.createElement("select");
- newList.style.cssText = "float:right";
- newList.setAttribute("id", key.toString());
- var dropdownItems = defaultProperties[key][1];
-
- for(var item in dropdownItems) {
- if (dropdownItems.hasOwnProperty(item)) {
- option = document.createElement('option');
- option.value = item;
- option.text = item;
- option.setAttribute("id", item);
- newList.appendChild(option);
+ if (key == "fontFamily") {
+ //Here we create a "select" element (a drop down list).
+ var newList = document.createElement("select");
+ newList.style.cssText = "float:right";
+ newList.setAttribute("id", key.toString());
+ var dropdownItems = defaultProperties[key][1];
+
+ for (var item in dropdownItems) {
+ if (dropdownItems.hasOwnProperty(item)) {
+ option = document.createElement('option');
+ option.value = item;
+ option.text = item;
+ option.setAttribute("id", item);
+ newList.appendChild(option);
+ }
+ }
+
+ var selectedFontFamily = 0;
+ var styleObject = styleToObject(style);
+ if ('fontFamily' in styleObject) {
+ selectedFontFamily = styleObject['fontFamily'];
}
- }
-
- var selectedFontFamily = 0;
- var styleObject = styleToObject(style);
- if ('fontFamily' in styleObject) {
- selectedFontFamily = styleObject['fontFamily'];
- }
- newList.selectedIndex = dropdownItems[selectedFontFamily];
- myform.appendChild(newList);
- }
- else {
- var input = document.createElement("input");
- input.name = key;
- input.value = defaultProperties[key][1];
- input.setAttribute("id", key.toString());
- input.setAttribute("class", "fieldInput");
- myform.appendChild(input);
+ newList.selectedIndex = dropdownItems[selectedFontFamily];
+ myform.appendChild(newList);
+ } else {
+ var input = document.createElement("input");
+ input.name = key;
+ input.value = defaultProperties[key][1];
+ input.setAttribute("id", key.toString());
+ input.setAttribute("class", "fieldInput");
+ myform.appendChild(input);
}
// Line break
var linebreak = document.createElement('br');
@@ -1151,30 +1165,29 @@
for "set" type, and toggles with the active class for "get" type.
*/
function changeFontStyle(type, graph, cell, button, bit) {
- var style = graph.getModel().getStyle(cell);
- var trigger = document.getElementById(button);
- var styleObject = styleToObject(style);
- var previousValue = 1;
- if ('fontStyle' in styleObjesct) {
- previousValue = styleObject['fontStyle'];
-
- // To get a bit mask:
- var mask = 1 << bit; // Get the 1st element
-
- if(type == "get") {
- // toggle the bit
- previousValue ^= mask;
- trigger.classList.toggle(button);
- styleObject['fontStyle'] = previousValue;
- style = objectToStyle(styleObject);
- graph.getModel().setStyle(cell, style);
- }
- else if(type == "set") {
- if ((previousValue & mask) != 0) {
- trigger.classList.toggle(button);
+ var style = graph.getModel().getStyle(cell);
+ var trigger = document.getElementById(button);
+ var styleObject = styleToObject(style);
+ var previousValue = 1;
+ if ('fontStyle' in styleObjesct) {
+ previousValue = styleObject['fontStyle'];
+
+ // To get a bit mask:
+ var mask = 1 << bit; // Get the 1st element
+
+ if (type == "get") {
+ // toggle the bit
+ previousValue ^= mask;
+ trigger.classList.toggle(button);
+ styleObject['fontStyle'] = previousValue;
+ style = objectToStyle(styleObject);
+ graph.getModel().setStyle(cell, style);
+ } else if (type == "set") {
+ if ((previousValue & mask) != 0) {
+ trigger.classList.toggle(button);
+ }
}
- }
- }
+ }
}
// Button - Bold
@@ -1184,7 +1197,7 @@
btn.type = "button";
btn.name = "submit";
btn.onclick = function() {
- changeFontStyle("get", graph, cell, 'boldButton', 0);
+ changeFontStyle("get", graph, cell, 'boldButton', 0);
}
myform.appendChild(btn);
@@ -1195,7 +1208,7 @@
btn.type = "button";
btn.name = "submit";
btn.onclick = function() {
- changeFontStyle("get", graph, cell, 'italicButton', 1);
+ changeFontStyle("get", graph, cell, 'italicButton', 1);
}
myform.appendChild(btn);
@@ -1206,7 +1219,7 @@
btn.type = "button";
btn.name = "submit";
btn.onclick = function() {
- changeFontStyle("get", graph, cell, 'underlineButton', 2);
+ changeFontStyle("get", graph, cell, 'underlineButton', 2);
}
myform.appendChild(btn);
@@ -1256,10 +1269,10 @@
for the selected edge label, add the respective active class to that button.
*/
- if('fontStyle' in styleObject) {
- changeFontStyle("set", graph, cell, 'boldButton', 0);
- changeFontStyle("set", graph, cell, 'italicButton', 1);
- changeFontStyle("set", graph, cell, 'underlineButton', 2);
+ if ('fontStyle' in styleObject) {
+ changeFontStyle("set", graph, cell, 'boldButton', 0);
+ changeFontStyle("set", graph, cell, 'italicButton', 1);
+ changeFontStyle("set", graph, cell, 'underlineButton', 2);
}
};
/*
@@ -1490,12 +1503,11 @@
} else if (selectProperty == "bgColor") {
graph.container.style.backgroundColor = input;
} else if (selectProperty == "vertexStrokeColor") {
- styleObject['strokeColor'] = input;
+ styleObject['strokeColor'] = input;
} else if (selectProperty == "vertexFillColor") {
- styleObject['fillColor'] = input;
- }
- else if(selectProperty == "edgeTextColor") {
- styleObject['fontColor'] = input;
+ styleObject['fillColor'] = input;
+ } else if (selectProperty == "edgeTextColor") {
+ styleObject['fontColor'] = input;
}
style = objectToStyle(styleObject);
graph.getModel().setStyle(cell, style);
@@ -1603,6 +1615,7 @@
return wind;
};
+ var flag = 0;
function addSidebarIcon(graph, sidebar, name, image) {
// Function that is executed when the image is dropped on
@@ -1616,341 +1629,56 @@
model.beginUpdate();
try {
var label = getImgHTML(name); // Will not exist for all blocks
- if (name == 'ANDBLK') {
- var details = ANDBLK("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, 'ANDBLK');
- createPorts(graph, v1, [], ['CONTROL', 'CONTROL'], [], ['COMMAND']);
- } else if (name == 'CMSCOPE') {
- var details = CMSCOPE("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, 'CMSCOPE');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], [], []);
- } else if (name == 'CONST_m') {
- var details = CONST_m("define");
- var enc = new mxCodec(mxUtils.createXmlDocument());
- var node = enc.encode(details);
- 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');
- createPorts(graph, v1, [], [], ['EXPLICIT'], []);
- } else if (name == 'CONVERT') {
- v1 = graph.insertVertex(parent, null, 'Convert to', x, y, 80, 80, 'CONVERT');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'CSCOPXY') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'CSCOPXY');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], [], []);
- } else if (name == 'DEMUX') {
- v1 = graph.insertVertex(parent, null, '', x, y, 80, 80, 'DEMUX');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT', 'EXPLICIT'], []);
- } else if (name == 'IN_f') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'IN_f');
- createPorts(graph, v1, [], [], ['EXPLICIT'], []);
- } else if (name == 'LOGICAL_OP') {
- v1 = graph.insertVertex(parent, null, 'AND', x, y, 80, 80, 'LOGICAL_OP');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'MUX') {
- v1 = graph.insertVertex(parent, null, '', x, y, 80, 80, 'MUX');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'NRMSOM_f') {
- v1 = graph.insertVertex(parent, null, '', x, y, 80, 80, 'NRMSOM_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'OUT_f') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'OUT_f');
- createPorts(graph, v1, ['EXPLICIT'], [], [], []);
- } else if (name == 'RELATIONALOP') {
- v1 = graph.insertVertex(parent, null, '<FONT SIZE="6"><</FONT>', x, y, 80, 80, 'RELATIONALOP');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SWITCH2_m') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'SWITCH2_m');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- }
- // CONTINUOUS
- else if (name == 'CLINDUMMY_f') {
- v1 = graph.insertVertex(parent, null, 'DUMMY<BR>CLSS', x, y, 80, 80, 'CLINDUMMY_f');
- createPorts(graph, v1, [], [], [], []);
- } else if (name == 'CLR') {
- v1 = graph.insertVertex(parent, null, '1<BR><HR>1 + s', x, y, 80, 80, 'CLR');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'CLSS') {
- v1 = graph.insertVertex(parent, null, '<TABLE><TR><TD ALIGN="RIGHT">xd</TD><TD>=</TD><TD>Ax+Bu</TD></TR><TR><TD ALIGN="RIGHT">y</TD><TD>=</TD><TD>Cx+Du</TD></TR></TABLE>', x, y, 130, 80, 'CLSS');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'DERIV') {
- v1 = graph.insertVertex(parent, null, 'du / dt', x, y, 80, 80, 'DERIV');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'INTEGRAL_f') {
- v1 = graph.insertVertex(parent, null, '1/s', x, y, 80, 80, 'INTEGRAL_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'INTEGRAL_m') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'INTEGRAL_m');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'PID') {
- v1 = graph.insertVertex(parent, null, 'PID', x, y, 80, 80, 'PID');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'TCLSS') {
- v1 = graph.insertVertex(parent, null, 'Jump<BR>(A,B,C,D)', x, y, 80, 80, 'TCLSS');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'TIME_DELAY') {
- v1 = graph.insertVertex(parent, null, 'Continuous<BR>fix delay', x, y, 80, 80, 'TIME_DELAY');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'VARIABLE_DELAY') {
- v1 = graph.insertVertex(parent, null, 'Variable<BR>delay', x, y, 80, 80, 'VARIABLE_DELAY');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'PDE') {
- v1 = graph.insertVertex(parent, null, 'PDE', x, y, 80, 80, 'PDE');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT', 'EXPLICIT', 'EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT', 'EXPLICIT'], []);
- }
- // DISCONTINUOUS
- else if (name == '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');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'DELAYV_f') {
- v1 = graph.insertVertex(parent, null, 'Variable<BR>delay', x, y, 80, 80, 'DELAYV_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], ['EXPLICIT'], ['COMMAND', 'COMMAND']);
- } else if (name == 'HYSTHERESIS') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'HYSTHERESIS');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'RATELIMITER') {
- v1 = graph.insertVertex(parent, null, 'Rate limiter', x, y, 80, 80, 'RATELIMITER');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'QUANT_f') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'QUANT_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SATURATION') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'SATURATION');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- }
- // DISCRETE
- else if (name == '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');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'DLR') {
- v1 = graph.insertVertex(parent, null, '1<BR><HR>1 + z', x, y, 80, 80, 'DLR');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'DLRADAPT_f') {
- v1 = graph.insertVertex(parent, null, 'N(z,p)<BR><HR>D(z,p)', x, y, 80, 80, 'DLRADAPT_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'DLSS') {
- v1 = graph.insertVertex(parent, null, '<TABLE><TR><TD ALIGN="RIGHT">x</TD><TD ALIGN="CENTER">+=</TD><TD>Ax+Bu</TD></TR><TR><TD ALIGN="RIGHT">y</TD><TD ALIGN="CENTER">=</TD><TD>Cx+Du</TD></TR></TABLE>', x, y, 80, 80, 'DLSS');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'DOLLAR_f') {
- v1 = graph.insertVertex(parent, null, '1/z', x, y, 80, 80, 'DOLLAR_f');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'DOLLAR') {
- v1 = graph.insertVertex(parent, null, '1/z', x, y, 80, 80, 'DOLLAR');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'DOLLAR_m') {
- v1 = graph.insertVertex(parent, null, '1/z', x, y, 80, 80, 'DOLLAR_m');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'SAMPHOLD_m') {
- v1 = graph.insertVertex(parent, null, 'S / H', x, y, 80, 80, 'SAMPHOLD_m');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'REGISTER') {
- 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 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, 'ANDBLK');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- }
- // EVENTS
- else if (name == 'CLOCK_c') {
- var details = CLOCK_c("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, 'CLOCK_c');
- createPorts(graph, v1, [], [], [], ['COMMAND']);
- } else if (name == 'SampleCLK') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'SampleCLK');
- createPorts(graph, v1, [], [], [], ['COMMAND']);
- } else if (name == 'VirtualCLK0') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'VirtualCLK0');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- }
- // ANDBLK to come here
- else if (name == 'ANDLOG_f') {
- v1 = graph.insertVertex(parent, null, 'LOGICAL<BR>AND', x, y, 80, 80, 'ANDLOG_f');
- createPorts(graph, v1, [], ['CONTROL', 'CONTROL'], ['EXPLICIT'], []);
- } else if (name == 'CEVENTSCOPE') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'CEVENTSCOPE');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- } else if (name == 'CLKFROM') {
- v1 = graph.insertVertex(parent, null, 'A', x, y, 80, 80, 'CLKFROM');
- createPorts(graph, v1, [], [], [], ['COMMAND']);
- } else if (name == 'CLKGOTO') {
- v1 = graph.insertVertex(parent, null, 'A', x, y, 80, 80, 'CLKGOTO');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- } else if (name == 'CLKGotoTagVisibility') {
- v1 = graph.insertVertex(parent, null, '{A}', x, y, 80, 80, 'CLKGotoTagVisibility');
- createPorts(graph, v1, [], [], [], []);
- } else if (name == 'CLKOUTV_f') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'CLKOUTV_f');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- } else if (name == 'CLKSOMV_f') {
- v1 = graph.insertVertex(parent, null, '+', x, y, 80, 80, 'CLKSOMV_f');
- createPorts(graph, v1, [], ['CONTROL', 'CONTROL', 'CONTROL'], [], ['COMMAND']);
- } else if (name == 'EDGE_TRIGGER') {
- v1 = graph.insertVertex(parent, null, 'Edge<BR>trigger', x, y, 80, 80, 'EDGE_TRIGGER');
- createPorts(graph, v1, ['EXPLICIT'], [], [], ['COMMAND']);
- } else if (name == 'ENDBLK') {
- v1 = graph.insertVertex(parent, null, 'END', x, y, 80, 80, 'ENDBLK');
- createPorts(graph, v1, [], [], [], []);
- } else if (name == 'END_c') {
- v1 = graph.insertVertex(parent, null, 'END', x, y, 80, 80, 'END_c');
- createPorts(graph, v1, [], ['CONTROL'], [], ['COMMAND']);
- } else if (name == 'ESELECT_f') {
- v1 = graph.insertVertex(parent, null, 'Event select', x, y, 80, 80, 'ESELECT_f');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], [], ['COMMAND', 'COMMAND']);
- } else if (name == 'EVTDLY_c') {
- v1 = graph.insertVertex(parent, null, 'Delay: 0.1', x, y, 80, 80, 'EVTDLY_c');
- createPorts(graph, v1, [], ['CONTROL'], [], ['COMMAND']);
- } else if (name == 'EVTGEN_f') {
- v1 = graph.insertVertex(parent, null, 'Event at<BR>time 0', x, y, 80, 80, 'EVTGEN_f');
- createPorts(graph, v1, [], [], [], ['COMMAND']);
- } else if (name == 'EVTVARDLY') {
- v1 = graph.insertVertex(parent, null, 'Event<BR>delay', x, y, 80, 80, 'EVTVARDLY');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], [], ['COMMAND']);
- } else if (name == 'Extract_Activation') {
- v1 = graph.insertVertex(parent, null, 'Extract<BR>activation', x, y, 80, 80, 'Extract_Activation');
- createPorts(graph, v1, ['EXPLICIT'], [], [], ['COMMAND']);
- } else if (name == 'HALT_f') {
- v1 = graph.insertVertex(parent, null, 'HALT', x, y, 80, 80, 'HALT_f');
- createPorts(graph, v1, [], ['CONTROL'], [], []);
- } else if (name == 'IFTHEL_f') {
- v1 = graph.insertVertex(parent, null, 'if in>0<BR>then else', x, y, 80, 80, 'IFTHEL_f');
- createPorts(graph, v1, ['EXPLICIT'], ['CONTROL'], [], ['COMMAND', 'COMMAND']);
- } else if (name == 'M_freq') {
- v1 = graph.insertVertex(parent, null, 'Multiple<BR>frequency', x, y, 80, 80, 'M_freq');
- createPorts(graph, v1, [], ['CONTROL'], [], ['COMMAND', 'COMMAND', 'COMMAND']);
- } else if (name == 'MCLOCK_f') {
- v1 = graph.insertVertex(parent, null, '2freq clock<BR>f/n f', x, y, 80, 80, 'MCLOCK_f');
- createPorts(graph, v1, [], [], [], ['COMMAND', 'COMMAND']);
- } else if (name == 'MFCLCK_f') {
- v1 = graph.insertVertex(parent, null, 'M. freq<BR>clock', x, y, 80, 80, 'MFCLCK_f');
- createPorts(graph, v1, [], ['CONTROL'], [], ['COMMAND', 'COMMAND']);
- } else if (name == 'freq_div') {
- v1 = graph.insertVertex(parent, null, 'Frequency<BR>division', x, y, 80, 80, 'freq_div');
- createPorts(graph, v1, [], ['CONTROL'], [], ['COMMAND']);
+ 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 blockModel = details_instance.x.model;
+ var graphics = details_instance.x.graphics;
+
+ /* To determine number and type of Port*/
+ var inputPorts = [],
+ outputPorts = [],
+ controlPorts = [],
+ commandPorts = [];
+ if (blockModel.in.height != null) {
+ arr = getData(graphics.in_implicit);
+ if (arr.length != 0) {
+ inputPorts = arr;
+ } else {
+ for (i = 0; i < blockModel.in.height; i++) {
+ inputPorts.push("E");
+ }
+ }
}
- // LOOKUP TABLES
- else if (name == 'INTRP2BLK_f') {
- v1 = graph.insertVertex(parent, null, 'Interp 2', x, y, 80, 80, 'INTRP2BLK_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'INTRPLBLK_f') {
- v1 = graph.insertVertex(parent, null, 'Interp', x, y, 80, 80, 'INTRPLBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'LOOKUP_f') {
- v1 = graph.insertVertex(parent, null, label, x, y, 80, 80, 'LOOKUP_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
+ if (blockModel.out.height != null) {
+ arr = getData(graphics.out_implicit);
+ if (arr.length != 0) {
+ outputPorts = arr;
+ } else {
+ for (i = 0; i < blockModel.out.height; i++) {
+ outputPorts.push("E");
+ }
+ }
}
- // MATHEMATICAL OPERATIONS
- else if (name == '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');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'COSBLK_f') {
- v1 = graph.insertVertex(parent, null, 'COS', x, y, 80, 80, 'COSBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'EXPBLK_m') {
- v1 = graph.insertVertex(parent, null, 'a^u', x, y, 80, 80, 'EXPBLK_m');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'GAINBLK_f') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'GAINBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'GAINBLK') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'GAINBLK');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'GAIN_f') {
- v1 = graph.insertVertex(parent, null, '1', x, y, 80, 80, 'GAIN_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'INVBLK') {
- v1 = graph.insertVertex(parent, null, '1/u', x, y, 80, 80, 'INVBLK');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'LOGBLK_f') {
- v1 = graph.insertVertex(parent, null, 'LOG', x, y, 80, 80, 'LOGBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'MATMAGPHI') {
- v1 = graph.insertVertex(parent, null, 'Mag & Phi', x, y, 80, 80, 'MATMAGPHI');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT', 'EXPLICIT'], []);
- } else if (name == 'MATZREIM') {
- v1 = graph.insertVertex(parent, null, 'Re & Im', x, y, 80, 80, 'MATZREIM');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT', 'EXPLICIT'], []);
- } else if (name == 'MAXMIN') {
- v1 = graph.insertVertex(parent, null, 'MAX', x, y, 80, 80, 'MAXMIN');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'MAX_f') {
- v1 = graph.insertVertex(parent, null, 'MAX', x, y, 80, 80, 'MAX_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'MIN_f') {
- v1 = graph.insertVertex(parent, null, 'MIN', x, y, 80, 80, 'MIN_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'POWBLK_f') {
- v1 = graph.insertVertex(parent, null, 'u^a', x, y, 80, 80, 'POWBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'PRODUCT') {
- v1 = graph.insertVertex(parent, null, '<TABLE><TR><TD>*</TD><TD ROWSPAN="2"><FONT SIZE="6">∏</FONT><TD></TR><TR><TD>÷</TD><TD/></TR></TABLE>', x, y, 80, 80, 'PRODUCT');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'PROD_f') {
- v1 = graph.insertVertex(parent, null, 'X', x, y, 80, 80, 'PROD_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SIGNUM') {
- v1 = graph.insertVertex(parent, null, 'SIGN', x, y, 80, 80, 'SIGNUM');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SINBLK_f') {
- v1 = graph.insertVertex(parent, null, 'SIN', x, y, 80, 80, 'SINBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SQRT') {
- v1 = graph.insertVertex(parent, null, 'SQRT', x, y, 80, 80, 'SQRT');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SUMMATION') {
- v1 = graph.insertVertex(parent, null, '<TABLE><TR><TD>+</TD> <TD ROWSPAN="2"><FONT SIZE="6">∑</FONT><TD></TR><TR><TD>-</TD> <TD/></TR></TABLE>', x, y, 80, 80, 'SUMMATION');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SUM_f') {
- v1 = graph.insertVertex(parent, null, '+', x, y, 80, 80, 'SUM_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'SOM_f') {
- v1 = graph.insertVertex(parent, null, '+', x, y, 80, 80, 'SOM_f');
- createPorts(graph, v1, ['EXPLICIT', 'EXPLICIT', 'EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'TANBLK_f') {
- v1 = graph.insertVertex(parent, null, 'TAN', x, y, 80, 80, 'TANBLK_f');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
- } else if (name == 'TrigFun') {
- v1 = graph.insertVertex(parent, null, 'Trig function', x, y, 80, 80, 'TrigFun');
- createPorts(graph, v1, ['EXPLICIT'], [], ['EXPLICIT'], []);
+ if (blockModel.evtin.width != null) {
+ for (i = 0; i < blockModel.evtin.width; i++) {
+ controlPorts.push("CONTROL");
+ }
}
- // MATRIX
- else if (name == 'OpAmp') {
- v1 = graph.insertVertex(parent, null, '<table><tr><td>+</td><td></td></tr><tr><td></td><td>OP</td></tr><tr><td>-</td><td></td></tr></table>', x, y, 80, 80, 'OpAmp');
- createPorts(graph, v1, ['IMPLICIT', 'IMPLICIT'], [], ['IMPLICIT'], []);
- } else if (name == 'TEXT_f') {
- v1 = graph.insertVertex(parent, null, '', x, y, 80, 80, 'TEXT_f');
- createPorts(graph, v1, [], [], [], []);
+ if (blockModel.evtout.width != null) {
+ for (i = 0; i < blockModel.evtout.width; i++) {
+ commandPorts.push("COMMAND");
+ }
}
+ v1 = graph.insertVertex(parent, null, node, x, y, 80, 80, name);
+ // @Chhavi: Additional attribute to store the block's instance
+ v1.blockInstance = createInstanceTag(details_instance);
+ createPorts(graph, v1, inputPorts, controlPorts, outputPorts, commandPorts);
v1.setConnectable(false);
} finally {
model.endUpdate();
@@ -2034,9 +1762,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) {
@@ -2045,7 +1773,7 @@
} else if (position == 'left') {
port.geometry.offset = new mxPoint(-10, -6);
}
- port.ordering=ordering;
+ port.ordering = ordering;
}
};
@@ -2055,9 +1783,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) {
@@ -2067,7 +1795,7 @@
if (position == 'right') {
port.geometry.offset = new mxPoint(0, -6);
}
- port.ordering=ordering;
+ port.ordering = ordering;
}
};