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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/* autogenerated from "macros/Events/freq_div.sci" */
function freq_div() {
freq_div.prototype.define = function freq_div() {
var scs_m_1 = scicos_diagram();
scs_m_1.objs[1-1] = Modulo_Count("define");
scs_m_1.objs[2-1] = CLKINV_f("define");
scs_m_1.objs[3-1] = CLKOUTV_f("define");
scs_m_1.objs[4-1] = IFTHEL_f("define");
scs_m_1.objs[5-1] = CLKSPLIT_f("define");
scs_m_1.objs[6-1] = scicos_link();
scs_m_1.objs[7-1] = scicos_link();
scs_m_1.objs[8-1] = scicos_link();
scs_m_1.objs[9-1] = scicos_link();
scs_m_1.objs[10-1] = scicos_link();
var blk = scs_m_1.objs[1-1];
this.graphics = blk.graphics;
this.model = blk.model;
this.graphics.orig = new ScilabDouble([0,-100]);
this.graphics.sz = new ScilabDouble([60,40]);
this.graphics.exprs = new ScilabDouble(["0"],["3"]);
this.model.dstate = new ScilabDouble([3]);
this.model.ipar = new ScilabDouble([3]);
this.graphics.pout = new ScilabDouble([7]);
this.graphics.pein = new ScilabDouble([10]);
blk.graphics = this.graphics;
blk.model = this.model;
scs_m_1.objs[1-1] = blk;
var blk = scs_m_1.objs[2-1];
this.graphics = blk.graphics;
this.model = blk.model;
this.graphics.orig = new ScilabDouble([120,0]);
this.graphics.sz = new ScilabDouble([20,20]);
this.graphics.exprs = new ScilabDouble(["1"]);
this.model.ipar = new ScilabDouble([1]);
this.graphics.peout = new ScilabDouble([6]);
blk.graphics = this.graphics;
blk.model = this.model;
scs_m_1.objs[2-1] = blk;
var blk = scs_m_1.objs[3-1];
this.graphics = blk.graphics;
this.model = blk.model;
this.graphics.orig = new ScilabDouble([130,-160]);
this.graphics.sz = new ScilabDouble([20,20]);
this.graphics.exprs = new ScilabDouble(["1"]);
this.model.ipar = new ScilabDouble([1]);
this.graphics.pein = new ScilabDouble([8]);
blk.graphics = this.graphics;
blk.model = this.model;
scs_m_1.objs[3-1] = blk;
var blk = scs_m_1.objs[4-1];
this.graphics = blk.graphics;
this.model = blk.model;
this.graphics.orig = new ScilabDouble([100,-100]);
this.graphics.sz = new ScilabDouble([60,40]);
this.graphics.exprs = new ScilabDouble(["1"],["0"]);
this.model.ipar = new ScilabDouble([1]);
this.graphics.pin = new ScilabDouble([7]);
this.graphics.pein = new ScilabDouble([9]);
this.graphics.peout = new ScilabDouble([0],[8]);
blk.graphics = this.graphics;
blk.model = this.model;
scs_m_1.objs[4-1] = blk;
var blk = scs_m_1.objs[5-1];
this.graphics = blk.graphics;
this.model = blk.model;
this.graphics.orig = new ScilabDouble([127,-33]);
this.graphics.sz = new ScilabDouble([7,7]);
this.graphics.pein = new ScilabDouble([6]);
this.graphics.peout = new ScilabDouble([9],[10]);
blk.graphics = this.graphics;
blk.model = this.model;
scs_m_1.objs[5-1] = blk;
var lnk = scs_m_1.objs[6-1];
lnk.ct = [5,-1];
lnk.from = [2,1,0];
lnk.to = [5,1,1];
scs_m_1.objs[6-1] = lnk;
var lnk = scs_m_1.objs[7-1];
lnk.from = [1,1,0];
lnk.to = [4,1,1];
scs_m_1.objs[7-1] = lnk;
var lnk = scs_m_1.objs[8-1];
lnk.ct = [5,-1];
lnk.from = [4,2,0];
lnk.to = [3,1,1];
scs_m_1.objs[8-1] = lnk;
var lnk = scs_m_1.objs[9-1];
lnk.ct = [5,-1];
lnk.from = [5,1,0];
lnk.to = [4,1,1];
scs_m_1.objs[9-1] = lnk;
var lnk = scs_m_1.objs[10-1];
lnk.xx = [0,30,1];
lnk.yy = [0,-30,1];
lnk.ct = [5,-1];
lnk.from = [5,2,0];
lnk.to = [1,1,1];
scs_m_1.objs[10-1] = lnk;
blk={};
lnk={};
this.model = scicos_model();
this.model.sim = new ScilabString(["csuper"]);
this.model.evtin = new ScilabDouble([1]);
this.model.evtout = new ScilabDouble([1]);
this.model.rpar = scs_m_1;
var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"freq_div\",sz(1),sz(2));"]);
this.x = standard_define([3,2],this.model,[],gr_i);
return new BasicBlock(this.x);
}
freq_div.prototype.details = function freq_div() {
return this.x;
}
freq_div.prototype.get = function freq_div() {
var options = {
%ph:["Phase (0 to division factor -1)",%ph],
%df:["Division factor",%df],
}
return options;
}
freq_div.prototype.set = function freq_div() {
%ph = parseFloat(arguments[0]["%ph"])
%df = parseFloat(arguments[0]["%df"])
for (i=1;i<=length(arg1.model.rpar.objs);i+=1) {
var o = arg1.model.rpar.objs[i-1];
if (typeof(o)=="Block"&&o.gui=="Modulo_Count") {
var path = i;
break;
}
}
var newpar = list();
var y = 0;
var spath = list();
spath[$+1-1] = "model";
spath[$+1-1] = "rpar";
spath[$+1-1] = "objs";
spath[$+1-1] = path;
var xx = arg1[spath-1];
var xxn = xx;
this.graphics = xx.graphics;
var exprs = this.graphics.exprs;
this.model = xx.model;
while (true) {
[ok,%ph,%df,exprs] = scicos_getvalue("Set frequency division block parameters",["Phase (0 to division factor -1)","Division factor"],list("vec",1,"vec",1),exprs);
if (!ok) {
break;
}
if (ok) {
if (%df<1) {
%df = 1;
}
%ph = abs(%ph);
if (%ph>%df-1) {
%ph = %df-1;
}
this.graphics.exprs = new ScilabDouble(exprs);
this.model.ipar = new ScilabDouble([%df]);
this.model.dstate = new ScilabDouble([%ph]);
xxn.graphics = this.graphics;
xxn.model = this.model;
break;
}
}
if (diffobjs(xxn,xx)) {
this.model = xx.model;
var model_n = xxn.model;
if (!is_modelica_block(xx)) {
var modified = or(this.model.sim!=model_n.sim)||!isequal(this.model.state,model_n.state)||!isequal(this.model.dstate,model_n.dstate)||!isequal(this.model.rpar,model_n.rpar)||!isequal(this.model.ipar,model_n.ipar)||!isequal(this.model.label,model_n.label);
if (or(this.model.in1!=model_n.in1)||or(this.model.out!=model_n.out)) {
var needcompile = 1;
}
if (or(this.model.firing!=model_n.firing)) {
var needcompile = 2;
}
if (this.model.sim=="input"||this.model.sim=="output") {
if (this.model.ipar!=model_n.ipar) {
var needcompile = 4;
}
}
if (or(this.model.blocktype!=model_n.blocktype)||or(this.model.dep_ut!=model_n.dep_ut)) {
var needcompile = 4;
}
if ((this.model.nzcross!=model_n.nzcross)||(this.model.nmode!=model_n.nmode)) {
var needcompile = 4;
}
if (prod(size(model_n.sim))>1) {
if (model_n.sim[2-1]>1000) {
if (this.model.sim[1-1]!=model_n.sim[1-1]) {
var needcompile = 4;
}
}
}
} else {
var modified = or(model_n!=this.model);
var eq = this.model.equations;
var eqn = model_n.equations;
if (or(eq.model!=eqn.model)||or(eq.inputs!=eqn.inputs)||or(eq.outputs!=eqn.outputs)) {
var needcompile = 4;
}
}
arg1[spath-1] = xxn;
newpar[size(newpar)+1-1] = 1;
var y = max(y,needcompile);
}
this.x = arg1;
var typ = newpar;
return new BasicBlock(this.x);
}
}
|