Index: mttroot/mtt/bin/trans/m/rbg2abg.m ================================================================== --- mttroot/mtt/bin/trans/m/rbg2abg.m +++ mttroot/mtt/bin/trans/m/rbg2abg.m @@ -3,10 +3,14 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.26 1998/04/16 14:07:51 peterg +% %% Sorted out [] problem with vector ports -- new octave function +% %% split_port +% %% % %% Revision 1.25 1998/04/12 15:01:04 peterg % %% Converted to uniform port notation - always use [] % %% % %% Revision 1.24 1998/02/19 08:57:16 peterg % %% Fixed mtt-info bug -- confused filename with number @@ -158,25 +162,26 @@ end; %The (signed) bond corresponding to the ith port label port_bond(i) = near_bond(1)*sign(1.5-near_bond(2)); end; - +port_bond %We now have the (signed) bond (port_bond(i)) correponding to the % ith port label within the component % Locate the components at the ends of each bond % col 1 of comp_near_bond contain the component nearest to the arrow end % col 2 of comp_near_bond contain the component nearest to the other end for i = 1:n_bonds comp_near_bond(i,:) = adjcomp(arrow_end(i,:),other_end(i,:),rcomponents); end; - +comp_near_bond % We now have a list (comp_near_bond) of the component(s) at each end % of each bond % Now do a list of the bonds on each component - unsorted at this stage. +% Also expand aliases using the alias list for each component components = []; for i = 1:n_components %Get component type eval(['[comp_type, comp_name] = ', name, '_cmp(i)']); @@ -196,14 +201,37 @@ if unique(bond_list)==0 mtt_info(sprintf("Component %s (%s) is at both ends of a bond", comp_name, comp_type),fnum); end; - bond_end = index(:,2); % which end of bond at component? + + % which end of bond at component? + bond_end = index(:,2); direction = -sign(bond_end-1.5*one); - signed_bond_list = bond_list.*direction; + signed_bond_list = bond_list.*direction components = add_bond(components,signed_bond_list',i); + + % Unalias all the ports on this component - if not a junction + if ((comp_type!="0")&&(comp_type!="1")) + eval( ["alias = ", comp_type, '_alias']); # Get aliases + if is_struct(alias) # are there any aliases + for j=1:n_comp_bonds + port_name_index = getindex(port_bond,signed_bond_list(j)) + if port_name_index>0 # There is a port on this bond + port_name_i = deblank(port_name(port_name_index,:)); + port_name_i = port_name_i(2:length(port_name_i)-1) # strip [] + if struct_contains(alias,port_name_i) # Is this an alias? + eval(["new_port_name_i = alias.",port_name_i]); + mtt_info(["Expanding port name " port_name_i " of component " \ + comp_name " (" comp_type ") to ", new_port_name_i],fnum); + port_name = replace_name(port_name, \ + ["[",new_port_name_i,"]"], port_name_index); + end + end + end + end + end end; components % Deduce causality from the strokes (if any) and create the list of bonds @@ -388,11 +416,17 @@ %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); + 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_info(portnames,fnum); end; %Compute the number of labeled ports [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list); if m_unsorted_ports==0