-- Project : MTR390 - EMOS
-- Item/File Name : C2C_RECH.ADA, result_check.ads for GNAT/Unix
-- Authors: Paul Proudfoot, D.Hanske - EEEP, H. Pfoertner, TPMM / MTU-M
--
-- Change History :
-- 06.08.91: Created
-- 17.02.95: updated and file renamed
-- 07.03.95: prepared for separate fault counting
-- 13.03.95: parameter added to MIP_FAULT_COUNTING
-- 14.03.95: FIF_IDENT (from MCP) changed from BOOLEAN to SHORT
-- 10.09.96: Definition of subtype dam_vec
-- 27.02.97: Complete revision, introduction of thermal severities for
--           creep areas
-- 28.02.97: Realistic default values for fill-in factors
-- 03.03.97: Dimension of DAM_VEC defined in package stress_damage
-- 13.03.97: DAM_VEC replaced by type RESULT_ARRAY from stress_damage,
--           default value of FIF_IDENT set to 1
-- 10.04.97: FIFs for PT turbine blade adapted to changed creep coeffs
--
-- Description:  This package contains routines necessary for the result
--               check and correction.
--
-- Defined
-- Modules:     PERFORM
--              MIP_FAULT_COUNTING
--------------------------------------------------------------------------------

with Interfaces, SERV95, DATA_CHECK, STRESS_DAMAGE;
use  Interfaces, SERV95;

--------------------------------------------------------------------------------

package RESULT_CHECK is

    -- The following global variables with initial values will be updated with
    -- actual values from the MCP in state INIT1, after the MCP data set has been
    -- identified as valid.

    DROPOUT_AMOUNT : Integer_16 := 655;  -- Scaling: 32768
    DROPOUT_TIME   : Integer_16 := 240;  -- 2 minutes

    -- constant part of fill-in factors (scaling 2048),
    -- factor for SEV_TH1 for creep areas 22, 33
    FIF_0 : STRESS_DAMAGE.RESULT_ARRAY := STRESS_DAMAGE.RESULT_ARRAY'(
        1=>1946, 2=>1024, 3=>614, 4=>1024,       -- Compressor impellers
        9..18=>307, 19=>246, 20=>328,            -- HPT disk
        21=>0, 22=>2167,                         -- HPT blades
        25=>41, 26=>225,                         -- HPT cover plate
        33=>0,                                   -- PT stage 1 blades
        35=>1638, 36=>778, 37=>1516, 38=>1352, 39=>1393,  -- PT disks
        others => 0);

    -- proportional part of fill-in factors (scaling 2048)
    -- factor for SEV_TH2 for creep areas 22, 33
    FIF_1 : STRESS_DAMAGE.RESULT_ARRAY := STRESS_DAMAGE.RESULT_ARRAY'(
        1=>453, 2=>780, 3=>418, 4=>154,          -- Compressor impellers
        9=>795, 10..18=>819, 19=>530, 20=>364,   -- HPT disk
        21=>899, 22=>0,                          -- HPT blades
        25=>1189, 26=>538,                       -- HPT cover plate
        33=>2048,                                -- PT stage 1 blades
        35=>639, 36=>464, 37=>660, 38=>520, 39=>527,  -- PT disks
        others => 0);

    FIF_IDENT : Integer_16 := 1;
    FIF_HLF   : Integer_16 := 8192;  -- Scaling:2048

    -- The fault counts are made global because they have to be
    -- placed in the result block EMA.

    FAULT_COUNTS : array (DATA_CHECK.STATUS_INDEX) of Integer_16
        := (others => 0);

    -- The following booleans are for the status message in MOP.

    MIP_ERROR         : BOOLEAN := FALSE;
    FATAL_MIP_ERROR   : BOOLEAN := FALSE;
    CONT_MIP_ERROR    : BOOLEAN := FALSE;
    MIP_ERROR_HIGH    : BOOLEAN := FALSE;
    DAM_INCR_HIGH     : BOOLEAN := FALSE;
    NO_RESULT_CHECKS  : BOOLEAN := FALSE;
    DAM_CORR_BY_CM1   : BOOLEAN := FALSE;
    DAM_CORR_BY_CM2   : BOOLEAN := FALSE;
    NO_DAM_CORRECTION : BOOLEAN := FALSE;

    -- Define booleans for CM errors

    CM_ERROR          : BOOLEAN := FALSE;
    CM2_ERROR         : BOOLEAN := FALSE;

    -- Two global variables will be used to store the first faulty value with its
    -- corresponding area in the monitoring account set EMA .

    RESULT_VALUE      : Integer_16 := 0;
    RESULT_AREA       : Integer_16 := 0;

    -- Define the status of the result check which will be required in COUNT
    -- to discriminate whether time counting is normal or has to be counted as
    -- 'time without valid monitoring'.

    type STATUS_OF_RESULT_CHECK is (PASS, FAIL);

    --------------------------------------------------------------------------------

    procedure MIP_FAULT_COUNTING (MIPS_STATUS : in DATA_CHECK.STATUS_DATA_TYPE);

    --------------------------------------------------------------------------------

    procedure PERFORM (SEV_CY_OWN     : in Integer_16;
        SEV_CY_OTHER   : in Integer_16;
        SEV_TH1_OWN    : in Integer_16;
        SEV_TH1_OTHER  : in Integer_16;
        SEV_TH2_OWN    : in Integer_16;
        SEV_TH2_OTHER  : in Integer_16;
        RUNTIME        : in Integer_16;
        DAMAGE         : in out STRESS_DAMAGE.RESULT_ARRAY;
        STATUS_RESULT  : out STATUS_OF_RESULT_CHECK);

    --------------------------------------------------------------------------------

end RESULT_CHECK;