Overview
Comment:Now generates (exampaded) port_bond list correctely
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 34c2407185f8592bb6ee1195461439e7b978909ef826a49d5bca406d0e74fd36
User & Date: gawthrop@users.sourceforge.net on 1997-08-18 19:39:48
Other Links: branch diff | manifest | tags
Context
1997-08-19
09:41:47
Some debugging lines added. check-in: a9dfa0341a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1997-08-18
19:39:48
Now generates (exampaded) port_bond list correctely check-in: 34c2407185 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
16:25:25
Minor bug fixes check-in: e87199e5d9 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/rbg2abg.m from [4917e3f3d1] to [8751eebb58].

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







+
+
+







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

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.19  1997/08/14  11:59:47  peterg
% %% Vector ports added!!
% %%
% %% Revision 1.18  1997/08/14  11:01:42  peterg
% %% Reordered algorithms as follows:
% %% bond end coordinates
% %% associate port labels with bonds (port_bond)
% %% associate bonds with components
% %% unsorted list of bonds on each component (components)
% %% interpret strokes and setup the causality of the bonds (bonds)
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
240

241
242
243
244

245
246
247
248
249



250







251
252
253
254
255
256
257
258
259
260
261
262



263
264

265
266
267
268
269
270
271
272
273
274
275
276
277

278
279

280
281
282
283
284
285
286
218
219
220
221
222
223
224
225
226
227
228

229
230
231
232


233
234
235
236
237
238
239
240
241
242
243
244

245
246
247

248
249
250
251

252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276



277
278
279
280

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296

297
298
299
300
301
302
303
304







+


+
-
+

+
+
-
-
+
+
+









-
+


-
+



-
+




-
+
+
+

+
+
+
+
+
+
+









-
-
-
+
+
+

-
+













+

-
+








bonds = causality;

% Now expand vector ports
[n_bonds,junk] = size(bonds);
n_exp_ports=n_ports;
exp_port_name="";
exp_port_bond = [];
%exp_comps = [];
for i=1:n_ports
  port_name_i = port_name(i,:)
  subport = split(port_name(i,:), ',');
  subport = split(port_name_i, ','); % Find the components of the vector port
  [n_subports,junk] = size(subport);

  if n_subports==1 % an ordinary port
  exp_port_name = [exp_port_name; subport(1,:)];
  if n_subports>1
    exp_port_name = [exp_port_name; subport(1,:)]; % Write out the only port
    exp_port_bond = [exp_port_bond; port_bond(i)]; % and the port_bond
  else % its a vector port
    % Check that there is a corresponding vector port at the other end of the
    % bond
    signed_bond_index = port_bond(i);
    [other_bond_index,n_other] = getindex(port_bond,-signed_bond_index);
    if n_other == 1
      other_port_name = port_name(other_bond_index,:);
      other_subport = split(other_port_name, ',');
      [n_other_subports,junk] = size(other_subport);
      if n_other_subports~=n_subports
	mtt_info(['Vector ports ', port_name(i,:), ' and ', other_port_name, 'are not compatible'],infofile);
	mtt_info(['Vector ports ', port_name_i, ' and ', other_port_name, 'are not compatible'],infofile);
      end
    else 
      mtt_info(['Vector port ', port_name(i,:), ' has no matching port'], infofile);
      mtt_info(['Vector port ', port_name_i, ' has no matching port'], infofile);
    end;
    
    if other_bond_index>i %then its not been done yet
      mtt_info(['Vector port: ', port_name(i,:)],infofile);
      mtt_info(['Vector port: ', port_name_i],infofile);
      mtt_info(['matching: ', other_port_name],infofile);
      % Remove sign info.
      bond_index = abs(signed_bond_index);
      sig = sign(signed_bond_index);
      % add first element of port list to the expanded list
      
      % Put the first element of each port list in the expanded list
      exp_port_name = [exp_port_name; subport(1,:)];
      exp_port_name = [exp_port_name; other_subport(1,:)];
      
      % Add to the expanded port_bond list
      exp_port_bond = [exp_port_bond; signed_bond_index; ...
	-signed_bond_index];
      
      % Add the other names to the expanded list and augment the bonds,
      % components and port_bond lists.
      for j=2:n_subports
	% Add a new name (for each end) to give a non-vector list
	exp_port_name = [exp_port_name; subport(j,:)];
	exp_port_name = [exp_port_name; other_subport(j,:)];
	      
	% Add one more bond to the list
	bonds = [bonds; bonds(bond_index,:)];
	n_bonds = n_bonds + 1;
      
	% Add bond to the port_bond list
	port_bond = [port_bond; sig*n_bonds]; %this end
	port_bond = [port_bond; -sig*n_bonds]; %other end
	% Add bond to the expanded port_bond list (ports at both ends)
	exp_port_bond = [exp_port_bond; sig*n_bonds; -sig*n_bonds];


	% Add a new bond to the component at both ends (taking note 
	% Add the new bond to the component at both ends (taking note 
	% of the direction).
	arrow_index = comp_near_bond(bond_index,1);
	components = add_bond(components, n_bonds, arrow_index);
	other_index = comp_near_bond(bond_index,2);
	components = add_bond(components, -n_bonds, other_index);
      end;
    end;
  end;
end;


%Replace old list by new
port_name = exp_port_name
port_bond = exp_port_bond

%Resize the lists
% Resize the lists
[n_ports,junk] = size(port_name);

port_name, components
% Produce a list of bonds on each component (within this component) 
%  - sorted if explicit port numbers
for i = 1:n_components    
  disp('-----------------');
328
329
330
331
332
333
334
335

336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358



359
360
361
362
363
364
365
366
367
368

369
370
371

372
373
374
375
376
377
378

379
380
381
382
383
384
385
346
347
348
349
350
351
352

353


354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371



372
373
374
375
376
377
378
379
380
381
382
383

384
385
386

387
388
389
390
391
392
393

394
395
396
397
398
399
400
401







-
+
-
-


















-
-
-
+
+
+









-
+


-
+






-
+







      % Find the port label on component end of bond (if any)
      [port_index,m] = getindex(port_bond,b);
      if m==1
	k=k+1;
	unsorted_port_list(k,:) = port_name(port_index,:);
      end;
    end;
  else % just use that provided by the component
  else 
    %      unsorted_port_list = port_list;
    %      k = n_comp_bonds;
    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'], infofile); 
    mtt_info(sprintf("\tit has %1.0f labels but should have 0 or %1.0f",k,n_comp_bonds), infofile); 
  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;
  n_unsorted_ports,n_comp_bonds
  % One port defaults:
  if (n_comp_bonds==1)&(n_unsorted_ports==0)
    if (direction(1)<0) & ~strcmp(comp_type,'SS') % Wrong way for default
      mtt_info(['One-port ', comp_name, ' (', comp_type, ') has the sign pointing the wrong way '], infofile);
    end;
    %if (direction(1)<0) & ~strcmp(comp_type,'SS') % Wrong way for default
    % mtt_info(['One-port ', comp_name, ' (', comp_type, ') has the sign pointing the wrong way '], infofile);
    %end;
    unsorted_port_list = port_list;
  end;
  
  %Two port defaults
  if (n_comp_bonds==2)&(n_unsorted_ports==0)
    if direction(1)==direction(2) % Wrong way for default
      mtt_info(['Two-port ', comp_name, ' (', comp_type, ') does not have though-pointing arrows'], infofile);
    end;
    if direction(1)==1 %in
      mtt_info([comp_name, ' in'],infofile);
      % mtt_info([comp_name, ' in'],infofile);
      unsorted_port_list = ['in';'out'];
    else %reverse the order
      mtt_info([comp_name, ' out'],infofile);
      % mtt_info([comp_name, ' out'],infofile);
      unsorted_port_list = ['out';'in'];
    end;
  end;
  
  % Recompute the number of unsorted ports
  [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list);
  if m_unsorted_ports<2
  if m_unsorted_ports==0
    n_unsorted_ports = 0;
  end;
  
  % Junctions or no lables(order of ports unimportant)
  if strcmp(comp_type,'zero')|strcmp(comp_type,'one')
    for j = 1:n_comp_bonds
      components(i,j) = signed_bond_list(j);


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