/*MAIN
 Overview
 
 GEN_RECIPE1 is a sub-procedure of the main reconstruction procedure 
    RECONSTRUCTION1.  The role of this procedure is to go through the Working
    Frames Statistics Table (WFST) and, for each major frame for which there 
    exists minor frames in the BFST, GEN_RECIPE1 will call on INSERT_POINTERS
    to register SPOINTERS in the five minor frame location tables that will 
    provide the exact location of each major frame's minor frames.
MAIN*/

/*ARGUMENTS
  Arguments
 
  GEN_RECIPE1 takes the following arguments, all of which have an IN 
  parameter mode:
   - GFST (VARCHAR2).  This variable represents the name of the Good Frames
     Statistics Table that was posted by Labview just prior to the onset of
     reconstruction.  Entries in the GFST were built and logged into a script
     file during processing of the annotated minor frames file by AD.

   - BFST (VARCHAR2).  This variable represents the name of the bad Frames 
     Statistics Table that was posted by Labview just prior to the onset of 
     reconstruction.  Entries in the BFST were built and logged into a script
     file during processing of the annotated minor frames file by AD.

   - AMF_FILE (VARCHAR2).  This variable represents the name of the annotated 
     minor frames file generated by the frame synchronizer software.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies
 
 The following are the procedures called by GEN_RECIPE1 (listed in their
 order of call):
   - SWITCH.  This is the package that manipulates the switches for all
     the reconstruction rules.

   - RULES_STATES.  This is a package of three procedures and one function all
     of which track and post reconstruction states for all rules as they become
     available, in the temporary table LOGT.

   - RULE.  This is the stored package that manipulates the reconstruction rules
     numbers, name and version number.

   - OPEN_AND_PARSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.OPEN_CURSOR and
     DBMS_SQL.PARSE procedures, into a single function.

   - EXECUTE_AND_CLOSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.EXECUTE and
     DBMS_SQL.CLOSE procedures, into a single function.

   - CONFIG.  This is the stored package that manipulates the configuration
     parameters for all the reconstruction rules.

   - DBMS_SQL.  This the native Oracle dynamic SQL package.

   - COUNT_ALL.  This is a stored function created to count all entries in any
     table.  This function takes in as argument the name of the table to count
     from (as a varchar2), and any "where" clause that may be used to constraint
     the count (as a varchar2).  Note that if no "where" clause is to be used in
     a count, the second argument to this function is optional.

   - LOG_FILE.  This is a package of procedures which handle the tasks of
     creating the file in which reconstruction output messages will be written
     to, writing to the latter file, and closing it at the end of
     reconstruction.

   - INSERT_POINTERS.  This is a stored procedure that inserts SPOINTERS into 
     all five minor frame location tables for minor frames of major frames that
     are present in the session's BFST and will eventually be part of the RECIPE.

   - POST_STATE.  This is a package of three procedures and one function all
     of which serve the role of writing the states of all rules as they become
     available, in the system_state table.
DEPENDENCIES*/

/*VARIABLES
 Variables

 The following are variables used in the procedure:
   - C,D, and E (INTEGER). Cursor handle.

   - EXECUTE1 (INTEGER).  The number of rows processed by the SQL statement
     if that statement is an UPDATE, INSERT, or DELETE.  If the SQL statement
     is not an UPDATE, INSERT, or DELETE, this value should be ignored.

   - FP_UMF_DATETIME1 (NUMBER).  Represents the value of the Unpacked Major 
     Frame Floating Point Datetime (the major frame spacecraft time).

   - SPOINTER (MNFFPT.SPOINTER%TYPE).  The small pointer that was assigned to
     the current session.

   - SLOP (NUMBER).  Represents the configuration parameter
     TOL_BFST_DUPLICATE_MFT.

   - STATE (NUMBER).  Represents an indicator in rule GEN_RECIPE1 as to what
     happened during the execution of rule INSERT_POINTERS (i.e. for each major
     frame in the Working Frames Statistics Table, it tells rule GEN_RECIPE1 if
     the current session's BFST contained any usable minor frame.
VARIABLES*/

/*EXAMPLES
  Examples
 
  Here is a call to GEN_RECIPE1:
 
   BEGIN
       GEN_RECIPE1 ('PWIW1997287095646983GOOD',
                    'PWIW1997287095644634BAD','POLAR_DG_1996_077_00204_4038c');
   END;
   /
 
 The arguments of this procedure are passed in from procedure RECONSTRUCTION1.
EXAMPLES*/

   be opened are closed.  
EXCEPTIONS*/

/*ERRORS
 Errors

 There are no errors that this procedure is known to generate.  Should an
   error occur, take action based on the description of the error.
ERRORS*/

/*TABLES
 Tables
 
 The following tables are referenced in this procedure:
   - GFST. This is the Good Frames Statistics Table that was posted by
     AD just prior to the onset of reconstruction.

   - BFST. This is the Bad Frame statistics Table that was posted by AD
     just prior to the onset of reconstruction.

   - WFST.  This is the Working Frames Statistics Table, a temporary table
     created to hold information on missing and reconstructed frames that
     will ultimately be written to the AFST.

   - AFST.  This is the Accumulated Frames Statistics Table, which stores information
     about major frames of all grades that have ever been processed.

   - GRADE2_TEMP_STOR.  This a temporary table created by procedure GFST_PROCESS1.
     Its purpose is to temporarily store information about all the major frames
     (grades 2) that have been found as missing within and accross data spans of
     the GFST.  

   - MNFFPT.  This is the minor frame file pointer table used to keep statistic
     information on at most one thousand sessions.  Among other data, this table
     stores the short and long pointers for each session.

 For more information on these and other tables, see the documentation on tables.
TABLES*/

/*OTHERS
 Others
 
 It should be noted that at the end of GEN_RECIPE1's execution, all grade 2 major
   frames that were temporarily stored in table GRADE2_TEMP_STOR are now inserted
   into the WFST.

 For more details on this procedure see the reconstruction documentation.
OTHERS*/
