/******************************************************************************/
// @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-08-19 00:41:30 +0200 (Thu, 19 Aug 2010) $
// $Rev: 3726 $
/******************************************************************************/

module RRC_Measurement_C2K_CDMA2000 {
  
  import from CommonIratDefs all;
  import from CDMA2000_CellInfo all;
  import from CDMA2000_CommonFunctions all;
  import from CDMA2000_Component all;
  import from CDMA2000_CommonDefs all;
  
  //****************************************************************
  //Common functions
  //****************************************************************
  
  
  

  //****************************************************************
  //Testcases
  //****************************************************************
  
  //================================================================
  // testcase 8.3.2.7:
  // Measurement configuration control and reporting / inter RAT measurements: event B2 (measurement of HRPD cells)
  function f_TC_8_3_2_7_CDMA2000 () runs on CDMA2000_PTC
  {
    var boolean v_TriggerRxd := false;
    var PowerIor_Type  v_T0_T2_T4_Cell15 := -20; // cell power corresponds to Ior //R5s103646
    var PowerIor_Type  v_T1_T3_Cell15 := -5;     // cell power corresponds to Ior //R5s103646
    var PowerIor_Type  v_T0_T1_T2_T3_T4_Cell16 := -20; // cell power corresponds to Ior //R5s103646
    
    //Initialise test case
    f_CDMA2000_Init ( EUTRA_CDMA2000 );
    // Set MAX reference power corresponding to Ior/Ioc =-5 and -20 for cell 15 and 16 respectively
    // Note as cell 15 and 16 are on different frequency the
    f_CDMA2000_CellInfo_InitMaxReferencePower(cdma2000_Cell15, cs_CDMA2000_AbsoluteCellPowerDef(-55, -60, 0));    //Ioc =-55, Ior/Ioc=-5, Pilot offset =0 i.e. only pilot is transmitted //R5s103646
    f_CDMA2000_CellInfo_InitMaxReferencePower(cdma2000_Cell16, cs_CDMA2000_AbsoluteCellPowerDef(-55, -75, 0));    //Ioc =-55, ior/Ioc=-20, Pilot offset =0 i.e. only pilot is transmitted //R5s103646
    
    //Create CDMA2000 cell15 and cell16 and broadcast System Infomation
    f_CDMA2000CreateCell ( cdma2000_Cell15 );
    f_CDMA2000CreateCell ( cdma2000_Cell16 );
    f_CDMA2000_Send_IR_SysInfoToEUTRA (cdma2000_Cell15 );
    
    //First Trigger: to Change cell power according to T0 after EUTRA Registration
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //Set CDMA2000 cell's power level for T0
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T0_T2_T4_Cell15 );
    f_CDMA2000_SetCellPower( cdma2000_Cell16, v_T0_T1_T2_T3_T4_Cell16 );
    
    f_CDMA2000_TestBody_Set( true );
    //------------------------------------------------
    //Start TestBody
    
    //Second Trigger: Step 4: Change cell power according to T1
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T1_T3_Cell15 );
    
    //Third Trigger: Step 7: Change cell power according to T2
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T0_T2_T4_Cell15 );
    
    //Fourth Trigger: Step 9: Change cell power according to T3
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T1_T3_Cell15 );
    
    //Fifth Trigger: Step 12: Change cell power according to T4
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T0_T2_T4_Cell15 );
    
    //Wait for the end of the test
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //End TestBody
    //------------------------------------------------
    f_CDMA2000_TestBody_Set ( false );
    
    f_CDMA2000_ReleaseCells(); //Delete all configured CDMA2000 cells
    
  }; //end of testcase 8.3.2.7
  
  //================================================================
  
  // Measurement configuration control and reporting / inter RAT measurements: Periodic reporting (measurement of HRPD cells)
  function f_TC_8_3_2_8_CDMA2000 () runs on CDMA2000_PTC
  {
    var boolean v_TriggerRxd := false;
    var PowerIor_Type v_T0_T1_Cell15 := -5; // cell power corresponds to Ior
    var PowerIor_Type v_T2_Cell15 := -20;
    var PowerIor_Type v_T0_Cell16 := -20;
    var PowerIor_Type v_T1_T2_Cell16 := -5;
    
    //Initialise test case
    f_CDMA2000_Init ( EUTRA_CDMA2000 );
    
    //Create CDMA2000 cell15 and cell16 and broadcast System Infomation
    f_CDMA2000CreateCell ( cdma2000_Cell15 );
    f_CDMA2000CreateCell ( cdma2000_Cell16 );
    
    //Set CDMA2000 cell's power level for T0
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T0_T1_Cell15 );
    f_CDMA2000_SetCellPower( cdma2000_Cell16, v_T0_Cell16 );
    
    f_CDMA2000_Send_IR_SysInfoToEUTRA (cdma2000_Cell15 );
    f_CDMA2000_Send_IR_SysInfoToEUTRA (cdma2000_Cell16 );
    
    f_CDMA2000_TestBody_Set( true );
    //------------------------------------------------
    //Start TestBody
    
    //@siclog "Step 4" siclog@
    //First Trigger: Step 4: Change cell power according to T1
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T0_T1_Cell15 );  // not required since cell 15 power does not change, doing this because prose mentions so
    f_CDMA2000_SetCellPower( cdma2000_Cell16, v_T1_T2_Cell16 );
    
    //@siclog "Step 7" siclog@
    //Second Trigger: Step 7: Change cell power according to T2
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_CDMA2000_SetCellPower( cdma2000_Cell15, v_T2_Cell15 );
    
    //Wait for the end of the test
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //End TestBody
    //------------------------------------------------
    f_CDMA2000_TestBody_Set ( false );
    
    f_CDMA2000_ReleaseCells(); //Delete all configured CDMA2000 cells
  }; // end of test case 8.3.2.8
} // end of Module
