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);
17 // Rewrite tkscaleblk so it minds sciblk2's syntax
18 wMode = warning("query");
20 function [xd, tvec, z, x, outptr] = tkscaleblk(flag, nevprt, t, x, z, rpar, ipar, inptr)
24 slider = get("-38f07e57:12bd41b596e:-7f2b#slider");
27 // Calculate real value
28 value = get(slider,"value") / rpar(3);
30 w = get("-38f07e57:12bd41b596e:-7f2b");
32 set(w, "info_message", string(value));
40 // If already exists (stopped) then reuse
41 f = get("-38f07e57:12bd41b596e:-7f2b");
46 f = figure("Figure_name", "TK Source: " + "", ...
47 "dockable", "off", ...
48 "infobar_visible" , "on", ...
49 "toolbar", "none", ...
50 "menubar_visible", "off", ...
51 "menubar", "none", ...
52 "backgroundcolor", [1 1 1], ...
53 "default_axes", "off", ...
54 "figure_size", [180 350], ...
55 "layout", "border", ...
56 "figure_position", [40 40], ...
57 "Tag", "-38f07e57:12bd41b596e:-7f2b");
59 frame_slider = uicontrol(f, ...
61 "constraints", createConstraints("border", "left", [180, 0]), ...
62 "border", createBorder("line", "lightGray", 1), ...
63 "backgroundcolor", [1 1 1], ...
68 initial = mean(bounds);
69 uicontrol(frame_slider, ...
70 "Style", "slider", ...
71 "Tag", "-38f07e57:12bd41b596e:-7f2b#slider", ...
75 "Position", [0 0 10 20], ...
76 "SliderStep", [rpar(3) 2*rpar(3)]);
78 frame_label = uicontrol(frame_slider, ...
80 "constraints", createConstraints("border", "right"), ...
81 "backgroundcolor", [1 1 1], ...
85 labels = string([bounds(2) ; ...
86 mean([bounds(2) initial]) ; ...
88 mean([bounds(1) initial]) ; ...
90 labels = "<html>" + strcat(labels, "<br /><br /><br />") + "</html>";
92 uicontrol(frame_label, ...
94 "String", labels(1), ...
95 "FontWeight", "bold", ...
96 "backgroundcolor", [1 1 1]);
98 // Update default value
99 outptr = list(initial / rpar(3));
100 elseif flag == 5 then
102 f = get("-38f07e57:12bd41b596e:-7f2b");
112 cpr = scicos_simulate(scs_m);
120 // Check the sensitive value of the continuous state
121 assert_checkalmostequal(list2vec(cpr(2)(2)(9)), cpr229);
124 // Load and run a diagram that calls a Scilab macro (anim_pen.sci)
125 exec("SCI/modules/scicos/tests/unit_tests/pendulum_anim5.cosf", -1);
126 // Call sciblk2 instead of sciblk4
127 scs_m.objs(8).model.sim = list("anim_pen", 3);
129 // Rewrite anim_pen so it minds sciblk2's syntax
130 wMode = warning("query");
132 function [xd, tvec, z, x, outptr] = anim_pen(flag, nevprt, t, x, z, rpar, ipar, inptr)
145 set("figure_style","new")
149 Axe.data_bounds=rpar(4:7)
152 S=[cos(phi),-sin(phi);sin(phi),cos(phi)]
153 XY=S*[rpar(4),rpar(5);-csiz,-csiz]
154 gca().foreground = 3;
155 xsegs(XY(1,:),XY(2,:)-rcirc)
163 XY=S*[x1 x2 x2 x1 x1;y1,y1,y2,y2,y1]
164 gca().foreground = 5;
165 xfpoly(XY(1,:),XY(2,:))// cart
166 gca().foreground = 2;
167 xfarc(XY(1,1),XY(2,1),rcirc,rcirc,0,360*64) //wheel
168 xfarc(XY(1,2),XY(2,2),rcirc,rcirc,0,360*64) //wheel
170 XY=S*[xTemp,xTemp+plen*sin(theta);0,0+plen*cos(theta)]//pendulum
171 xsegs(XY(1,:),XY(2,:))
179 XY=Axe.children(4).data'+ [cos(phi)*(xTemp-xold);sin(phi)*(xTemp-xold)]*ones(1,5)
180 Axe.children(4).data=XY'
182 Axe.children(3).data(1)=XY(1,1)
183 Axe.children(3).data(2)=XY(2,1)
184 XY=Axe.children(4).data'+ [cos(phi)*(xTemp-xold-rcirc);sin(phi)*(xTemp-xold-rcirc)]*ones(1,5)
185 Axe.children(2).data(1)=XY(1,2)
186 Axe.children(2).data(2)=XY(2,2)
189 XY=[x1,x1+plen*sin(theta);y1,y1+plen*cos(theta)]
190 Axe.children(1).data=XY'
200 cpr = scicos_simulate(scs_m);
203 -0.00000010072892435; ...
204 -0.0000000093251865; ...
205 12.731754622278423; ...
206 0.00000000775393652; ...
207 -0.00000007274473145; ...
208 0.00000008598899216; ...
209 -0.00000000636625628; ...
210 -0.00000010072892435;
211 -0.0000000093251865; ...
212 -0.00000100269157242; ...
213 12.7317556249699955; ];
215 // Check the sensitive value of the continuous state
216 assert_checkalmostequal(list2vec(cpr(2)(2)(9)), cpr229, [], 1e9);