function dispsys(PID2,LeftMargin)
%DISPLAY

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

WITH = sprintf('%s%s',LeftMargin,...
    ctrlMsgUtils.message('Control:ltiobject:pidDisplayWith'));
if PID2.Ts==0
    StrSampleTime = '';
    StrKd = 'Kd*';
else
    StrSampleTime = sprintf(', Ts = %.3g',PID2.Ts);
    StrKd = 'Kd ';
end
disp(' ');
switch PID2.getType
    case 'P2'
        fprintf('%s u = Kp (b*r-y)\n',LeftMargin)
        fprintf('\n%s Kp = %.3g, b = %.3g%s\n',WITH,PID2.Kp,PID2.b,StrSampleTime)
    case 'I2'
        StrI = ltipack.piddata.utGetStrI(PID2.Ts,PID2.IFormula);
        disp([LeftMargin blanks(3) StrI(1,:)]);
        disp([LeftMargin 'Ki ' StrI(2,:)]);
        disp([LeftMargin blanks(3) StrI(3,:)]);
        fprintf('\n%s Ki = %.3g%s\n',WITH,PID2.Ki,StrSampleTime)
    case 'PI2'
        StrI = ltipack.piddata.utGetStrI(PID2.Ts,PID2.IFormula);
        disp([LeftMargin blanks(20) StrI(1,:)]);
        disp([LeftMargin 'u = Kp (b*r-y) + Ki ' StrI(2,:) ' (r-y)']);
        disp([LeftMargin blanks(20) StrI(3,:)]);
        fprintf('\n%s Kp = %.3g, Ki = %.3g, b = %.3g%s\n',WITH,PID2.Kp,PID2.Ki,PID2.b,StrSampleTime)
    case 'PD2'
        StrD = ltipack.piddata.utGetStrForS(PID2.Ts,PID2.DFormula);
        disp([LeftMargin blanks(20) StrD(1,:)]);
        disp([LeftMargin 'u = Kp (b*r-y) + ' StrKd StrD(2,:) ' (c*r-y)']);
        disp([LeftMargin blanks(20) StrD(3,:)]);
        fprintf('\n%s Kp = %.3g, Kd = %.3g, b = %.3g, c = %.3g%s\n',WITH,PID2.Kp,PID2.Kd,PID2.b,PID2.c,StrSampleTime)
    case 'PDF2'
        StrD = ltipack.piddata.utGetStrD_Parallel(PID2.Ts,PID2.DFormula);
        disp([LeftMargin blanks(20) StrD(1,:)]);
        disp([LeftMargin 'u = Kp (b*r-y) + Kd ' StrD(2,:) ' (c*r-y)']);
        disp([LeftMargin blanks(20) StrD(3,:)]);
        fprintf('\n%s Kp = %.3g, Kd = %.3g, Tf = %.3g, b = %.3g, c = %.3g%s\n',...
            WITH,PID2.Kp,PID2.Kd,PID2.Tf,PID2.b,PID2.c,StrSampleTime)
    case 'PID2'
        StrI = ltipack.piddata.utGetStrI(PID2.Ts,PID2.IFormula);
        StrD = ltipack.piddata.utGetStrForS(PID2.Ts,PID2.DFormula);
        disp([LeftMargin blanks(20) StrI(1,:) blanks(12) StrD(1,:)]);
        disp([LeftMargin 'u = Kp (b*r-y) + Ki ' StrI(2,:) ' (r-y) + ' StrKd StrD(2,:) ' (c*r-y)']);
        disp([LeftMargin blanks(20) StrI(3,:) blanks(12) StrD(3,:)]);
        fprintf('\n%s Kp = %.3g, Ki = %.3g, Kd = %.3g, b = %.3g, c = %.3g%s\n',...
            WITH,PID2.Kp,PID2.Ki,PID2.Kd,PID2.b,PID2.c,StrSampleTime)
    case 'PIDF2'
        StrI = ltipack.piddata.utGetStrI(PID2.Ts,PID2.IFormula);
        StrD = ltipack.piddata.utGetStrD_Parallel(PID2.Ts,PID2.DFormula);
        disp([LeftMargin blanks(20) StrI(1,:) blanks(12) StrD(1,:)]);
        disp([LeftMargin 'u = Kp (b*r-y) + Ki ' StrI(2,:) ' (r-y) + Kd ' StrD(2,:) ' (c*r-y)']);
        disp([LeftMargin blanks(20) StrI(3,:) blanks(12) StrD(3,:)]);
        fprintf('\n%s Kp = %.3g, Ki = %.3g, Kd = %.3g, Tf = %.3g, b = %.3g, c = %.3g%s\n',...
            WITH,PID2.Kp,PID2.Ki,PID2.Kd,PID2.Tf,PID2.b,PID2.c,StrSampleTime)
end
disp(' ');

