view m-toolbox/classes/@LTPDAworkbench/runPipeline.m @ 11:9174aadb93a5 database-connection-manager

Add LTPDA Repository utility functions into utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% RUNPIPELINE runs the currently active pipeline from the beginning.
%
% CALL: wb.runPipeline
%
% M Hewitson 13-11-08
%
% $Id: runPipeline.m,v 1.21 2011/03/29 13:40:16 hewitson Exp $
%
function varargout = runPipeline(varargin)
  
  wb = varargin{1};
  if ~isa(wb, 'LTPDAworkbench')
    error('runPipeline needs an LTPDAworkbench instance as the first input.');
  end
  
  % Assume running is successful
  res = true;
  
  setappdata(0, 'LTPDAworkbench', wb);
  wb.reset(false);
  
  wb.mp.setExecuting(true);
  if wb.mp.popupConsoleOnExecution()
    wb.mp.showConsole();
  end
  
  try
    
    LTPDAworkbench.executeConstants(wb);
    
    % Now execute all other blocks
    cmds = {};
    while awtinvoke(wb.mp, 'countReadyBlocks') > 0
      try
        wb.stepForward;
      catch exception
        utils.helper.errorDlg([exception.message], 'Execution error');
        wb.addErrorMessage(exception.cause{1}.message);
        utils.helper.err(exception.message);
        res = false;
      end
      drawnow;
    end
  catch
    wb.mp.setExecuting(false);
    res = false;
  end
  wb.mp.setExecuting(false);
  
  setappdata(0, 'LTPDAworkbench', []);
  
  if nargout == 1
    varargout{1} = res;
  end
  
end