Overview
| Comment: | Compares full-name with empty string (instead of testing for zero length) |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | origin/master | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
558b159355fc9c1ab48faf21c83000d9 |
| User & Date: | gawthrop@users.sourceforge.net on 1996-12-04 21:49:47.000 |
| Other Links: | branch diff | manifest | tags |
Context
|
1996-12-04
| ||
| 21:51:02 |
Now uses filenum instead of line name. Uses fopen check-in: 86e3cc0ec8 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
| 21:49:47 |
Compares full-name with empty string (instead of testing for zero length) check-in: 558b159355 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
| 21:48:55 |
Compares full-name with empty string (instead of testing for zero length. check-in: a881d61f6d user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/bin/trans/m/cbg2ese.m
from [e724fb0e3a]
to [3e4a5831fd].
1 | function structure = cbg2ese(system_name, system_type, system_cr, ... | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
function structure = cbg2ese(system_name, system_type, system_cr, ...
system_args, full_name, full_name_repetition, ...
repetition,...
structure, infofile)
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%% Model Transformation Tools %%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function cbg2ese.m
% Acausal bond graph to causal bond graph: mfile format
% Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.8 1996/08/30 16:36:08 peter
% %% More info written to ese files.
% %%
% %% Revision 1.7 1996/08/30 11:23:13 peter
% %% Argument substitution implemented.
% %%
% %% 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
|
| ︙ | ︙ | |||
46 47 48 49 50 51 52 | eqnfile = 'stdout'; end; if nargin<4 infofile = 'stdout'; end; % Create the (full) system name | | > > > | | | < > | | > > > | > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
eqnfile = 'stdout';
end;
if nargin<4
infofile = 'stdout';
end;
% Create the (full) system name
if strcmp(full_name,'')
full_name = system_name;
full_name_repetition = system_name;
system_type = system_name;
else
full_name = [full_name, '_', system_name];
full_name_repetition = [full_name_repetition, ...
'_', system_name, '_', num2str(repetition)];
end;
% $$$ full_name_type = [full_name, '_', system_type];
% $$$ cbg_name = [full_name_type, '_cbg'];
cbg_name = [full_name, '_cbg'];
% Return if cbg file doesn't exist
if exist(cbg_name)~=2
disp([cbg_name, ' does not exist']);
return
end;
% Setup file
ese_name = [full_name_repetition, '_ese.r'];
filenum = fopen(ese_name, 'w');
fprintf(filenum, '\n%s%s Equation file for system %s (file %s)\n', ...
pc, pc, full_name_repetition, ese_name);
fprintf(filenum, '%s%s Generated by MTT\n\n', pc, pc);
% Evaluate the system function to get the bonds
eval(['[bonds,status,system_type] = ', cbg_name, ';']);
abg_name = [system_type, '_abg'];
cmp_name = [system_type, '_cmp'];
eval(['[junk,components]=', abg_name, ';']);
% Find number of bonds
[n_bonds,columns] = size(bonds);
if (columns ~= 2)&(n_bonds>0)
error('Incorrect bonds matrix: must have 2 columns');
end;
% Find number of components
[n_components,columns] = size(components);
n_components = n_components
% Set up the first dummy bond number - needed for repetative components
next_bond = max(max(abs(components)))+1;
for i = 1:n_components
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;
|
| ︙ | ︙ | |||
120 121 122 123 124 125 126 |
repetitions = 1;
end;
end;
if repetitions>1
odd_bonds = bond_list(1:2:ports-1);
even_bonds = bond_list(2:2:ports);
| < > > | | > | > > | < > | > | | | | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
repetitions = 1;
end;
end;
if repetitions>1
odd_bonds = bond_list(1:2:ports-1);
even_bonds = bond_list(2:2:ports);
end;
for k = 1:repetitions
if repetitions>1
if k==1
bond_list(1:2:ports-1) = odd_bonds;
else
bond_list(1:2:ports-1) = bond_list(2:2:ports);
end;
if k==repetitions
bond_list(2:2:ports) = even_bonds;
else
new_bonds = [next_bond:next_bond+port_pairs-1];
next_bond = next_bond+port_pairs;
bond_list(2:2:ports) = new_bonds;
end;
end;
% Invoke the appropriate equation-generating procedure
name_r = 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, cr, args, ...
full_name, full_name_repetition, ...
k, structure, infofile);
% Link up the bonds
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_repetition, comp_name, k);
name_comp_name = sprintf('%s_%s_%1.0f', ...
full_name_repetition, comp_name, k);
for port_number=1:length(bond_list)
% Effort
if comp_bonds(port_number,1)==1 % Source
fprintf(filenum, '%s_MTTu%1.0f := %s;\n', ...
name_comp_name, port_number, varname(name_r, ...
bond_list(port_number),1));
else % sensor
fprintf(filenum, '%s := %s_MTTy%1.0f;\n', ...
varname(name_r, ...
bond_list(port_number),1), name_comp_name, port_number);
end;
% flow
if comp_bonds(port_number,2)==-1 % Source
fprintf(filenum, '%s_MTTu%1.0f := %s;\n', ...
name_comp_name, port_number, varname(name_r, ...
bond_list(port_number),-1));
else % sensor
fprintf(filenum, '%s := %s_MTTy%1.0f;\n', ...
varname(name_r, ...
bond_list(port_number),-1), name_comp_name, port_number);
end;
end;
disp('---POP---');
else % its a simple component
|
| ︙ | ︙ |