From a6f422179a58c224ee87677f8e87d9d62be8c04c Mon Sep 17 00:00:00 2001 From: sarangsingh29 Date: Tue, 12 Jul 2016 18:32:50 +0530 Subject: four blocks --- combined.js | 203 +++++++++++++++++++---------------- data_structures_correct/INIMPL_f.js | 5 +- data_structures_correct/IN_f.js | 6 +- data_structures_correct/OUTIMPL_f.js | 5 +- data_structures_correct/OUT_f.js | 5 +- dependencies.js | 54 ++++++++-- index.html | 41 +++++-- 7 files changed, 206 insertions(+), 113 deletions(-) diff --git a/combined.js b/combined.js index 5e0c942..2e485d2 100644 --- a/combined.js +++ b/combined.js @@ -6161,12 +6161,16 @@ function INIMPL_f() { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"INIMPL_f",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); this.x.graphics.out_implicit = new ScilabString(["I"]); - return new ImplicitInBlock(this.x); + + this.implicitInBlock = new ImplicitInBlock(this.x); + this.displayParameter = [this.implicitInBlock.ordering]; + return this.implicitInBlock; } INIMPL_f.prototype.details = function INIMPL_f() { return this.x; } } + function INTEGRAL_f() { INTEGRAL_f.prototype.define = function INTEGRAL_f() { @@ -6327,51 +6331,55 @@ function INVBLK() { function IN_f () { - IN_f.prototype.internal = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["IN_f"]); // changed - block.graphics.out_implicit = new ScilabString(["E"]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.out_label = new ScilabString([""]); - return block; - } - - IN_f.prototype.define = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new ExplicitInBlock(this.x); - } - - IN_f.prototype.details = function IN_f() { - return this.x; - } + IN_f.prototype.internal = function IN_f() { + this.prt = 1; + + var model = scicos_model(); + model.sim = new ScilabString(["input"]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.outtyp = new ScilabDouble([-1]); + model.ipar=new ScilabDouble([this.prt]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false,false]); + + var exprs = new ScilabString([sci2exp(this.prt)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); + var block = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); + block.graphics.style = new ScilabString(["IN_f"]); // changed + block.graphics.out_implicit = new ScilabString(["E"]); + block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); + block.graphics.out_label = new ScilabString([""]); + return block; + } + + IN_f.prototype.define = function IN_f() { + this.prt = 1; + + var model = scicos_model(); + model.sim = new ScilabString(["input"]); + model.out = new ScilabDouble([-1]); + model.out2 = new ScilabDouble([-2]); + model.outtyp = new ScilabDouble([-1]); + model.ipar = new ScilabDouble([this.prt]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false,false]); + + var exprs = new ScilabString([sci2exp(this.prt)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); + + this.explicitInBlock = new ExplicitInBlock(this.x); + this.displayParameter = [this.explicitInBlock.ordering]; + return this.explicitInBlock; + + } + + IN_f.prototype.details = function IN_f() { + return this.x; + } } function ISELECT_m() { @@ -7779,61 +7787,68 @@ function OUTIMPL_f() { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"OUTIMPL_f",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); this.x.graphics.in_implicit = new ScilabString(["I"]); - return new ImplicitOutBlock(this.x); + + this.implicitOutBlock = new ImplicitOutBlock(this.x); + this.displayParameter = [this.implicitOutBlock.ordering]; + return this.implicitOutBlock; } OUTIMPL_f.prototype.details = function OUTIMPL_f() { return this.x; } } + function OUT_f () { - OUT_f.prototype.internal = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["OUT_f"]); // changed - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.in_label = new ScilabString([""]); - block.graphics.in_implicit = new ScilabString(["E"]); - return block; - } - - OUT_f.prototype.define = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - this.x.graphics.style = new ScilabString(["OUT_f"]); - return new ExplicitOutBlock(this.x); - } - - OUT_f.prototype.details = function OUT_f() { - return this.x; - } + OUT_f.prototype.internal = function OUT_f() { + this.n = -1; + this.prt = 1; + + var model = scicos_model(); + model.sim = new ScilabString(["output"]); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([-1]); + model.ipar = new ScilabDouble([this.prt]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false,false]); + var exprs = new ScilabString([sci2exp(this.prt)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); + var block=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); + block.graphics.style = new ScilabString(["OUT_f"]); // changed + block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); + block.graphics.in_label = new ScilabString([""]); + block.graphics.in_implicit = new ScilabString(["E"]); + return block; + } + + OUT_f.prototype.define = function OUT_f() { + this.n = -1; + this.prt = 1; + + var model = scicos_model(); + model.sim = new ScilabString(["output"]); + model.in = new ScilabDouble([-1]); + model.in2 = new ScilabDouble([-2]); + model.intyp = new ScilabDouble([-1]); + model.ipar=new ScilabDouble([this.prt]); + model.blocktype = new ScilabString(["c"]); + model.dep_ut = new ScilabBoolean([false,false]); + + var exprs = new ScilabString([sci2exp(this.prt)]); + + var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); + this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); + this.x.graphics.style = new ScilabString(["OUT_f"]); + + this.explicitOutBlock = new ExplicitOutBlock(this.x); + this.displayParameter = [this.explicitOutBlock.ordering]; + return this.explicitOutBlock; + } + + OUT_f.prototype.details = function OUT_f() { + return this.x; + } } function PDE() { diff --git a/data_structures_correct/INIMPL_f.js b/data_structures_correct/INIMPL_f.js index 68555d7..81d2374 100644 --- a/data_structures_correct/INIMPL_f.js +++ b/data_structures_correct/INIMPL_f.js @@ -20,7 +20,10 @@ function INIMPL_f() { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"INIMPL_f",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); this.x.graphics.out_implicit = new ScilabString(["I"]); - return new ImplicitInBlock(this.x); + + this.implicitInBlock = new ImplicitInBlock(this.x); + this.displayParameter = [this.implicitInBlock.ordering]; + return this.implicitInBlock; } INIMPL_f.prototype.details = function INIMPL_f() { return this.x; diff --git a/data_structures_correct/IN_f.js b/data_structures_correct/IN_f.js index 1a2545a..c269a7a 100644 --- a/data_structures_correct/IN_f.js +++ b/data_structures_correct/IN_f.js @@ -39,7 +39,11 @@ function IN_f () { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new ExplicitInBlock(this.x); + + this.explicitInBlock = new ExplicitInBlock(this.x); + this.displayParameter = [this.explicitInBlock.ordering]; + return this.explicitInBlock; + } IN_f.prototype.details = function IN_f() { diff --git a/data_structures_correct/OUTIMPL_f.js b/data_structures_correct/OUTIMPL_f.js index 25207b3..82cd6c2 100644 --- a/data_structures_correct/OUTIMPL_f.js +++ b/data_structures_correct/OUTIMPL_f.js @@ -22,7 +22,10 @@ function OUTIMPL_f() { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"OUTIMPL_f",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); this.x.graphics.in_implicit = new ScilabString(["I"]); - return new ImplicitOutBlock(this.x); + + this.implicitOutBlock = new ImplicitOutBlock(this.x); + this.displayParameter = [this.implicitOutBlock.ordering]; + return this.implicitOutBlock; } OUTIMPL_f.prototype.details = function OUTIMPL_f() { return this.x; diff --git a/data_structures_correct/OUT_f.js b/data_structures_correct/OUT_f.js index 277148c..e480a65 100644 --- a/data_structures_correct/OUT_f.js +++ b/data_structures_correct/OUT_f.js @@ -41,7 +41,10 @@ function OUT_f () { var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); this.x.graphics.style = new ScilabString(["OUT_f"]); - return new ExplicitOutBlock(this.x); + + this.explicitOutBlock = new ExplicitOutBlock(this.x); + this.displayParameter = [this.explicitOutBlock.ordering]; + return this.explicitOutBlock; } OUT_f.prototype.details = function OUT_f() { diff --git a/dependencies.js b/dependencies.js index 4e44388..44ca79d 100644 --- a/dependencies.js +++ b/dependencies.js @@ -15,7 +15,7 @@ $.ajax({ url: "/data_structures_correct/" }, success: function (data) { - + // @Parameter: data will have the required filenames in the mentioned folder // For each url, add the script to the body div element with getScript function for (i in data) { @@ -25,6 +25,47 @@ $.ajax({ }); */ +// Added to handle ordering for a few blocks. + +window.inBitMap='0'; +window.outBitMap='0'; + +String.prototype.replaceAt=function(index, character) { + return this.substr(0, index) + character + this.substr(index+character.length); +} + +/* + Maverick, Adhitya + ImplicitInBlock, ImplicitOutBlock, ExplicitInBlock, ExplicitOutBlock + These blocks need their orderings to be handled. + We are using a bitmap to do the same. +*/ + +function handleOrdering(inOrOut){ + var bitmap; + if(inOrOut=='in'){ + bitmap=window.inBitMap; + } + else{ + bitmap=window.outBitMap; + } + var index = bitmap.indexOf('0'); + if(index == -1){ + bitmap += '0'; + index = bitmap.indexOf('0'); + } + bitmap = bitmap.replaceAt(index,'1'); + if(inOrOut=='in'){ + window.inBitMap=bitmap; + } + else{ + window.outBitMap=bitmap; + } + var position = 1+index; + + return position; +} + function AfficheBlock() { if (arguments.length > 0) { var options = arguments[0]; @@ -682,7 +723,7 @@ function ImplicitOutBlock() { this.dependsOnT = "1"; this.id = options.id; this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; + this.ordering = handleOrdering('out'); this.parent = options.parent; if (options.model.sim instanceof Array) { this.simulationFunctionName = getData(options.model.sim[0])[0]; @@ -767,7 +808,7 @@ function ImplicitInBlock() { this.dependsOnT = "1"; this.id = options.id; this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; + this.ordering = handleOrdering('in'); this.parent = options.parent; if (options.model.sim instanceof Array) { this.simulationFunctionName = getData(options.model.sim[0])[0]; @@ -847,7 +888,7 @@ function ExplicitInBlock() { this.connectable = options.connectable; // Not Known this.id = options.id; this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; + this.ordering = handleOrdering('in'); this.parent = options.parent; if (options.model.sim instanceof Array) { this.simulationFunctionName = getData(options.model.sim[0])[0]; @@ -919,6 +960,7 @@ function ExplicitInBlock() { } } + function ExplicitOutBlock() { if (arguments.length > 0) { var options = arguments[0]; @@ -927,7 +969,7 @@ function ExplicitOutBlock() { this.connectable = options.connectable; // Not Known this.id = options.id; this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; + this.ordering = handleOrdering('out'); this.parent = options.parent; if (options.model.sim instanceof Array) { this.simulationFunctionName = getData(options.model.sim[0])[0]; @@ -1147,7 +1189,7 @@ function inverse() { function _str2code() { var conversion = "0123456789abcdefghijklmnopqrstuvwxyz_#!$ ();:+-*/\\=.,'[]%|&<>~^"; - var conversion2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ00?0 00000000$000\"{}000`0@0r"; + var conversion2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ00?0 00000000$000\"{}000`0@0r"; var str = arguments[0]; var code = []; for (var i = 0; i < str.length; i++) { diff --git a/index.html b/index.html index a8c1179..dd4e608 100755 --- a/index.html +++ b/index.html @@ -822,7 +822,6 @@ editor.addAction('deleteBlock', function(editor, cell) { graph.getModel().beginUpdate(); try { - // getEdgeId(@edgeObject) finds all the associated edges and split-block, and deletes them function getEdgeId(edgeObject) { @@ -925,6 +924,22 @@ // If the cell is a vertex, select the cell else { var portCount = selectionCells[k].getChildCount(); + /* + Maverick, Adhitya + switch-case statements to handle the ordering of following blocks. + The variables window.inBitMap and window.outBitMap are defined in + the file 'dependencies.js'. + */ + switch(selectionCells[k].value.nodeName){ + case 'ImplicitInBlock': + case 'ExplicitInBlock': + window.inBitMap = window.inBitMap.replaceAt(parseInt(selectionCells[k].value.getAttribute('ordering'))-1,'0') ; + break; + case 'ImplicitOutBlock': + case 'ExplicitOutBlock': + window.outBitMap = window.outBitMap.replaceAt(parseInt(selectionCells[k].value.getAttribute('ordering'))-1,'0') ; + break; + } cells.push(selectionCells[k]); for (var i = 0; i < portCount; i++) { var edgeCount = selectionCells[k].getChildAt(i).getEdgeCount(); @@ -943,7 +958,6 @@ } } } - graph.removeCells(cells, true); } finally { graph.getModel().endUpdate(); @@ -1239,7 +1253,7 @@ Ports will be automatically handled with the respective constructor calls. */ if (!(curNodeName.endsWith('Link') || curNodeName.endsWith('Port'))) { - var ifaceFuncName = cell.interfaceFunctionName; + var ifaceFuncName = null; /* Maverick @@ -1255,13 +1269,21 @@ temporaryMapObject.outputIds = []; temporaryMapObject.controlIds = []; temporaryMapObject.commandIds = []; + + switch(curNodeName){ + case 'ExplicitInBlock': ifaceFuncName='IN_f'; break; + case 'ExplicitOutBlock': ifaceFuncName='OUT_f'; break; + case 'ImplicitInBlock': ifaceFuncName='INIMPL_f'; break; + case 'ImplicitOutBlock': ifaceFuncName='OUTIMPL_f'; break; + default: cell.interfaceFunctionName; + } - - var details_instance = null; + var details_instance=null if (ifaceFuncName != null) { - details_instance = new window[ifaceFuncName](); } + + if (details_instance != null) { var details = details_instance.define(); var enc = new mxCodec(mxUtils.createXmlDocument()); @@ -1269,8 +1291,10 @@ var temp = enc.encode(parent); var stylesheet = graph.getStylesheet(); var styleName = currentNode.getAttribute('style'); - if (styleName.indexOf(';') != -1) { - styleName = styleName.substring(0, styleName.indexOf(';')); + if(styleName!=null){ + if (styleName.indexOf(';') != -1) { + styleName = styleName.substring(0, styleName.indexOf(';')); + } } var style = stylesheet.styles[styleName]; @@ -2549,7 +2573,6 @@ // Get the stylesheet for the graph var stylesheet = graph.getStylesheet(); - console.log(name); // From the stylesheet, get the style of the particular block var style = stylesheet.styles[name]; -- cgit