1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
function [bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,infofile)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.31 1998/07/02 14:30:50 peterg
% %% Corrected various bugs - including resettting n_ports to correct value
% %%
% %% Revision 1.30 1998/07/02 13:40:50 peterg
% %% Added extra ports names (due to defaults) to relevant lists:
% %% port_name
% %% port_bond
|
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function [bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,infofile)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.32 1998/07/02 15:12:05 peterg
% %% Added hard error reporting
% %% Added error when two unlabled bonds point in.
% %%
% %% Revision 1.31 1998/07/02 14:30:50 peterg
% %% Corrected various bugs - including resettting n_ports to correct value
% %%
% %% Revision 1.30 1998/07/02 13:40:50 peterg
% %% Added extra ports names (due to defaults) to relevant lists:
% %% port_name
% %% port_bond
|
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
unsorted_port_list(k,:) = port_name(port_index,:);
end;
end;
else
k=0;
end;
%Either all ports or no ports should be labelled - write error
%message if this is not so
if (k~=0)&(k~=n_comp_bonds)
mtt_info(['Component ', comp_name, ' (', comp_type, ') has wrong number of labels'], fnum);
mtt_info(sprintf("\tit has %1.0f labels but should have 0 or \
%1.0f",k,n_comp_bonds), fnum);
portnames="";
for kk=1:k
portnames=sprintf("%s %s",portnames, unsorted_port_list(kk,:));
end;
mtt_error(portnames,fnum);
end;
%Compute the number of labeled ports
[n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
if m_unsorted_ports==0
n_unsorted_ports = 0;
end;
n_unsorted_ports,n_comp_bonds
% One port defaults:
if (n_comp_bonds==1)&(n_unsorted_ports==0)
%if (direction(1)<0) & ~strcmp(comp_type,'SS') % Wrong way for default
% mtt_error(['One-port ', comp_name, ' (', comp_type, ') has the sign pointing the wrong way '], fnum);
%end;
unsorted_port_list = port_list;
end;
%Two port defaults
if (n_comp_bonds==2)&(n_unsorted_ports==0)
if direction(1)==direction(2) % Wrong way for default
% mtt_error(['Two-port ', comp_name, ' (', comp_type, ') does not have through-pointing arrows'], fnum);
end;
if direction(1)==1 %in
% mtt_info([comp_name, ' in'],fnum);
unsorted_port_list = ['[in]';'[out]'];
else %reverse the order
% mtt_info([comp_name, ' out'],fnum);
unsorted_port_list = ['[out]';'[in]'];
end;
end;
% Recompute the number of unsorted ports
[n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
if m_unsorted_ports==0
n_unsorted_ports = 0;
end;
% Junctions or no lables(order of ports unimportant)
if strcmp(comp_type,'zero')|strcmp(comp_type,'one')
for j = 1:n_comp_bonds
components(i,j) = signed_bond_list(j);
end
else %Order of ports is important
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
unsorted_port_list(k,:) = port_name(port_index,:);
end;
end;
else
k=0;
end;
# %Either all ports or no ports should be labelled - write error
# %message if this is not so
# if (k~=0)&(k~=n_comp_bonds)
# mtt_info(['Component ', comp_name, ' (', comp_type, ') has wrong number of labels'], fnum);
# mtt_info(sprintf("\tit has %1.0f labels but should have 0 or \
# %1.0f",k,n_comp_bonds), fnum);
# portnames="";
# for kk=1:k
# portnames=sprintf("%s %s",portnames, unsorted_port_list(kk,:));
# end;
# mtt_error(portnames,fnum);
# end;
%Compute the number of labeled ports
[n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
if m_unsorted_ports==0
n_unsorted_ports = 0;
end;
# n_unsorted_ports,n_comp_bonds
# % One port defaults:
# if (n_comp_bonds==1)&(n_unsorted_ports==0)
# %if (direction(1)<0) & ~strcmp(comp_type,'SS') % Wrong way for default
# % mtt_error(['One-port ', comp_name, ' (', comp_type, ') has the sign pointing the wrong way '], fnum);
# %end;
# unsorted_port_list = port_list;
# end;
# %Two port defaults
# if (n_comp_bonds==2)&(n_unsorted_ports==0)
# if direction(1)==direction(2) % Wrong way for default
# % mtt_error(['Two-port ', comp_name, ' (', comp_type, ') does not have through-pointing arrows'], fnum);
# end;
# if direction(1)==1 %in
# % mtt_info([comp_name, ' in'],fnum);
# unsorted_port_list = ['[in]';'[out]'];
# else %reverse the order
# % mtt_info([comp_name, ' out'],fnum);
# unsorted_port_list = ['[out]';'[in]'];
# end;
# end;
# % Recompute the number of unsorted ports
# [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
# if m_unsorted_ports==0
# n_unsorted_ports = 0;
# end;
% Junctions or no lables(order of ports unimportant)
if strcmp(comp_type,'zero')|strcmp(comp_type,'one')
for j = 1:n_comp_bonds
components(i,j) = signed_bond_list(j);
end
else %Order of ports is important
|
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
|
mtt_error(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], fnum);
else
components(i,k) = signed_bond_list(j);
end;
end;
end;
end;
fclose(fnum);
|
<
<
|
562
563
564
565
566
567
568
569
570
571
572
573
574
|
mtt_error(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], fnum);
else
components(i,k) = signed_bond_list(j);
end;
end;
end;
end;
fclose(fnum);
|