/*MAIN
 Overview
 
 BFST_REFILL_TIMES is procedure called called by the main reconstruction procedure
    RECONSTRUCTION1.  Its purpose is to attempt to fill the conseq of the BFST that
    did not get filled during the execution of procedure BFST_FILL_TIMES.  The conseqs
    that did not get filled are identified by their FILL_STATUS being equal to 0 in 
    table CS_STATE_REPORT.
MAIN*/

/*ARGUMENTS
  Arguments
 
  BFST_REFILL_TIMES 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.  
ARGUMENTS*/

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

   - DBMS_UTILITY.GET_TIME.  The GET_TIME function of the native oracle package
     DBMS_UTILITY returns the elapsed time since an arbitrary time in 100ths of 
     seconds

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

   - DROP_OBJECT.  This procedure drops the specified object.

DEPENDENCIES*/

/*VARIABLES
 Variables

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

   - MIN_ID (CS_STATE_REPORT.MIN_ID%TYPE).  Represents the lower bound of the 
     conseq under examination.

   - MAX_ID (CS_STATE_REPORT.MIN_ID%TYPE).  Represents the upper bound of the 
     conseq under examination.

   - NUM_DT (CS_STATE_REPORT.NUM_DT%TYPE).  Represents the number of unpacked 
     major frame datetimes found in the conseq under examination.

   - NUM_UMFC (CS_STATE_REPORT.NUM_UMFC%TYPE).  Represents the number of unpacked 
     major frame counters found in the conseq under examination.

   - CS_STATE (CS_STATE_REPORT.CS_STATE%TYPE).  Represents the overall state of
     the conseq under examination.

   - 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.
VARIABLES*/

/*EXAMPLES
  Examples
 
  Here is a call to BFST_REFILL_TIMES: 
 
   BEGIN
       BFST_REFILL_TIMES ('GEOTAIL1997281181217431GOOD','GEOTAIL1997281181217481BAD');
   END;
   /

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:
  - CS_STATE_REPORT.  This table created during the initial installation of the
    rules, stores information on the state of all the conseqs found in the BFST
    after every session.

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

/*OTHERS
 Others
 
 Note that the reason for attempting a second time to fill conseqs that did not get 
 filled a first time is that most of the time when a conseq can not be filled, it 
 is because a baseline major frame could not be found in the BFST (either to fill
 based on the ground receipt time or based on the major frame counter) in conseqs 
 ahead in the processing chain, since filling the BFST is a forward ordered process.
 Therefore once all conseqs that can be filled are filled, the probability of now
 finding baseline major frames where none existed before is improved significantly.

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