% RESET the current pipeline.
%
% CALL: wb.reset
%
% M Hewitson 11-10-08
%
% $Id: reset.m,v 1.13 2011/03/31 08:00:18 hewitson Exp $
%
function reset(varargin)
  
  if nargin==2
    clearWS = varargin{2};
  else
    clearWS = false;
  end
  wb = varargin{1};
  
  setappdata(0, 'LTPDAworkbench', wb);
  
  utils.helper.msg(utils.const.msg.PROC1, ['*** resetting pipeline ' char(awtinvoke(wb.mp, 'getDisplayTitle'))]);
  awtinvoke(wb.mp, 'resetCurrentPipeline');
  
  % clear structure for this diagram
  cdiagName = strrep(awtinvoke(wb.mp, 'getInstanceIdentifier'), ' ', '_');
  
  if evalin('base', sprintf('exist(''%s'', ''var'')', cdiagName)) == 0
    utils.helper.warn(sprintf('The variable "%s" does not exist in the MATLAB workspace. Not clearing.', cdiagName));
  end
  
  if clearWS
    evalin('base', sprintf('%s=[];', cdiagName));
  end
  
  wb.executing = false;
  setappdata(0, 'LTPDAworkbench', []);
  
end
