Index: mttroot/mtt/bin/trans/m/abg2cbg.m ================================================================== --- mttroot/mtt/bin/trans/m/abg2cbg.m +++ mttroot/mtt/bin/trans/m/abg2cbg.m @@ -15,10 +15,14 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.19 1997/08/18 11:23:59 peterg +% %% Main component loop now misses out the ports (SS:[]) -- the causality +% %% is merely passed through these components. +% %% % %% Revision 1.18 1997/08/08 08:11:04 peterg % %% Suppress compoment trace. % %% % %% Revision 1.17 1997/08/07 16:10:13 peterg % %% Move the if status .. to the beginning of the main loop. @@ -158,11 +162,11 @@ if n_port_bonds~=n_ports mtt_info(sprintf('%s: %1.0f port bonds incompatible with %1.0f ports', ... full_name, n_port_bonds, n_ports), infofile); else % Copy the port bonds & status - j = abs(components(1:n_ports,1)); %relevant bond numbers + j = abs(components(1:n_ports,1)) % relevant bond numbers bonds(j,:) = port_bonds; status(1:n_ports) = port_status; end else n_port_bonds=0; @@ -181,11 +185,11 @@ % Inner loop propagates causality while done~=old_done % disp(sprintf('Causality is %3.0f%s complete.', done, pc)); old_done = done; - for i = n_port_bonds+1:n_components + for i = n_port_bonds+1:n_components % Miss out the ports if status(i) ~= 0 % only do this if causality not yet complete % Get the bonds on this component comp = nozeros(components(i,:)) bond_list = abs(comp); @@ -204,21 +208,30 @@ end; % Component causality procedure name cause_name = [comp_type, '_cause']; - % Bonds on this component (arrow-orientated) - port_bonds = bonds(bond_list,:); + % Bonds on this component (arrow-orientated) -- these become the + % port bonds on the ith component of this subsystem. + + % a bug in octave 1.92 (??) prevents this from working -- replace by + % a loop -- but check on V2.0 + % comp_bonds = bonds(bond_list,:) + + for kk = 1:n_comp + comp_bonds(kk,:) = bonds(comp(kk),:); + end; + % Invoke the appropriate causality procedure if exist(cause_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(port_bonds'))'==2*one) - one; - [port_bonds,s] = abg2cbg(name, comp_type, full_name, - port_bonds, port_status, ... + port_status = (sum(abs(comp_bonds'))'==2*one) - one; + [comp_bonds,s] = abg2cbg(name, comp_type, full_name, + comp_bonds, port_status, ... typefile, infofile); % Create a single status from the status vector s if max(abs(s)) == 0 % Causal status(i) = 0; @@ -229,29 +242,28 @@ status(i) = -1; end; end; else % its a simple component - port_bonds_in = port_bonds + comp_bonds_in = comp_bonds % Convert from arrow orientated to component orientated causality - port_bonds = port_bonds.*direction; + comp_bonds = comp_bonds.*direction; disp(['---', name, ' (', cause_name, ') ---']); % Evaluate the built-in causality procedure - eval([ '[port_bonds,status(i)] = ', cause_name, '(port_bonds);' ]); + eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]); % and convert from component orientated to arrow orientated causality - port_bonds = port_bonds.*direction; + comp_bonds = comp_bonds.*direction; - port_bonds_out = port_bonds - + comp_bonds_out = comp_bonds end; % Update the full bonds list - bonds(bond_list,:) = port_bonds + bonds(bond_list,:) = comp_bonds end; end; done = sum(sum(abs(bonds)))/total*100; %disp(sprintf('Causality is %3.0f%s complete.', done, pc), infofile)); @@ -302,14 +314,14 @@ cbgfilenum = fopen(file_name,'w'); write_cbg(cbgfilenum,full_name,system_type,bonds,status); fclose(cbgfilenum); % Return the port bonds - arrow orientated causality -if ~at_top_level %Not at top level +if ~at_top_level % Not at top level j = abs(components(1:n_ports,1)) %relevant bond numbers port_bonds = bonds(j,:) end; disp('===================================='); disp(['END: ', full_name, ' (', fun_name, ')']); disp('====================================');