function dispsys(PID,LeftMargin)
%DISPLAY

%   Author(s): Rong Chen
%   Copyright 2009-2011 The MathWorks, Inc.

WITH = sprintf('%s%s',LeftMargin,...
   ctrlMsgUtils.message('Control:ltiobject:pidDisplayWith'));
if PID.Ts==0
   StrSampleTime = '';
else
   StrSampleTime = sprintf(', Ts = %.3g',PID.Ts);
end
disp(' ');
switch PID.getType
   case 'P'
      fprintf('%sKp = %.3g\n',LeftMargin,PID.Kp)
   case 'PI'
      StrI = ltipack.piddata.utGetStrI(PID.Ts,PID.IFormula);
      disp([LeftMargin '           1     ' StrI(1,:)]);
      disp([LeftMargin 'Kp * (1 + ---- * ' StrI(2,:) ')']);
      disp([LeftMargin '           Ti    ' StrI(3,:)]);
      fprintf('\n%s Kp = %.3g, Ti = %.3g%s\n',WITH,PID.Kp,PID.Ti,StrSampleTime)
   case 'PD'
      StrD = ltipack.piddata.utGetStrForS(PID.Ts,PID.DFormula);
      disp([LeftMargin blanks(15) StrD(1,:)]);
      disp([LeftMargin 'Kp * (1 + Td * ' StrD(2,:) ')']);
      disp([LeftMargin blanks(15) StrD(3,:)]);
      fprintf('\n%s Kp = %.3g, Td = %.3g%s\n',WITH,PID.Kp,PID.Td,StrSampleTime)
   case 'PDF'
      StrD = ltipack.piddata.utGetStrD_Standard(PID.Ts,PID.DFormula);
      disp([LeftMargin blanks(15) StrD(1,:)]);
      disp([LeftMargin 'Kp * (1 + Td * ' StrD(2,:) ')']);
      disp([LeftMargin blanks(15) StrD(3,:)]);
      fprintf('\n%s Kp = %.3g, Td = %.3g, N = %.3g%s\n',...
         WITH,PID.Kp,PID.Td,PID.N,StrSampleTime)
   case 'PID'
      StrI = ltipack.piddata.utGetStrI(PID.Ts,PID.IFormula);
      StrD = ltipack.piddata.utGetStrForS(PID.Ts,PID.DFormula);
      disp([LeftMargin '           1     ' StrI(1,:) blanks(8) StrD(1,:)]);
      disp([LeftMargin 'Kp * (1 + ---- * ' StrI(2,:) ' + Td * ' StrD(2,:) ')']);
      disp([LeftMargin '           Ti    ' StrI(3,:) blanks(8) StrD(3,:)]);
      fprintf('\n%s Kp = %.3g, Ti = %.3g, Td = %.3g%s\n',...
         WITH,PID.Kp,PID.Ti,PID.Td,StrSampleTime)
   case 'PIDF'
      StrI = ltipack.piddata.utGetStrI(PID.Ts,PID.IFormula);
      StrD = ltipack.piddata.utGetStrD_Standard(PID.Ts,PID.DFormula);
      disp([LeftMargin '           1     ' StrI(1,:) blanks(8) StrD(1,:)]);
      disp([LeftMargin 'Kp * (1 + ---- * ' StrI(2,:) ' + Td * ' StrD(2,:) ')']);
      disp([LeftMargin '           Ti    ' StrI(3,:) blanks(8) StrD(3,:)]);
      fprintf('\n%s Kp = %.3g, Ti = %.3g, Td = %.3g, N = %.3g%s\n',...
         WITH,PID.Kp,PID.Ti,PID.Td,PID.N,StrSampleTime)
end
disp(' ');

