/******************************************************************************/
// @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-16 13:32:53 +0200 (Thu, 16 Sep 2010) $
// $Rev: 3931 $
/******************************************************************************/
module InterRat_CellReSelection_EtoC {
/////////////////
// Import Part //
/////////////////
  
  
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from EUTRA_Component all;
  import from CommonIratDefs all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_CellInfo all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_ConfigurationSteps all;
  



  //==============================================================================
// Functions
//==============================================================================
  type BandClassInfoCDMA2000.threshX_High ThreshX_High_Type;
  type BandClassInfoCDMA2000.threshX_Low ThreshX_Low_Type;
  function f_EUTRA_CellInfo_SetCellPrioritySIB8_HRPD ( CellId_Type p_CellId,
                                                    CellReselectionPriority  p_CellReselectionPriority   ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib8.parametersHRPD.cellReselectionParametersHRPD.bandClassList[0].cellReselectionPriority  := p_CellReselectionPriority;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };
  function f_EUTRA_CellInfo_SetThreshXHigh_HRPD ( CellId_Type p_CellId,
                                                    ThreshX_High_Type    p_ThreshX_High  ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib8.parametersHRPD.cellReselectionParametersHRPD.bandClassList[0].threshX_High     := p_ThreshX_High;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };
  function f_EUTRA_CellInfo_SetThreshXLow_HRPD ( CellId_Type p_CellId,
                                                    ThreshX_Low_Type     p_ThreshX_Low   ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib8.parametersHRPD.cellReselectionParametersHRPD.bandClassList[0].threshX_Low  := p_ThreshX_Low;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };
  function f_EUTRA_CellInfo_SetT_ReselectionCDMA_SIB8_HRPD ( CellId_Type p_CellId,
                                                    T_Reselection    p_T_Reselection     ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib8.parametersHRPD.cellReselectionParametersHRPD.t_ReselectionCDMA2000     := p_T_Reselection;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };


  /*
   * @desc      REFERENCE TS 36.523-1 clause 6.2.2.3
   * Inter-RAT Cell selection / From E-UTRA RRC_IDLE to HRPD Idle / Serving cell becomes non-suitable (SServingCell<0)
   * @status
   */
  function f_TC_6_2_2_3_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c6  );
    //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.3.3.2-1)
    f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin ( eutra_Cell1, -55 );
    //Qrxlevminoffset is not present by default
    // SearchWindow is already 5 by default
    //Cell reselection priority changed to 5 (according to Table 6.2.2.3.3.2-2)
    f_EUTRA_CellInfo_SetCellPrioritySIB8_HRPD(eutra_Cell1,5 );
    //the specific values of  t_ReselectionCDMA timer =0 , threshX-High =30, threshX-L0w =32 are same  as default
    

    //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 ( eutra_Cell1, STATE2_IDLEUPDATE );

    f_EUTRA_TestBody_Set ( true );

    
    //Set cell power level according to T1
    f_SendIRATCoOrd ( CDMA2000, cms_IRAT_Trigger );
    //@siclog "Step 2" siclog@
    //Step 2: Set cell power level according to T2
    f_EUTRA_SetCellPower ( eutra_Cell1, -120, cs_TimingInfo_Now );

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

    f_EUTRA_TestBody_Set ( false );

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

 /*
   * @desc      REFERENCE TS 36.523-1 clause 6.2.3.7
   * Inter-RAT cell reselection / From E-UTRA RRC_IDLE to HRPD Idle / HRPD cell is higher reselection priority than E-UTRA
   * @status
   */
  function f_TC_6_2_3_7_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c6  );
    //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.3.7.3.2-1)
    f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin ( eutra_Cell1, -55 );
    //Qrxlevminoffset is not present by default
    // SearchWindow is already 5 by default
    //the specific values of  threshX-High =30, threshX-L0w =32 are same  as default
    //Cell reselection priority changed to 5 (according to Table 6.2.3.7.3.2-2)
    f_EUTRA_CellInfo_SetCellPrioritySIB8_HRPD(eutra_Cell1,5 );
    //t_ReselectionCDMA timer changed to 7 (according to Table 6.2.3.7.3.2-2)
    f_EUTRA_CellInfo_SetT_ReselectionCDMA_SIB8_HRPD(eutra_Cell1,7);

    //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 ( eutra_Cell1, STATE2_IDLEUPDATE );

    
    //------------------------------------------------
    //Start TestBody
    f_EUTRA_TestBody_Set ( true );

    
    //Send co-ordination message to Set cell power level according to T1 step 1
    f_SendIRATCoOrd ( CDMA2000, cms_IRAT_Trigger );

    
    //Wait for the end of the test case
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( CDMA2000 );
    //@siclog "Step 2 Void" siclog@
    //Set cell power level according to T2
    f_EUTRA_SetCellPower ( eutra_Cell1, -120, cs_TimingInfo_Now );



    f_EUTRA_TestBody_Set ( false );

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

/*
   * @desc      REFERENCE TS 36.523-1 clause 6.2.3.8
   * Inter-RAT cell reselection / From E-UTRA RRC_IDLE to HRPD Idle / HRPD cell is Lower reselection priority than E-UTRA
   * @status
   */
  function f_TC_6_2_3_8_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c6  );
    //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.3.8.3.2-1)
    f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin ( eutra_Cell1, -55 );
    //Qrxlevminoffset is not present by default
    // SearchWindow is already 5 by default
    //the specific values of  t_ReselectionCDMA timer =0 , threshX-High =30, threshX-L0w =32
    // (according to Table 6.2.3.8.3.2-2) are same  as default
    //Cell reselection priority changed to 5 (according to Table 6.2.3.8.3.2-2)
    f_EUTRA_CellInfo_SetCellPrioritySIB8_HRPD(eutra_Cell1,3 );
   
    //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 ( eutra_Cell1, STATE2_IDLEUPDATE );

    
    //------------------------------------------------
    //Start TestBody
    f_EUTRA_TestBody_Set ( true );

    
    //Send co-ordination message to Set cell power level according to T1 step 1
    f_SendIRATCoOrd ( CDMA2000, cms_IRAT_Trigger );
    //@siclog "Step 1" siclog@
    f_EUTRA_SetCellPower ( eutra_Cell1, -70, cs_TimingInfo_Now );

   //Wait for co-ordination message to set power level as per T2
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( CDMA2000 );

    
    //@siclog "Step 5" siclog@
    //Set cell power level according to T2
    f_EUTRA_SetCellPower ( eutra_Cell1, -120, cs_TimingInfo_Now );


    //Wait for the end of the test case
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( CDMA2000 );
    f_EUTRA_TestBody_Set ( false );

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



}
