function harnessFilePath = slvnvmakeharness(model, dataFile, harnessOpts)
%SLVNVMAKEHARNESS - Generates Simulink Coverage test harness model.  
%    
%   SAVEDHARNESSFILEPATH = SLVNVMAKEHARNESS(MODEL) generates a test 
%   harness from MODEL, which is a handle to a Simulink model, or a string 
%   with the model name. SLVNVMAKEHARNESS returns the path and file name of 
%   the generated harness model in SAVEDHARNESSFILEPATH. SLVNVMAKEHARNESS 
%   creates an empty harness model; the test harness includes one default 
%   test case that specifies the default values for all input signals.
%
%   SAVEDHARNESSFILEPATH = SLVNVMAKEHARNESS(MODEL, DATAFILE) generates a 
%   test harness from the data file DATAFILE. 
%
%   SAVEDHARNESSFILEPATH = SLVNVMAKEHARNESS(MODEL, DATAFILE, HARNESSOPTS)
%   generates a test harness from MODEL using the DATAFILE and HARNESSOPTS,
%   which specifies the harness creation options. Requires '' for DATAFILE 
%   if dataFile not available. 
%
%   HARNESSOPTS : A structure whose fields specify the configuration for 
%   slvnvmakeharness:
%
%        harnessFilePath = Specifies the file path for creating the harness 
%                          model. If invalid path is specified, 
%                          slvnvmakeharness does not save the harness, but 
%                          it creates and opens the harness model. If this 
%                          option is not specified, a new harness model 
%                          will be generated.
%                          Default: ''                            
%        modelRefHarness = Generates the test harness model that includes
%                          MODEL in a Model block. When false, test harness 
%                          model includes a copy of MODEL.
%                          Default: true
%       usedSignalsOnly  = When true, the Signal Builder block in the 
%                          harness model has signals only for input signals 
%                          used in the MODEL. Simulink Design Verifier 
%                          software must be available and MODEL must be 
%                          compatible with Simulink Design Verifier software 
%                          to detect used inputs signals.
%                          Default: false
%
%   NOTES:
%   slvnvharnessopts() returns HARNESSOPTS with default values for each
%   field. 
%
%   See also SLVNVHARNESSOPTS, SLVNVLOGSIGNALS, SLVNVMERGEHARNESS.

%   Copyright 2010-2017 The MathWorks, Inc.



    if nargin<1
        error(message('Slvnv:slvnvmakeharness:NoBlockModel'));
    end
    
    if nargin<2
        dataFile = '';
    end
    
    if (nargin < 3)
        harnessOpts = Sldv.HarnessUtils.getHarnessOpts;
    elseif((nargin == 3) && isstruct(harnessOpts))
        errMsg = Sldv.HarnessUtils.iscorrectHarnessOpts(harnessOpts);
        if(~isempty(errMsg))
            error(errMsg);
        end
    else
        error(message('Slvnv:slvnvmakeharness:ExpressInputArgument'));
    end

    errMsg = Sldv.HarnessUtils.isValidMdl(model);
    if(~isempty(errMsg))
        error(errMsg);
    end
    
    try
        [harnessFilePath, warnmsgs] = ...
            Sldv.HarnessUtils.make_model_harness(model, dataFile, harnessOpts, mfilename);
        if(~isempty(warnmsgs))
            for i=1:length(warnmsgs)
                warning(warnmsgs{i});
            end
        end
    catch Mex
        throw(Mex) 
    end

end

