Differences From Artifact [e2573b8bd0]:

To Artifact [c289a11e44]:


13
14
15
16
17
18
19



20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+







% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.24  1998/06/25 17:45:03  peterg
% %% No change -- but checked that explicit causality works!
% %%
% %% Revision 1.23  1998/04/04 10:46:37  peterg
% %% Coerces port bonds to have smae direction as the imposing bonds
% %% _cbg now generates the (coerced) components as welll as the (coerced)
% %% causality.
% %%
% %% Revision 1.22  1997/08/19 10:21:09  peterg
% %% Only copy port cuaslity info if not already set within the
258
259
260
261
262
263
264



265
266
267
268
269
270
271
272
273
274
275
276

277
278
279
280

281
282













283
284
285
286
287
288
289
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309







+
+
+











-
+




+


+
+
+
+
+
+
+
+
+
+
+
+
+







	end;
	if strcmp(comp_type,'1')
	  comp_type = 'one';
	end;
      
	% Component causality procedure name
	cause_name = [comp_type, '_cause'];

	% Component equation procedure name
	eqn_name = [comp_type, '_eqn'];
	
        % Bonds on this component (arrow-orientated) -- these become the
        % port bonds on the ith component of this subsystem.
	
	comp_bonds=[];
	for kk = 1:n_bonds
	  comp_bonds(kk,:) = bonds(bond_list(kk),:);
	end;
	

      % Invoke  the appropriate causality procedure
      if exist(cause_name)~=2 % Try a compound component
      if exist(eqn_name)~=2 % Try a compound component
        % Port status depends on whether the corresponding bonds are
        %  fully causal at this stage.
        one = ones(n_bonds,1);
        port_status = (sum(abs(comp_bonds'))'==2*one) - one;

	% Direction of bonds on the ports (0 if next to port)
	port_bond_direction = -sign(components(i,1:n_bonds))';

	% If there is a predefined causality function; use it
        if exist(cause_name)==2
    	  % Convert from arrow orientated to component orientated causality
	  comp_bonds = comp_bonds.*(port_bond_direction*[1 1]);
	
          % Evaluate the built-in causality procedure
	  eval([ '[comp_bonds] = ', cause_name, '(comp_bonds);' ]);

         % and convert from component orientated to arrow orientated causality
         comp_bonds = comp_bonds.*(port_bond_direction*[1 1]); 
        end;

	[comp_bonds,s] = abg2cbg(name, comp_type, full_name, 
            comp_bonds, port_bond_direction, port_status, ...
	    typefile, infofile);
	
	% Create a single status from the status vector s
	if max(abs(s)) == 0 % Causal
	  status(i) = 0;
301
302
303
304
305
306
307
308
309


310
311
312
313
314
315
316
321
322
323
324
325
326
327


328
329
330
331
332
333
334
335
336







-
-
+
+








	% Convert from arrow orientated to component orientated causality
	comp_bonds = comp_bonds.*direction;
	
        % Evaluate the built-in causality procedure
	eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);

       % and convert from component orientated to arrow orientated causality
       comp_bonds = comp_bonds.*direction; 
        % and convert from component orientated to arrow orientated causality
        comp_bonds = comp_bonds.*direction; 
       
       comp_bonds_out = comp_bonds
      end;
      
      % Update the full bonds list
      bonds(bond_list,:) = comp_bonds
    end;

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]