summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhitya Kamakshidasan2016-07-11 16:23:37 +0530
committerGitHub2016-07-11 16:23:37 +0530
commit3c55efcb3ce622ea006b0126460bc6d1536f9753 (patch)
tree3e91efd3fa580bd61e3175200e67f6e6a95473b8
parent2b8ff4319806419bf796a2b40ade9df6676cde18 (diff)
parent479d6c2a826b6c470731260860fe3e3a5906db7c (diff)
downloadxcos-on-web-3c55efcb3ce622ea006b0126460bc6d1536f9753.tar.gz
xcos-on-web-3c55efcb3ce622ea006b0126460bc6d1536f9753.tar.bz2
xcos-on-web-3c55efcb3ce622ea006b0126460bc6d1536f9753.zip
Merge pull request #161 from ASP1234/master
Implement SET,GET of CLOCK_c Block
-rw-r--r--data_structures_correct/CCS.js58
-rw-r--r--data_structures_correct/CLOCK_c.js16
2 files changed, 74 insertions, 0 deletions
diff --git a/data_structures_correct/CCS.js b/data_structures_correct/CCS.js
new file mode 100644
index 0000000..d1ca10c
--- /dev/null
+++ b/data_structures_correct/CCS.js
@@ -0,0 +1,58 @@
+function CCS() {
+
+ CCS.prototype.define = function CCS() {
+ this.ModelName = "CCS";
+ this.PrametersValue = new ScilabDouble();
+ this.ParametersName = new ScilabDouble();
+ var model = scicos_model();
+ this.Typein = [];
+ this.Typeout = [];
+ this.MI = [];
+ this.MO = [];
+ this.P = [[2,50,1,0],[70,98,2,0],[70,2,-2,0]];
+ this.PortName = [["Iin"],["p"],["n"]];
+
+ 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 = new modelica_function();
+ model.sim = new ScilabString([this.ModelName]);
+ mo.inputs = new ScilabString(...this.MI);
+ mo.outputs = new ScilabString(...this.MO);
+ model.rpar = this.PrametersValue;
+ mo.parameters = list(this.ParametersName, this.PrametersValue, new ScilabDouble(...zeros(getData(this.ParametersName))));
+ var exprs = new ScilabDouble();
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CCS\",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.1, 3]), model, exprs, list(new ScilabString([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);
+ }
+
+ CCS.prototype.details = function CCS() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/CLOCK_c.js b/data_structures_correct/CLOCK_c.js
index 1284626..b6910b2 100644
--- a/data_structures_correct/CLOCK_c.js
+++ b/data_structures_correct/CLOCK_c.js
@@ -1,4 +1,20 @@
function CLOCK_c() {
+
+ CLOCK_c.prototype.get = function CLOCK_c() {
+ var options = {
+ dt: ["Period", getData(this.x.model.rpar.objs[1].model.rpar)[0]],
+ t0: ["Initialisation Time", getData(this.x.model.rpar.objs[1].model.firing)],
+ };
+ return options;
+ }
+
+ CLOCK_c.prototype.set = function CLOCK_c() {
+ this.x.model.rpar.objs[1].model.firing = new ScilabDouble([arguments[0]["t0"]]);
+ this.x.model.rpar.objs[1].model.rpar = new ScilabDouble([arguments[0]["dt"]], [arguments[0]["t0"]]);
+ this.x.model.rpar.objs[1].graphics.exprs = new ScilabString([arguments[0]["dt"]], [arguments[0]["t0"]])
+ return new BasicBlock(this.x);
+ }
+
CLOCK_c.prototype.define = function CLOCK_c() {
var evtdly = new EVTDLY_c().internal();
evtdly.graphics.orig = new ScilabDouble([320, 232]);