/******************************************************************************/
// @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_GERAN
{
//=========================================================================
// Imports
//=========================================================================

  import from GERAN_Component all;
  import from GERAN_CommonFunctions all;
  import from CommonIratDefs all;
  import from GERAN_Templates all;
  import from GERAN_TypeDefs 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_GERAN ( ) runs on GERAN_PTC {

    var boolean v_TriggerRxd := false;
    //@sic removed T0 and specified T2 from CR R5-104783 @sic
    var integer v_T2_RF_SignalLevel_Cell24 := tsc_GERAN_ChPwrLvl_Off;
    var integer v_T1_RF_SignalLevel_Cell24 := -80;

    //Initialise test case
    f_GERAN_Init ( EUTRA_GERAN );

    //Create GERAN cell and broadcast System Infomation
    f_GERAN_CreateCell ( geran_Cell24 );

    //* @desc Set cell power level according to T0
    //f_GERAN_SetCellPowerLevel( geran_Cell24, v_T0_RF_SignalLevel_Cell24 );

    f_GERAN_InterRAT_InitialiseAuthParams();  // The UE starts in EUTRA, so wait for it to send the Auth Params

    f_GERAN_TestBody_Set( true );

    //@siclog "Step 1" siclog@
    //Set cell power level according to T1
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_GERAN_SetCellPowerLevel( geran_Cell24, v_T1_RF_SignalLevel_Cell24 );

    //@siclog "Step 2" siclog@
    //does the test result of generic test procedure in 36.508
    //subclause 6.4.2.9 indicate that the UE is camped on GERAN Cell 24?
    f_GERAN_IdleMode_RAU( geran_Cell24 );

    //Since Authentication parameters have been updated. Send them to EUTRA PTC
    f_GERAN_SendAuthParameters();

    //@siclog "Step 3" siclog@
    //Switch off and detach UE and set cell power level according to T2
    f_GERAN_SwitchPowerOff (geran_Cell24);
    f_GERAN_SetCellPowerLevel ( geran_Cell24, v_T2_RF_SignalLevel_Cell24 );//Set OFF
    f_SendIRATCoOrd ( EUTRA, cms_IRAT_Trigger );

    //Receive updated Authentication parameters from EUTRA PTC from registration on Cell 1 in step5
    f_GERAN_InterRAT_InitialiseAuthParams();

    //@siclog "Step 6" siclog@
    //Set Cell 24 power level according to T1
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );
    f_GERAN_SetCellPowerLevel ( geran_Cell24, v_T1_RF_SignalLevel_Cell24 );

    //@siclog "Step 7" siclog@
    //Check: does the test result of generic test procedure in 36.508
    //subclause 6.4.2.9 indicate that the UE is camped on GERAN Cell 24?
    f_GERAN_IdleMode_RAU ( geran_Cell24 );

    //* @desc Tell the EUTRA component that the test is over
    f_SendIRATCoOrd ( EUTRA, cms_IRAT_Trigger );

    f_GERAN_TestBody_Set ( false );

    //* @desc Release Cell 24
    f_GERAN_Postamble (geran_Cell24, G1_IDLE);
  }
}
