Overview
Comment:Appended 't' to fopen mode string to open in text mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 1459f7b012b06188df30b91935b8bb1b384afd58d66a2b3cf030eb50838a695d
User & Date: geraint@users.sourceforge.net on 2004-09-12 22:27:27
Other Links: branch diff | manifest | tags
Context
2004-09-12
23:16:24
A passive multiple trailer system dor indoor service robots. check-in: 09dab38f4a user: geraint@users.sourceforge.net tags: origin/master, trunk
22:27:27
Appended 't' to fopen mode string to open in text mode. check-in: 1459f7b012 user: geraint@users.sourceforge.net tags: origin/master, trunk
2004-09-10
21:05:15
Ensure that the system exists before proceeding.
This should stop me from copying my home directory to MTT_work.
check-in: d2d3d9eba8 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/abg2cbg_m from [5440b5dfe8] to [aeca6fdc92].

9
10
11
12
13
14
15



16
17
18
19
20
21
22
# Acausal bond graph to causal bond graph: mfile format

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



## Revision 1.16  2001/07/26 04:07:28  gawthrop
## Changed a to w on open (Geraint's suggestion)
## Explictly close files
##
## Revision 1.15  2001/07/23 23:24:02  gawthrop
## Now only writes to type.sh and cbg.m when causality is complete
##







>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Acausal bond graph to causal bond graph: mfile format

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17  2001/07/28 21:09:22  geraint
## Eliminated duplicate lines in type.sh.
##
## Revision 1.16  2001/07/26 04:07:28  gawthrop
## Changed a to w on open (Geraint's suggestion)
## Explictly close files
##
## Revision 1.15  2001/07/23 23:24:02  gawthrop
## Now only writes to type.sh and cbg.m when causality is complete
##
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

## Start the type.sh file
mtt_header $1 type sh > $typefile

# Use matrix manipulation to accomplish the transformation
$MATRIX << EOF  >abg2cbg_m.log  #2>mtt_error.txt

  infofilenum  = fopen("$infofile",'w');
  errorfilenum = fopen("$errorfile",'w');
  typefilenum  = fopen("$typefile",'w');

  %Convert from acausal to causal bond graph in m-file form.
  system_name='$1';

  port_bonds = [];
  port_direction = [];
  port_status = [];







|
|
|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

## Start the type.sh file
mtt_header $1 type sh > $typefile

# Use matrix manipulation to accomplish the transformation
$MATRIX << EOF  >abg2cbg_m.log  #2>mtt_error.txt

  infofilenum  = fopen("$infofile",'wt');
  errorfilenum = fopen("$errorfile",'wt');
  typefilenum  = fopen("$typefile",'wt');

  %Convert from acausal to causal bond graph in m-file form.
  system_name='$1';

  port_bonds = [];
  port_direction = [];
  port_status = [];

Modified mttroot/mtt/bin/trans/cbg2ese_m2r from [f8d94a9670] to [fe2612a1bc].

12
13
14
15
16
17
18




19
20
21
22
23
24
25

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




## Revision 1.31  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint







>
>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.32  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.31  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.30  2001/07/12 04:02:53  gawthrop
## Now fixes multiports for input and output as well as state
##
## Revision 1.29.2.1  2001/06/26 22:29:05  geraint
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
# This creates an ese file for every subsystem.
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"w");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"w");
deffile = "$1_def.r";
deffilenum = fopen(deffile,"w");

system_name = "$1";
system_type = "";
system_cr = "";
system_args = "";
full_name = "";
full_name_repetition = "";







|

|

|







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
# This creates an ese file for every subsystem.
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"wt");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"wt");
deffile = "$1_def.r";
deffilenum = fopen(deffile,"wt");

system_name = "$1";
system_type = "";
system_cr = "";
system_args = "";
full_name = "";
full_name_repetition = "";
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Nuc=`mtt_getsize -internal $1 u`

# echo Ny $Ny Nu $Nu Nx $Nx Nui $Nui Nuc $Nuc

## Definitions file
octave -q <<EOF
  deffile = '$1_def.r';
  deffilenum = fopen(deffile,'w');

  ## Set up the structure vector
  structure = zeros(1,7);  
  structure(1) = $Nx; # States
  structure(2) = $Nz; # Non-states
  structure(3) = $Nu; # Inputs
  structure(4) = $Ny; # Outputs







|







230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
Nuc=`mtt_getsize -internal $1 u`

# echo Ny $Ny Nu $Nu Nx $Nx Nui $Nui Nuc $Nuc

## Definitions file
octave -q <<EOF
  deffile = '$1_def.r';
  deffilenum = fopen(deffile,'wt');

  ## Set up the structure vector
  structure = zeros(1,7);  
  structure(1) = $Nx; # States
  structure(2) = $Nz; # Non-states
  structure(3) = $Nu; # Inputs
  structure(4) = $Ny; # Outputs

Modified mttroot/mtt/bin/trans/ibg2abg_m from [1eb25954c2] to [32d431a21d].

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

# Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'w');
  errorfile = fopen('mtt_error.txt', 'w');
  
  ## Interpret data from the ibg representation
  ibonds = $1_ibg;
  bonds = ibonds.bonds;

  [bonds,components,n_vector_bonds] = ibg2abg(name,bonds, \
					      infofile,errorfile)







|
|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

# Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret data from the ibg representation
  ibonds = $1_ibg;
  bonds = ibonds.bonds;

  [bonds,components,n_vector_bonds] = ibg2abg(name,bonds, \
					      infofile,errorfile)

Modified mttroot/mtt/bin/trans/m/cbg2ese.m from [71450118ad] to [c96ae35fd7].

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.50  2003/05/08 18:47:50  gawthrop
  ## ## Fixed __ bug when using * representations
  ## ##
  ## ## Revision 1.49  2003/03/13 15:19:04  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.48  2003/03/13 15:10:26  gawthrop







>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs]
  
  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.51  2003/05/16 11:16:28  gawthrop
  ## ## Fixed bug with multiports
  ## ##
  ## ## Revision 1.50  2003/05/08 18:47:50  gawthrop
  ## ## Fixed __ bug when using * representations
  ## ##
  ## ## Revision 1.49  2003/03/13 15:19:04  gawthrop
  ## ## Now uses __ to delimit subsystems in names.
  ## ##
  ## ## Revision 1.48  2003/03/13 15:10:26  gawthrop
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
  if exist(cbg_name)~=2		# Return if cbg file doesn't exist
    disp([cbg_name, " does not exist"]);
    return
  end;
  
  ## Setup files
  ese_name = [full_name_repetition, "_ese.r"];
  ese_file = fopen(ese_name, "w") # open file (first time)
  icd_file = fopen([full_name_repetition,"_icd.txt2"],"w")

  fprintf(ese_file, "\n%s%s Equation file for system %s (file %s)\n", ...
	  pc, pc, full_name_repetition, ese_name);
  fprintf(ese_file, "%s%s Generated by MTT\n\n", pc, pc);
  
  ## Evaluate the system function to get the bonds
  eval(["CBG = ", cbg_name, ";"]);







|
|







239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  if exist(cbg_name)~=2		# Return if cbg file doesn't exist
    disp([cbg_name, " does not exist"]);
    return
  end;
  
  ## Setup files
  ese_name = [full_name_repetition, "_ese.r"];
  ese_file = fopen(ese_name, "wt") # open file (first time)
  icd_file = fopen([full_name_repetition,"_icd.txt2"],"wt")

  fprintf(ese_file, "\n%s%s Equation file for system %s (file %s)\n", ...
	  pc, pc, full_name_repetition, ese_name);
  fprintf(ese_file, "%s%s Generated by MTT\n\n", pc, pc);
  
  ## Evaluate the system function to get the bonds
  eval(["CBG = ", cbg_name, ";"]);
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407

	    disp("---PUSH---"); bond_list, comp_name, subsystem.type
	    structure = cbg2ese(comp_name, subsystem.type, subsystem.cr, subsystem.arg, ...
				full_name, full_name_repetition, ...
				k, structure,  structure_file, infofilenum);
	    
	    disp("---POP---");
	    ese_file = fopen(ese_name, "a") # open file (again)

	    eval(["subABG = ",subsystem.type , "_abg;"]); # Get the information

	    ## Link up the bonds for this compound component
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);







|







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410

	    disp("---PUSH---"); bond_list, comp_name, subsystem.type
	    structure = cbg2ese(comp_name, subsystem.type, subsystem.cr, subsystem.arg, ...
				full_name, full_name_repetition, ...
				k, structure,  structure_file, infofilenum);
	    
	    disp("---POP---");
	    ese_file = fopen(ese_name, "at") # open file (again)

	    eval(["subABG = ",subsystem.type , "_abg;"]); # Get the information

	    ## Link up the bonds for this compound component
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);

Modified mttroot/mtt/bin/trans/m/cbg2fig.m from [040a608b2a] to [7902a61185].

20
21
22
23
24
25
26



27
28
29
30
31
32
33
  ## Copyright (c) P.J.Gawthrop, 1996.

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



  ## %% Revision 1.15  2001/03/23 11:20:20  gawthrop
  ## %% Fixed bug with vector components --NB takes geometric info from _rbg.fig
  ## %%
  ## %% Revision 1.14  2000/09/14 12:07:15  peterg
  ## %% Fixed overwriting of ports.
  ## %%
  ## %% Revision 1.13  2000/09/14 09:12:19  peterg







>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  ## Copyright (c) P.J.Gawthrop, 1996.

  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% Version control history
  ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  ## %% $Id$
  ## %% $Log$
  ## %% Revision 1.16  2001/03/23 14:58:16  gawthrop
  ## %% Fixed cosmetic bugs -- component display
  ## %%
  ## %% Revision 1.15  2001/03/23 11:20:20  gawthrop
  ## %% Fixed bug with vector components --NB takes geometric info from _rbg.fig
  ## %%
  ## %% Revision 1.14  2000/09/14 12:07:15  peterg
  ## %% Fixed overwriting of ports.
  ## %%
  ## %% Revision 1.13  2000/09/14 09:12:19  peterg
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'a');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = ', system_type, '_rbg;']);
  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  
  ## Return if initial fig file doesn't exist
  if exist(fig_name)~=2
    return
  end;

  ## Setup file - append to the fig file
  filenum = fopen(fig_name, 'at');

  ## Get the raw and the processed bonds
  eval(['[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = ', system_type, '_rbg;']);
  eval(["ABG = ", system_type, "_abg;"]);
  bonds=ABG.bonds;

  ## Original number of bonds

Modified mttroot/mtt/bin/trans/m/figfig.m from [bec738695e] to [f08a96551e].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
  ## key=1 gives the key legend

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



  ## Revision 1.10  2003/08/19 13:13:28  gawthrop
  ## No legend
  ##
  ## Revision 1.9  2002/09/12 08:39:27  gawthrop
  ## Removed spurious text
  ##
  ## Revision 1.8  2002/09/11 15:04:59  gawthrop







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  ## key=1 gives the key legend

  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.11  2004/03/15 11:44:34  gawthrop
  ## Yet another option (to allow legend).
  ##
  ## Revision 1.10  2003/08/19 13:13:28  gawthrop
  ## No legend
  ##
  ## Revision 1.9  2002/09/12 08:39:27  gawthrop
  ## Removed spurious text
  ##
  ## Revision 1.8  2002/09/11 15:04:59  gawthrop
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  endif
  replot;
  gset term x11
  gset output
  replot;

  if boxed # Add a box - makes a visible bounding box
    fid = fopen(figfilename,"a+");
    fprintf(fid,"2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5\n");
    fprintf(fid,"\t9675 5310 9675 270 225 270 225 5310 9675 5310\n");
    fclose(fid);
  endif
  

  if nargin>1			# Do a file in another langueage







|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  endif
  replot;
  gset term x11
  gset output
  replot;

  if boxed # Add a box - makes a visible bounding box
    fid = fopen(figfilename,"a+t");
    fprintf(fid,"2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5\n");
    fprintf(fid,"\t9675 5310 9675 270 225 270 225 5310 9675 5310\n");
    fclose(fid);
  endif
  

  if nargin>1			# Do a file in another langueage

Modified mttroot/mtt/bin/trans/m/mtt_error.m from [73f0ddc790] to [85c51b0617].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$



% %% Revision 1.2  1997/02/11 10:06:42  peterg
% %% Removed a debugging line.
% %%
% %% Revision 1.1  1996/08/18  20:06:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set default file if it isn't there already
if nargin<2
  errorfile = fopen('mtt_error.txt','a');
end;

fprintf(errorfile, '*MTT ERROR : %s\n', message);

#error('MTT exiting this transformation on error');








>
>
>










|






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
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.1  1998/12/03 16:21:27  peterg
% %% Initial revision
% %%
% %% Revision 1.2  1997/02/11 10:06:42  peterg
% %% Removed a debugging line.
% %%
% %% Revision 1.1  1996/08/18  20:06:57  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set default file if it isn't there already
if nargin<2
  errorfile = fopen('mtt_error.txt','at');
end;

fprintf(errorfile, '*MTT ERROR : %s\n', message);

#error('MTT exiting this transformation on error');

Modified mttroot/mtt/bin/trans/m/mtt_info.m from [0d1963332d] to [5fc6fed510].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
  ##     ######################################

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



  ## ## Revision 1.3  2000/11/12 17:10:51  peterg
  ## ## Close file if it is opened
  ## ## Reformated  octave style
  ## ##
  ## ## Revision 1.2  1997/02/11 10:06:42  peterg
  ## ## Removed a debugging line.
  ## ##







>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  ##     ######################################

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.4  2003/03/24 12:18:00  gawthrop
  ## ## Default file when no second argument
  ## ##
  ## ## Revision 1.3  2000/11/12 17:10:51  peterg
  ## ## Close file if it is opened
  ## ## Reformated  octave style
  ## ##
  ## ## Revision 1.2  1997/02/11 10:06:42  peterg
  ## ## Removed a debugging line.
  ## ##
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  elseif infofile<0
    nofile = 1;
  else
    nofile = 0;
  endif
  
  if nofile
    infofile = fopen("mtt_info.txt","a");
  end;

  fprintf(infofile, "INFORMATION: %s\n", info);

  if nofile
    fclose(infofile);
  end;







|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  elseif infofile<0
    nofile = 1;
  else
    nofile = 0;
  endif
  
  if nofile
    infofile = fopen("mtt_info.txt","at");
  end;

  fprintf(infofile, "INFORMATION: %s\n", info);

  if nofile
    fclose(infofile);
  end;

Modified mttroot/mtt/bin/trans/m/mtt_save_alias.m from [85981ff6a1] to [d6d06732d5].

11
12
13
14
15
16
17
18
19
20
21
  ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## mtt_info.m,v 1.2 1997/02/11 10:06:42 peterg Exp peterg $ ## $Log:
  ## mtt_info.m,v $ ## Revision 1.2  1997/02/11 10:06:42  peterg ##
  ## ###############################################################

  fileid = fopen('mtt_aliased.txt','a');
  fprintf(fileid, "%s\t%s\n", arg,system_name);
  fclose(fileid);
endfunction







|



11
12
13
14
15
16
17
18
19
20
21
  ## Version
  ## control history
  ## ############################################################### ## $Id:
  ## mtt_info.m,v 1.2 1997/02/11 10:06:42 peterg Exp peterg $ ## $Log:
  ## mtt_info.m,v $ ## Revision 1.2  1997/02/11 10:06:42  peterg ##
  ## ###############################################################

  fileid = fopen('mtt_aliased.txt','at');
  fprintf(fileid, "%s\t%s\n", arg,system_name);
  fclose(fileid);
endfunction

Modified mttroot/mtt/bin/trans/m/write_abg.m from [6d40a77baf] to [ec868dcca7].

1
2
3
4
5
6
7



8
9
10
11
12
13
14
function write_abg(system_name,bonds,connections,n_vector_bonds);

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



## Revision 1.9  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.8  1999/10/18 22:41:41  peterg
## Corrected vector junction expansion
##
## Revision 1.7  1999/10/18 05:16:51  peterg







>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function write_abg(system_name,bonds,connections,n_vector_bonds);

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2004/08/09 14:47:28  gawthrop
## Changed arg to args to avoid strange octave bug
##
## Revision 1.9  2001/04/15 21:15:41  geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.8  1999/10/18 22:41:41  peterg
## Corrected vector junction expansion
##
## Revision 1.7  1999/10/18 05:16:51  peterg
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
##
## Revision 1.1  1998/08/25 06:22:02  peterg
## Initial revision
##
###############################################################


  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 = [";







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
##
## Revision 1.1  1998/08/25 06:22:02  peterg
## Initial revision
##
###############################################################


  fid=fopen([system_name,"_abg.m"], "wt");
  [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 = [";

Modified mttroot/mtt/bin/trans/m/write_cbg.m from [9ac520a74a] to [bf1b05ce91].

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
function write_cbg(system_name,system_type,system,Flipped)

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



## Revision 1.3  1998/08/25 20:05:33  peterg
## Write flipped port info
##
## Revision 1.2  1998/08/25 06:21:19  peterg
## Just writes additional information; basic info from the abg structure.
##
## 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";
  Iformat = "  %s.%s.%s.connections(%i) = %i;\n";


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







>
>
>












|







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
function write_cbg(system_name,system_type,system,Flipped)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1998/08/26 12:26:17  peterg
## Replaced if N>0 by   if (N>0)&&(M>0)		# Flipped ports exist
##
## Revision 1.3  1998/08/25 20:05:33  peterg
## Write flipped port info
##
## Revision 1.2  1998/08/25 06:21:19  peterg
## Just writes additional information; basic info from the abg structure.
##
## Revision 1.1  1998/08/25 05:55:10  peterg
## Initial revision
##
###############################################################


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

  StatusFormat = "  %s.%s.%s.status = %i;\n";
  Bformat = "  %s.bonds = [\n";
  Iformat = "  %s.%s.%s.connections(%i) = %i;\n";


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

Modified mttroot/mtt/bin/trans/m/write_ibg.m from [eba86d514c] to [041b691f80].

1
2
3
4
5
6
7
8
9
10
11
12
## -*-octave-*-

function write_ibg(system_name,bonds);
  
  fid = fopen([system_name,"_ibg.m"], "w");
  [nbonds, junk] = size(struct_elements(bonds));
  format_hc = "  %s.bonds.bond%i.head.component\t= \"%s\";\n";
  format_tc = "  %s.bonds.bond%i.tail.component\t= \"%s\";\n";
  format_hp = "  %s.bonds.bond%i.head.ports\t= \"%s\";\n";
  format_tp = "  %s.bonds.bond%i.tail.ports\t= \"%s\";\n";
  format_ce = "  %s.bonds.bond%i.causality.effort\t= \"%s\";\n";
  format_cf = "  %s.bonds.bond%i.causality.flow\t= \"%s\";\n";




|







1
2
3
4
5
6
7
8
9
10
11
12
## -*-octave-*-

function write_ibg(system_name,bonds);
  
  fid = fopen([system_name,"_ibg.m"], "wt");
  [nbonds, junk] = size(struct_elements(bonds));
  format_hc = "  %s.bonds.bond%i.head.component\t= \"%s\";\n";
  format_tc = "  %s.bonds.bond%i.tail.component\t= \"%s\";\n";
  format_hp = "  %s.bonds.bond%i.head.ports\t= \"%s\";\n";
  format_tp = "  %s.bonds.bond%i.tail.ports\t= \"%s\";\n";
  format_ce = "  %s.bonds.bond%i.causality.effort\t= \"%s\";\n";
  format_cf = "  %s.bonds.bond%i.causality.flow\t= \"%s\";\n";

Modified mttroot/mtt/bin/trans/m/write_matrix.m from [b13ea8436c] to [969955d3a1].

1
2
3
4
5
6
7
8
9



10
11
12
13
14
15
16
function write_matrix(matrix,name,extn);

% Writes the matrix function file

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$



% %% Revision 1.6  2000/12/27 16:06:17  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.5  1998/02/03 08:40:39  peterg
% %% Fixed a horrible bug -- changed filename -> filenum
% %%
% %% Revision 1.4  1996/08/15  11:56:11  peter









>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function write_matrix(matrix,name,extn);

% Writes the matrix function file

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2002/05/15 16:37:30  gawthrop
% %% Added third argument (file extension)
% %%
% %% Revision 1.6  2000/12/27 16:06:17  peterg
% %% *** empty log message ***
% %%
% %% Revision 1.5  1998/02/03 08:40:39  peterg
% %% Fixed a horrible bug -- changed filename -> filenum
% %%
% %% Revision 1.4  1996/08/15  11:56:11  peter
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43


if nargin<3
  extn="m";
endif

filename = sprintf("%s.%s", name, extn);
filenum = fopen(filename,'w');

% Write the function m-file for the causal bond graph
pc = '%';
fprintf(filenum, 'function data = %s\n', name);
fprintf(filenum, '%s data = %s\n\n', pc, name);

fprintf(filenum, 'data = [\n');







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46


if nargin<3
  extn="m";
endif

filename = sprintf("%s.%s", name, extn);
filenum = fopen(filename,'wt');

% Write the function m-file for the causal bond graph
pc = '%';
fprintf(filenum, 'function data = %s\n', name);
fprintf(filenum, '%s data = %s\n\n', pc, name);

fprintf(filenum, 'data = [\n');

Modified mttroot/mtt/bin/trans/makesspar from [74fdc0a727] to [52aff62f6f].

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
# Copyright (c) P.J.Gawthrop, 1998.

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



## Revision 1.2  1998/02/09 08:39:27  peterg
## Set inputs to zero as well.
##
## Revision 1.1  1998/02/06 15:53:49  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_sspar.r

echo "% Steady-state parameters for system $1 ($1_sspar.r)"> $1_sspar.r
echo "% Generated by MTT on" `date`. >> $1_sspar.r                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_sspar.r
echo "% Set all states and inputs to zero" >> $1_sspar.r                  	   

$MATRIX  <<EOF >> /dev/null

fnum=fopen("$1_sspar.r","a");

[nx,ny,nu,nz,nyz] = $1_def;

for i = 1:nx
  fprintf(fnum,"MTTX%i := 0;\n", i);
end;
fprintf(fnum,"\n");







>
>
>



















|







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
# Copyright (c) P.J.Gawthrop, 1998.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1998/02/09 14:13:39  peterg
## Put octave stuff to /dev/null
##
## Revision 1.2  1998/02/09 08:39:27  peterg
## Set inputs to zero as well.
##
## Revision 1.1  1998/02/06 15:53:49  peterg
## Initial revision
##
###############################################################


#Inform user
echo Creating $1_sspar.r

echo "% Steady-state parameters for system $1 ($1_sspar.r)"> $1_sspar.r
echo "% Generated by MTT on" `date`. >> $1_sspar.r                  	   
cat $MTTPATH/trans/m/rcs_header.txt  >> $1_sspar.r
echo "% Set all states and inputs to zero" >> $1_sspar.r                  	   

$MATRIX  <<EOF >> /dev/null

fnum=fopen("$1_sspar.r","at");

[nx,ny,nu,nz,nyz] = $1_def;

for i = 1:nx
  fprintf(fnum,"MTTX%i := 0;\n", i);
end;
fprintf(fnum,"\n");

Modified mttroot/mtt/bin/trans/rbg2abg_m from [9082db29a6] to [064144351b].

1
2
3
4
5
6
7
8
9
10
11
12
13



14
15
16
17
18
19
20
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.19  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.18  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##













>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: rbg2abg_m
#
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.20  2004/02/19 12:05:49  gawthrop
## Fix prob. when no bonds
##
## Revision 1.19  2002/04/28 18:55:03  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.18  2001/03/30 15:13:58  gawthrop
## Rationalised simulation modes to each return mtt_data
##
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

#Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>mtt_error.txt << EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'w');
  errorfile = fopen('mtt_error.txt', 'w');

  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg
  [n_ports, junk] = size(port_list)
 
  N_ports = 0;
  for i=1:n_ports		# Count the true number of ports.







|
|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

#Inform user
echo Creating ${abg_file}

# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log  2>mtt_error.txt << EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');

  %Convert from the fig version of the bonds to a structured version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg
  [n_ports, junk] = size(port_list)
 
  N_ports = 0;
  for i=1:n_ports		# Count the true number of ports.

Modified mttroot/mtt/bin/trans/rbg2ibg_m from [f7d2755771] to [855051faf6].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

# Inform user
echo Creating ${ibg}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'w');
  errorfile = fopen('mtt_error.txt', 'w');
  
  ## Interpret the connections from the fig version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
  [n_ports, junk] = size(port_list);
  
  ## Strip the directional information
  rbonds = rbonds(:,1:6);







|
|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

# Inform user
echo Creating ${ibg}

# Use matrix manipulation to accomplish the transformation
${MATRIX} > ${log} 2> ${err} <<EOF
  name = '$1'
  infofile = fopen('mtt_info.txt', 'wt');
  errorfile = fopen('mtt_error.txt', 'wt');
  
  ## Interpret the connections from the fig version
  [rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
  [n_ports, junk] = size(port_list);
  
  ## Strip the directional information
  rbonds = rbonds(:,1:6);


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