/******************************************************************************/
// @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 18:04:54 +0200 (Wed, 15 Sep 2010) $
// $Rev: 3907 $
/******************************************************************************/
module InterRat_CellSelection_EtoU
{
//=========================================================================
// 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_RRCSteps all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_IRATFunctions all;
  import from EUTRA_IdleMode all;
  
  import from CommonIratDefs all;

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

  /*
   * @desc      REFERENCE TS 36.523-1 clause 6.2.2.1
   * @status
   */
  function f_TC_6_2_2_1_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    var Q_Rxlevmin_Type v_Q_Rxlevmin := -55;
    var CellBarred_Type v_CellBarred := barred;

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init(c4);

    //Set maximum cell powel level for Cell 1
    f_EUTRA_CellInfo_InitMaxReferencePower (eutra_Cell1, -60);

    //Set Sys. info for Cell 1 to be used in creation (according to Table 6.2.2.1.3.2-1)
    f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin (eutra_Cell1, v_Q_Rxlevmin);

    //Create and configure Cell 1
    f_EUTRA_CellConfig_Def (eutra_Cell1);

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

    f_EUTRA_TestBody_Set (true);

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

    //@siclog "Step 3" siclog@
    //Set power level of Cell 1 according to row "T3" in table 6.1.2.3.3.2-1 & cell 5 according to row "T2" in table 6.1.2.3.3.2-2.
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (UTRAN);
    f_EUTRA_SetCellPower (eutra_Cell1, -60, cs_TimingInfo_Now);

    //@siclog "Step 4" siclog@
    //Generic test procedure TS 36.508 subclause 6.4.2.7A is executed as UE camps on cell 1
    f_EUTRA_IdleMode_TAU_UponMobility_FromOtherRAT (eutra_Cell1);

    //@siclog "Step 5" siclog@
    //Void

    //@siclog "Step 6" siclog@
    //Set Cell 1 paramters according to T2 and Cell 5 power level according to T1
    f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
    f_EUTRA_CellInfo_SetSysInfo_CellBarred (eutra_Cell1, v_CellBarred);
    f_EUTRA_ModifySysinfo (eutra_Cell1);
    
    //@siclog "Step 6A" siclog@
    //Void

    //Wait for the end of the test case
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (UTRAN);

    f_EUTRA_TestBody_Set (false);

    //Remove the non-serving cells
    f_EUTRA_ReleaseAllCells();
  }

  /*
   * @desc      REFERENCE TS 36.523-1 clause 6.2.2.5
   * @status
   */
  function f_TC_6_2_2_5_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    var EUTRA_FDD_TDD_Mode_Type v_FDD_TDD_Cell1;

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c4 );
    
    //Get FDD or TDD mode
    v_FDD_TDD_Cell1 := f_EUTRA_CellInfo_GetFDD_TDD ( eutra_Cell1 );

    //Set TAC according to 36.523-1 Table 6.0.4-2: Tracking Area Code (TAC) for E-UTRAN cells
    //TAC for Cell 1 is set to 1 in f_EUTRA_Init

    //Create and configure Cell 1
    f_EUTRA_CellConfig_Def ( eutra_Cell1 );

    //Set cell power level for test
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( UTRAN );
    f_EUTRA_SetCellPower ( eutra_Cell1, -85, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set ( true );

    //Wait till test case finishes
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( UTRAN );

    f_EUTRA_TestBody_Set ( false );

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