/*MAIN
 Overview

 W_BFST_CALC_TIME_GRT is a procedure that contains the necessary steps to take
    when within a conseq, there are two or more unpacked major frame datetimes
    and two or more unpacked major frame counters.  This state is represented by 
    the last two characters in the name of the procedure (22).  W_BFST_CALC_TIME_GRT is
    stored as a VARCHAR2 action item in table CS_LOOKUPT, table which contains
    all the other actions to take depending on the state of the conseq.
MAIN*/

/*ARGUMENTS
  Arguments

  W_BFST_CALC_TIME_GRT takes the following arguments, all of which have an IN
  parameter mode:
   - NEW_ID1 (INTEGER).  This variable represents the lower boundary of the
     conseq in examination.

   - NEW_ID2 (INTEGER).  This variable represents the upper boundary of the
     conseq in examination.  Note that NEW_ID2 is not included in the conseq.

   - GFST (VARCHAR2).  This variable represents the Good Frames Statistics
     Table that is posted by Labview just prior to the onset of reconstruction.

   - BFST (VARCHAR2).  This variable represents the Bad Frame statistics Table
     that is posted by Labview just prior to the onset of reconstruction.

   - NUM_DT (INTEGER).  This variable represents the number of distinct not
     null floating point datetimes present in the conseq, with no Minor Frame
     Failing Flag (MNFFF) or date error (DATEERR) flag raised in the BFST.

   - NUM_UMFC (INTEGER).  This variable represents the number of distinct not
     null major frame counter present in the conseq, with no Minor Frame
     Failing Flag (MNFFF) raised in the BFST.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies

 The following are the programs called by W_BFST_CALC_TIME_GRT:
   - W_BFST_CALC_UMFC.  This function computes the expected major frame
     counted for a datetime that is receives as one of its arguments.

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

   - DBMS_OUTPUT.PUT_LINE.  This native oracle package writes to the
     buffer.
DEPENDENCIES*/

/*VARIABLES
 Variables

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

   - FP_UMF_DATETIME1, FP_UMF_DATETIME2, FP_UMF_DATETIME3 (NUMBER).  The values
     of the Unpacked Major Frame Floating Point Datetime.  The two floating point
     times unpacked in the conseq are extracted into FP_UMF_DATETIME1 and are
     in turn assigned to FP_UMF_DATETIME2 and FP_UMF_DATETIME3.

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

   - LOOP_ENTRY (INTEGER).  A variable used to initialize the entry in the
     loop where the two floating point datetimes present in this conseq will be
     extracted into two local variables (FP_UMF_DATETIME2 and FP_UMF_DATETIME3).

   - DATETIME_GRT (NUMBER).  The major frame floating point datetime
     computed based on the minor frame floating point ground recept datetime.

   - COUNT1 (INTEGER).  The number of distinct not null floating point datetimes 
     present in the conseq, with no Minor Frame Failing Flag (MNFFF) or date 
     error flag (DATEERR = 1) raised in the BFST.

   - COUNT2 (INTEGER).  The number of distinct ot null major frame counter
     present in the conseq, with no Minor Frame Failing Flag (MNFFF) raised
     in the BFST.

   - UMFC1, UMFC2 and UMFC3 (INTEGER).  The values of major frame counters
     unpacked in this conseq.  The two UMFCs in the conseq are extracted
     into UMFC1 and are in turn assigned to UMFC2 and UMFC3.

   - DISC1 (INTEGER).  The value of the discontinuity in this conseq.

   - EUMFC2, EUMFC3 (NUMBER).  The expected unpacked major frame counters 
     returned from procedure W_BFST_CALC_UMFC.
VARIABLES*/

/*EXAMPLES
 Examples

 Here is a call to W_BFST_CALC_TIME_GRT

   BEGIN
       W_BFST_CALC_TIME_GRT (1, 100, WINDxxxGOOD, WINDyyyBAD, 0,0);
   END;
   /

 The arguments for this procedure are passed in from procedure 
   W_BFST_FILL_TIMES.
EXAMPLES*/

/*EXCEPTIONS
 Exceptions

 There are no named exceptions for this procedure, execpt for the generic one
 WHEN OTHERS.  When the latter is triggered, the error message is outputed
 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:
  - GFST. This is the Good Frames Statistics Table that was posted by
    Labview just prior to the onset of reconstruction.

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

  - UNIQUE_TIME.  This is a temporary table that is created by
    procedure W_BFST_FILL_TIMES.  It contains all the distinct not null
    unpacked major frame floating point datetimes that are present in the
    BFST from minor frames with MNFFF (Minor Frame Fail Flag) = FALSE 
    and DATERR (the date error flag) = 0.

  - UNIQUE_UMFC.  This is a temporary table that is created and dropped by
    procedure W_BFST_FILL_TIMES.  It contains all the distinct not null
    unpacked major frame counters that are present in the BFST from minor
    frames with MNFFF (Minor Frame Fail Flag) = FALSE.

 For more information on these and other tables, see (xxxx).
TABLES*/

/*OTHERS
 Others
 
 It should be noted that with this procedure, if there are more than two
   unpacked major frame floating point datetimes or more than two unpacked
   major frame counters a the conseq, the analysts will be alerted and
   no filling of the times will be done because this state is currently not
   being handled.

 When there are exactly two major frames datetimes unpacked in a 
   conseq, an expected major frame counter (EUMFC) is computed from each 
   using procedure W_BFST_CALC_UMFC, and the resulting EUMFCs are 
   compared to the major frame counter unpacked in the conseq.

 Note that the resulting UMFC in the conseq is also filled in the minor frames
    where it has not been unpacked because in the system state where there is
    no Good Frame Statistics Table but there is a Bad Frame Statistics Table,
    this filled UMFC is used by Oracle to identify the major frame to which
    the minor frames belong.

 For more details on this procedure see WIND_RECONSTRUCTION.
OTHERS*/
