% MODIFY FEEDBACK PROCESS PARAMETERS
% FILENAME: PROCESS.M
% DONE BY : RENO CIPOLLA
% DATE: January 1995
% VERSION: 2.0
% COPYRIGHT  1995
% This M-file is called from mactune.m
% The parameters of the nominal process model is 
% editted in this M-file.
% ***********************************************************


while 1
  clc
  disp('*************************************************************')
  disp('*           MODIFY FEEDBACK PROCESS PARAMETERS              *')
  disp('*                                                           *')
  disp('*************************************************************')
  disp('')
  disp('SELECT THE APPROPRIATE MENU ITEM(S)')
  disp('')
  disp('MODIFY...')
  disp('                                       PRESENT VALUES')
  fprintf('1) Process Gain, Kp                      %4.4f\n',Kp(1))
  fprintf('2) Dead time, theta                      %4.2f\n',theta(1))
  fprintf('3) Lead time,taulead                     %4.2f\n',taulead(1))
  fprintf('4) Time Constant tau1                    %4.2f\n',tau1(1))
  fprintf('5) Time Constant tau2                    %4.2f\n',tau2(1))
  fprintf('6) Time Constant tau3                    %4.2f\n',tau3(1))
  fprintf('7) Damping Coefficient                   %4.2f\n',xi)
  fprintf('8) Noise [Kn (+)  A (0 to .99)]          %4.3f, %4.2f\n',Kn,A)
  disp('9) Return To Main Menu')
  disp('')      
  PRO = input('Enter Your Selection:   ');
  
  if isempty(PRO), break, end
      
  PRO = round(PRO);
  if (PRO<1) | (PRO>9)
      disp('')
      disp('Not a valid selection')
      disp('')
      disp('Press ENTER to continue')
      pause;
  end    
  if PRO == 1
      junk = input('Enter value for process gain, Kp:  ') ;
      if isempty(junk)
         junk =Kp(1);
      end
      Kp(1)=junk;
      mvtest=1; cn_t=1; scn_t=1;

  elseif PRO == 2
      junk = input('Enter value for the dead time:  ') ;
      if junk < 0
       disp('')
       disp(' You cannot have a negative dead time')
       disp('')
       disp(' Press any key to continue')
       pause
       junk=theta(1);
      end
%                          if no entry, don't change      
      if isempty(junk)
          junk=theta(1);
      end
%                          if too large, don't accept 
      if junk > tset | junk > tdist
       clc
       disp('')
       disp('')
       disp('Warning: Dead time must be less than input time !! ')
       disp('')
       disp(' Check implementation time for SP change or Disturbance in ')
       disp(' Simulation or Optimization Menu (default is 10% of time).')
       disp('')
       disp(' Press any key to continue ... ')
       pause
       disp('Press any key to continue...')
       junk=theta(1);
      end

      theta(1)=junk;
      mvtest=1; cn_t=1; scn_t=1;

  elseif PRO == 3
      junk = input('Enter Lead time (numerator):  ') ;
      if isempty(junk)
          junk=taulead(1);
      end
      taulead(1)=junk;

  elseif PRO == 4
      junk = input('Enter value for time constant, tau1:  ') ;
      if isempty(junk)
         junk=tau1(1);
      end
      if junk < 0
         junk = tau1(1);
         disp ('  ')
         disp(' time constant must be nonnegative, press enter to continue')
         pause
      end
      tau1(1)=junk;
      mvtest=1; cn_t=1; scn_t=1;

  elseif PRO == 5
      junk = input('Enter value for time constant, tau2:  ') ;
      if isempty(junk)
         junk=tau2(1);
      end
      if junk < 0
         junk = tau2(1);
         disp(' ')
         disp ('time constant must be nonnegative, press enter to continue') 
         pause
      end   
      tau2(1)=junk;
      mvtest=1; cn_t=1; scn_t=1;

  elseif PRO == 6
      junk = input('Enter value for time constant, tau3:  ') ;
      if isempty(junk)
         junk=tau3(1);
      end
      if junk < 0
         junk = tau3(1);
         disp('  ')
         disp('time constant must be nonnegative, press enter to continue')
         pause
      end
      tau3(1)=junk;
      mvtest=1; cn_t=1; scn_t=1;

  elseif PRO == 7
      junk = input('Enter value for Damping coef.:  ') ;
      if isempty(junk)
          junk=xi;
      end
      if junk < 0
         junk = xi;
         disp('  ')
         disp('damping coef. must be greater than zero')
         disp('press enter to continue')
         pause
      end
      xi=junk;

  elseif PRO == 8
      junk = input('Enter the noise gain, Kn:  ');
      if isempty(junk)
          junk=Kn;
      end
      if junk < 0
         junk = Kn;
         disp ('  ')
         disp('noise gain must be nonnegative, last entry ignored')
         disp('press enter to continue')
         pause
      end
      Kn=junk;
      
      junk = input('Enter the parameter A :  ');
      if isempty(junk)
          junk=A; 
      end    
      if junk < 0
         junk = A;
         disp ('  ')
         disp ('noise time correlation parameter must be nonnegative')
         disp ('last entry ignored, press enter to continue')
         pause
      end
      if junk >= 1.0
         junk = A;
         disp ('noise time correlation parameter must be less than 1.0')
         disp ('last entry ignored, press enter to continue')
         pause
      end

      A=junk;
  else
      break
  end        % if PRO

end 

