Overview
Comment:Expand port aliases
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: f51e5d63a6e07d09dd478019a6f2c263740b40825ef00f2a15234d79e3250839
User & Date: gawthrop@users.sourceforge.net on 1998-07-02 12:24:02
Other Links: branch diff | manifest | tags
Context
1998-07-02
12:36:05
Removed debugging lines check-in: 3a5336b3d3 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:24:02
Expand port aliases check-in: f51e5d63a6 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
10:55:54
Lower case in out check-in: 25c97e12f7 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/rbg2abg.m from [93303fe713] to [f334abe696].

1
2
3
4
5
6
7




8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18







+
+
+
+







function [bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,infofile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% 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
% %%
% %% Revision 1.23  1997/12/04 14:24:22  peterg
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
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







-
+









-
+




+







	 ("A port is near to more than one bond at coordinates %g,%g\n", ...
	 port_coord(i,1)/scale,  port_coord(i,2)/scale));
   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)']);

  % There are n_comp_bonds bonds on this component with corresponding index
  [index,n_comp_bonds] = getindex(comp_near_bond,i);
194
195
196
197
198
199
200


201

202
203

204





















205
206
207
208
209
210
211
199
200
201
202
203
204
205
206
207

208
209

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239







+
+
-
+

-
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  
  % Check that all bonds are unique -- error if not
  if unique(bond_list)==0
    mtt_info(sprintf("Component %s (%s) is at both ends of a bond", comp_name,
    comp_type),fnum);
  end;
    

  % which end of bond at component?
  bond_end = index(:,2);  % 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
causality = zeros(n_bonds,2);
if n_strokes>0
386
387
388
389
390
391
392
393







394
395
396
397
398
399
400
414
415
416
417
418
419
420

421
422
423
424
425
426
427
428
429
430
431
432
433
434







-
+
+
+
+
+
+
+







    k=0;
  end;
    
  %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
    n_unsorted_ports = 0;
  end;


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]