function [stat,post] = blkpidcon(path,prop,bstr,bint,bflt,parent,name,catalog,ws,node,sbSample)
%BLKPIDCON The output of the block is the sum of proportional, integral and
%          differential operations on the input.
%
% See also BLKINTEG, BLK2NDORD.

% Initial coding by A S Bozin, 6-30-97
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2000/06/14 16:10:11 $

   stat = 0;			   		   % Error flag
   nInputs = bint(5);
   nOutputs = bint(6);
   nStates = bint(7);
   %
   % Add mux and demux blocks if necessary
   %
   [post,rect] = blkio('port',nInputs,nOutputs,prop,path);
   %
   % Get the proportional, integral and derivative gains, as well as
   % derivative time constant and initial condition.
   %
   indStr = bint(17)+1;
   indInt = bint(15)+1;
   npar = 5;					   % Number of parameters
   symInd = zeros(1,npar);
   str = cell(npar,1);
   mode = bint(indInt);
   if (bitand(mode,8))
      ind = mfindstr(bstr,indStr,'|');
      symInd(npar) = 1;
      str{npar} = bstr(indStr:ind-1);
      indStr = ind+1;
   end
   indInt = indInt+1;
   nCoeffs = bint(indInt);
   indInt = indInt+2*nCoeffs+1;
   if (bitand(mode,16))
      iRange = 1:bint(indInt);
      kRange = bint(indInt+iRange);
      symInd(kRange) = 1;
      for (k = kRange)
	 ind = mfindstr(bstr,indStr,'|');
	 str{k} = bstr(indStr:ind-1);
	 indStr = ind+1;
      end
   end
   %
   % Get the block parameter variables
   %
   [symInd,str] = mgetscope(symInd,str,catalog,ws,node);
   if (symInd(npar) == 0)
      x0 = zeros(nStates,1);
      if (nCoeffs ~= 0)
	 indInt = bint(15)+2+nCoeffs;
	 cRange = 1:nCoeffs;
	 indFlt = bint(16);
	 x0(bint(indInt+cRange)) = bflt(indFlt+cRange);
      end
      str{npar} = mat2char(x0);
   end
   indFlt = bint(19);
   param = 0;
   for (k = find(~symInd(1:npar-1)))
      param(:) = bflt(indFlt+k);
      str{k} = mat2char(param);
   end
   %
   % PID control block (can be continuous or discrete)
   %
   if (any(sbSample))
      bh = add_block('libsb2sl/DYN/DPIDControlLaw',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'P',str{1},...
		     'I',str{2},...
		     'D',str{3},...
		     'TAU',str{4},...
		     'X0',str{5},...
		     'TS',mat2char(sbSample));
   else
      bh = add_block('libsb2sl/DYN/CPIDControlLaw',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'P',str{1},...
		     'I',str{2},...
		     'D',str{3},...
		     'TAU',str{4},...
		     'X0',str{5});
   end
   %
   % Connect the current PID control law block with the mux and demux blocks
   %
   blkio('line',nInputs,nOutputs,post,parent,name);
   return					   % Last card of BLKPIDCON
