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
|
function [port_bonds, status] = abg2cbg(system_name, ...
system_type, full_name, ...
port_bonds, typefile, infofile)
% abg2cbg - acausal to causal bg conversion
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%% Model Transformation Tools %%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function abg2cbg.m
% Acausal bond graph to causal bond graph: mfile format
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.10 1996/12/04 21:48:55 peterg
% %% Compares full-name with empty string (instead of testing for zero
% %% length.
% %%
% %% Revision 1.9 1996/08/30 12:55:40 peter
% %% More heirachical stuff added.
% %%
|
>
>
>
>
>
|
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
29
30
|
function [port_bonds, status] = abg2cbg(system_name, ...
system_type, full_name, ...
port_bonds, typefile, infofile)
% abg2cbg - acausal to causal bg conversion
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%% Model Transformation Tools %%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function abg2cbg.m
% Acausal bond graph to causal bond graph: mfile format
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.11 1996/12/07 17:10:48 peterg
% %% Allows port SS at top level - ie takes it to be an ardianry SS at top
% %% level.
% %%
% %% Revision 1.10 1996/12/04 21:48:55 peterg
% %% Compares full-name with empty string (instead of testing for zero
% %% length.
% %%
% %% Revision 1.9 1996/08/30 12:55:40 peter
% %% More heirachical stuff added.
% %%
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
% Find number of components
[n_components,columns] = size(components);
if n_components==0 % there is nothing to be done
return
end;
% If not at top level, then sort out the port bonds.
if !at_top_level
% Find number of port bonds
[n_port_bonds,columns] = size(port_bonds);
% Check compatibility - if ok copy port bonds to the internal bonds list.
if n_port_bonds~=n_ports
mtt_info(sprintf('%1.0f port bonds incompatible with %1.0f ports', ...
n_port_bonds, n_ports), infofile);
|
|
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
% Find number of components
[n_components,columns] = size(components);
if n_components==0 % there is nothing to be done
return
end;
% If not at top level, then sort out the port bonds.
if at_top_level==0
% Find number of port bonds
[n_port_bonds,columns] = size(port_bonds);
% Check compatibility - if ok copy port bonds to the internal bonds list.
if n_port_bonds~=n_ports
mtt_info(sprintf('%1.0f port bonds incompatible with %1.0f ports', ...
n_port_bonds, n_ports), infofile);
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
eval([ '[comp_type,name] = ', system_type, '_cmp(i);' ]);
mtt_info(sprintf('Component %s (%s) is undercausal', name, comp_type), ...
infofile);
end;
end;
% $$$ file_name = [full_name, '_', system_type]
file_name = full_name;
write_cbg(file_name,system_type,bonds,status);
% Return the port bonds
for i = 1:n_ports % The port SSs come first
j = abs(components(i,1)); % Get the bonds attached to the ports
direction = -sign(components(i,1));
port_bonds(i,:) = direction*bonds(j,:);
end;
|
|
>
|
>
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
eval([ '[comp_type,name] = ', system_type, '_cmp(i);' ]);
mtt_info(sprintf('Component %s (%s) is undercausal', name, comp_type), ...
infofile);
end;
end;
% $$$ file_name = [full_name, '_', system_type]
file_name = [full_name, '_cbg.m']
cbgfilenum = fopen(file_name,'w');
write_cbg(cbgfilenum,full_name,system_type,bonds,status);
fclose(cbgfilenum);
% Return the port bonds
for i = 1:n_ports % The port SSs come first
j = abs(components(i,1)); % Get the bonds attached to the ports
direction = -sign(components(i,1));
port_bonds(i,:) = direction*bonds(j,:);
end;
|