%  ***********  GENERAL SINGLE LEVEL CONTROL  **************
%  **  CAN BE USED FOR EXAMPLES 18.2 TO 18.4  *************
%  **  AND FIGURES 18-6A-6C                   *************
%  COPYRIGHT McMASTER UNIVERSITY
%  WRITTEN BY T. MARLIN
%  FILENEME: PROPARA.M
%  LAST UPDATED: DECEMBER 1994
%  VERSION 2.0
%  DESCRIPTION
%  this is the sub-menu called from LEVEL.M 
%  used to  input data for the process
%  ********************************************************

%  ********************************************************
%  submenu for process
%  ********************************************************

while 1
  clc
  disp('*************************************************************')
  disp('*     SIMULATION OF NON-SELF-REGULATING LEVEL SYSTEM        *')
  disp('*          INPUT THE PROCESS PARAMETERS HERE                *')
  disp('*      (setting disturbance to zero eliminates it)          *')
  disp('*************************************************************')
  disp('')
  disp('SELECT THE APPROPRIATE MENU ITEM(s)')
  disp('')
  disp('                                        PRESENT VALUES')
  fprintf('1) Level cross sectional area (constant)    %4.3f\n',A)
  fprintf('2) Initial level (typically (V/2A)          %4.3f\n',Linit)
  fprintf('3) Initial flow in (and out)                %4.3f\n',fouti)
  fprintf('4) Flow in step disturbance size            %4.3f\n',delf)
  fprintf('5) Flow in sine disturbance amplitude       %4.3f\n',amp)
  fprintf('6) Flow in sine disturbance period          %4.3f\n',T)
  disp('7) Return to Main Menu')
  disp('')
        
  userin = input('Enter the desired selection:   ');
  
  if isempty(userin), break, end   % go back to main menu if ENTER is pressed
      
  userin = round(userin);
  if (userin<1) | (userin>7)
      disp('')
      disp('Not a valid selection')
      disp('')
      disp('Press ENTER to continue')
      pause;
  end    

% ********************************************************  
  if userin == 1
      junk = input('Enter value for area: ') ;
      if isempty(junk)
          junk=A;
      end
      if junk <= 0
         junk = A;
         disp('area must be positive, entry ignored')
         disp(' press enter to continue')
         pause
      end
      A = junk ;
% ********************************************************
  elseif userin == 2
      junk = input('Enter value for initial level: ') ;
      if isempty(junk) 
          junk = Linit;
      end
      if junk < 0.
          junk = Linit;
          disp (' level must be non-zero, entry ignored')
          disp ('press enter to continue')
          pause
      end
      Linit = junk ;


% *********************************************************
  elseif userin == 3
      junk = input('Enter value for initial flow:  ') ;
      if isempty(junk) 
          junk=fouti;
      end
      if junk <= 0
          junk = fouti;
          disp ('initial flow must be nonnegative, entry ignored')
          disp ('press enter to continue')
          pause
      end
      fouti = junk; 
  
% **********************************************************
  elseif userin == 4
      junk = input('Enter value for step disturbance (delta):  ') ;
      if isempty(junk)
          junk = delf;
      end
      delf = junk; 

% **********************************************************  
  elseif userin == 5
      junk = input('Enter value for sine disturbance amplitude:  ') ;
      if isempty(junk)
          junk= amp;
      end
      if junk < 0.
          junk = amp;
          disp ('amplitude of sine must be nonnegative, entry ignored')
          disp ('press enter to continue')
          pause
      end
      amp = junk; 

% **********************************************************  
  elseif userin == 6
      junk = input('Enter value for sine disturbance period:  ') ;
      if isempty(junk) 
          junk= T;
      end
      if junk <=0.
          junk = T;
          disp (' period must be positive')
          disp (' press enter to continue')
          pause
      end
      T = junk; 

% ***********************************************************
  else
       break
  end 
  
end 
