1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2015 - Scilab Enterprises - Paul Bignier
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
9 // <-- ENGLISH IMPOSED -->
11 // Load and run a diagram that calls a Scilab macro (tkscaleblk.sci)
12 exec("SCI/modules/scicos/tests/unit_tests/bug_8348.cosf", -1);
13 // Call sciblk2 instead of sciblk4
14 scs_m.objs(1).model.sim = list("tkscaleblk", 3);
16 // Rewrite tkscaleblk so it minds sciblk2's syntax
17 wMode = warning("query");
19 function [xd, tvec, z, x, outptr] = tkscaleblk(flag, nevprt, t, x, z, rpar, ipar, inptr)
23 slider = get("-38f07e57:12bd41b596e:-7f2b#slider");
25 // Calculate real value
26 value = get(slider,"value") / rpar(3);
27 w = get("-38f07e57:12bd41b596e:-7f2b");
29 set(w, "info_message", string(value));
35 // If already exists (stopped) then reuse
36 f = get("-38f07e57:12bd41b596e:-7f2b");
40 f = figure("Figure_name", "TK Source: " + "", ...
41 "dockable", "off", ...
42 "infobar_visible" , "on", ...
43 "toolbar", "none", ...
44 "menubar_visible", "off", ...
45 "menubar", "none", ...
46 "backgroundcolor", [1 1 1], ...
47 "default_axes", "off", ...
48 "figure_size", [180 350], ...
49 "layout", "border", ...
50 "figure_position", [40 40], ...
51 "Tag", "-38f07e57:12bd41b596e:-7f2b");
52 frame_slider = uicontrol(f, ...
54 "constraints", createConstraints("border", "left", [180, 0]), ...
55 "border", createBorder("line", "lightGray", 1), ...
56 "backgroundcolor", [1 1 1], ...
60 initial = mean(bounds);
61 uicontrol(frame_slider, ...
62 "Style", "slider", ...
63 "Tag", "-38f07e57:12bd41b596e:-7f2b#slider", ...
67 "Position", [0 0 10 20], ...
68 "SliderStep", [rpar(3) 2*rpar(3)]);
69 frame_label = uicontrol(frame_slider, ...
71 "constraints", createConstraints("border", "right"), ...
72 "backgroundcolor", [1 1 1], ...
75 labels = string([bounds(2) ; ...
76 mean([bounds(2) initial]) ; ...
78 mean([bounds(1) initial]) ; ...
80 labels = "<html>" + strcat(labels, "<br /><br /><br />") + "</html>";
81 uicontrol(frame_label, ...
83 "String", labels(1), ...
84 "FontWeight", "bold", ...
85 "backgroundcolor", [1 1 1]);
86 // Update default value
87 outptr = list(initial / rpar(3));
90 f = get("-38f07e57:12bd41b596e:-7f2b");
99 cpr = scicos_simulate(scs_m);
105 // Check the sensitive value of the continuous state
106 assert_checkalmostequal(list2vec(cpr(2)(2)(9)), cpr229);
108 // Load and run a diagram that calls a Scilab macro (anim_pen.sci)
109 exec("SCI/modules/scicos/tests/unit_tests/pendulum_anim5.cosf", -1);
110 // Call sciblk2 instead of sciblk4
111 scs_m.objs(8).model.sim = list("anim_pen", 3);
112 // Rewrite anim_pen so it minds sciblk2's syntax
113 wMode = warning("query");
115 function [xd, tvec, z, x, outptr] = anim_pen(flag, nevprt, t, x, z, rpar, ipar, inptr)
128 set("figure_style","new")
132 Axe.data_bounds=rpar(4:7)
134 S=[cos(phi),-sin(phi);sin(phi),cos(phi)]
135 XY=S*[rpar(4),rpar(5);-csiz,-csiz]
136 gca().foreground = 3;
137 xsegs(XY(1,:),XY(2,:)-rcirc)
144 XY=S*[x1 x2 x2 x1 x1;y1,y1,y2,y2,y1]
145 gca().foreground = 5;
146 xfpoly(XY(1,:),XY(2,:))// cart
147 gca().foreground = 2;
148 xfarc(XY(1,1),XY(2,1),rcirc,rcirc,0,360*64) //wheel
149 xfarc(XY(1,2),XY(2,2),rcirc,rcirc,0,360*64) //wheel
150 XY=S*[xTemp,xTemp+plen*sin(theta);0,0+plen*cos(theta)]//pendulum
151 xsegs(XY(1,:),XY(2,:))
158 XY=Axe.children(4).data'+ [cos(phi)*(xTemp-xold);sin(phi)*(xTemp-xold)]*ones(1,5)
159 Axe.children(4).data=XY'
160 Axe.children(3).data(1)=XY(1,1)
161 Axe.children(3).data(2)=XY(2,1)
162 XY=Axe.children(4).data'+ [cos(phi)*(xTemp-xold-rcirc);sin(phi)*(xTemp-xold-rcirc)]*ones(1,5)
163 Axe.children(2).data(1)=XY(1,2)
164 Axe.children(2).data(2)=XY(2,2)
167 XY=[x1,x1+plen*sin(theta);y1,y1+plen*cos(theta)]
168 Axe.children(1).data=XY'
177 cpr = scicos_simulate(scs_m);
178 INTEGRAL('set'): Wrong type for block parameter 'Initial Condition': v
179 ec(-1) expected, getting z0
180 INTEGRAL('set'): Wrong type for block parameter 'Initial Condition': v
181 ec(-1) expected, getting th0 Generate a loader file
183 ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
184 ilib_gen_Make: Copy inv_pend.c to TMPDIR
185 ilib_gen_Make: configure : Generate Makefile.
186 ilib_gen_Make: Modification of the Makefile in TMPDIR.
188 Generate a cleaner file
189 Shared archive loaded.
191 INTEGRAL('set'): Wrong type for block parameter 'Initial Condition': v
192 ec(-1) expected, getting z0
193 INTEGRAL('set'): Wrong type for block parameter 'Initial Condition': v
194 ec(-1) expected, getting th0
196 -0.00000010072892435; ...
197 -0.0000000093251865; ...
198 12.731754622278423; ...
199 0.00000000775393652; ...
200 -0.00000007274473145; ...
201 0.00000008598899216; ...
202 -0.00000000636625628; ...
203 -0.00000010072892435;
204 -0.0000000093251865; ...
205 -0.00000100269157242; ...
206 12.7317556249699955; ];
207 // Check the sensitive value of the continuous state
208 assert_checkalmostequal(list2vec(cpr(2)(2)(9)), cpr229, [], 1e9);