function uplant = SRblock(qS,v,pSR,Vh)
% v   - internal signl to the splt range block
% pSR - parameters
% u(1) - source; u(2) discharge; u(3) - electric
v0=500/qS*100/3;
N       = pSR(end);                                         % number of MVs
u0      = pSR(1:N);                                      % bias for each MV
alpha   = pSR(N+1:2*N);                                 % slope for each MV
umax    = pSR(2*N+1:3*N);                            % maximum limit for MV
umax(1) = qS;                         % variable available heat from boiler


u       = u0+alpha.*(v+v0);                 % controller output scalled to 100 %
uscld = min(max(0,u),100);               % scaled MV with saturation limits
uplant  = uscld.*umax./100;              % unscaled MV applied to the plant

if Vh<=0
     uplant(3) = uplant(2);
     uplant(2) = 0;
end

% if   Vh  <= 0
% umax(2) = 0;
% v0      = 250/3; 
% 
% u(3)       = u0(3)+alpha(3)*(v+v0);                 % controller output scalled to 100 %
% uscld(3) = min(max(0,u(3)),100);               % scaled MV with saturation limits
% uplant(3)  = uscld(3)*umax(3)/100;              % unscaled MV applied to the plant
% end

end