function loops = sltpda_buildloops(sys)

% Build an array of loop structures from the loop blocks on the given
% pipeline.
% 
% M Hewitson 05-05-07
% 
% $Id: sltpda_buildLoops.m,v 1.2 2007/06/13 08:47:28 hewitson Exp $
% 


loops = [];

blockhandles   = find_system(gcs, 'FindAll', 'on', 'type', 'block');
k      = 1;
for j=1:length(blockhandles)
  b = blockhandles(j);
  maskType = get(b, 'MaskType');
  if strcmp(maskType, 'loop')
    maskvals = get(b, 'MaskValues')
    loops(k).block  = maskvals{1};
    loops(k).handle = maskvals{2};
    loops(k).key    = maskvals{3};
    loops(k).values = maskvals{4};
    loops(k).on     = maskvals{5};
    loops(k).level  = maskvals{6};
    k = k + 1;
  end
end



% END