Overview
Comment:Changed newline escape from backslash to ellipsis in m files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: a349b0c96b1104575b9c84b9557a9eaea321c9d709df74afb29630884657f94b
User & Date: geraint@users.sourceforge.net on 2014-07-25 21:31:48
Other Links: branch diff | manifest | tags
Context
2014-08-02
16:36:14
Replaced continuation character in lib m files, except PPP and Control check-in: 67e34974df user: geraint@users.sourceforge.net tags: origin/master, trunk
2014-07-25
21:31:48
Changed newline escape from backslash to ellipsis in m files check-in: a349b0c96b user: geraint@users.sourceforge.net tags: origin/master, trunk
2014-07-14
06:37:07
Avoid continuation \ issues. check-in: 53581fb570 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/abg2cbg.m from [d576ebb7c3] to [27f38055ab].

16
17
18
19
20
21
22



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







+
+
+







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

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.53  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.52  2004/09/07 18:22:53  geraint
  ## ## Issues a more helpful error message than the cryptic Octave stuff
  ## ## if there are unconnected ports.
  ## ##
  ## ## Revision 1.51  2004/02/20 20:42:40  geraint
  ## ## Initialize Flipped.cons with [] instead of "".
  ## ##
322
323
324
325
326
327
328
329

330
331
332
333
334
335
336
337

338
339
340
341
342
343
344
325
326
327
328
329
330
331

332
333
334
335
336
337
338
339

340
341
342
343
344
345
346
347







-
+







-
+







	mtt_error (sprintf ("abg2cbg: port_bond_direction(%d) does not exist.", i));
	exit(1);
      end
      if (sign(port.connections)!=port_bond_direction(i)) # Direction different?
      	eval(["ABG.ports.",name,".connections = - port.connections;"]); # Flip direction at port
	Flipped.ports=[Flipped.ports;name];	# Remember which port has been flipped
        bond_index=abs(port.connections); # Index of bond on port
      	mtt_info(sprintf("Flip port %s on %s"\
      	mtt_info(sprintf("Flip port %s on %s" ...
			 ,name,full_name),infofile); # And report
      	for [subsystem,name] = ABG.subsystems # and at the other end
	  for k=1:length(subsystem.connections)
	    if (abs(subsystem.connections(k))==bond_index) # Then flip the connection
	      eval(["ABG.subsystems.",name,".connections(k)   = -subsystem.connections(k);"]);
	      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"\
      	      mtt_info(sprintf("Flip subsystem %s on %s" ...
			       ,name,full_name),infofile); # And report
	    endif
	  endfor
      	endfor			# subsystem = ABG.subsystems

      	ABG.bonds(bond_index,:) = -ABG.bonds(bond_index,:);	# Flip the bond causalities 
	##(these are arrow-orientated)

Modified mttroot/mtt/bin/trans/m/alias_args.m from [e741159462] to [52ee84b0ea].

1
2
3
4
5
6
7



8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17







+
+
+







function args = alias_args(args,alias,delim,message,FileID,sys_name)

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  2012/10/15 19:16:03  geraint
## split is obsolete in Octave, replaced with strsplit
##
## Revision 1.9  2009/11/02 16:54:03  geraint
## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
##
## Revision 1.8  2001/06/13 16:07:15  gawthrop
## Fixed bug with three separators in a row eg )/(
##
## Revision 1.7  2001/06/13 14:50:15  gawthrop
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







-
+







      Args = char(strsplit(args,delim)); args="";
      [N,M]= size(Args);
      for i=1:N
        arg = deblank(Args(i,:));
        arg_ = strrep(arg,",","__");
        if isfield(alias,arg_)
          eval(["new_arg = alias.", arg_,";"]);
  	  mtt_info(["Replacing ", arg, "\t by ",\
  	  mtt_info(["Replacing ", arg, "\t by ", ...
		    new_arg, message],FileID);
  	  mtt_save_alias(arg,sys_name);
##	  printf("%s --> %s\n",arg,new_arg);
          arg = new_arg;
## 	else
## 	  mtt_info(["NOT replacing ", arg, message],FileID);
        end

Modified mttroot/mtt/bin/trans/m/cbg2ese.m from [ea5247f84f] to [fbe5a968f6].

19
20
21
22
23
24
25



26
27
28
29
30
31
32
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.54  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## 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.
  ## ##
226
227
228
229
230
231
232
233
234


235
236
237

238
239
240
241
242
243
244
229
230
231
232
233
234
235


236
237
238
239

240
241
242
243
244
245
246
247







-
-
+
+


-
+







    full_name = system_name;
    full_name_repetition = system_name;
    system_type = system_name;
  else
    full_name = [full_name, sub_delim, system_name];

    if (repetition>1)
      full_name_repetition = [full_name_repetition, \
			      sub_delim, system_name, sub_delim, \
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name, sub_delim, ...
			      num2str(repetition)];
    else
      full_name_repetition = [full_name_repetition, \
      full_name_repetition = [full_name_repetition, ...
			      sub_delim, system_name];
    endif
    
  end;
  
  
  
289
290
291
292
293
294
295
296

297
298
299
300
301
302
303
304

305
306
307
308
309
310
311
292
293
294
295
296
297
298

299
300
301
302
303
304
305
306

307
308
309
310
311
312
313
314







-
+







-
+







  
  ## Set up the counters for the labelled SS. These are, by definition,
  ## encountered first and so the counters will not be messed up by subsystems.
  local_u_index = 0;
  local_y_index = 0;
  
  if (length(system_args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s(%s)",\
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingArguments=0;
  else
    AliasingArguments=1;
  endif;
  
  if (length(system_cr)==0)
    mtt_info(sprintf("No cr given so no cr aliasing done for system %s(%s)",\
    mtt_info(sprintf("No cr given so no cr aliasing done for system %s(%s)", ...
		     system_name,system_type), infofilenum);
    AliasingCRs=0;
  else
    AliasingCRs=1;  endif;
  
  
  fields=["ports";"subsystems"]; # Do for both ports and subsystems -
325
326
327
328
329
330
331
332

333
334
335
336
337
338
339
340

341
342
343
344
345
346
347
328
329
330
331
332
333
334

335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350







-
+







-
+







    	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",\
    	  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",\
    	  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
414
415
416
417
418
419
420
421

422
423
424
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
465
466

467
468
469
470


471
472
473
474
475
476
477

478
479
480
481
482
483

484
485
486
487


488
489
490
491
492
493
494
417
418
419
420
421
422
423

424
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
465
466
467
468

469
470
471


472
473
474
475
476
477
478
479

480
481
482
483
484
485

486
487
488


489
490
491
492
493
494
495
496
497







-
+



-
+




-
+






-
+

-
+





-
+


-
+

-
+









-
+





-
+


-
-
+
+






-
+





-
+


-
-
+
+







	    ## 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);
	    
	    if (k>1)
	      name_comp_name = sprintf("%s%s%s%s%d", ...
				       full_name_repetition, sub_delim, \
				       full_name_repetition, sub_delim, ...
				       comp_name, sub_delim, k);
	    else
	      name_comp_name = sprintf("%s%s%s", ...
				       full_name_repetition, sub_delim, \
				       full_name_repetition, sub_delim, ...
				       comp_name);
	    endif
	    
	    
	    printf("\n\t%s Equations linking up subsystem %s (%s)\n\n",\
	    printf("\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		   pc, comp_name, subsystem.type);
	    
	    u_index = 0; y_index = 0; ## Count the inputs and outputs
	    for port_number=1:length(bond_list)
	      repetition,port_number
              port_bond_number = bond_list(port_number)
# 	      this_bond_effort_unit = \
# 	      this_bond_effort_unit = ...
# 		  deblank(bond_effort_unit(port_bond_number,:))
# 	      this_bond_flow_unit = \
# 	      this_bond_flow_unit = ...
# 		  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;", \
#               eval(sprintf("this_port = subABG.ports.%s;", ...
# 			   this_port_name));
# 	      if isfield(this_port,"units")
#                 eval(["effort_unit = \
#                 eval(["effort_unit = ...
# 		    subABG.ports.",this_port_name,".units.effort;"]);
#                 eval(["flow_unit = \
#                 eval(["flow_unit = ...
# 		    subABG.ports.",this_port_name,".units.flow;"]);
# 	      else
# 		effort_unit = "none";
# 		flow_unit = "none";
# 	      endif

# 	      ## and check consistency
#               ## Efforts
# 	      if strcmp(this_bond_effort_unit,"null") # set
# 		bond_effort_unit = \
# 		bond_effort_unit = ...
# 		    [bond_effort_unit(1:port_bond_number-1,:)
# 		     effort_unit
# 		     bond_effort_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_effort_unit,"none") && !strcmp(effort_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, effort_unit, \
# 		mtt_info(sprintf(unit_info,full_name, effort_unit, ...
# 				 this_bond_effort_unit), infofilenum);
# 		if !strcmp(this_bond_effort_unit,effort_unit)
# 		  error_string = sprintf(unit_error, full_name,\
# 					 effort_unit, \
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 effort_unit, ...
# 					 this_bond_effort_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
# 	      ## Flows
# 	      if strcmp(this_bond_flow_unit,"null") # set
# 		bond_flow_unit = \
# 		bond_flow_unit = ...
# 		    [bond_flow_unit(1:port_bond_number-1,:)
# 		     flow_unit
# 		     bond_flow_unit(port_bond_number+1:n_bonds,:)
# 		     ]
# 	      elseif (!strcmp(this_bond_flow_unit,"none") && !strcmp(flow_unit,"none")) # check
# 		mtt_info(sprintf(unit_info,full_name, flow_unit, \
# 		mtt_info(sprintf(unit_info,full_name, flow_unit, ...
# 				 this_bond_flow_unit), infofilenum);
# 		if !strcmp(this_bond_flow_unit,flow_unit)
# 		  error_string = sprintf(unit_error, full_name,\
# 					 flow_unit, \
# 		  error_string = sprintf(unit_error, full_name, ...
# 					 flow_unit, ...
# 					 this_bond_flow_unit);
# 		  mtt_error(error_string);
# 		endif
# 	      endif
	      

	      ## Effort
560
561
562
563
564
565
566
567

568
569
570
571
572
573
574
563
564
565
566
567
568
569

570
571
572
573
574
575
576
577







-
+







		    cause_name = cause2name(-comp_bonds(1,k));
		  else		# Maybe multiport - but unicausal
		    cause_name = cause2name(-comp_bonds(k,1));
		  endif
 		  fprintf(structure_file, ...
 			  "%s\t%i\t%s\t%s%s%s\t%i\t%s\n", ...
 			  structure_name(which_index,:), value-k+1, ...
 			  comp_name, full_name_repetition, sub_delim, comp_name, \
 			  comp_name, full_name_repetition, sub_delim, comp_name, ...
 			  repetition, cause_name); 
 	    	endfor;
 	      endfor;
 	    endif;
	  endif
	endfor
	fflush (structure_file);

Modified mttroot/mtt/bin/trans/m/ibg2abg.m from [ac24c78571] to [acf7448537].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







## -*-octave-*-

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

  ## write useful quantity of data to log
  struct_levels_to_print(6);

  ################################
  ## create component structure ##
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
178

179
180
181
182
183
184
185
186







-
+








-
+








-
+







	    endif
	  endif
	  eval(sprintf("comp.%s = bond;", bond_name));
	endfor
	
	## attach labels to unlabelled ports
	if (n_named_ports == 0)
	  mtt_info(sprintf("Defaulting all ports on junction %s to 'in'", \
	  mtt_info(sprintf("Defaulting all ports on junction %s to 'in'", ...
			   comp_name), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = "in";
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports == 1)
	  mtt_info(sprintf("Defaulting all ports on junction %s to %s", \
	  mtt_info(sprintf("Defaulting all ports on junction %s to %s", ...
			   comp_name, port_label), infofile);
	  for [bond, bond_name] = comp
	    if (index(bond_name, "bond") == 1)
	      bond.label = port_label;
	    endif
	    eval(sprintf("comp.%s = bond;", bond_name));
	  endfor
	elseif (n_named_ports != comp.n_bonds)
	  mtt_error(sprintf("Junction must have 0,1 or %i port labels", \
	  mtt_error(sprintf("Junction must have 0,1 or %i port labels", ...
			    comp.n_bonds), errorfile);
	endif
	
      else
	## component is not a junction
	for [bond, bond_name] = comp
	  if (index(bond_name, "bond") == 1)

Modified mttroot/mtt/bin/trans/m/mtt_alias.m from [8f9f502367] to [95ae877303].

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

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







function [args] = mtt_alias (fullname,args,default);
  ## usage:  [cr,args] = mtt_alias (fullname,cr,args)
  ##
  ## Aliasing code for mtt.
  ## Abstracted from cbg2ese for use in cbg2sese_m2r

  ## Copyright (C) 2003 by Peter J. Gawthrop

  filenum = -1;			# No file number for messages

  [Name,name] = mtt_subname(fullname); # Split fullname

  if (length(args)==0)
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s",\
    mtt_info(sprintf("No arguments given so no argument aliasing done for system %s", ...
		     fullname));
    return
  endif
  
  ## Info for component and surrounding subsystem
  cbg = mtt_cbg(fullname);	# Structure for this component

Modified mttroot/mtt/bin/trans/m/mtt_component_eqn.m from [50cfed29c8] to [a190371a3c].

1

2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
-
+







function [known] = mtt_component_eqn (fullname, port, causality, \
function [known] = mtt_component_eqn (fullname, port, causality, ...
				      known, Cbg)

  ## function [known] = mtt_component_eqn (fullname, port, causality, known)
  ##
  ## Recursively finds the equations giving the signal of specified
  ## causality on the specified port of component named "name" within
  ## subsystem Name 
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84







-
+







    if port>N_ports
      error(sprintf("port (%i) > N_ports (%i)", port, N_ports));
    else			# Get name and find equation
      name = deblank(cbg.portlist(port,:));
      if DEBUG
	disp("----> lower-level system")
      endif
      known = mtt_component_eqn (mtt_fullname(Name,name), 1, \
      known = mtt_component_eqn (mtt_fullname(Name,name), 1, ...
				 causality, known, cbg);
      return
    endif
  endif
  

  ## Other causality representations
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112







-
+







  
  ## A useful composite name
  name_port_cause = sprintf("%s_%i_%s",name, port, cause);
  full_name_port_cause = mtt_fullname(Name,name_port_cause);

  ## If value is known, don't do anything.
  if findstr(sprintf(" %s ", full_name_port_cause), known)>0
    eqn = sprintf("%s The %s signal on port %i of %s is known already", \
    eqn = sprintf("%s The %s signal on port %i of %s is known already", ...
		  CD, causality, port, name);
    return
  else			# Add to list
    known = sprintf("%s %s", known, full_name_port_cause);
  endif
  
  
134
135
136
137
138
139
140
141

142
143
144

145
146
147
148
149
150
151
134
135
136
137
138
139
140

141
142
143

144
145
146
147
148
149
150
151







-
+


-
+







  bonds = cbg.bonds;

  ## List of component bond causality (component-orientated causality)
  comp_bonds = bonds(bond_list,:).*directions; # Component bonds

  ## What components are at the other ends of the in bonds?
  ## Effort
  [in_e_bonds,in_e_components,in_e_ports,N_e] = mtt_component_inputs \
  [in_e_bonds,in_e_components,in_e_ports,N_e] = mtt_component_inputs ...
      (name,comp_type,causality,"effort",comp_bonds,connections,cbg);
  ## Flow
  [in_f_bonds,in_f_components,in_f_ports,N_f] = mtt_component_inputs \
  [in_f_bonds,in_f_components,in_f_ports,N_f] = mtt_component_inputs ...
      (name,comp_type,causality,"flow",comp_bonds,connections,cbg);


  ##Composite values
  N_ef = N_e + N_f;
  in_ef_bonds = [in_e_bonds; in_f_bonds];
  in_ef_components = [in_e_components; in_f_components];
192
193
194
195
196
197
198
199

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
224




225
226
227
228
229
230
231
192
193
194
195
196
197
198

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

216
217
218
219
220




221
222
223
224
225
226
227
228
229
230
231







-
+
















-
+




-
-
-
-
+
+
+
+








    ## Find its equation
    if DEBUG
      disp("----> higher level system")
    endif
    

    known = mtt_component_eqn (mtt_fullname(new_Name,in_name), \
    known = mtt_component_eqn (mtt_fullname(new_Name,in_name), ...
			       in_port, causality, known, cbg);

    LHS = Source_seqn ("external",Name);
    RHS = varname(NAME, abs(in_bond), i_cause);
    eqn = sprintf("%s%s%s := %s;", LHS, SD, name, RHS);

    if !DEBUG
      comment = sprintf("%s PORT", CD);
      disp(sprintf("%s\n%s",comment, eqn));
    endif

  endif
  

  ## Handle special components
  if strcmp(comp_type,"0")||strcmp(comp_type,"1") # Junctions
    [eqn,insigs,innames] = junction_seqn (comp_type,Name, outsig, \
    [eqn,insigs,innames] = junction_seqn (comp_type,Name, outsig, ...
					  insigs, innames);
  else				# Everything else
    if exist(sprintf("%s_cause", comp_type)) # Simple component
      ## Do the equations
      [eqn,insigs,innames] = eval(sprintf("%s_seqn (Name, name, cr, \
						    arg, outsig, \
						    insigs, \
						    innames, is_port_output);", \
      [eqn,insigs,innames] = eval(sprintf("%s_seqn (Name, name, cr, ...
						    arg, outsig, ...
						    insigs, ...
						    innames, is_port_output);", ...
					  comp_type));
      ## Resolve CR
      eqn = mtt_resolve_cr(eqn);

    else			# Compound component
      new_NAME = Name;
      new_Name = mtt_fullname(Name,name);
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253


254
255
256
257
258
259
260
239
240
241
242
243
244
245

246
247
248
249
250
251


252
253
254
255
256
257
258
259
260







-
+





-
-
+
+







      RHS = Sensor_seqn ("external",new_Name);
      eqn = sprintf("%s := %s%s%s;", LHS, RHS, SD, port_name);

      if DEBUG
	disp("----> same-level subsystem")
      endif

      [known] = mtt_component_eqn \
      [known] = mtt_component_eqn ...
   	  (mtt_fullname(new_Name,new_name), port, causality, known, cbg);
      
    endif
  endif

  comment = \
      sprintf("%s Equation for %s signal on port %i of %s (%s), subsystem %s.", \
  comment = ...
      sprintf("%s Equation for %s signal on port %i of %s (%s), subsystem %s.", ...
     	      CD, causality, port, name, comp_type, Name);

  if DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif
  
  is_external = mtt_is_external(comp_type,outsig, insigs, is_port_output);
272
273
274
275
276
277
278
279
280


281
282
283
284
285
286
287
288
289
290
291
272
273
274
275
276
277
278


279
280
281
282
283
284
285
286
287
288
289
290
291







-
-
+
+











      other_port = insigs(i,3);
      other_name = deblank(innames(i,:));
      if DEBUG
	disp("----> same-level component")
      endif
      

      [known] = mtt_component_eqn \
    	  (mtt_fullname(Name,other_name), other_port, other_causality, \
      [known] = mtt_component_eqn ...
    	  (mtt_fullname(Name,other_name), other_port, other_causality, ...
	   known, cbg);
    endfor
  endif

  ## Write this signal
  ##comment_2 = sprintf("Connected to:%s", in_component_list);
  if !DEBUG
    disp(sprintf("%s\n%s",comment, eqn));
  endif

endfunction

Modified mttroot/mtt/bin/trans/m/mtt_component_inputs.m from [654cc2c381] to [6889a2a85b].

1

2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
-
+







function [in_bonds,in_components,in_ports,N] = mtt_component_inputs \
function [in_bonds,in_components,in_ports,N] = mtt_component_inputs ...
      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)

  ## usage:  [in_bonds,in_components,in_ports,N] = mtt_component_inputs 
  ##      (name,comp_type, out_causality, causality,comp_bonds,bond_list,cbg)
  ##
  ## 

Modified mttroot/mtt/bin/trans/m/mtt_stime.m from [57b5993ee0] to [588e121a7c].

34
35
36
37
38
39
40
41

42
43
44

45
46
47
48
49
50
51
34
35
36
37
38
39
40

41
42
43

44
45
46
47
48
49
50
51







-
+


-
+







    for j=1:length(theta)
      args = sprintf("%s %g",args, theta(j));
    endfor

    ## Run system and replace NaN by 1e30 -- easier to handle
    file_name = sprintf("%s_input.dat", system_name);
    if exist(file_name)==2	# Then use data from this file ...
      command = sprintf("./%s_ode2odes.out %s < %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", \
      command = sprintf("./%s_ode2odes.out %s < %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args, file_name);
    else
      command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", \
      command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", ...
			system_name, args);
    endif
      
   system(command);

    ## Retrieve out_data
    load -force mtt_out_data.dat

Modified mttroot/mtt/bin/trans/m/printcr.m from [4fb181bd27] to [33c745664a].

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







+
+
+
















-
+









## ###############################################################
## ## Version control history
## ###############################################################
## ## $Id$
## ## $Log$
## ## Revision 1.2  2003/01/07 09:11:53  gawthrop
## ## Octavised
## ##
## ## Revision 1.1  1998/07/25 09:47:43  peterg
## ## Initial revision
## ##
## ###############################################################



  if nargin<7
    eqnfile = "stdout";
  endif

  ## Find the number of ports
  ports = length(RHS_cause);

  ## Print the CR
  if length(cr) == 0 # No CR given - use unity CR
    fprintf(eqnfile, "%s;\n", varname(name,bond_number(outport), \
    fprintf(eqnfile, "%s;\n", varname(name,bond_number(outport), ...
				      RHS_cause(outport)));
  else # CR exists
    fprintf(eqnfile, "%s(%s", cr, name); # The CR name and component type
    if ports>1 # Multi ports - port no. is first arg of CR
      fprintf(eqnfile, "#1.0f,", outport);
    endif
    fprintf(eqnfile, "%s", args); # Print the arguments

Modified mttroot/mtt/bin/trans/m/rbg2abg.m from [c3c2325f5b] to [19a07974ce].

1
2


3
4
5
6
7
8
9



10
11
12
13
14
15
16


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-
-
+
+







+
+
+







function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,\
				      port_coord,port_name,\
function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents, ...
				      port_coord,port_name, ...
				      infofile,errorfile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.51  2012/10/15 19:22:44  geraint
  ## ## mtt_isunique replaces unique which masks a built-in function.
  ## ##
  ## ## Revision 1.50  2009/11/02 16:54:03  geraint
  ## ## Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char
  ## ##
  ## ## Revision 1.49  2004/07/22 13:18:02  geraint
  ## ## Minor typo in error message.
  ## ##
  ## ## Revision 1.48  2004/02/19 18:27:47  geraint
347
348
349
350
351
352
353
354

355
356
357
358
359
360
361

362
363
364
365
366
367
368
369

370
371
372
373

374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391

392
393
394


395
396
397
398
399
400
401
402
403
404
405
406

407
408
409
410
411
412
413
350
351
352
353
354
355
356

357
358
359
360
361
362
363

364
365
366
367
368
369
370
371

372
373
374
375

376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393

394
395


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

409
410
411
412
413
414
415
416







-
+






-
+







-
+



-
+

















-
+

-
-
+
+











-
+







	      out_bonds++;
	      port_name_i = "out";
	    endif
	    
	  elseif (unlabelled_ports==2)
	    if port_direction>0
	      if (++in_bonds>1)
		mtt_error(["More than one unlabelled INport on component " \
		mtt_error(["More than one unlabelled INport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "in";
	      end
	    else
	      if (++out_bonds>1)
		mtt_error(["More than one unlabelled OUTport on component " \
		mtt_error(["More than one unlabelled OUTport on component " ...
			   comp_name " (" comp_type ")"],errorfile);
	      else
		port_name_i = "out";
	      end
	    endif
	    
	  else
	    mtt_error(["More than two unlabelled ports on component " \
	    mtt_error(["More than two unlabelled ports on component " ...
		       comp_name " (" comp_type ")"],errorfile);
          endif
	  
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " \
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " ...
		    comp_name " (" comp_type ")" ],infofile);
	  port_name = [port_name; ["[" port_name_i "]"]];	# add to list
	  [port_name_index,junk] = size(port_name); # the corresponding
				# index
	  port_bond(port_name_index,:) = signed_bond; # add to port bond
	else  
	  port_name_i = mtt_strip_name(port_name(port_name_index,:))
	  ## port_name_i = deblank(port_name(port_name_index,:));
	  ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip []
	endif
	
	
	## Replace by alias -- if any
    	eval( ["alias = ", comp_type, '_alias';]); # Get aliases
    	if isstruct(alias)		# are there any aliases
          if isfield(alias,port_name_i) # Is this an alias?
	    eval(["new_port_name_i = alias.",port_name_i]);
	    mtt_info(["Aliasing name [" port_name_i "]\t on component " \
	    mtt_info(["Aliasing name [" port_name_i "]\t on component " ...
		      comp_name " (" comp_type ")\t to [" new_port_name_i "]"],infofile);
	    port_name = replace_name(port_name, \
				     ["[",new_port_name_i,"]"], \
	    port_name = replace_name(port_name, ...
				     ["[",new_port_name_i,"]"], ...
				     port_name_index);
	  endif
	  
      	endif
	
      endfor
      
    endif
    
  endfor
  
  ## At this point, every port should be labeled (port_name) and \
  ## At this point, every port should be labeled (port_name) and ...
  ## associated with a bond (port_bond).
  disp("--- Completed portnames and the corresponding bonds ---")
  port_name, port_bond


  ## Deduce causality from the strokes (if any) and create the list of bonds
  causality = zeros(n_bonds,2);
590
591
592
593
594
595
596
597

598
599
600
601
602
603
604
593
594
595
596
597
598
599

600
601
602
603
604
605
606
607







-
+








    [n_comp_ports,m_comp_ports] = size(port_list);
    subport_list="";
    for p=1:n_comp_ports		# Expand any vector ports
      [subport,n_sub] = split_port(port_list(p,:), ','); # Find the components
				# of the vector port
      if n_sub>1
	mtt_info(sprintf("Expanding vector port %s of component type %s",\
	mtt_info(sprintf("Expanding vector port %s of component type %s", ...
			 port_list(p,:), comp_type, infofile));	
      endif
      
      subport_list = [subport_list; subport];
    endfor
    
    port_list = subport_list;	# Set the expanded port list.
652
653
654
655
656
657
658
659

660
661
662
663
664
665
666
655
656
657
658
659
660
661

662
663
664
665
666
667
668
669







-
+







	mtt_error(['Component ', comp_name, ' (', comp_type, ') has no labeled ports'], errorfile); 
      endif
      
      ##Write out the signed bond list in the correct order
      unsorted_port_list
      [n_list,m_list] = size(unsorted_port_list);
      if n_list!=n_comp_bonds
	error(sprintf("Component %s (%s) has %i bonds but %i port labels",\
	error(sprintf("Component %s (%s) has %i bonds but %i port labels", ...
		      comp_name, comp_type, n_comp_bonds, n_list))
      endif

      for j = 1:n_comp_bonds
	j
	name_k = unsorted_port_list(j,:)
	k = name_in_list(name_k, port_list);

Modified mttroot/mtt/bin/trans/m/rbg2ibg.m from [d1b6aaad6f] to [ec747e75b4].

1
2
3
4


5
6
7
8
9
10
11
1
2


3
4
5
6
7
8
9
10
11


-
-
+
+







## -*-octave-*-

function [bonds] = \
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, \
function [bonds] = ...
      rbg2ibg(name,rbonds,rstrokes,rcomponents,port_coord,port_name, ...
	      infofile, errorfile)

  rbonds
  rstrokes
  rcomponents
  port_coord
  port_name
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
90
91

92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
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
90

91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107







-
+

-
+












-
+

-
+
















-
+


-
+








-
+







  arrow_end	= rbonds(:,3:4);
  other_end_2	= rbonds(:,5:6);

  distance_1	= length2d(other_end_1 - arrow_end);
  distance_2	= length2d(other_end_2 - arrow_end);
  which_end	= (distance_1 > distance_2) * [1, 1];
  one		= ones(size(which_end));
  other_end	= which_end .* other_end_1 + (one - which_end) .* \
  other_end	= which_end .* other_end_1 + (one - which_end) .* ...
      other_end_2;
  arrow_vector	= (which_end .* other_end_2 + (one - which_end) .* \
  arrow_vector	= (which_end .* other_end_2 + (one - which_end) .* ...
		   other_end_1) - arrow_end;
  
  ## Locate bond end nearest each port
  ## col 1 of port_near_bond contains a signed bond number (+ for arrow
  ## end)
  ## col 2 of port_near_bond contains the corresponding port index
  port_bond = [];
  for i = 1:n_ports
    near_bond = adjbond(port_coord(i,1:2), arrow_end, other_end);
    [rows,cols] = size(near_bond);
    if (rows > 1)
      error(sprintf ...
	    ("A port is near to more than one bond at coordinates \
	    ("A port is near to more than one bond at coordinates ...
	  %g,%g %s\n", ...
	     port_coord(i,1)/scale, port_coord(i,2)/scale, \
	     port_coord(i,1)/scale, port_coord(i,2)/scale, ...
	     deblank(port_name(i,:))));
    endif
    
    ## The (signed) bond corresponding to the ith port label
    port_bond(i,1) = near_bond(1) * sign(1.5 - near_bond(2));
  endfor
  port_bond

  ## Now have (signed) bond (port_bond(i)) corresponding to the ith port
  ## Create inverse mapping
  for i = 1:n_bonds
    eval(sprintf('bond_port_head%i = "[]"', i))
    eval(sprintf('bond_port_tail%i = "[]"', i))
  endfor  
  for i = 1:n_ports
    if (port_bond(i) > 0)
      eval(sprintf('bond_port_head%i = "%s"', port_bond(i), \
      eval(sprintf('bond_port_head%i = "%s"', port_bond(i), ...
		   deblank(port_name(i,:))))
    else
      eval(sprintf('bond_port_tail%i = "%s"', -port_bond(i), \
      eval(sprintf('bond_port_tail%i = "%s"', -port_bond(i), ...
		   deblank(port_name(i,:))))
    endif
  endfor
  
  ## Locate the components at the ends of each bond
  ## col 1 of comp_near_bond contains component nearest to the arrow end
  ## col 2 of comp_near_bond contains component nearest other end
  for i = 1:n_bonds
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), \
    comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), ...
				  rcomponents);
  endfor
  comp_near_bond

  ## Deduce causality from the strokes (if any)
  causality = zeros(n_bonds,2);
  if (n_strokes > 0)
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133

134
135
136
137
138
139
140
119
120
121
122
123
124
125

126
127
128
129
130
131
132

133
134
135
136
137
138
139
140







-
+






-
+







		stroke_end_2(i,:)];


      ## Find the nearest bond end
      [index,distance] = adjbond(stroke(1,:),arrow_end,other_end);
      if (distance > (2 * stroke_length(i)))
	info = sprintf('Stroke at (%4.3f,%4.3f) is %4.3f away from the nearest bond\n', ...
		       stroke(1,1)/scale, stroke(1,2)/scale, \
		       stroke(1,1)/scale, stroke(1,2)/scale, ...
		       distance/scale);
      endif

      ## Bond end coordinates
      j = index(1,1);
      which_end = (index(1,2) == 1);
      bond_end = arrow_end(j,:) * which_end + other_end(j,:) * (1 - \
      bond_end = arrow_end(j,:) * which_end + other_end(j,:) * (1 - ...
								which_end);
      
      ## Now decide which bit of the stroke is nearest
      stroke_index = adjbond(bond_end, stroke, zeros(size(stroke)));

      if (stroke_index(1) == 1)	# uni-causal stroke
	causality(j,1:2) = (2 * which_end - 1) * [1, 1];
148
149
150
151
152
153
154
155

156
157

158
159
160
161
162
163
164
148
149
150
151
152
153
154

155
156

157
158
159
160
161
162
163
164







-
+

-
+







  causality

  ## Write data
  for i = 1:n_bonds
    [hc_type, hc_name] = eval([name, '_cmp(comp_near_bond(i,1))']);
    [tc_type, tc_name] = eval([name, '_cmp(comp_near_bond(i,2))']);
    ## components
    eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, \
    eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, ...
		 hc_name));
    eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, \
    eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, ...
		 tc_name));
    ## ports
    eval(sprintf("bonds.bond%i.head.ports\t= bond_port_head%i", i, i));
    eval(sprintf("bonds.bond%i.tail.ports\t= bond_port_tail%i", i, i));
    ## causality
    if (causality(i,1) == 1)
      effort_causality = "head"

Modified mttroot/mtt/bin/trans/m/subs_arg.m from [5ca842278f] to [9eca75053a].

13
14
15
16
17
18
19



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







+
+
+









% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.7  2001/07/03 22:59:10  gawthrop
% %% Fixed problems with argument passing for CRs
% %%
% %% Revision 1.6  1998/07/27 09:53:44  peterg
% %% No change
% %%
% %% Revision 1.5  1998/07/21 16:43:26  peterg
% %% Now writes to an explicit fileID - otherwise we may run out of IDs.
% %%
% %% Revision 1.4  1996/12/10 16:04:11  peterg
76
77
78
79
80
81
82
83

84
85
86
87
88
89
90
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93







-
+







      % Test for empty argument -- replace by default and tell user
      message = 'Argument %1.0f of component %s(%s) of system %s is undefined - \n replacing by %s';
      if strcmp(arg_out,'')
	info = sprintf(message, ...
	    i, comp_name, comp_type, full_name, default);
	arg_out = default;
      else
	info = sprintf("Replacing $%i \t by %s for component %s (%s) \
	info = sprintf("Replacing $%i \t by %s for component %s (%s) ...
	within %s", i, arg_out, comp_name, comp_type, full_name);
      end;
      mtt_info(info,fileID);
      args_out = [args_out, arg_out];
    end;
  end;
end;

Modified mttroot/mtt/bin/trans/m/write_ibg.m from [3ea7c08bfd] to [bff06207d1].

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







-
+









-
+

-
+

-
+

-
+

-
+

-
+







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

  fprintf(fid, "## -*-octave-*-\n\n");
  fprintf(fid, "function [%s] = %s_ibg\n\n", system_name, system_name);
  fprintf(fid, "  ## Intermediate bond graph representation of %s\n", \
  fprintf(fid, "  ## Intermediate bond graph representation of %s\n", ...
	  system_name);

  fprintf(fid, "  ## Generated by MTT on %s\n", ctime(time));
  fprintf(fid, "  ## head refers to the harpoon end of a bond\n");
  fprintf(fid, "  ## tail refers to the other end of a bond\n");
  fprintf(fid, "  ## causality.? is the end at which ? is imposed\n\n");

  for i=1:nbonds
    fprintf(fid, "\n  ## bond %i\n", i);
    fprintf(fid, format_hc, system_name, i, \
    fprintf(fid, format_hc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.component", i)));
    fprintf(fid, format_tc, system_name, i, \
    fprintf(fid, format_tc, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.component", i)));
    fprintf(fid, format_hp, system_name, i, \
    fprintf(fid, format_hp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.head.ports", i)));
    fprintf(fid, format_tp, system_name, i, \
    fprintf(fid, format_tp, system_name, i, ...
	    eval(sprintf("bonds.bond%i.tail.ports", i)));
    fprintf(fid, format_ce, system_name, i, \
    fprintf(fid, format_ce, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.effort", i)));
    fprintf(fid, format_cf, system_name, i, \
    fprintf(fid, format_cf, system_name, i, ...
	    eval(sprintf("bonds.bond%i.causality.flow", i)));
  endfor;

  fprintf(fid, "\nendfunction\n");
  fclose(fid);

endfunction;


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