%

%   Copyright 2016 The MathWorks, Inc.
%
% Transformation function for upgrading slider-gain block in 17a. The older
% slider gain allowed low and high to be same which was a buggy behavior.
% As part of upgrade if we encounter low and high to be equal we bump the
% value of high. 
function [outData] = transformSliderGainBlock(inData)
    outData.NewBlockPath = '';
    outData.NewInstanceData = [];
    
    try
        instanceData = inData.InstanceData;
        lowIndex = strcmp({instanceData.Name}, 'low');    
        highIndex = strcmp({instanceData.Name}, 'high');
        
        low = instanceData(lowIndex).Value;
        high = instanceData(highIndex).Value;
        
        if isequal(low, high)
            high = str2double(high);
            if (ceil(high) - high == 0)
                high = high + 1;
            else
                high = high + 0.1;
            end

            instanceData(highIndex).Value = num2str(high);
        end
    catch
    end
    
    outData.NewInstanceData = instanceData;
end