function sid = getSidForSfObj(sfObj, slObj)
    % The SID should be generated for SF objects

%   Copyright 2011 The MathWorks, Inc.

    if nargin<2 || slObj==0
        % Old code (Should not execute)
        bd = sfroot;
        handle = idToHandle(bd,sfObj);
        sid = Simulink.ID.getSID(handle);
    else
        if strcmp(get_param(slObj,'BlockType'),'S-Function')
            slObj = get_param(get_param(slObj,'Parent'),'Handle');
        end
        slSid = Simulink.ID.getSID(slObj);
        if (sf('get',sfObj,'.isa')==sf('get', 'default', 'chart.isa'))
            sid = slSid;
        else
            sfSidNum = sf('get', sfObj, '.ssIdNumber');
            sid = sprintf('%s:%d',slSid,sfSidNum);
        end
    end
end