summaryrefslogtreecommitdiff
path: root/data_structures_correct
diff options
context:
space:
mode:
authorAdhitya Kamakshidasan2016-07-07 16:01:01 +0530
committerGitHub2016-07-07 16:01:01 +0530
commitc2837aa63e52b258ac8ac2109451a161f8ea43a1 (patch)
tree3c5ef784bbe4555e0490ce085f5f333987cee7a0 /data_structures_correct
parent8f6a729cb4698f548c7ab08365b397f9d4c22754 (diff)
parent9dca28dfc8255370d720fd23af6dff32ce730839 (diff)
downloadxcos-on-web-c2837aa63e52b258ac8ac2109451a161f8ea43a1.tar.gz
xcos-on-web-c2837aa63e52b258ac8ac2109451a161f8ea43a1.tar.bz2
xcos-on-web-c2837aa63e52b258ac8ac2109451a161f8ea43a1.zip
Merge pull request #148 from ASP1234/master
Implement Blocks
Diffstat (limited to 'data_structures_correct')
-rw-r--r--data_structures_correct/MBLOCK.js45
-rw-r--r--data_structures_correct/SAWTOOTH_f.js23
-rw-r--r--data_structures_correct/SHIFT.js30
-rw-r--r--data_structures_correct/SQRT.js24
-rw-r--r--data_structures_correct/SineVoltage.js38
-rw-r--r--data_structures_correct/SourceP.js36
6 files changed, 196 insertions, 0 deletions
diff --git a/data_structures_correct/MBLOCK.js b/data_structures_correct/MBLOCK.js
new file mode 100644
index 0000000..e2b6725
--- /dev/null
+++ b/data_structures_correct/MBLOCK.js
@@ -0,0 +1,45 @@
+function MBLOCK() {
+
+ MBLOCK.prototype.define = function MBLOCK() {
+ this.in1 = ["u1"];
+ this.intype = ["I"];
+ this.out = [["y1"],["y2"]];
+ this.outtype = [["I"],["E"]];
+ this.param = [["R"],["L"]];
+ this.paramv = list(new ScilabDouble([0.1]), new ScilabDouble([0.0001]));
+ this.pprop = [[0],[0]];
+ this.nameF = "generic";
+
+ var exprs = tlist(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"], new ScilabString(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"]), new ScilabString([sci2exp(this.in1)]), new ScilabString([sci2exp(this.intype)]), new ScilabString([sci2exp(this.out)]), new ScilabString([sci2exp(this.outtype)]), new ScilabString([sci2exp(this.param)]), list(new ScilabString([0.1]), new ScilabString([0.0001])), new ScilabString([sci2exp(this.pprop)]), new ScilabString([this.nameF]), new ScilabDouble());
+
+ var model = scicos_model();
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([false, true]);
+ model.rpar = [];
+
+ for (var i = 0; i < this.paramv.length; i++) {
+ model.rpar.push(getData(this.paramv[i]));
+ }
+
+ model.rpar = new ScilabDouble(...model.rpar);
+ var mo = modelica();
+ mo.model = new ScilabString([this.nameF]);
+ mo.parameters = list(new ScilabString(...this.param), this.paramv);
+ model.sim = list(mo.model, new ScilabDouble([30004]));
+ mo.inputs = new ScilabString(this.in1);
+ mo.outputs = new ScilabString(...this.out);
+ model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "r"), 1));
+ model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "r"), 1));
+ model.equations = mo;
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MBLOCK\",sz(1),sz(2));"]);
+
+ this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i);
+ this.x.graphics.in_implicit = new ScilabString(this.intype);
+ this.x.graphics.out_implicit = new ScilabString(...this.outtype);
+ return new BasicBlock(this.x);
+ }
+
+ MBLOCK.prototype.details = function MBLOCK() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/SAWTOOTH_f.js b/data_structures_correct/SAWTOOTH_f.js
new file mode 100644
index 0000000..75a8fec
--- /dev/null
+++ b/data_structures_correct/SAWTOOTH_f.js
@@ -0,0 +1,23 @@
+function SAWTOOTH_f() {
+
+ SAWTOOTH_f.prototype.define = function SAWTOOTH_f() {
+
+ var model = scicos_model();
+ model.sim = new ScilabString(["sawtth"]);
+ model.out = new ScilabDouble([1]);
+ model.evtin = new ScilabDouble([1]);
+ model.dstate = new ScilabDouble([0]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([false, true]);
+
+ var exprs = new ScilabString([" "]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SAWTOOTH_f\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+
+ SAWTOOTH_f.prototype.details = function SAWTOOTH_f() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/SHIFT.js b/data_structures_correct/SHIFT.js
new file mode 100644
index 0000000..a0e9283
--- /dev/null
+++ b/data_structures_correct/SHIFT.js
@@ -0,0 +1,30 @@
+function SHIFT() {
+
+ SHIFT.prototype.define = function SHIFT() {
+ this.sgn = [[0],[0]];
+ this.OPER = 0;
+
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["shift_32_LA"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble([-1]);
+ model.out = new ScilabDouble([-1]);
+ model.in2 = new ScilabDouble([-2]);
+ model.out2 = new ScilabDouble([-2]);
+ model.intyp = new ScilabDouble([3]);
+ model.outtyp = new ScilabDouble([3]);
+ model.rpar = new ScilabDouble();
+ model.ipar = new ScilabDouble(...this.sgn);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+
+ var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)], [sci2exp(0)]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SHIFT\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+
+ SHIFT.prototype.details = function SHIFT() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/SQRT.js b/data_structures_correct/SQRT.js
new file mode 100644
index 0000000..f9ddb24
--- /dev/null
+++ b/data_structures_correct/SQRT.js
@@ -0,0 +1,24 @@
+function SQRT() {
+
+ SQRT.prototype.define = function SQRT() {
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["mat_sqrt"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble([-1]);
+ model.in2 = new ScilabDouble([-2]);
+ model.intyp = new ScilabDouble([1]);
+ model.outtyp = new ScilabDouble([1]);
+ model.out = new ScilabDouble([-1]);
+ model.out2 = new ScilabDouble([-2]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+
+ var label = new ScilabString([sci2exp(1)]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SQRT\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i);
+ return new BasicBlock(this.x);
+ }
+
+ SQRT.prototype.details = function SQRT() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/SineVoltage.js b/data_structures_correct/SineVoltage.js
new file mode 100644
index 0000000..e2bd1e4
--- /dev/null
+++ b/data_structures_correct/SineVoltage.js
@@ -0,0 +1,38 @@
+function SineVoltage() {
+
+ SineVoltage.prototype.define = function SineVoltage() {
+ var model = scicos_model();
+ model.in = new ScilabDouble([1]);
+ model.out = new ScilabDouble([1]);
+
+ this.V = 1;
+ this.ph = 0;
+ this.frq = 1;
+ this.offset = 0;
+ this.start = 0;
+
+ model.rpar = new ScilabDouble([this.V], [this.ph], [this.frq], [this.offset], [this.start]);
+ model.sim = new ScilabString(["SineVoltage"]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+
+ var mo = modelica();
+ mo.model = new ScilabString(["SineVoltage"]);
+ mo.inputs = new ScilabString(["p"]);
+ mo.outputs = new ScilabString(["n"]);
+ mo.parameters = list(new ScilabString(["V"], ["phase"], ["freqHz"], ["offset"], ["startTime"]), list(new ScilabDouble([this.V]), new ScilabDouble([this.ph]), new ScilabDouble([this.frq]), new ScilabDouble([this.offset]), new ScilabDouble([this.start])));
+ model.equations = mo;
+
+ var exprs = new ScilabString([this.V], [this.ph], [this.frq], [this.offset], [this.start]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SineVoltage\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i);
+ this.x.graphics.in_implicit = new ScilabString(["I"]);
+ this.x.graphics.out_implicit = new ScilabString(["I"]);
+ return new BasicBlock(this.x);
+ }
+
+ SineVoltage.prototype.details = function SineVoltage() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/SourceP.js b/data_structures_correct/SourceP.js
new file mode 100644
index 0000000..20b9e5a
--- /dev/null
+++ b/data_structures_correct/SourceP.js
@@ -0,0 +1,36 @@
+function SourceP() {
+
+ SourceP.prototype.define = function SourceP() {
+ var model = scicos_model();
+
+ this.P0 = 300000;
+ this.T0 = 290;
+ this.H0 = 100000;
+ this.option_temperature = 1;
+
+ model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]);
+ model.sim = new ScilabString(["Source"]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+
+ var mo = modelica();
+ mo.model = new ScilabString(["Source"]);
+ mo.inputs = new ScilabDouble();
+ mo.outputs = new ScilabString(["C"]);
+ mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]));
+ model.equations = mo;
+ model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1));
+ model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1));
+
+ var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SourceP\",sz(1),sz(2));"]);
+ this.x = new standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble([0])));
+ this.x.graphics.out_implicit = new ScilabString(["I"]);
+ return new BasicBlock(this.x);
+ }
+
+ SourceP.prototype.details = function SourceP() {
+ return this.x;
+ }
+}