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