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.51 2004/02/20 20:42:40 geraint
## ## Initialize Flipped.cons with [] instead of "".
## ##
## ## Revision 1.50 2003/03/13 15:18:39 gawthrop
## ## Now uses __ to delimit subsystems in names.
## ##
## ## Revision 1.49 2001/07/26 05:02:53 geraint
|
>
>
>
>
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
## [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)
## ###############################################################
## ## Version control history
## ###############################################################
## ## $Id$
## ## $Log$
## ## Revision 1.52 2004/09/07 18:22:53 geraint
## ## Issues a more helpful error message than the cryptic Octave stuff
## ## if there are unconnected ports.
## ##
## ## Revision 1.51 2004/02/20 20:42:40 geraint
## ## Initialize Flipped.cons with [] instead of "".
## ##
## ## Revision 1.50 2003/03/13 15:18:39 gawthrop
## ## Now uses __ to delimit subsystems in names.
## ##
## ## Revision 1.49 2001/07/26 05:02:53 geraint
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
status = [];
return
end;
## Evaluate the system function to get the bonds and number of ports
##eval(["[bonds,components,n_ports,N_ports]=", fun_name, ";"]);
eval(["[ABG]=", fun_name, ";"]);
!struct_contains(ABG,"subsystems")
if !struct_contains(ABG,"subsystems")# Are there any subsystems?
return; # Nothing to do
else
[n_subsystems,junk] = size(struct_elements(ABG.subsystems))
endif
if struct_contains(ABG,"portlist")# Are there any ports?
[n_ports,junk] = size(ABG.portlist);
## port_bond_index=zeros(n_ports,1);
i_port = 0;
for i=1:n_ports # Find indices of the internal ports
name = deblank(ABG.portlist(i,:)); # Name of this port
eval(["port = ABG.ports.",name,";"]); # Extract port info
for j=1:length(port.connections) # Maybe vector SS
|
|
|
|
|
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
status = [];
return
end;
## Evaluate the system function to get the bonds and number of ports
##eval(["[bonds,components,n_ports,N_ports]=", fun_name, ";"]);
eval(["[ABG]=", fun_name, ";"]);
!isfield(ABG,"subsystems")
if !isfield(ABG,"subsystems")# Are there any subsystems?
return; # Nothing to do
else
[n_subsystems,junk] = size(fieldnames(ABG.subsystems))
endif
if isfield(ABG,"portlist")# Are there any ports?
[n_ports,junk] = size(ABG.portlist);
## port_bond_index=zeros(n_ports,1);
i_port = 0;
for i=1:n_ports # Find indices of the internal ports
name = deblank(ABG.portlist(i,:)); # Name of this port
eval(["port = ABG.ports.",name,";"]); # Extract port info
for j=1:length(port.connections) # Maybe vector SS
|
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
total = 2*n_bonds;
done = sum(sum(abs(ABG.bonds)))/total*100;
fields=["ports";"subsystems"]; # Do for both ports and subsystems -
## ports first
for i=1:2
field=deblank(fields(i,:));
if struct_contains(ABG,field);
eval(["ABG_field = ABG.",field, ";"]);
field,ABG_field
sum_ok = 0; n_comp = 0;
for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
eval(["ok = (ABG_field.",name,".status==0);"]);
sum_ok = sum_ok + ok; n_comp ++;
|
|
|
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
total = 2*n_bonds;
done = sum(sum(abs(ABG.bonds)))/total*100;
fields=["ports";"subsystems"]; # Do for both ports and subsystems -
## ports first
for i=1:2
field=deblank(fields(i,:));
if isfield(ABG,field);
eval(["ABG_field = ABG.",field, ";"]);
field,ABG_field
sum_ok = 0; n_comp = 0;
for [subsystem,name] = ABG_field# Find % status = 0 (causally complete)
eval(["ok = (ABG_field.",name,".status==0);"]);
sum_ok = sum_ok + ok; n_comp ++;
|
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
prefered = -prefered;
end;
ABG.bonds(ci_bond_index,1:2) = prefered*ci_direction'*[1 1]
eval(["ABG.subsystems.",name,".status=0"]); #set status of the C or I
endif
endwhile # ( ci_index>0)
eval(["ABG.",field," = ABG_field;"]); # Copy back to actual structure
endif # struct_contains(CBG,field(i,:));
endfor
## if n_ports>0
## status(1:n_ports) = zeros(n_ports,1); # Port status not relevant
## endif;
## Print final causality
## final_done = (sum(status==zeros(n_components,1))/n_components)*100;
|
|
|
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
prefered = -prefered;
end;
ABG.bonds(ci_bond_index,1:2) = prefered*ci_direction'*[1 1]
eval(["ABG.subsystems.",name,".status=0"]); #set status of the C or I
endif
endwhile # ( ci_index>0)
eval(["ABG.",field," = ABG_field;"]); # Copy back to actual structure
endif # isfield(CBG,field(i,:));
endfor
## if n_ports>0
## status(1:n_ports) = zeros(n_ports,1); # Port status not relevant
## endif;
## Print final causality
## final_done = (sum(status==zeros(n_components,1))/n_components)*100;
|