summaryrefslogtreecommitdiff
path: root/js/Misc/CONSTRAINT2_c.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/Misc/CONSTRAINT2_c.js')
-rw-r--r--js/Misc/CONSTRAINT2_c.js89
1 files changed, 45 insertions, 44 deletions
diff --git a/js/Misc/CONSTRAINT2_c.js b/js/Misc/CONSTRAINT2_c.js
index 4d755545..50012f65 100644
--- a/js/Misc/CONSTRAINT2_c.js
+++ b/js/Misc/CONSTRAINT2_c.js
@@ -14,59 +14,60 @@ function CONSTRAINT2_c() {
model.dep_ut = [false,true];
exprs = list(strcat(sci2exp(x0)),strcat(sci2exp(xd0)),strcat(sci2exp(id)));
gr_i = [];
- x = standard_define([3,2],model,exprs,gr_i);
+ this.x = standard_define([3,2],model,exprs,gr_i);
}
CONSTRAINT2_c.prototype.details = function CONSTRAINT2_c() {
+ return this.x;
}
CONSTRAINT2_c.prototype.get = function CONSTRAINT2_c() {
}
CONSTRAINT2_c.prototype.set = function CONSTRAINT2_c() {
- x = arg1;
+ this.x = arg1;
graphics = arg1.graphics;
exprs = graphics.exprs;
model = arg1.model;
while (true) {
- ask_again = false;
- [ok,x0,xd0,id,exprs] = scicos_getvalue("Set Constraint block parameters",[["Initial guess values of states x"],["Initial guess values of derivative x\'"],["Id(i)=1: if x\'(i) is present in the feedback, else Id(i)=0"]],list("vec",-1,"vec",-1,"vec",-1),exprs);
- if (!ok) {
-break;
-}
- x0 = x0.slice();
- N = size(x0,"*");
- xd0 = xd0.slice();
- Nxd = size(xd0,"*");
- id = id.slice();
- Nid = size(id,"*");
- if ((N!=Nxd)||(N!=Nid)) {
-message("incompatible sizes, states, their derivatives, and ID should be the same size ");
- ask_again = true;
-}
- if ((N<=0&&!ask_again)) {
-x_message("number of states (constraints) must be > 0 ");
- ask_again = true;
-}
- if ((!ask_again)) {
-for (i=1;i<=N;i+=1) {
- if (!((id[i-1]==0)||(id[i-1]==1))) {
- ask_again = true;
-x_message([["Id(i) must be either"],["0 when x\'(i) is not present in the feedback"],["1: when x\'(i) is present in the feedback"]]);
-break;
-}
- if ((id[i-1]==0)) {
- id[i-1] = -1;
-}
-}
-}
- if (!ask_again) {
- graphics.exprs = exprs;
- model.state = [[x0],[xd0]];
- model.out = [[N],[N]];
- model.in1 = N;
- model.ipar = id;
- x.graphics = graphics;
- x.model = model;
-break;
-}
-}
+ ask_again = false;
+ [ok,x0,xd0,id,exprs] = scicos_getvalue("Set Constraint block parameters",[["Initial guess values of states x"],["Initial guess values of derivative x\'"],["Id(i)=1: if x\'(i) is present in the feedback, else Id(i)=0"]],list("vec",-1,"vec",-1,"vec",-1),exprs);
+ if (!ok) {
+ break;
+ }
+ x0 = x0.slice();
+ N = size(x0,"*");
+ xd0 = xd0.slice();
+ Nxd = size(xd0,"*");
+ id = id.slice();
+ Nid = size(id,"*");
+ if ((N!=Nxd)||(N!=Nid)) {
+ message("incompatible sizes, states, their derivatives, and ID should be the same size ");
+ ask_again = true;
+ }
+ if ((N<=0&&!ask_again)) {
+ x_message("number of states (constraints) must be > 0 ");
+ ask_again = true;
+ }
+ if ((!ask_again)) {
+ for (i=1;i<=N;i+=1) {
+ if (!((id[i-1]==0)||(id[i-1]==1))) {
+ ask_again = true;
+ x_message([["Id(i) must be either"],["0 when x\'(i) is not present in the feedback"],["1: when x\'(i) is present in the feedback"]]);
+ break;
+ }
+ if ((id[i-1]==0)) {
+ id[i-1] = -1;
+ }
+ }
+ }
+ if (!ask_again) {
+ graphics.exprs = exprs;
+ model.state = [[x0],[xd0]];
+ model.out = [[N],[N]];
+ model.in1 = N;
+ model.ipar = id;
+ this.x.graphics = graphics;
+ this.x.model = model;
+ break;
+ }
+ }
}
}