function filWizard(varargin)
%FILWIZARD FPGA-in-the-Loop Wizard
%   FILWIZARD launches the FPGA-in-the-Loop (FIL) Wizard. FIL Wizard is a
%   Graphical User Interface (GUI) that guides you through the process of
%   setting up cosimulation between FPGA and Simulink.
%
%   FILWIZARD(FILENAME) re-launches the FIL Wizard using information saved
%   in the specified FILENAME MAT-file. At the end of each FIL Wizard
%   session, a MAT-file that contains the session information is saved to
%   disk. This MAT-file can be used to restore the session later.

% Copyright 2010 The MathWorks, Inc.
narginchk(0,2);
if(nargin == 1)
    assert(ischar(varargin{1}),message('EDALink:FILWizard:NotString'));
    assert(exist(varargin{1},'file')==2,message('EDALink:FILWizard:MatFileNotExist',varargin{1}));
    
    [buildInfo, boardSet] = loadBuildInfo(varargin{1});
    h = eda.FilAssistantDlg(buildInfo);
    if boardSet
        h.Board = h.BuildInfo.Board; 
    end
elseif(nargin == 2)
    % the fil wizard is launched from sl toolstirp, the second arg is the
    % hdlvAppContext
    h = eda.FilAssistantDlg('',varargin{2});
else
    h = eda.FilAssistantDlg;
end

DAStudio.Dialog(h);

% warning about white space in the project dir
if any(isspace(pwd))
    warning(message('EDALink:FILWizard:SpaceInPath'));
end