1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2014 - Scilab Enterprises - Paul Bignier
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
8 // Allocate a diagram and access its fields
9 scs_m = scicos_diagram()
10 objectCreated( 1 , DIAGRAM )
11 propertyUpdated( 1 , DIAGRAM , TITLE ) : NO_CHANGES
12 propertyUpdated( 1 , DIAGRAM , PATH ) : NO_CHANGES
13 propertyUpdated( 1 , DIAGRAM , PROPERTIES ) : NO_CHANGES
14 propertyUpdated( 1 , DIAGRAM , PROPERTIES ) : NO_CHANGES
15 propertyUpdated( 1 , DIAGRAM , CONTEXT ) : NO_CHANGES
16 propertyUpdated( 1 , DIAGRAM , CHILDREN ) : NO_CHANGES
17 propertyUpdated( 1 , DIAGRAM , VERSION_NUMBER ) : NO_CHANGES
27 title = ["Untitled";""]
28 tol = [0.000001;0.000001;1.0000D-10;100001;0;1;0]
32 options = tlist("scsopt")
45 // Create a diagram containing 2 summation blocks and an empty link
46 Sum = BIGSOM_f("define");
47 objectCreated( 2 , BLOCK )
48 propertyUpdated( 2 , BLOCK , GEOMETRY ) : NO_CHANGES
49 propertyUpdated( 2 , BLOCK , GEOMETRY ) : SUCCESS
50 propertyUpdated( 2 , BLOCK , ANGLE ) : NO_CHANGES
51 propertyUpdated( 2 , BLOCK , ANGLE ) : NO_CHANGES
52 propertyUpdated( 2 , BLOCK , EXPRS ) : SUCCESS
53 objectCreated( 3 , PORT )
54 propertyUpdated( 3 , PORT , SOURCE_BLOCK ) : SUCCESS
55 propertyUpdated( 3 , PORT , PORT_KIND ) : SUCCESS
56 objectCreated( 4 , PORT )
57 propertyUpdated( 4 , PORT , SOURCE_BLOCK ) : SUCCESS
58 propertyUpdated( 4 , PORT , PORT_KIND ) : SUCCESS
59 propertyUpdated( 2 , BLOCK , INPUTS ) : SUCCESS
60 objectCreated( 5 , PORT )
61 propertyUpdated( 5 , PORT , SOURCE_BLOCK ) : SUCCESS
62 propertyUpdated( 5 , PORT , PORT_KIND ) : SUCCESS
63 propertyUpdated( 2 , BLOCK , OUTPUTS ) : SUCCESS
64 propertyUpdated( 2 , BLOCK , LABEL ) : NO_CHANGES
65 propertyUpdated( 3 , PORT , IMPLICIT ) : NO_CHANGES
66 propertyUpdated( 4 , PORT , IMPLICIT ) : NO_CHANGES
67 propertyUpdated( 5 , PORT , IMPLICIT ) : NO_CHANGES
68 propertyUpdated( 3 , PORT , STYLE ) : NO_CHANGES
69 propertyUpdated( 4 , PORT , STYLE ) : NO_CHANGES
70 propertyUpdated( 5 , PORT , STYLE ) : NO_CHANGES
71 propertyUpdated( 3 , PORT , LABEL ) : NO_CHANGES
72 propertyUpdated( 4 , PORT , LABEL ) : NO_CHANGES
73 propertyUpdated( 5 , PORT , LABEL ) : NO_CHANGES
74 propertyUpdated( 2 , BLOCK , STYLE ) : NO_CHANGES
75 propertyUpdated( 2 , BLOCK , SIM_FUNCTION_NAME ) : SUCCESS
76 propertyUpdated( 2 , BLOCK , SIM_FUNCTION_API ) : SUCCESS
77 propertyUpdated( 4 , PORT , DATATYPE ) : SUCCESS
78 propertyUpdated( 3 , PORT , DATATYPE ) : SUCCESS
79 propertyUpdated( 5 , PORT , DATATYPE ) : SUCCESS
80 propertyUpdated( 2 , BLOCK , STATE ) : NO_CHANGES
81 propertyUpdated( 2 , BLOCK , DSTATE ) : NO_CHANGES
82 propertyUpdated( 2 , BLOCK , RPAR ) : SUCCESS
83 propertyUpdated( 2 , BLOCK , IPAR ) : NO_CHANGES
84 propertyUpdated( 2 , BLOCK , SIM_BLOCKTYPE ) : SUCCESS
85 propertyUpdated( 2 , BLOCK , SIM_DEP_UT ) : SUCCESS
86 propertyUpdated( 2 , BLOCK , LABEL ) : NO_CHANGES
87 propertyUpdated( 2 , BLOCK , NZCROSS ) : NO_CHANGES
88 propertyUpdated( 2 , BLOCK , NMODE ) : NO_CHANGES
89 propertyUpdated( 2 , BLOCK , UID ) : NO_CHANGES
90 propertyUpdated( 2 , BLOCK , INTERFACE_FUNCTION ) : SUCCESS
91 Scope1 = CSCOPE("define");
92 objectCreated( 6 , BLOCK )
93 propertyUpdated( 6 , BLOCK , GEOMETRY ) : NO_CHANGES
94 propertyUpdated( 6 , BLOCK , GEOMETRY ) : SUCCESS
95 propertyUpdated( 6 , BLOCK , ANGLE ) : NO_CHANGES
96 propertyUpdated( 6 , BLOCK , ANGLE ) : NO_CHANGES
97 propertyUpdated( 6 , BLOCK , EXPRS ) : SUCCESS
98 objectCreated( 7 , PORT )
99 propertyUpdated( 7 , PORT , SOURCE_BLOCK ) : SUCCESS
100 propertyUpdated( 7 , PORT , PORT_KIND ) : SUCCESS
101 propertyUpdated( 6 , BLOCK , INPUTS ) : SUCCESS
102 objectCreated( 8 , PORT )
103 propertyUpdated( 8 , PORT , SOURCE_BLOCK ) : SUCCESS
104 propertyUpdated( 8 , PORT , PORT_KIND ) : SUCCESS
105 propertyUpdated( 6 , BLOCK , EVENT_INPUTS ) : SUCCESS
106 propertyUpdated( 6 , BLOCK , LABEL ) : NO_CHANGES
107 propertyUpdated( 7 , PORT , IMPLICIT ) : NO_CHANGES
108 propertyUpdated( 7 , PORT , STYLE ) : NO_CHANGES
109 propertyUpdated( 7 , PORT , LABEL ) : NO_CHANGES
110 propertyUpdated( 6 , BLOCK , STYLE ) : NO_CHANGES
111 propertyUpdated( 6 , BLOCK , SIM_FUNCTION_NAME ) : SUCCESS
112 propertyUpdated( 6 , BLOCK , SIM_FUNCTION_API ) : SUCCESS
113 propertyUpdated( 7 , PORT , DATATYPE ) : SUCCESS
114 propertyUpdated( 7 , PORT , DATATYPE ) : NO_CHANGES
115 propertyUpdated( 8 , PORT , DATATYPE ) : SUCCESS
116 propertyUpdated( 6 , BLOCK , STATE ) : NO_CHANGES
117 propertyUpdated( 6 , BLOCK , DSTATE ) : NO_CHANGES
118 propertyUpdated( 6 , BLOCK , RPAR ) : SUCCESS
119 propertyUpdated( 6 , BLOCK , IPAR ) : SUCCESS
120 propertyUpdated( 6 , BLOCK , SIM_BLOCKTYPE ) : SUCCESS
121 propertyUpdated( 6 , BLOCK , SIM_DEP_UT ) : SUCCESS
122 propertyUpdated( 6 , BLOCK , LABEL ) : NO_CHANGES
123 propertyUpdated( 6 , BLOCK , NZCROSS ) : NO_CHANGES
124 propertyUpdated( 6 , BLOCK , NMODE ) : NO_CHANGES
125 propertyUpdated( 6 , BLOCK , UID ) : NO_CHANGES
126 propertyUpdated( 6 , BLOCK , INTERFACE_FUNCTION ) : SUCCESS
127 Scope2 = CSCOPE("define");
128 objectCreated( 9 , BLOCK )
129 propertyUpdated( 9 , BLOCK , GEOMETRY ) : NO_CHANGES
130 propertyUpdated( 9 , BLOCK , GEOMETRY ) : SUCCESS
131 propertyUpdated( 9 , BLOCK , ANGLE ) : NO_CHANGES
132 propertyUpdated( 9 , BLOCK , ANGLE ) : NO_CHANGES
133 propertyUpdated( 9 , BLOCK , EXPRS ) : SUCCESS
134 objectCreated( 10 , PORT )
135 propertyUpdated( 10 , PORT , SOURCE_BLOCK ) : SUCCESS
136 propertyUpdated( 10 , PORT , PORT_KIND ) : SUCCESS
137 propertyUpdated( 9 , BLOCK , INPUTS ) : SUCCESS
138 objectCreated( 11 , PORT )
139 propertyUpdated( 11 , PORT , SOURCE_BLOCK ) : SUCCESS
140 propertyUpdated( 11 , PORT , PORT_KIND ) : SUCCESS
141 propertyUpdated( 9 , BLOCK , EVENT_INPUTS ) : SUCCESS
142 propertyUpdated( 9 , BLOCK , LABEL ) : NO_CHANGES
143 propertyUpdated( 10 , PORT , IMPLICIT ) : NO_CHANGES
144 propertyUpdated( 10 , PORT , STYLE ) : NO_CHANGES
145 propertyUpdated( 10 , PORT , LABEL ) : NO_CHANGES
146 propertyUpdated( 9 , BLOCK , STYLE ) : NO_CHANGES
147 propertyUpdated( 9 , BLOCK , SIM_FUNCTION_NAME ) : SUCCESS
148 propertyUpdated( 9 , BLOCK , SIM_FUNCTION_API ) : SUCCESS
149 propertyUpdated( 10 , PORT , DATATYPE ) : SUCCESS
150 propertyUpdated( 10 , PORT , DATATYPE ) : NO_CHANGES
151 propertyUpdated( 11 , PORT , DATATYPE ) : SUCCESS
152 propertyUpdated( 9 , BLOCK , STATE ) : NO_CHANGES
153 propertyUpdated( 9 , BLOCK , DSTATE ) : NO_CHANGES
154 propertyUpdated( 9 , BLOCK , RPAR ) : SUCCESS
155 propertyUpdated( 9 , BLOCK , IPAR ) : SUCCESS
156 propertyUpdated( 9 , BLOCK , SIM_BLOCKTYPE ) : SUCCESS
157 propertyUpdated( 9 , BLOCK , SIM_DEP_UT ) : SUCCESS
158 propertyUpdated( 9 , BLOCK , LABEL ) : NO_CHANGES
159 propertyUpdated( 9 , BLOCK , NZCROSS ) : NO_CHANGES
160 propertyUpdated( 9 , BLOCK , NMODE ) : NO_CHANGES
161 propertyUpdated( 9 , BLOCK , UID ) : NO_CHANGES
162 propertyUpdated( 9 , BLOCK , INTERFACE_FUNCTION ) : SUCCESS
163 lnk = scicos_link(); // Data link
164 objectCreated( 12 , LINK )
165 propertyUpdated( 12 , LINK , CONTROL_POINTS ) : NO_CHANGES
166 propertyUpdated( 12 , LINK , CONTROL_POINTS ) : NO_CHANGES
167 propertyUpdated( 12 , LINK , LABEL ) : NO_CHANGES
168 propertyUpdated( 12 , LINK , THICK ) : NO_CHANGES
169 propertyUpdated( 12 , LINK , COLOR ) : NO_CHANGES
170 propertyUpdated( 12 , LINK , KIND ) : NO_CHANGES
171 propertyUpdated( 12 , LINK , SOURCE_PORT ) : NO_CHANGES
172 propertyUpdated( 12 , LINK , DESTINATION_PORT ) : NO_CHANGES
173 lnk2 = scicos_link(ct=[1,-1]); // Activation link
174 objectCreated( 13 , LINK )
175 propertyUpdated( 13 , LINK , CONTROL_POINTS ) : NO_CHANGES
176 propertyUpdated( 13 , LINK , CONTROL_POINTS ) : NO_CHANGES
177 propertyUpdated( 13 , LINK , LABEL ) : NO_CHANGES
178 propertyUpdated( 13 , LINK , THICK ) : NO_CHANGES
179 propertyUpdated( 13 , LINK , COLOR ) : NO_CHANGES
180 propertyUpdated( 13 , LINK , KIND ) : SUCCESS
181 propertyUpdated( 13 , LINK , SOURCE_PORT ) : NO_CHANGES
182 propertyUpdated( 13 , LINK , DESTINATION_PORT ) : NO_CHANGES
183 scs_m = scicos_diagram( objs=list(Sum,Scope1,Scope2,lnk,lnk2) )
184 objectCreated( 14 , DIAGRAM )
185 propertyUpdated( 14 , DIAGRAM , TITLE ) : NO_CHANGES
186 propertyUpdated( 14 , DIAGRAM , PATH ) : NO_CHANGES
187 propertyUpdated( 14 , DIAGRAM , PROPERTIES ) : NO_CHANGES
188 propertyUpdated( 14 , DIAGRAM , PROPERTIES ) : NO_CHANGES
189 propertyUpdated( 14 , DIAGRAM , CONTEXT ) : NO_CHANGES
190 propertyUpdated( 2 , BLOCK , PARENT_DIAGRAM ) : SUCCESS
191 propertyUpdated( 6 , BLOCK , PARENT_DIAGRAM ) : SUCCESS
192 propertyUpdated( 9 , BLOCK , PARENT_DIAGRAM ) : SUCCESS
193 propertyUpdated( 12 , LINK , PARENT_DIAGRAM ) : SUCCESS
194 propertyUpdated( 13 , LINK , PARENT_DIAGRAM ) : SUCCESS
195 propertyUpdated( 14 , DIAGRAM , CHILDREN ) : SUCCESS
196 propertyUpdated( 14 , DIAGRAM , VERSION_NUMBER ) : NO_CHANGES
198 scicos_diagram type :
241 // Link output port #1 of block #1 with input port #1 of block #2
243 l(4).from = [1 1 0]; // Link block #1
244 propertyUpdated( 5 , PORT , CONNECTED_SIGNALS ) : SUCCESS
245 propertyUpdated( 12 , LINK , SOURCE_PORT ) : SUCCESS
246 l(1).graphics.pout // Check that block #1 is connected to the link
252 l(4).to = [2 1 1]; // Link block #2
253 propertyUpdated( 7 , PORT , CONNECTED_SIGNALS ) : SUCCESS
254 propertyUpdated( 12 , LINK , DESTINATION_PORT ) : SUCCESS
261 l(2).graphics.pin // Check that block #2 is connected to the link
267 // Change the end of the link to input port #2 of block #2
269 propertyUpdated( 7 , PORT , CONNECTED_SIGNALS ) : SUCCESS
270 objectCreated( 15 , PORT )
271 propertyUpdated( 15 , PORT , IMPLICIT ) : NO_CHANGES
272 propertyUpdated( 15 , PORT , PORT_KIND ) : SUCCESS
273 propertyUpdated( 15 , PORT , SOURCE_BLOCK ) : SUCCESS
274 propertyUpdated( 15 , PORT , CONNECTED_SIGNALS ) : NO_CHANGES
275 propertyUpdated( 15 , PORT , DATATYPE ) : SUCCESS
276 propertyUpdated( 6 , BLOCK , INPUTS ) : SUCCESS
277 propertyUpdated( 15 , PORT , CONNECTED_SIGNALS ) : SUCCESS
278 propertyUpdated( 12 , LINK , DESTINATION_PORT ) : SUCCESS
285 l(2).graphics.pin // Check that block #2 is connected to the link
293 // Disconnect the source, the destination is also disconnected
295 propertyUpdated( 5 , PORT , CONNECTED_SIGNALS ) : SUCCESS
296 propertyUpdated( 15 , PORT , CONNECTED_SIGNALS ) : SUCCESS
297 propertyUpdated( 12 , LINK , SOURCE_PORT ) : SUCCESS
298 propertyUpdated( 12 , LINK , DESTINATION_PORT ) : SUCCESS
305 l(1).graphics.pout // Check that both blocks are unconnected
308 l(2).graphics.pin // "
312 // Now link the two Scope blocks together by adding an event output port to block #3
313 l(5).from = [2 1 1]; // Link the input of block #2
314 propertyUpdated( 8 , PORT , CONNECTED_SIGNALS ) : SUCCESS
315 propertyUpdated( 13 , LINK , SOURCE_PORT ) : SUCCESS
316 l(5).to = [3 1 0]; // Add an event output to block #3 and link it to the previous
317 objectCreated( 16 , PORT )
318 propertyUpdated( 16 , PORT , IMPLICIT ) : NO_CHANGES
319 propertyUpdated( 16 , PORT , PORT_KIND ) : SUCCESS
320 propertyUpdated( 16 , PORT , SOURCE_BLOCK ) : SUCCESS
321 propertyUpdated( 16 , PORT , CONNECTED_SIGNALS ) : NO_CHANGES
322 propertyUpdated( 16 , PORT , DATATYPE ) : SUCCESS
323 propertyUpdated( 9 , BLOCK , EVENT_OUTPUTS ) : SUCCESS
324 propertyUpdated( 16 , PORT , CONNECTED_SIGNALS ) : SUCCESS
325 propertyUpdated( 13 , LINK , DESTINATION_PORT ) : SUCCESS
344 // Verify that it is impossible to link two inputs or two outputs together
345 l(5).from = [2 1 0]; // Two outputs
346 scicos_setfield: Wrong value for input argument #2: unable to set "from".
347 l(5).to = [3 1 1]; // Two inputs
348 scicos_setfield: Wrong value for input argument #2: unable to set "to".