Overview
Comment:Just writes additional information; basic info from the abg structure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: aa30e2fc5cce453174f25c1e11a6825e45dd361fafd74295c34c66e72d701337
User & Date: gawthrop@users.sourceforge.net on 1998-08-25 06:21:19
Other Links: branch diff | manifest | tags
Context
1998-08-25
06:22:02
Initial revision check-in: 9b56187ca2 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
06:21:19
Just writes additional information; basic info from the abg structure. check-in: aa30e2fc5c user: gawthrop@users.sourceforge.net tags: origin/master, trunk
05:55:10
Initial revision check-in: a396fc9230 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/write_cbg.m from [541af08db7] to [1d9a8b7921].

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function write_cbg(system_name,system);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



###############################################################


  fid=fopen([system_name,"_cbg.m"], "w");# Open file

  Sformat = "  %s.subsystems.%s.%s = \"%s\";\n";
  PSformat = "  %s.ports.%s.%s = \"%s\";\n";
  Iformat = "  %s.subsystems.%s.%s = %i;\n";
  Cformat = "  %s.subsystems.%s.connections = [";
  PCformat = "  %s.ports.%s.connections = [";
  Bformat = "  %s.bonds = [\n";

  fprintf(fid,"function [%s] =  %s_cbg\n", system_name, system_name);



  
  if struct_contains(system,"ports")
    for [port,name]=system.ports
      fprintf(fid,"\n# Port %s\n", name);
      fprintf(fid,PSformat,system_name,name,"arg",port.arg);
      
      m = length(port.connections);		# Number of connections
      fprintf(fid,PCformat,system_name,name);
      for j=1:m
      	fprintf(fid,"%i ", port.connections(j));
      endfor;
      fprintf(fid,"];\n");
    endfor;
  endif
  
  fprintf(fid,"\n# Components \n");
  if struct_contains(system,"subsystems")
    for [subsystem,name]=system.subsystems
    
      fprintf(fid,"\n# Component %s\n", name);
      fprintf(fid,Sformat,system_name,name,"type",subsystem.type);
      fprintf(fid,Sformat,system_name,name,"cr",subsystem.cr);
      fprintf(fid,Sformat,system_name,name,"arg",subsystem.arg);
      fprintf(fid,Iformat,system_name,name,"repetitions",subsystem.repetitions);
      fprintf(fid,Iformat,system_name,name,"status",subsystem.status);

      m = length(subsystem.connections);		# Number of connections

      fprintf(fid,Cformat,system_name,name);
      for j=1:m
      	fprintf(fid,"%i ", subsystem.connections(j));
      endfor;
      fprintf(fid,"];\n");
    endfor
  endif
  
  

  [N,M]=size(system.bonds);		# Bonds
  fprintf(fid,"\n# Bonds \n");
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", system.bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");
    
  fprintf(fid,"\n# Aliases \n");
  if struct_contains(system,"alias")
    for [val,key] = system.alias
      fprintf(fid,"%s.alias.%s = \"%s\";\n", system_name,key,val);
    endfor
  endif

  fclose(fid);
  

|






>
>
>





<
|
<
<
<



>
>
>

<
<
|
|
|
<
|
<
|
|
|


<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|


<
<

|










<
<
<
<
<
<
<



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
31
32


33
34














35
36
37
38


39
40
41
42
43
44
45
46
47
48
49
50







51
52
53
function write_cbg(system_name,system_type,system);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1  1998/08/25 05:55:10  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_cbg.m"], "w");# Open file


  StatusFormat = "  %s.%s.%s.status = %i;\n";



  Bformat = "  %s.bonds = [\n";

  fprintf(fid,"function [%s] =  %s_cbg\n", system_name, system_name);
  fprintf(fid,"# This function is the causal bond graph representation of %s\n",system_name);
  fprintf(fid,"# Generated by MTT on %s",ctime(time));
  fprintf(fid,"# The file is in Octave format\n");
  


  fprintf(fid,"\n# Acausal bond graph structure\n");
  fprintf(fid,"  [%s] =  %s_abg;\n", system_name, system_name);


  fprintf(fid,"\n# Status information\n");

  if struct_contains(system,"ports")
    for [port,name]=system.ports
      fprintf(fid,StatusFormat,system_name,"ports",name,subsystem.status);
    endfor;
  endif


  if struct_contains(system,"subsystems")
    for [subsystem,name]=system.subsystems














      fprintf(fid,StatusFormat,system_name,"subsystems",name,subsystem.status);
    endfor;
  endif
  


  [N,M]=size(system.bonds);		# Bonds
  fprintf(fid,"\n# Causal bond information\n");
  fprintf(fid,Bformat,system_name);
  for i=1:N
    fprintf(fid,"      ");
    for j=1:M
      fprintf(fid,"%i ", system.bonds(i,j));
    endfor;
    fprintf(fid,"\n");
  endfor;
  fprintf(fid,"      ];\n");
    







  fclose(fid);
  


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