function [sldvData, sampleTimeInformation] = generateDataForLogging(obj)
%

%   Copyright 2009-2020 The MathWorks, Inc.

    modelBlockH = obj.ModelBlockH;
    sldvHarnessMdlH = obj.SldvHarnessModelH;
    
    LoggedTestUnitInfo = [];                
    ReferencedModel = [];
    defaultTestCase = [];
    
    if ~isempty(modelBlockH)        
        referencedModelName = get_param(modelBlockH,'ModelName');   
        refmodelH = get_param(referencedModelName,'Handle');
        [InputPortInfo, OutputPortInfo, flatInfo] = ...
            Sldv.DataUtils.generateIOportInfo(refmodelH);        
                
        ReferencedModel.Name = referencedModelName;
        ReferencedModel.Version = get_param(refmodelH,'ModelVersion');
        ReferencedModel.Author = get_param(refmodelH,'Creator');
        ReferencedModel.InputPortInfo = InputPortInfo;
        ReferencedModel.OutputPortInfo = OutputPortInfo;
        ReferencedModel.SampleTimes = flatInfo.SampleTimes;
        ReferencedModel.mdlFlatIOInfo = flatInfo;
        sampleTimeInformation = flatInfo.ModelSampleTimesDetails;        
        
        ModelBlock.Path = getfullname(modelBlockH);
        ModelBlock.ReferencedModel = ReferencedModel;
        
        LoggedTestUnitInfo.ModelBlock = ModelBlock;
        
        % Get model name from block
        parentModelName = get_param(bdroot(modelBlockH), 'Name');
        parentModelHandle = get_param(parentModelName, 'Handle');
        
        defaultTestCase = Sldv.DataUtils.createDefaultTC(...
            parentModelHandle, flatInfo.InportCompInfo, true);
    end
    
    if ~isempty(sldvHarnessMdlH)
        SldvHarnessModel.Name = get_param(sldvHarnessMdlH, 'Name');
        SldvHarnessModel.Version = get_param(sldvHarnessMdlH,'ModelVersion');
        SldvHarnessModel.Author = get_param(sldvHarnessMdlH,'Creator'); 
        
        if ~isempty(ReferencedModel)
            SldvHarnessModel.TestUnitModel = ReferencedModel;
        else
            modelNameHarnessGenerated = ...
                    Sldv.HarnessUtils.getGeneratedModel(sldvHarnessMdlH);
            modelHHarnessGenerated = get_param(modelNameHarnessGenerated,'Handle');
            [InputPortInfo, OutputPortInfo, flatInfo] = ...
                Sldv.DataUtils.generateIOportInfo(modelHHarnessGenerated);
            
            TestUnitModel.Name = modelNameHarnessGenerated;
            TestUnitModel.Version = get_param(modelHHarnessGenerated,'ModelVersion');
            TestUnitModel.Author = get_param(modelHHarnessGenerated,'Creator');
            TestUnitModel.InputPortInfo = InputPortInfo;
            TestUnitModel.OutputPortInfo = OutputPortInfo;
            TestUnitModel.SampleTimes = flatInfo.SampleTimes;
            sampleTimeInformation = flatInfo.ModelSampleTimesDetails;            
            
            SldvHarnessModel.TestUnitModel = TestUnitModel;
            
            defaultTestCase = Sldv.DataUtils.createDefaultTC(...
                modelHHarnessGenerated, flatInfo.InportCompInfo, true);
        end
        
        LoggedTestUnitInfo.SldvHarnessModel = SldvHarnessModel;                                                
    end                
    
    sldvData.LoggedTestUnitInfo = LoggedTestUnitInfo;
    sldvData.TestCases = defaultTestCase;    
end
