summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhitya Kamakshidasan2016-06-30 23:40:28 +0530
committerGitHub2016-06-30 23:40:28 +0530
commitdee1e850d2938c9291c9d8d8b1505b4d6294527b (patch)
treecfb3d778b8c7dfc6e3b35c1358dcb313055631ae
parent1643dcd2803d9f19d52af25ebb64fb68e6e5fac8 (diff)
parent3c7047a4bcf9265372ded0a1ebe3a6b34638b998 (diff)
downloadxcos-on-web-dee1e850d2938c9291c9d8d8b1505b4d6294527b.tar.gz
xcos-on-web-dee1e850d2938c9291c9d8d8b1505b4d6294527b.tar.bz2
xcos-on-web-dee1e850d2938c9291c9d8d8b1505b4d6294527b.zip
Merge pull request #98 from avi-psvm-dutta/master
Implement IdealTransformer Block
-rw-r--r--data_structures_correct/INTRPLBLK_f.js26
-rw-r--r--data_structures_correct/IdealTransformer.js61
2 files changed, 87 insertions, 0 deletions
diff --git a/data_structures_correct/INTRPLBLK_f.js b/data_structures_correct/INTRPLBLK_f.js
new file mode 100644
index 0000000..2b073e0
--- /dev/null
+++ b/data_structures_correct/INTRPLBLK_f.js
@@ -0,0 +1,26 @@
+function INTRPLBLK_f() {
+
+ INTRPLBLK_f.prototype.define = function INTRPLBLK_f() {
+ this.a = [[0],[1]];
+
+ this.b = [[0],[1]];
+
+ var model = scicos_model();
+ model.sim = new ScilabString(["intrpl"]);
+ model.in = new ScilabDouble(1);
+ model.out = new ScilabDouble(1);
+ model.rpar = new ScilabDouble(...this.a, ...this.b);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true,false]);
+
+ var exprs = new ScilabString([sci2exp(this.a)], [sci2exp(this.b)]);
+
+ var gr_i = ["xstringb(orig(1),orig(2),\"INTRPLBLK_f\",sz(1),sz(2));"];
+ this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+
+ INTRPLBLK_f.prototype.details = function INTRPLBLK_f() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/IdealTransformer.js b/data_structures_correct/IdealTransformer.js
new file mode 100644
index 0000000..3c97211
--- /dev/null
+++ b/data_structures_correct/IdealTransformer.js
@@ -0,0 +1,61 @@
+function IdealTransformer() {
+
+ IdealTransformer.prototype.define = function IdealTransformer() {
+ this.ModelName = "IdealTransformer";
+ this.PrametersValue = [1];
+ this.ParametersName = ["N"];
+
+ var model = scicos_model();
+
+ this.Typein = [];
+ this.Typeout = [];
+ this.MI = [];
+ this.MO = [];
+ this.P = [[2.5,90,2,0],[2.5,10,2,0],[97.5,90,-2,0],[97.5,10,-2,0]];
+ this.PortName = [["p1"],["n1"],["p2"],["n2"]];
+
+ for (var i = 0; i < size(this.P, "r"); i++) {
+ if (this.P[i][2] == 1) {
+ this.Typein.push(["E"]);
+ this.MI.push(this.PortName[i]);
+ }
+
+ if (this.P[i][2] == 2) {
+ this.Typein.push(["I"]);
+ this.MI.push(this.PortName[i]);
+ }
+ if (this.P[i][2] == -1) {
+ this.Typeout.push(["E"]);
+ this.MO.push(this.PortName[i]);
+ }
+ if (this.P[i][2] == -2) {
+ this.Typeout.push(["I"]);
+ this.MO.push(this.PortName[i]);
+ }
+ }
+ var mo = modelica();
+ model.sim = new ScilabString([this.ModelName]);
+ mo.inputs = new ScilabString(...this.MI);
+ mo.outputs = new ScilabString(...this.MO);
+ model.rpar = new ScilabDouble(this.PrametersValue);
+ console.log(zeros(getData(this.ParametersName)));
+ mo.parameters = list(new ScilabString(this.ParametersName), new ScilabDouble(this.PrametersValue), new ScilabDouble(zeros(getData(this.ParametersName))));
+ var exprs = new ScilabString(["1"]);
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IdealTransformer\",sz(1),sz(2));"]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([false, true]);
+ mo.model = new ScilabString([this.ModelName]);
+ model.equations = mo;
+ model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1));
+ model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1));
+ this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, list(gr_i), new ScilabDouble([0]));
+ this.x.graphics.in_implicit = new ScilabDouble(this.Typein);
+ this.x.graphics.out_implicit = new ScilabDouble(this.Typeout);
+ return new BasicBlock(this.x);
+ }
+
+ IdealTransformer.prototype.details = function IdealTransformer() {
+ return this.x;
+ }
+
+}