function [ts,tsStr] = getSampleTime(compTs)
    
    % If the port is multirate (for example, because it is fed by a mixed-rate
    % virtual bus), then the string to use in setting makes no sense.
    if iscell(compTs)
        tsStr = '';
        ts = compTs;
    else
        %  1) Constant sample time [inf 0]
        %  2) Triggered sample time [-1 -1 containerSampleTime containerOffset]
        %  3) Continuous  [0 0]
        %  4) ZOHContinuous [0 1]
        %  5) Variable sample time [-2 0]
        %  6) Discrete sample time [sampleTime offset]
        if isinf(compTs(1))
            % Constant sample time
            tsStr = 'inf';
            ts = inf;
        else
            if (length(compTs) == 2) && (compTs(1) == 0) && (compTs(2) == 0)
                % Continuous sample time
                tsStr = '0';
                ts = 0;
            else
                % trigger sample time is: [-1, -1, container sample time[2]]
                if (compTs(1) == -1 && compTs(2) == -1)
                    ts = compTs(3:4);
                else
                    ts = compTs;
                end
                % ts always have two elements
                tsStr = ['[',sprintf('%.17g',ts(1)),',',sprintf('%.17g',ts(2)),']'];
            end
        end
    end
end