Index: mttroot/mtt/bin/trans/m/cbg2ese.m ================================================================== --- mttroot/mtt/bin/trans/m/cbg2ese.m +++ mttroot/mtt/bin/trans/m/cbg2ese.m @@ -1,6 +1,7 @@ -function structure = cbg2ese(system_name, system_type, full_name, ... +function structure = cbg2ese(system_name, system_type, system_cr, ... + system_args, full_name, ... repetition,... structure, infofile) % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %%%%% Model Transformation Tools %%%%% @@ -13,10 +14,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.6 1996/08/27 08:04:52 peterg +% %% Handles complex components and repetative components. +% %% % %% Revision 1.5 1996/08/24 15:02:23 peter % %% Writes `END;' to keep reduce happy. % %% % %% Revision 1.4 1996/08/19 09:03:41 peter % %% Handles repeating components. @@ -60,10 +64,13 @@ end; % Setup file ese_name = sprintf('%s_%1.0f_ese.r', full_name, repetition); filenum = fopen(ese_name, 'w'); +fprintf(filenum, '\n%s%s Equation file for system %s (file %s)\n', ... + pc, pc, full_name, ese_name); +fprintf(filenum, '%s%s Generated by MTT\n\n', pc, pc); % Evaluate the system function to get the bonds eval(['[junk,components]=', abg_name, ';']); eval(['bonds=', cbg_name, ';']); % Find number of bonds @@ -79,11 +86,19 @@ comp = nozeros(components(i,:)); bond_list = abs(comp); direction = sign(comp)'*[1 1]; % Convert from arrow orientated to component orientated causality comp_bonds = bonds(bond_list,:).*direction; - eval([ '[comp_type,comp_name,cr,args,repetitions] = ', cmp_name, '(i);' ]); + + % Get the component details + eval([ '[comp_type,comp_name,cr,args,repetitions] = ', cmp_name, '(i);' ... + ]); + + % Substitute positional ($1 etc) arguments + cr = subs_arg(cr,system_cr); + args = subs_arg(args,system_args); + % change name of 0 and 1 components -- matlab doesn't like numbers here if strcmp(comp_type,'0') comp_type = 'zero'; end; if strcmp(comp_type,'1') @@ -128,16 +143,20 @@ end; % Invoke the appropriate equation-generating procedure name_r = sprintf('%s_%1.0f', full_name, repetition); eqn_name = [comp_type, '_eqn'] + if exist(eqn_name)~=2 % Try a compound component disp('---PUSH---'); - structure = cbg2ese(comp_name, comp_type, full_name, k, ... + structure = cbg2ese(comp_name, comp_type, cr, args, full_name, k, ... structure, infofile); + % Link up the bonds - name_k = sprintf('%s_%1.0f', full_name, k); + fprintf(filenum, ... + '\n\t%s Equations linking up subsystem %s (%s)\n\n', ... + pc, comp_name, comp_type); name_comp_name = sprintf('%s_%s_%1.0f', full_name, comp_name, k); for port_number=1:length(bond_list) % Effort if comp_bonds(port_number,1)==1 % Source @@ -161,10 +180,13 @@ end; end; disp('---POP---'); else % its a simple component + fprintf(filenum, '\n\t%s Equations for component %s (%s)\n\n', ... + pc, comp_name, comp_type); + eval(['structure = ', ... eqn_name, ... '(name_r,bond_list,comp_bonds,direction,cr,args,structure,filenum);' ]); end; end;