mttApplyInterfaceDomains.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function model = mttApplyInterfaceDomains(model,branch) ;
  2. is_root_model = (nargin==1) ;
  3. objects = mttGetFieldNames(model,'obj') ;
  4. for i = 1:length(objects)
  5. object_name = objects{i} ;
  6. object = getfield(model,'obj',object_name) ;
  7. if isfield(object,'obj')
  8. if is_root_model
  9. branch = object_name ;
  10. else
  11. branch = [branch,'/',object_name] ;
  12. end
  13. object = mttApplyInterfaceDomains(object,branch) ;
  14. model = setfield(model,'obj',object_name,object) ;
  15. else
  16. if ~isempty(object.cr)
  17. if is_root_model
  18. branch = mttDetachText(model.source,'/') ;
  19. end
  20. here = [branch,':',object_name] ;
  21. port_names = mttGetFieldNames(object.cr.interface,'port') ;
  22. for j = 1:length(port_names)
  23. port_name = port_names{j} ;
  24. port = getfield(object.cr.interface,'port',port_name) ;
  25. predefined_domain = port.domain ;
  26. predefined_domain_item = port.domain_item ;
  27. inbond = port.in ;
  28. outbond = port.out ;
  29. if isempty(inbond)
  30. bond_number = outbond ;
  31. else
  32. bond_number = inbond ;
  33. end
  34. [model,ok] = mttUpdateBondDomain(model,bond_number,predefined_domain,predefined_domain_item) ;
  35. mttAssert(ok,['Domain conflict at port "',port_name,'" in ',here]) ;
  36. end
  37. end
  38. end
  39. end