function [offsetTable] = generateOffsetTable(pFloatDetails, pSoundsources)
%GETDEFAULTOFFSETTABLE Summary of this function goes here
%   Detailed explanation goes here

%% Get required variables
variableNames = artoa.offsets.getDefaultVariableNames();

%% Initialize return variable
offsetTable = cell2table( ...
    artoa.offsets.getDefaultRowValues(), ...
    'VariableNames', variableNames ...
);

%% Setup rows

% float
offsetTable.Properties.RowNames(1) = {'Float'};
floatOffsets = artoa.data.getMember(pFloatDetails, {'offset'}, false);
startDate = NaN;
endDate = NaN;
startOffset = NaN;
endOffset = NaN;
drift = NaN;
if ~islogical(floatOffsets)
    sizeOffsets = size(floatOffsets);
    if sizeOffsets(1) >= 1 && sizeOffsets(2) >= 3 % start date can be calculated
        startDate = artoa.convert.dmy2rd( ...
            floatOffsets(1, 3), ...
            floatOffsets(1, 2), ...
            floatOffsets(1, 1) ...
        );
    end
    if sizeOffsets(1) >= 2 && sizeOffsets(2) >= 3 % end date can be calculated
        endDate = artoa.convert.dmy2rd( ...
            floatOffsets(2, 3), ...
            floatOffsets(2, 2), ...
            floatOffsets(2, 1) ...
        );
    end
    if sizeOffsets(1) >= 1 && sizeOffsets(2) >= 7 % start offset can be stored
        startOffset = floatOffsets(1, 7);
    end
    if sizeOffsets(1) >= 2 && sizeOffsets(2) >= 7
        % end offset can be stored and drift can be calculated
        endOffset = floatOffsets(2, 7);
        % calculate drift per day
        drift = (endOffset - startOffset) / (endDate - startDate);
    end
end

offsetTable{1, variableNames{1}} = startDate;
offsetTable{1, variableNames{2}} = startOffset;
offsetTable{1, variableNames{3}} = endDate;
offsetTable{1, variableNames{4}} = endOffset;
offsetTable{1, variableNames{5}} = drift;
clear startDate startOffset endDate endOffset drift;

if nargin == 1
    return;
end

if iscell(pSoundsources)
    for i = 1:length(pSoundsources)
        offsetTable(i + 1, :) = artoa.offsets.getDefaultRowValues();
        offsetTable.Properties.RowNames(i + 1) = {pSoundsources{i}.sourcename};
        offsetTable{i + 1, variableNames{1}} = artoa.convert.dmy2rd(pSoundsources{i}.offset(3), pSoundsources{i}.offset(2), pSoundsources{i}.offset(1));
        offsetTable{i + 1, variableNames{2}} = pSoundsources{i}.offset(4);
        offsetTable{i + 1, variableNames{3}} = artoa.convert.dmy2rd(pSoundsources{i}.rcv_offset(3), pSoundsources{i}.rcv_offset(2), pSoundsources{i}.rcv_offset(1));
        offsetTable{i + 1, variableNames{4}} = pSoundsources{i}.rcv_offset(4);
        offsetTable{i + 1, variableNames{5}} = pSoundsources{i}.drift;
        offsetTable{i + 1, variableNames{8}} = pSoundsources{i}.empiric_offset(4);
        offsetTable{i + 1, variableNames{9}} = pSoundsources{i}.empiric_drift;
    end
end

if isstruct(pSoundsources)
    fnames = fieldnames(pSoundsources);
    for i = 1:length(fnames)
        offsetTable(i + 1, :) = artoa.offsets.getDefaultRowValues();
        offsetTable.Properties.RowNames(i + 1) = {pSoundsources.(fnames{i}).sourcename};
        offsetTable{i + 1, variableNames{1}} = artoa.convert.dmy2rd(pSoundsources.(fnames{i}).offset(3), pSoundsources.(fnames{i}).offset(2), pSoundsources.(fnames{i}).offset(1));
        offsetTable{i + 1, variableNames{2}} = pSoundsources.(fnames{i}).offset(4);
        offsetTable{i + 1, variableNames{3}} = artoa.convert.dmy2rd(pSoundsources.(fnames{i}).rcv_offset(3), pSoundsources.(fnames{i}).rcv_offset(2), pSoundsources.(fnames{i}).rcv_offset(1));
        offsetTable{i + 1, variableNames{4}} = pSoundsources.(fnames{i}).rcv_offset(4);
        offsetTable{i + 1, variableNames{5}} = pSoundsources.(fnames{i}).drift;
        offsetTable{i + 1, variableNames{8}} = pSoundsources.(fnames{i}).empiric_offset(4);
        offsetTable{i + 1, variableNames{9}} = pSoundsources.(fnames{i}).empiric_drift;
    end
end

end

