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
|
/* autogenerated from "macros/Linear/GAINBLK.sci" */
function GAINBLK() {
GAINBLK.prototype.define = function GAINBLK() {
this.gain = 1;
var in1 = -1;
var out = -1;
var in2 = -2;
var out2 = -2;
this.model = scicos_model();
this.model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4]));
this.model.in = new ScilabDouble([in1]);
this.model.out = new ScilabDouble([out]);
this.model.in2 = new ScilabDouble([in2]);
this.model.out2 = new ScilabDouble([out2]);
this.model.rpar = new ScilabDouble([this.gain]);
this.model.blocktype = new ScilabString(["c"]);
this.model.dep_ut = new ScilabBoolean([true,false]);
this.exprs = [strcat(sci2exp(this.gain))];
this.gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAINBLK\",sz(1),sz(2));"]);
this.x = new standard_define(new ScilabDouble([2,2]),this.model,new ScilabDouble(this.exprs),this.gr_i);
return new BasicBlock(this.x);
}
GAINBLK.prototype.details = function GAINBLK() {
return this.x;
}
GAINBLK.prototype.get = function GAINBLK() {
var options = {
gain:["Gain",this.gain],
over:["Do On Overflow(0=Nothing 1=Saturate 2=Error)",this.over],
}
return options;
}
GAINBLK.prototype.set = function GAINBLK() {
this.gain = parseFloat(arguments[0]["gain"])
this.over = arguments[0]["over"]
this.exprs = inverse(arguments[0]["exprs"])
this.exprs = this.graphics.exprs;
if (size(this.exprs,"*")==1) {
this.exprs = [[this.exprs],[sci2exp(0)]];
}
while (true) {
[ok,this.gain,this.over,this.exprs] = scicos_getvalue("Set gain block parameters",["Gain","Do On Overflow(0=Nothing 1=Saturate 2=Error)"],list("mat",[-1,-1],"vec",1),this.exprs);
if (!ok) {
break;
}
if (this.gain==[]) {
message("Gain must have at least one element");
} else {
if (typeof(this.gain)=="constant") {
if (isreal(this.gain)) {
var it = 1;
var ot = 1;
this.model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4]));
this.model.rpar = new ScilabDouble(this.gain.slice());
this.model.opar = list();
} else {
message("type is not supported");
var ok = false;
}
} else {
if ((this.over==0)) {
if ((typeof(this.gain)=="int32")) {
var ot = 3;
this.model.sim = list(new ScilabString(["gainblk_i32n"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int16")) {
var ot = 4;
this.model.sim = list(new ScilabString(["gainblk_i16n"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int8")) {
var ot = 5;
this.model.sim = list(new ScilabString(["gainblk_i8n"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint32")) {
var ot = 6;
this.model.sim = list(new ScilabString(["gainblk_ui32n"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint16")) {
var ot = 7;
this.model.sim = list(new ScilabString(["gainblk_ui16n"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint8")) {
var ot = 8;
this.model.sim = list(new ScilabString(["gainblk_ui8n"]), new ScilabDouble([4]));
} else {
message("type is not supported.");
var ok = false;
}
} else if ((this.over==1)) {
if ((typeof(this.gain)=="int32")) {
var ot = 3;
this.model.sim = list(new ScilabString(["gainblk_i32s"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int16")) {
var ot = 4;
this.model.sim = list(new ScilabString(["gainblk_i16s"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int8")) {
var ot = 5;
this.model.sim = list(new ScilabString(["gainblk_i8s"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint32")) {
var ot = 6;
this.model.sim = list(new ScilabString(["gainblk_ui32s"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint16")) {
var ot = 7;
this.model.sim = list(new ScilabString(["gainblk_ui16s"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint8")) {
var ot = 8;
this.model.sim = list(new ScilabString(["gainblk_ui8s"]), new ScilabDouble([4]));
} else {
message("type is not supported.");
var ok = false;
}
} else if ((this.over==2)) {
if ((typeof(this.gain)=="int32")) {
var ot = 3;
this.model.sim = list(new ScilabString(["gainblk_i32e"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int16")) {
var ot = 4;
this.model.sim = list(new ScilabString(["gainblk_i16e"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="int8")) {
var ot = 5;
this.model.sim = list(new ScilabString(["gainblk_i8e"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint32")) {
var ot = 6;
this.model.sim = list(new ScilabString(["gainblk_ui32e"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint16")) {
var ot = 7;
this.model.sim = list(new ScilabString(["gainblk_ui16e"]), new ScilabDouble([4]));
} else if ((typeof(this.gain)=="uint8")) {
var ot = 8;
this.model.sim = list(new ScilabString(["gainblk_ui8e"]), new ScilabDouble([4]));
} else {
message("type is not an integer.");
var ok = false;
}
} else {
message("Do on Overflow must be 0,1,2");
var ok = false;
}
this.model.rpar = new ScilabDouble([]);
this.model.opar = list(this.gain.slice());
}
if (ok) {
var tmpvar0 = size(this.gain);
var out = tmpvar0[0];
var in1 = tmpvar0[1];
if (out*in1!=1) {
var tmpvar1 = set_io(this.model,this.graphics,list([in1,-1],ot),list([out,-1],ot),[],[]);
this.model = tmpvar1[0];
this.graphics = tmpvar1[1];
var ok = tmpvar1[2];
} else {
var tmpvar2 = set_io(this.model,this.graphics,list([-1,-2],ot),list([-1,-2],ot),[],[]);
this.model = tmpvar2[0];
this.graphics = tmpvar2[1];
var ok = tmpvar2[2];
}
}
if (ok) {
this.graphics.exprs = new ScilabDouble(this.exprs);
this.x.graphics = this.graphics;
this.x.model = this.model;
break;
}
}
}
return new BasicBlock(this.x);
}
}
|