Overview
Comment:Close ese file before recursive call of cbg2ese -- reopen when
finished.
THis prevents a new file being opened for each subsystem which fails
when > 1K files opened
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 3098791faf8e469c11762b89f73f5f23b662e5d8071d443f3d223c18fb5fcb44
User & Date: gawthrop@users.sourceforge.net on 2000-11-12 16:45:57
Other Links: branch diff | manifest | tags
Context
2000-11-12
17:10:51
Close file if it is opened
Reformated octave style
check-in: b2c963fd73 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
16:45:57
Close ese file before recursive call of cbg2ese -- reopen when
finished.
THis prevents a new file being opened for each subsystem which fails
when > 1K files opened
check-in: 3098791faf user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2000-11-10
14:46:53
More fixes to avoid interpering variables as funs - basicly all
functions now have at least ()
check-in: 56bf7e740a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/cbg2ese.m from [9c7d81661a] to [c181a02f02].

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.35  2000/10/12 19:27:47  peterg
  ## ## Now writes the aliased args
  ## ##
  ## ## Revision 1.34  2000/09/01 08:42:44  peterg
  ## ## Cahged somes ends to end for etc for clarity
  ## ##
  ## ## Revision 1.33  2000/09/01 08:05:32  peterg







>
>
>







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.36  2000/10/13 10:54:47  peterg
  ## ## Now writes out a unique name for each state etc
  ## ##
  ## ## Revision 1.35  2000/10/12 19:27:47  peterg
  ## ## Now writes the aliased args
  ## ##
  ## ## Revision 1.34  2000/09/01 08:42:44  peterg
  ## ## Cahged somes ends to end for etc for clarity
  ## ##
  ## ## Revision 1.33  2000/09/01 08:05:32  peterg
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
  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");
  
  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, ";"]);







|







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  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)
  
  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, ";"]);
313
314
315
316
317
318
319


320
321
322
323
324



325
326
327
328
329
330
331
	  endif;
	  
	  ## Invoke the appropriate equation-generating procedure
	  name_r = full_name_repetition;
	  eqn_name = [subsystem.type, "_eqn"]
	  
	  if exist(eqn_name)~=2 ## Try a compound component


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



	    ## Link up the bonds
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);
	    name_comp_name = sprintf("%s_%s_%d", ...
				     full_name_repetition, comp_name, k);
	    







>
>





>
>
>







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
	  endif;
	  
	  ## Invoke the appropriate equation-generating procedure
	  name_r = full_name_repetition;
	  eqn_name = [subsystem.type, "_eqn"]
	  
	  if exist(eqn_name)~=2 ## Try a compound component
            fclose(ese_file);	# Close but reopen later

	    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)

	    ## Link up the bonds
	    fprintf(ese_file, ...
		    "\n\t%s Equations linking up subsystem %s (%s)\n\n", ...
		    pc, comp_name, subsystem.type);
	    name_comp_name = sprintf("%s_%s_%d", ...
				     full_name_repetition, comp_name, k);
	    
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),-1), name_comp_name, y_index);
	      end;	
	    end;
	    
	    disp("---POP---");
	  else # its a simple component
	    fprintf(ese_file, "\n\t%s Equations for component %s (%s), repetition %d\n\n", ...
		    pc, comp_name, subsystem.type,k);
	    
	    
	    ##				# Is it a named port? (Name begins with [)
	    ##            Named_Port = (comp_name(1)=="[");







<







365
366
367
368
369
370
371

372
373
374
375
376
377
378
	     	y_index = y_index + 1;
	     	fprintf(ese_file, "%s := %s_MTTy%d;\n", ...
		 	varname(name_r, ...
				bond_list(port_number),-1), name_comp_name, y_index);
	      end;	
	    end;
	    

	  else # its a simple component
	    fprintf(ese_file, "\n\t%s Equations for component %s (%s), repetition %d\n\n", ...
		    pc, comp_name, subsystem.type,k);
	    
	    
	    ##				# Is it a named port? (Name begins with [)
	    ##            Named_Port = (comp_name(1)=="[");
406
407
408
409
410
411
412
413
414
415
416
417
418
419
 	      endfor;
 	    endif;
	  endif
	endfor
      endfor			# [subsystem,comp_name] = CBG_field
    endif			# struct_contains(CBG,field)
  endfor			# i=1:2
  ## Close the files
  fclose(ese_file);
  
endfunction










|
|





413
414
415
416
417
418
419
420
421
422
423
424
425
426
 	      endfor;
 	    endif;
	  endif
	endfor
      endfor			# [subsystem,comp_name] = CBG_field
    endif			# struct_contains(CBG,field)
  endfor			# i=1:2

  fclose(ese_file);		# Close
  
endfunction




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