function invokess2mdl(obj)
%

%   Copyright 2010-2020 The MathWorks, Inc.
    obj.PhaseId = 1;
    obj.turnOffAndStoreWarningStatus;

    oldRoot = bdroot;
    cursys = get_param(0,'CurrentSystem');
    if ~isempty(cursys)
        curblk = get_param(cursys, 'CurrentBlock');
    else
        curblk = '';
    end

    try
        [modelH, portInfo, error_occ, ss2mdlExc] = Simulink.harness.internal.extractSubsystem(obj.SubSystemH);
    catch Mex
        error_occ = 1;
        ss2mdlExc = Mex;
    end

    try
        if ~isempty(curblk) && ~strcmp(get_param(cursys,'Lock'),'on')
            set_param(cursys, 'CurrentBlock', curblk);
        end
        if ~isempty(cursys)
            set_param(0,'CurrentSystem',cursys);
        end
    catch Mex  %#ok<NASGU>
    end

    bdroot(oldRoot);

    rtwprivate('rtwattic','clean');

    obj.Status = ~(logical(error_occ));

    if ~obj.Status
        if ~isempty(ss2mdlExc)
            newExc = MException('Sldv:SubSysExtract:SS2MDL',getString(message('Sldv:SubSysExtract:SS2MDL')));
            newExc = newExc.addCause(ss2mdlExc);
            obj.Ss2mdlExc = newExc;
        end
    else
        % ss2mdl compiled the model. Detect referenced Simulink.Signal
        % objects from the subsystem
        obj.detectReferencedSimulinkSignalVars;
        obj.ModelH = modelH;
        obj.PortInfo = portInfo;
        obj.fixExtractedMdlConfigCompName;
        obj.fixExtractedMdlSampleTimeConstraint;
    end

    obj.restoreWarningStatus;
    obj.PhaseId = 0;
end

% LocalWords:  rtwattic
