% **************************************************************************
% CASCADE-FEEDFORWARD CONTROL SIMULATOR 
% COPYRIGHT (C) 1994, T.E. MARLIN
%
% FILENAME : CFFMFF.M
% WRITTEN BY : F.BOUDREAU
% VERSION : 2.0
% LAST UPDATED : NOVEMBER 1994
% DESCRIPTION OF FILE :
%    MENU FOR F.F. CONTROLLER EDITING.
% ALL FILES IN THIS PACKAGE :
%    CFF     .M  - MAIN MENU AND ENTRY POINT
%    CFFDAT  .M  - EXTERNAL DATA FILE
%    CFFGRAPH.M  - PLOTS SIMULATION RESULTS
%    CFFM1   .M  - MENU FOR PROCESS T.F. EDITING
%    CFFM2   .M  - MENU FOR PID TUNING
%    CFFM3   .M  - MENU FOR DISTURBANCE T.F. EDITING
%    CFFMFF  .M  - FEEDFORWARD CONTROLLER MENU
%    CFFMSIM .M  - SIMULATION OPTIONS MENU
%    CFFNAME .M  - MENU FOR VARIABLES NAMES, INITIAL VALUES, BOUNDS
%    CFFSIM  .M  - EXECUTES SIMULATION
% **************************************************************************

while 1
   clc;
   fprintf('*************************************************************************\n')
   fprintf('*                                                                       *\n')
   fprintf('*                      FEEDFORWARD CONTROLLER TUNING                    *\n')  
   fprintf('*                    FOR PRIMARY LOOP DISTURBANCE (D1)                  *\n')
   fprintf('*                                                                       *\n')   
   fprintf('*                            Kff(Tld*s+1)exp(-Dff*s)                    *\n')
   fprintf('*                    Gff = ---------------------------                  *\n')
   fprintf('*                                   (Tlg*s+1)                           *\n')
   fprintf('*************************************************************************\n\n')
   fprintf('WHAT PARAMETER WOULD YOU LIKE TO UPDATE ?\n')
   fprintf('                                            Present Values\n')
   fprintf('1) Controller Gain (Kff)                          %-g\n',Kff)
   fprintf('2) Lead Time (Tld)                                %-g\n',Tld)
   fprintf('3) Dead Time (Dff)                                %-g\n',Dff)
   fprintf('4) Lag Time  (Tlg)                                %-g\n',Tlg)
   fprintf('5) Quit to main menu\n')

   m1 = input('PLEASE ENTER A SELECTION : ');
   if isempty(m1)==1         % RETURN TO MAIN MENU IF <CR> ONLY IS PRESSED
      break
   end
   m1 = round(m1);
   if (m1<1 | m1>5)        % VALIDATES SELECTION
      disp('')
      disp('NOT A VALID SELECTION')
      disp('')
      disp('PRESS ENTER TO CONTINUE')
      pause;
   end

   if m1 == 1
      temp = input('Kff : ');
      if isempty(temp) ~= 1
         Kff = temp;
      end
   elseif m1 == 2
      temp = input('Tld : ');
      if isempty(temp) ~= 1
         Tld = temp;
      end
   elseif m1 == 3
      temp = input('Dff : ');
      if isempty(temp) ~= 1
         if (temp) >= 0
             Dff = (temp);
         else
             disp('dead time must be non-negative, please reenter')
             pause (2)
         end
      end
   elseif m1 == 4
      temp = input ('Tlg');
      if isempty(temp) ~= 1
         Tlg = temp;
      end
   elseif m1 == 5
      break
   end % if
end % while
