/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// $Date: 2010-09-15 12:17:56 +0200 (Wed, 15 Sep 2010) $
// $Rev: 3891 $
/******************************************************************************/
module InterRat_CellSelection_EtoG
{
//=========================================================================
// Imports
//=========================================================================

  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from EUTRA_Component all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_CellInfo all;
  import from EUTRA_ConfigurationSteps all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_ASP_TypeDefs all;
  import from EUTRA_AspCommon_Templates all;

  import from EUTRA_IRATFunctions all;
  import from CommonIratDefs all;
  import from UpperTesterFunctions all;


//==============================================================================
// Functions
//==============================================================================

  //* @desc Test case 6.2.2.2 Inter-RAT cell Selection / from E-UTRA RRC_IDLE to
  //* GSM_Idle/GPRS Packet_Idle, serving cell becomes non-suitable
  //* (SServingCell<0, barred)
  function f_TC_6_2_2_2_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    //@sic Created T3 and removed T0 from CR R5-104783 @sic
    //var Q_Rxlevmin_Type v_Q_Rxlevmin := -55; //SystemInformationBlockType1 for cell 1
    //var T_ReselectionEutran_Type v_T_Reselection := 7;
    var CellBarred_Type v_CellBarred := barred;
    var AbsoluteCellPower_Type v_T1_Cell_Specific_RS_EPRE_Cell1 := -120;
    var AbsoluteCellPower_Type v_T2_T3_Cell_Specific_RS_EPRE_Cell1 := -60;

    //* @desc Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c1 );//Combination 1 in TS 36.508 section 4.4.3.1.1

    //* @desc Set maximum cell power level for Cell 1
    f_EUTRA_CellInfo_InitMaxReferencePower ( eutra_Cell1, -60 );

    //* @desc Set Sys. info for Cell 1 to be used in creation (according to Table 6.2.2.2.3.2-1)
    //f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin ( eutra_Cell1, v_Q_Rxlevmin );
    //Qrxlevminoffset is not present by default
    //f_EUTRA_CellInfo_SetSysInfo_T_Reselection ( eutra_Cell1, v_T_Reselection );

    //* @desc Create and configure Cell 1
    f_EUTRA_CellConfig_Def ( eutra_Cell1 );

    //* @desc Preamble to ensure USIM is updated with valid TAI and to bring UE to initial state
    f_EUTRA_Preamble_InterRAT(eutra_Cell1, STATE2_IDLEUPDATE, GERAN);

    //@sic default values at T0 removed from CR R5-104783 @sic
    //f_EUTRA_SetCellPower ( eutra_Cell1, v_T0_Cell_Specific_RS_EPRE_Cell1, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set ( true );

    //@siclog "Step 1" siclog@
    //Set cell power level according to T1
    f_SendIRATCoOrd ( GERAN, cms_IRAT_Trigger );
    f_EUTRA_SetCellPower ( eutra_Cell1, v_T1_Cell_Specific_RS_EPRE_Cell1, cs_TimingInfo_Now );

    //Receive Authentication parameters updated in the RAU on GERAN side
    f_EUTRA_InterRAT_InitialiseAuthParams(GERAN);

    //@siclog "Step 3" siclog@
    //Switch off and detach UE and set cell power level according to T3
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( GERAN );
    f_EUTRA_SetCellPower ( eutra_Cell1, v_T2_T3_Cell_Specific_RS_EPRE_Cell1, cs_TimingInfo_Now );

    //@siclog "Step 4" siclog@
    //Switch on UE
    f_UT_SwitchOnUE ( UT, false );

    //@siclog "Step 5" siclog@
    //Perform registration on Cell 1
    f_EUTRA_IdleUpdated ( eutra_Cell1, NORMAL, STATE2_IDLEUPDATE );

    //Since Authentication parameters have been updated. Send them to GERAN PTC
    f_EUTRA_SendAuthParameters(eutra_Cell1, GERAN);

    //@siclog "Step 6" siclog@
    //SS changes Cell 1 parameters according to T2, modifies SI so that Cell1 is barred and transmits Paging message
    //including systemInfoModification. Set Cell 24 power level according to T1
    //@sic CR R5-104722 @sic
    f_EUTRA_CellInfo_SetSysInfo_CellBarred ( eutra_Cell1, v_CellBarred );
    f_EUTRA_ModifySysinfo ( eutra_Cell1 );
    f_SendIRATCoOrd ( GERAN, cms_IRAT_Trigger );

    //* @desc Wait for the end of the test case
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( GERAN );

    f_EUTRA_TestBody_Set ( false );

    //* @desc Remove the non-camping cell
    f_EUTRA_ReleaseAllCells( );
  }
}
