mttIdentifyUndercausalBonds.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function next_next = mttIdentifyUndercausalBonds(model,branch,next)
  2. is_root_model = (nargin==1) ;
  3. if is_root_model
  4. mttNotify('...following bonds are under-causal:') ;
  5. mttWriteNewLine ;
  6. branch = mttDetachText(model.source,'/') ;
  7. next = 0 ;
  8. end
  9. number_of_bonds = mttGetFieldLength(model,'bond') ;
  10. for i = 1:number_of_bonds
  11. if isempty(model.bond(i).effort) | isempty(model.bond(i).flow)
  12. origin = model.bond(i).from.obj ;
  13. port = model.bond(i).from.interface ;
  14. if isfield(model.obj,origin)
  15. origin_class = getfield(model,'obj',origin,'class') ;
  16. switch origin_class
  17. case {'0','1'},
  18. bond_origin = [origin_class,':',origin] ;
  19. otherwise,
  20. origin_port = getfield(model,'obj',origin,'interface',{port},'name') ;
  21. bond_origin = [origin_class,':',origin,'[',origin_port,']'] ;
  22. end
  23. else
  24. bond_origin = ['SS:',origin] ;
  25. end
  26. target = model.bond(i).to.obj ;
  27. port = model.bond(i).to.interface ;
  28. if isfield(model.obj,target)
  29. target_class = getfield(model,'obj',target,'class') ;
  30. switch target_class
  31. case {'0','1'},
  32. bond_target = [target_class,':',target] ;
  33. otherwise,
  34. target_port = getfield(model,'obj',target,'interface',{port},'name') ;
  35. bond_target = [target_class,':',target,'[',target_port,']'] ;
  36. end
  37. else
  38. bond_target = ['SS:',target] ;
  39. end
  40. next = next + 1 ;
  41. descriptor = [' ',num2str(next),': ',branch,'(',num2str(i),') from: ',...
  42. bond_origin,' to: ',bond_target] ;
  43. mttNotify(descriptor) ;
  44. mttWriteNewLine ;
  45. end
  46. end
  47. next_next = next ;
  48. object_names = mttGetFieldNames(model,'obj') ;
  49. number_of_objects = length(object_names) ;
  50. for i = 1:number_of_objects
  51. object_name = object_names{i} ;
  52. object = getfield(model,'obj',object_name) ;
  53. if isfield(object,'obj')
  54. next_branch = [branch,'/',object_name] ;
  55. next_next = mttIdentifyUndercausalBonds(object,next_branch,next) ;
  56. next = next_next ;
  57. end
  58. end