/*MAIN
 Overview
 
 BFST_ASS_QRANK_PWIW is a sub-procedure of the main reconstruction procedure 
    RECONSTRUCTION1.  This procedure assigns quality ranks to all minor frames
    that will be referenced in the session's recipe.  To accomplish the latter,
    BFST_ASS_QRANK_PWIW goes into each minor frame's BFST and, based on the 
    combination of five error flags, each minor frames is assigned an overall
    quality rank. For PWIW data, the  individual flags considered are the frame
    synchronizer error flag (FSERR), the minor frame counter error flag (MNFCERR),
    the major frame counter error flag (MFCERR), the mode error flag (MODEERR),
    the High-Rate Processor error flag (HRP_ERR), and the date error flag (DATEERR).
MAIN*/

/*ARGUMENTS
  Arguments
 
  Procedure BFST_ASS_QRANK_PWIW takes no arguments.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies
 
 The following are the procedures called by BFST_ASS_QRANK_PWIW (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.

   - DBMS_SQL.  This the native Oracle dynamic SQL package.

   - 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.

   - 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.

   - 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:
   - B,C,D, and E (INTEGER). Cursor handles.

   - 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.

   - MNFCERR1 (INTEGER).  Represents the minor frame counter error flag.

   - MODEERR1 (INTEGER).  Represents the mode error flag.

   - DATEERR1 (INTEGER).  Represents the date error flag.

   - FSERR1 (INTEGER).  Represents the frame synchronizer error flag.

   - MFCERR1 (INTEGER).  Represents the major frame counter error flag.

   - HRP_ERR1 (INTEGER).  Represents the High-Rate Processor error flag.

   - ID1 (INTEGER).  Represents the ID of the minor frame in the BFST.  The ID
     of a frame in the BFST is simply a running count of how many minor frames 
     there are in the BFST.  Each minor frame has a unique ID per BFST.

   - QRANK1 (INTEGER).  Represents the overall quality rank of the minor frame
     determined based on the combination of its individual error flags.
VARIABLES*/

/*EXAMPLES
  Examples
 
  Here is a call to BFST_ASS_QRANK_PWIW:
 
   BEGIN
       BFST_ASS_QRANK_PWIW;
   END;
   /
 
 Note that this procedure takes no arguments.
EXAMPLES*/

/*EXCEPTIONS
 Exceptions

 There are no named exceptions for this procedure, except for the generic one
   WHEN OTHERS.  When the latter is triggered, the error message is outputted
   along with the name of the module that erred, and any cursors that may still
   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:
  - BFST. This is the Bad Frame statistics Table that was posted by AD
    just prior to the onset of reconstruction.
  
  - MNFFPT.  This is the Minor Frames File Pointer Table used to store
    the short and long pointer for each session, along with the name of
    the BFST (MNFFILE column), the amf file name (AMF_FILE column), the 
    name of the input file from JPL (INPUT_FILE column), and the session
    id (SESSION_ID column).

  - SPOINTERT.  This is a temporary table created during Reconstruction by 
    procedure CREATE_SPOINTERT1.  The purpose of this table is to store all
    the distinct small pointers for the major frames that will be reconstructed.

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

/*OTHERS
 Others

 Note that the overall quality rank that will be assigned by this procedure to 
   minor frames in the BFST, will be later used by procedure GEN_RECIPE4 to 
   decide when to when a minor frame in the recipe should be filled.  Also note
   that the mapping of the quality rank to the various error flags to the fill
   flag, is stored in table MNFQT (Minor Frames Quality Table).  The fill flag
   can be controlled through the reconstruction graphical user interface.

 Also note that this procedure is only executed for the PWIW mission because of
   the presence of one more error flag (the HRP error flag) than there exist
   for other mission.

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