Overview
Comment: | Initial revision |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9b56187ca27e4f5113fde7b559ab24b4 |
User & Date: | gawthrop@users.sourceforge.net on 1998-08-25 06:22:02 |
Other Links: | branch diff | manifest | tags |
Context
1998-08-25
| ||
06:43:02 |
Revised (partially) for data strucures - needs to include graphic info in abg file. check-in: 8d920e434f user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
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 | |
Changes
Added mttroot/mtt/bin/trans/m/write_abg.m version [8109016093].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 81 82 83 84 85 86 87 88 89 | function write_abg(system_name,bonds,connections); ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ############################################################### fid=fopen([system_name,"_abg.m"], "w"); [N,M]=size(connections); Sformat = " %s.subsystems.%s.%s = \"%s\";\n"; PSformat = " %s.ports.%s.%s = \"%s\";\n"; Iformat = " %s.subsystems.%s.%s = %i;\n"; PIformat = " %s.ports.%s.%s = %i;\n"; Cformat = " %s.subsystems.%s.connections = ["; PCformat = " %s.ports.%s.connections = ["; Bformat = " %s.bonds = [\n"; fprintf(fid,"function [%s] = %s_abg\n", system_name, system_name); fprintf(fid,"# This function is the acausal 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# Subsystems and Ports\n"); i_port=0; for i=1:N eval(["[comp_type, name, cr, arg, repetitions] = ", system_name, "_cmp(i);"]); if index(name,"[")==0 # Not a port fprintf(fid,"\n# Component %s\n", name); fprintf(fid,Sformat,system_name,name,"type",comp_type); fprintf(fid,Sformat,system_name,name,"cr",cr); fprintf(fid,Sformat,system_name,name,"arg",arg); fprintf(fid,Iformat,system_name,name,"repetitions",repetitions); c = nozeros(connections(i,:));# Connections to this component m = length(c); # Number of connections fprintf(fid,Cformat,system_name,name); for j=1:m fprintf(fid,"%i ", c(j)); endfor; fprintf(fid,"];\n"); else name = strrep(strrep(name,"[",""), "]", ""); fprintf(fid,"\n# Port %s\n", name); fprintf(fid,PIformat,system_name,name,"index",++i_port); fprintf(fid,PSformat,system_name,name,"arg",arg); c = nozeros(connections(i,:));# Connections to this component m = length(c); # Number of connections fprintf(fid,PCformat,system_name,name); for j=1:m fprintf(fid,"%i ", c(j)); endfor; fprintf(fid,"];\n"); endif; endfor; fprintf(fid,"\n# Bonds \n"); [N,M]=size(bonds); # Bonds fprintf(fid,Bformat,system_name); for i=1:N fprintf(fid," "); for j=1:M fprintf(fid,"%i ", bonds(i,j)); endfor; fprintf(fid,"\n"); endfor; fprintf(fid," ];\n"); fprintf(fid,"\n# Aliases \n"); fprintf(fid,"# A double underscore __ represents a comma \n"); eval(["alias = ", system_name, "_alias;"]); if is_struct(alias) for [val,key] = alias fprintf(fid,"%s.alias.%s = \"%s\";\n", system_name,key,val); endfor endif fclose(fid); |