Artifact 8fcc691ebd37f22f9ef529ad34a6e80c93e6c504f40f24e6444435706cee3a34:


## -*-octave-*-

function write_ibg(system_name,bonds);
  
  fid = fopen([system_name,"_ibg.m"], "w");
  [nbonds, junk] = size(struct_elements(bonds));
  format_hc = "  %s.bonds.b%i.head.component\t= \"%s\";\n";
  format_tc = "  %s.bonds.b%i.tail.component\t= \"%s\";\n";
  format_hp = "  %s.bonds.b%i.head.ports\t= \"%s\";\n";
  format_tp = "  %s.bonds.b%i.tail.ports\t= \"%s\";\n";
  format_ce = "  %s.bonds.b%i.causality.effort\t= \"%s\";\n";
  format_cf = "  %s.bonds.b%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", \
	  system_name);

  fprintf(fid, "## Generated by MTT on %s\n", ctime(time));

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

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

endfunction;

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