Differences From Artifact [5d61fecdc4]:

To Artifact [c68472150c]:


83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105







-
+







-
+








  ####################################################
  ## count number of vector bonds on each component ##
  ####################################################

  if (isfield(objects, "comp"))
    for [comp, comp_name] = objects.comp
      n = size(struct_elements(comp))(1) - 1;
      n = size(fieldnames(comp))(1) - 1;
      eval(sprintf("objects.comp.%s.n_bonds = %i;",
		   comp_name, n));
    endfor
  endif
  
  if (isfield(objects, "port"))
    for [port, port_name] = objects.port
      n = size(struct_elements(port))(1) - 1;
      n = size(fieldnames(port))(1) - 1;
      eval(sprintf("objects.port.%s.n_bonds = %i;",
		   port_name, n));
    endfor
  endif

  disp("-- finished counting number of bonds on components --")
  objects
334
335
336
337
338
339
340
341
342


343
344
345
346
347
348
349
334
335
336
337
338
339
340


341
342
343
344
345
346
347
348
349







-
-
+
+







    tail_str = sprintf("objects.%s.%s.bond%i",
		       tail_comp_or_port, tail_name, i)

    head_bond = eval(head_str);
    tail_bond = eval(tail_str);
    
    ## check compatible sizes
    head.n_subs = size(struct_elements(head_bond))(1) - 2;
    tail.n_subs = size(struct_elements(tail_bond))(1) - 2;
    head.n_subs = size(fieldnames(head_bond))(1) - 2;
    tail.n_subs = size(fieldnames(tail_bond))(1) - 2;
    if (head.n_subs != tail.n_subs)
      mtt_error(sprintf("Vector ports '%s' (%s:%s) and '%s' (%s:%s) are not compatible",
			head_bond.label, head.type, head_name,
			tail_bond.label, tail.type, tail_name),
		errorfile);
    elseif (head.n_subs > 1)
      mtt_info(sprintf("Vector port '%s'(%s:%s) matches '%s' (%s:%s)",
413
414
415
416
417
418
419
420

421
422
423
424
425
426
427

428
429
430
431
432
433
434
413
414
415
416
417
418
419

420
421
422
423
424
425
426

427
428
429
430
431
432
433
434







-
+






-
+








  #################################
  ## map component data to cmp.m ##
  #################################

  ## count number of components
  if (isfield(objects, "comp"))
    n_comps = size(struct_elements(objects.comp), 1)
    n_comps = size(fieldnames(objects.comp), 1)
  else
    n_comps = 0;
  endif

  ## count number of internal ports
  if (isfield(objects, "port"))
    n_ports = size(struct_elements(objects.port), 1)
    n_ports = size(fieldnames(objects.port), 1)
  else
    n_ports = 0;
  endif

  ## read data from _cmp.m
  for cmp = 1:(n_comps + n_ports)
    [this_type, this_name] = eval(sprintf("%s_cmp(%i)", name, cmp));
479
480
481
482
483
484
485
486

487
488
489
490
491
492
493
479
480
481
482
483
484
485

486
487
488
489
490
491
492
493







-
+







  n_vector_bonds

  ###########################################
  ## Write connections matrix (components) ##
  ###########################################
  
  if (isfield(objects, "comp"))
    n_comps = size(struct_elements(objects.comp))(1);
    n_comps = size(fieldnames(objects.comp))(1);
  else
    n_comps = 0;
  endif

  components = zeros(n_comps+n_ports, max(n_vector_bonds));

  if (isfield(objects, "comp"))

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