1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/* autogenerated from "macros/Misc/scifunc_block.sci" */
function scifunc_block() {
scifunc_block.prototype.define = function scifunc_block() {
var in1 = 1;
var out = 1;
var clkin = [];
var clkout = [];
var x0 = [];
var z0 = [];
var typ = "c";
var auto = [];
this.rpar = [];
this.model = scicos_model();
this.model.sim = list(new ScilabString(["scifunc"]), new ScilabDouble([3]));
this.model.in = new ScilabDouble([in1]);
this.model.out = new ScilabDouble([out]);
this.model.evtin = new ScilabDouble(clkin);
this.model.evtout = new ScilabDouble(clkout);
this.model.state = new ScilabDouble(x0);
this.model.dstate = new ScilabDouble(z0);
this.model.rpar = new ScilabDouble(this.rpar);
this.model.ipar = new ScilabDouble([0]);
this.model.opar = list();
this.model.blocktype = new ScilabString([typ]);
this.model.firing = new ScilabDouble(auto);
this.model.dep_ut = new ScilabBoolean([true,false]);
var exprs = list([[sci2exp(in1)],[sci2exp(out)],[sci2exp(clkin)],[sci2exp(clkout)],[strcat(sci2exp(x0))],[strcat(sci2exp(z0))],[strcat(sci2exp(this.rpar))],[sci2exp(auto)]],list("y1=sin(u1)"," "," ","y1=sin(u1)"," "," "," "));
var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"scifunc_block\",sz(1),sz(2));"]);
this.x = new standard_define(new ScilabDouble([2,2]),this.model,exprs,gr_i);
return new BasicBlock(this.x);
}
scifunc_block.prototype.details = function scifunc_block() {
return this.x;
}
scifunc_block.prototype.get = function scifunc_block() {
var needcompile = 0;
var exprs = this.graphics.exprs;
if (size(exprs[1-1],"*")==8) {
exprs[1-1][9-1] = "0";
}
this.set_param_popup_title = "Set scifunc_block parameters";
var options = {
i:["input ports sizes",this.i],
o:["output port sizes",this.o],
ci:["input event ports sizes",this.ci],
co:["output events ports sizes",this.co],
xx:["initial continuous state",this.xx],
z:["initial discrete state",this.z],
rpar:["System parameters vector",this.rpar],
auto0:["initial firing vector (<0 for no firing)",this.auto0],
deptime:["is block always active (0:no, 1:yes)",this.deptime],
}
return options;
}
scifunc_block.prototype.set = function scifunc_block() {
var needcompile = 0;
var exprs = this.graphics.exprs;
if (size(exprs[1-1],"*")==8) {
exprs[1-1][9-1] = "0";
}
while (true) {
var ok = true;
this.i = parseFloat(arguments[0]["i"]);
this.o = parseFloat(arguments[0]["o"]);
this.ci = parseFloat(arguments[0]["ci"]);
this.co = parseFloat(arguments[0]["co"]);
this.xx = inverse(arguments[0]["xx"]);
this.z = inverse(arguments[0]["z"]);
this.rpar = inverse(arguments[0]["rpar"]);
this.auto0 = arguments[0]["auto0"];
this.deptime = arguments[0]["deptime"];
var lab = [arguments[0]["i"], arguments[0]["o"], arguments[0]["ci"], arguments[0]["co"], arguments[0]["xx"], arguments[0]["z"], arguments[0]["rpar"], arguments[0]["auto0"], arguments[0]["deptime"]];
if (!ok) {
break;
}
exprs[1-1] = lab;
this.xx = this.xx.slice();
this.z = this.z.slice();
this.rpar = this.rpar.slice();
var nrp = prod(size(this.rpar));
this.i = int(this.i.slice());
var ni = size(this.i,1);
this.o = int(this.o.slice());
var no = size(this.o,1);
this.ci = int(this.ci.slice());
var nci = size(this.ci,1);
this.co = int(this.co.slice());
var nco = size(this.co,1);
var tmpvar0 = genfunc1(exprs[2-1],this.i,this.o,nci,nco,size(this.xx,1),size(this.z,1),nrp,"c");
var ok = tmpvar0[0];
var tt = tmpvar0[1];
var dep_ut = tmpvar0[2];
dep_ut[2-1] = (1==this.deptime);
if (!ok) {
break;
}
var tmpvar1 = check_io(this.model,this.graphics,this.i,this.o,this.ci,this.co);
this.model = tmpvar1[0];
this.graphics = tmpvar1[1];
var ok = tmpvar1[2];
if (ok) {
var auto = this.auto0;
this.model.state = new ScilabDouble(this.xx);
this.model.dstate = new ScilabDouble(this.z);
this.model.rpar = new ScilabDouble(this.rpar);
if (this.model.ipar!=0) {
this.model.opar = new ScilabDouble([this.model.ipar]);
this.model.ipar = new ScilabDouble([0]);
}
if (or(this.model.opar!=tt)) {
var needcompile = 4;
}
this.model.opar = new ScilabDouble([tt]);
this.model.firing = new ScilabDouble([auto]);
this.model.dep_ut = new ScilabDouble([dep_ut]);
this.x.model = this.model;
exprs[2-1] = tt;
this.graphics.exprs = new ScilabDouble([exprs]);
this.x.graphics = this.graphics;
break;
}
}
needcompile = resume(needcompile)
return new BasicBlock(this.x);
}
scifunc_block.prototype.get_popup_title = function scifunc_block() {
return this.set_param_popup_title;
}
scifunc_block.prototype.importset = function scifunc_block() {
var graphics = this.x.graphics;
var ary = getData(graphics.exprs);
this.i = ary[0];
this.o = ary[1];
this.ci = ary[2];
this.co = ary[3];
this.xx = ary[4];
this.z = ary[5];
this.rpar = ary[6];
this.auto0 = ary[7];
this.deptime = ary[8];
}
scifunc_block.prototype.getContainer = function scifunc_block() { return new BasicBlock(this.x); }
}
|