Differences From Artifact [855720c30a]:

To Artifact [ea5247f84f]:


19
20
21
22
23
24
25




26
27
28
29
30
31
32
  ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
  
  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$




  ## ## Revision 1.52  2004/09/12 22:27:27  geraint
  ## ## Appended 't' to fopen mode string to open in text mode.
  ## ##
  ## ## Revision 1.51  2003/05/16 11:16:28  gawthrop
  ## ## Fixed bug with multiports
  ## ##
  ## ## Revision 1.50  2003/05/08 18:47:50  gawthrop







>
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
  
  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.53  2005/03/21 11:09:47  gawthrop
  ## ## Now handles bicausal SS component -
  ## ##   ie source-source or sensor-sensor
  ## ##
  ## ## Revision 1.52  2004/09/12 22:27:27  geraint
  ## ## Appended 't' to fopen mode string to open in text mode.
  ## ##
  ## ## Revision 1.51  2003/05/16 11:16:28  gawthrop
  ## ## Fixed bug with multiports
  ## ##
  ## ## Revision 1.50  2003/05/08 18:47:50  gawthrop
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  
  fields=["ports";"subsystems"]; # Do for both ports and subsystems -
  ## ports first
  lists=["portlist";"subsystemlist"];
  for i=1:2
    field=deblank(fields(i,:));
    list=deblank(lists(i,:));
    if struct_contains(CBG,list);
      eval(["namelist=CBG.",list,";"]); # List of ports/subsystems
      [N,M]=size(namelist);	# Number of ports/subsystems
      for j=1:N
      	comp_name = deblank(namelist(j,:)); # Name of this component
	eval(["subsystem=CBG.",field,".",comp_name,";"]); # Pluck out the details
    	comp = subsystem.connections; # Connections
    	bond_list = abs(comp);
    	direction = sign(comp)'*[1 1];
				# Convert from arrow orientated to component orientated causality
    	comp_bonds = CBG.bonds(bond_list,:).*direction;
	
    	## disp(["---- ", field, " ---"]);    
    	
	if AliasingArguments	# Alias the args list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s",\
			    comp_name,subsystem.type,full_name);    
    	  if struct_contains(CBG,"alias")
	    subsystem.arg = alias_args(subsystem.arg,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;
	
	if AliasingCRs	# Alias the CR list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s",\
			    comp_name,subsystem.type,full_name);    
    	  if struct_contains(CBG,"alias")
	    subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;

	## Substitute positional ($1 etc) arguments
    	subsystem.cr = subs_arg(subsystem.cr,system_cr, ...
				"lin",full_name,subsystem.type,comp_name,infofilenum);







|
















|







|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
  
  fields=["ports";"subsystems"]; # Do for both ports and subsystems -
  ## ports first
  lists=["portlist";"subsystemlist"];
  for i=1:2
    field=deblank(fields(i,:));
    list=deblank(lists(i,:));
    if isfield(CBG,list);
      eval(["namelist=CBG.",list,";"]); # List of ports/subsystems
      [N,M]=size(namelist);	# Number of ports/subsystems
      for j=1:N
      	comp_name = deblank(namelist(j,:)); # Name of this component
	eval(["subsystem=CBG.",field,".",comp_name,";"]); # Pluck out the details
    	comp = subsystem.connections; # Connections
    	bond_list = abs(comp);
    	direction = sign(comp)'*[1 1];
				# Convert from arrow orientated to component orientated causality
    	comp_bonds = CBG.bonds(bond_list,:).*direction;
	
    	## disp(["---- ", field, " ---"]);    
    	
	if AliasingArguments	# Alias the args list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s",\
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.arg = alias_args(subsystem.arg,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;
	
	if AliasingCRs	# Alias the CR list if appropriate
    	  message = sprintf("\tfor component  %s (%s) within %s",\
			    comp_name,subsystem.type,full_name);    
    	  if isfield(CBG,"alias")
	    subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name);
    	  endif;
	endif;

	## Substitute positional ($1 etc) arguments
    	subsystem.cr = subs_arg(subsystem.cr,system_cr, ...
				"lin",full_name,subsystem.type,comp_name,infofilenum);
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# 		  deblank(bond_flow_unit(port_bond_number,:));

# 	      ## Extract the unit/domain stuff
#               this_port_name = subABG.portlist(port_number,:);
              
#               eval(sprintf("this_port = subABG.ports.%s;", \
# 			   this_port_name));
# 	      if struct_contains(this_port,"units")
#                 eval(["effort_unit = \
# 		    subABG.ports.",this_port_name,".units.effort;"]);
#                 eval(["flow_unit = \
# 		    subABG.ports.",this_port_name,".units.flow;"]);
# 	      else
# 		effort_unit = "none";
# 		flow_unit = "none";







|







440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# 		  deblank(bond_flow_unit(port_bond_number,:));

# 	      ## Extract the unit/domain stuff
#               this_port_name = subABG.portlist(port_number,:);
              
#               eval(sprintf("this_port = subABG.ports.%s;", \
# 			   this_port_name));
# 	      if isfield(this_port,"units")
#                 eval(["effort_unit = \
# 		    subABG.ports.",this_port_name,".units.effort;"]);
#                 eval(["flow_unit = \
# 		    subABG.ports.",this_port_name,".units.flow;"]);
# 	      else
# 		effort_unit = "none";
# 		flow_unit = "none";
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
 	      endfor;
 	    endif;
	  endif
	endfor
	fflush (structure_file);

	## component interface definition
	if struct_contains(CBG,"icd")
	  if struct_contains(CBG.icd,comp_name)
	    if AliasingArguments
	      subsystem.icd = alias_args(eval(["CBG.icd.",comp_name]),CBG.alias,";",message,infofilenum,full_name);
	    endif
	  endif
	  if (struct_contains(subsystem,"icd"))
	    subsystem.icd = subs_arg(subsystem.icd,system_args, ...
				     "null",full_name,subsystem.type,comp_name,infofilenum);
	    
	    fprintf(icd_file,"%s_%s\t%s\t",full_name_repetition,comp_name,subsystem.icd);
	    if (comp_bonds(1) == 1)
	      fprintf(icd_file,"output,");
	    elseif (comp_bonds(1) == -1)
	      fprintf(icd_file,"input,");
	    endif
	    if (comp_bonds(2) == 1)
	      fprintf(icd_file,"input\n");
	    elseif (comp_bonds(2) == -1)
	      fprintf(icd_file,"output\n");
	    endif
	  endif
	endif			# End of component interface definition

      endfor			# [subsystem,comp_name] = CBG_field
    endif			# struct_contains(CBG,field)
  endfor			# i=1:2

  fclose(icd_file);
  fclose(ese_file);		# Close
  
endfunction










|
|




|


















|









570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
 	      endfor;
 	    endif;
	  endif
	endfor
	fflush (structure_file);

	## component interface definition
	if isfield(CBG,"icd")
	  if isfield(CBG.icd,comp_name)
	    if AliasingArguments
	      subsystem.icd = alias_args(eval(["CBG.icd.",comp_name]),CBG.alias,";",message,infofilenum,full_name);
	    endif
	  endif
	  if (isfield(subsystem,"icd"))
	    subsystem.icd = subs_arg(subsystem.icd,system_args, ...
				     "null",full_name,subsystem.type,comp_name,infofilenum);
	    
	    fprintf(icd_file,"%s_%s\t%s\t",full_name_repetition,comp_name,subsystem.icd);
	    if (comp_bonds(1) == 1)
	      fprintf(icd_file,"output,");
	    elseif (comp_bonds(1) == -1)
	      fprintf(icd_file,"input,");
	    endif
	    if (comp_bonds(2) == 1)
	      fprintf(icd_file,"input\n");
	    elseif (comp_bonds(2) == -1)
	      fprintf(icd_file,"output\n");
	    endif
	  endif
	endif			# End of component interface definition

      endfor			# [subsystem,comp_name] = CBG_field
    endif			# isfield(CBG,field)
  endfor			# i=1:2

  fclose(icd_file);
  fclose(ese_file);		# Close
  
endfunction




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