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
|
/* autogenerated from "macros/Sinks/WRITEC_f.sci" */
function WRITEC_f() {
WRITEC_f.prototype.define = function WRITEC_f() {
this.in = 1;
var nin = sum(this.in);
var frmt = "c ";
var fname = "foo";
this.swap = 0;
var lunit = 0;
this.N = 2;
this.model = scicos_model();
this.model.sim = list(new ScilabString(["writec"]), new ScilabDouble([2]));
this.model.in = new ScilabDouble([this.in]);
this.model.evtin = new ScilabDouble([1]);
this.model.dstate = new ScilabDouble([-1],[lunit],[zeros((nin+1)*this.N,1)]);
this.model.ipar = new ScilabDouble([length(fname)],[this._str2code[frmt-1]],[this.N],[this.swap],[this._str2code[fname-1]]);
this.model.blocktype = new ScilabString(["d"]);
this.model.dep_ut = new ScilabBoolean([true,false]);
var exprs = [[sci2exp(this.in)],[fname],[frmt],[string(this.N),string(this.swap)]];
var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"WRITEC_f\",sz(1),sz(2));"]);
this.x = new standard_define(new ScilabDouble([4,2]),this.model,new ScilabDouble(exprs),gr_i);
return new BasicBlock(this.x);
}
WRITEC_f.prototype.details = function WRITEC_f() {
return this.x;
}
WRITEC_f.prototype.get = function WRITEC_f() {
var exprs = this.graphics.exprs;
var ipar = this.model.ipar;
var dstate = this.model.dstate;
var lunit = dstate[2-1];
var fname = exprs[2-1];
var frmt = exprs[3-1];
this.set_param_popup_title = msprintf("Set %s block parameters","WRITEC_f");
var options = {
in:["Input Size",this.in],
fname1:["Output File Name",this.fname1],
frmt1:["Output Format",this.frmt1],
N:["Buffer Size",this.N],
swap:["Swap Mode (0:No, 1:Yes)",this.swap],
}
return options;
}
WRITEC_f.prototype.set = function WRITEC_f() {
var exprs = this.graphics.exprs;
var ipar = this.model.ipar;
var dstate = this.model.dstate;
var lunit = dstate[2-1];
var fname = exprs[2-1];
var frmt = exprs[3-1];
while (true) {
var ok = true;
this.in = parseFloat(arguments[0]["in"]);
this.fname1 = parseFloat(arguments[0]["fname1"]);
this.frmt1 = arguments[0]["frmt1"];
this.N = parseFloat(arguments[0]["N"]);
this.swap = parseFloat(arguments[0]["swap"]);
var exprs = [arguments[0]["in"], arguments[0]["fname1"], arguments[0]["frmt1"], arguments[0]["N"], arguments[0]["swap"]];
if (!ok) {
break;
}
this.in = int(this.in);
var nin = this.in;
this.fname1 = pathconvert(stripblanks(this.fname1),false,true);
this.frmt1 = stripblanks(this.frmt1);
var fmts = ["s","l","d","f","c","us","ul","uc","ull","uls","ubl","ubs","dl","fl","ll","sl","db","fb","lb","sb"];
if (and(this.frmt1!=fmts)) {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter: %s.","Input Format",this.frmt1),"Valid formats are: "+strcat(fmts,", "));
var ok = false;
} else if (this.alreadyran&&this.fname1!=fname) {
block_parameter_error(msprintf("You cannot modify \'%s\' when running","Input Format"),"End current simulation first.");
var ok = false;
} else if (this.alreadyran&&this.N!=ipar[5-1]) {
block_parameter_error(msprintf("You cannot modify \'Buffer Size\' when running.","Buffer Size"),"End current simulation first");
var ok = false;
} else if (this.fname1=="") {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter.","Output File Name"),"You must provide a filename.");
} else if (fileparts(this.fname1)!="") {
var tmpvar0 = fileparts(this.fname1);
var pa = tmpvar0[0];
var fn = tmpvar0[1];
var ex = tmpvar0[2];
if (!this.isdir[pa-1]) {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter.","Output File Name"),msprintf("Directory \'%s\' does not exist",pa));
var ok = false;
}
} else if (this.N<1) {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter: %d.","Buffer Size",this.N),"Strictly positive integer expected.");
var ok = false;
} else if (this.in<=0) {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter: %d.","Input Size",this.in),"Strictly positive integer expected.");
var ok = false;
} else if (this.swap!=0&&this.swap!=1) {
block_parameter_error(msprintf("Wrong value for \'%s\' parameter: %d.","Swap Mode",this.swap),msprintf("Must be in the interval %s.","[0, 1]"));
var ok = false;
}
this.frmt1 = part(this.frmt1,1,3);
if (ok) {
var ipar = [[length(this.fname1)],[this._str2code[this.frmt1-1]],[this.N],[this.swap],[this._str2code[this.fname1-1]]];
if (prod(size(dstate))!=(nin+1)*this.N+2) {
var dstate = [[-1],[lunit],[zeros((nin+1)*this.N,1)]];
}
this.model.in = new ScilabDouble([nin]);
this.model.dstate = new ScilabDouble(dstate);
this.model.ipar = new ScilabDouble(ipar);
this.graphics.exprs = new ScilabDouble([exprs]);
this.x.graphics = this.graphics;
this.x.model = this.model;
break;
}
}
return new BasicBlock(this.x);
}
WRITEC_f.prototype.get_popup_title = function WRITEC_f() {
return this.set_param_popup_title;
}
WRITEC_f.prototype.importset = function WRITEC_f() {
var graphics = this.x.graphics;
var ary = getData(graphics.exprs);
this.in = ary[0];
this.fname1 = ary[1];
this.frmt1 = ary[2];
this.N = ary[3];
this.swap = ary[4];
}
WRITEC_f.prototype.getContainer = function WRITEC_f() { return new BasicBlock(this.x); }
}
|