function uSRC = SRblock_update(v,pSR,umin)
% v   - internal signl to the splt range block
% pSR - parameters
% u(1) - charging valve; u(2) discharge valve

N       = pSR(end);                                         % number of MVs
u0      = pSR(1:N);                                      % bias for each MV
alpha   = pSR(N+1:2*N);                                 % slope for each MV
u       = (u0+alpha.*v).*1./100;                                       % MV
uSRC    = min(max(0,u),1);                      % MV with saturation limits

%% update controller bias based on the min selector output

for i=1:N
     if uSRC(i)>umin(i)            % update only if SRC output > min output
          
           dv      = (umin(i)-uSRC(i)).*100./alpha(i);     % change in bias
           u(i)    = (u0(i)+alpha(i)*(v+dv))/100;                      % MV
           uSRC(i) = min(max(0,u(i)),1);        % MV with saturation limits
     end
end

