/*MAIN
 Overview

 W_ACTION_CS_20 is a procedure that contains the necessary steps to take
    when within a conseq, there are two or more unpacked major frame datetimes
    and no unpacked major frame counter.  This state is represented by the
    last two characters in the name of the procedure (20).  W_ACTION_CS_20 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_ACTION_CS_20 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_ACTION_CS_20:
   - W_BFST_CALC_TIME_GRT.  This procedure computes the major frame
     floating point datetime in the conseq based on the floating point
     ground receipt datetime.

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

   - DIFF1, DIFF2 (NUMBER).  The absolute difference between the floating point datetime
     datetime computed based on the ground receipt datetime and one of the major frame 
     datetimes unpacked in this conseq.

   - SLOP (NUMBER).  This variable represents the allowable tolerance for variable 
     DIFF1 and DIFF2.
VARIABLES*/

/*EXAMPLES
 Examples

 Here is a call to W_ACTION_CS_20

   BEGIN
       W_ACTION_CS_20 (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.

  - MISSIONS_PARAMETERS.  This table stores all the parameters for each 
    mission and it is the alternative chosen to avoid harcoding these 
    parameters into the code.  

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

/*OTHERS
 Others
 
 It should be noted that in this procedure, if there are more than two
   unpacked major frame floating point datetimes in 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, they are both compared to the datetime computed based on the
   ground receipt time and using a tolerance stored into the missions-
   parameters table.

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