Overview
Comment:Writes flipped port info
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: d92c3d35def14adc038d01cbe0580f8b53b50ee4bef4015ef751a736fd8e7bb5
User & Date: gawthrop@users.sourceforge.net on 1998-08-25 20:06:16
Other Links: branch diff | manifest | tags
Context
1998-08-25
20:06:56
New data structure for abg.m and cbg.m check-in: 3416b8080a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
20:06:16
Writes flipped port info check-in: d92c3d35de user: gawthrop@users.sourceforge.net tags: origin/master, trunk
20:05:33
Write flipped port info check-in: e34ae7e51b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/abg2cbg.m from [d3bc550e93] to [fe77282cde].

15
16
17
18
19
20
21








22
23
24
25
26
27
28
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+
+
+
+
+
+
+
+







# [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

# ###############################################################
# ## Version control history
# ###############################################################
# ## $Id$
# ## $Log$
# ## Revision 1.38  1998/08/25 09:15:28  peterg
# ## Fixed couple of problems with using two copies of the one data
# ## stucture:
# ##
# ## ABG_field and ABG.field
# ##
# ## Maybe this is conceptually wrong?
# ##
# ## Revision 1.37  1998/08/25 08:33:29  peterg
# ## Now does ports as well - fixed string prob by using deblank
# ##
# ## Revision 1.36  1998/08/25 06:44:40  peterg
# ## Furhter revisions
# ##
# ## Revision 1.35  1998/08/24 10:16:32  peterg
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
305
306
307
308
309
310
311
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







+
-
-
+
+
-
-
-
-
+
-
-
-
+
+
-
-
-
-
-
+
+
+
-
-
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+

-
-
+
+
-
+
+
+


-
-
+
-
-
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
+


-
+
-







#    return
#  end;


  
# Coerce the port (SS:[]) component bonds to have the same direction as
# of the bonds in the encapsulating system -- but not at top level
  Flipped.ports="";Flipped.subs="";Flipped.cons="";
#  if (n_ports>0)&&(!at_top_level)
    
  if (n_ports>0)&&(!at_top_level) # Coerce directions
    for [port,name] = ABG.ports	# Just ports are relevant here
#   # port_bond_index = abs(components(1:n_ports,1:m_components))# relevant
#							     # bond
#							     # numbers
#				#    port_bond_index = nozeros(reshape(\
      if (sign(port.connections)!=port_bond_direction(port.index)) # Direction different?
#				#			      port_bond_index',n_ports*m_components,1))'# vectorise

#    for port = ABG.ports
      	eval(["ABG.ports.",name,".connections = - port.connections;"]); # Flip direction at port
	Flipped.ports=[Flipped.ports;name];	# Remember which port has been flipped
#    #for i=1:n_ports
#				# Is the direction different?
#      if (sign(port.connections)!=port_bond_direction(i))
#      	mtt_info(sprintf("Flip port #i",i),infofile);
#				# Flip direction at port
        bond_index=abs(port.connections); # Index of bond on port
      	mtt_info(sprintf("Flip port %s on %s"\
			 ,name,full_name),infofile); # And report
#      	port.connections = - port.connections;
#				# and at the other end
      	for [subsystem,name] = ABG.subsystems # and at the other end
#      	for subsystem = ABG.subsystems
#	  for k=1:length(subsystem.connections)
#	    if (abs(subsystem.connection(k))==port_bond_index(i))
#	    subsystem.connection(k)   = -subsystem.connection(k);
	  for k=1:length(subsystem.connections)
	    if (abs(subsystem.connections(k))==bond_index)
	    eval(["ABG.subsystems.",name,".connections(k)   = -subsystem.connections(k);"]);
#	    end
#	  end
#      	end;
#				# Flip the bond causalities (these are arrow-orientated)
	    Flipped.subs=[Flipped.subs;name];	# Remember which subsystem has been flipped
	    Flipped.cons=[Flipped.cons;k];	# Remember which connection has been flipped
      	    mtt_info(sprintf("Flip subsystem %s on %s"\
#      	ABG.bonds(port_bond_index(i),:) = -ABG.bonds(port_bond_index(i),:);
#      end
#    end
#  end

			     ,name,full_name),infofile); # And report
	    endif
	  endfor
      	endfor			# subsystem = ABG.subsystems


# Set initial status
      	ABG.bonds(bond_index,:) = -ABG.bonds(bond_index,:);	# Flip the bond causalities 
				#(these are arrow-orientated)
#  status = -ones(n_subsystems,1);
      endif			# Is the direction different?
    endfor			# port = ABG.ports
  endif				# (n_ports>0)&&(!at_top_level)

# If not at top level, then copy the port bonds.
  if ~at_top_level 
  # Find number of port bonds
  if !at_top_level		# Find number of port bonds
    [n_port_bonds,columns] = size(port_bonds);

    for port = ABG.ports	# Copy the port bonds.
  # Check compatibility - if ok copy port bonds to the internal bonds list.
#    if n_port_bonds~=N_ports
#      mtt_error(sprintf("#s: #1.0f port bonds incompatible with #1.0f ports", ...
#			full_name, n_port_bonds, n_ports), errorfile);

#    else # Copy the port bonds & status
      jj = abs(port.connections); # The index of the bond
      j = port.index;		# The index of the port bond
      for j = 1:n_port_bonds
      	jj = port_bond_index(j);
      	for k = 1:2
	  if ABG.bonds(jj,k)==0 # only copy if not already set
	    ABG.bonds(jj,k) = port_bonds(j,k);
	  end;
      	end;
      for k = 1:2
	if ABG.bonds(jj,k)==0 # only copy if not already set
	  ABG.bonds(jj,k) = port_bonds(j,k);
	endif
      endfor
#      status(1:N_ports) = port_status;
#      end
    end
    endfor
  else
    n_port_bonds=0;
  end;
  endif
# bonds,port_bonds

# Causality indicator
  total = 2*n_bonds;
  done = sum(sum(abs(ABG.bonds)))/total*100;


  fields=["ports";"subsystems"];	# Do for both ports and subsystems -
435
436
437
438
439
440
441
442

443
444
445
446
447


448
449
450
451
452
453
454
455
456
457
458











459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
425
426
427
428
429
430
431

432
433
434
435
436
437
438
439











440
441
442
443
444
445
446
447
448
449
450

451
452
453
454
455
456
457
458
459
460
461
462
463
464







-
+





+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-














    if done<100
      mtt_error(sprintf("Unable to complete causality"),errorfile);
    end;
  endif				# at_top_level
  

  disp(["Writing ", full_name]);
  write_cbg(full_name,system_type,ABG);
  write_cbg(full_name,system_type,ABG,Flipped);
  
				# Return the port bonds - arrow orientated causality - and the direction 
  status=0;
  if !at_top_level # Not at top level
    port_bonds = ABG.bonds(port_bond_index,:); # Return port bonds
  endif;				# at top level

    for [subsystem,name] = ABG.subsystems
      if subsystem.status==-1	# Under causal
      	status=-1;
      	mtt_info(sprintf("Component %s (%s) is undercausal", name, subsystem.type), ...
		 infofile);
      elseif subsystem.status==1;	# Over causal
      	status=-1;
      	mtt_info(sprintf("Component %s (%s) is overcausal", name, subsystem.type), ...
		 infofile);
      endif;
    endfor;			# [subsystem,name] = ABG.subsystems
  for [subsystem,name] = ABG.subsystems
    if subsystem.status==-1	# Under causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is undercausal", name, subsystem.type), ...
	       infofile);
    elseif subsystem.status==1;	# Over causal
      status=-1;
      mtt_info(sprintf("Component %s (%s) is overcausal", name, subsystem.type), ...
	       infofile);
    endif;
  endfor;			# [subsystem,name] = ABG.subsystems
  endif;				# at top level

  status, port_bonds
  disp("====================================");
  disp(["END: ", full_name, " (", fun_name, ")"]);
  disp("====================================");

endfunction;








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