/******************************************************************************/
// @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_ConnRel_C2K {
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from CommonIratDefs all;
  import from EUTRA_Component all;
  import from EUTRA_CellInfo all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_ConfigurationSteps all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_RRC_Templates all;

  template (value) RedirectedCarrierInfo cs_RedirectionInfo_HRPD ( template (value) CarrierFreqCDMA2000 p_CarrierFreqCDMA2000 ) := {
    cdma2000_HRPD := p_CarrierFreqCDMA2000
  }
template (value) CarrierFreqCDMA2000  cs_CarrierFreqCDMA2000(BandclassCDMA2000 p_Bandclass ,
                                                                        ARFCN_ValueCDMA2000 p_ChannelNum  ):=
  {
    bandClass := p_Bandclass,
    arfcn := p_ChannelNum
  };

//==============================================================================
// Functions
//==============================================================================
 /*
   * @desc      REFERENCE TS 36.523-1 clause 8.1.3.6
   * RRC connection release / Redirection from E-UTRAN to CDMA2000-HRPD
   * @status
   */
  function f_TC_8_1_3_9_EUTRA ( ) runs on EUTRA_PTC {

    var boolean v_TriggerRxd := false;
    //var CellReselectionPriority v_CellReselectionPriority_Cell5 := 3;
    var ReleaseCause v_ReleaseCause := other;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    //var template (value) RedirectedCarrierInfo v_RedirectedCarrierInfo;
    var IRAT_CoOrd_SysInfo_Type v_CDMA2000SysInfo;
    var EUTRA_FDD_TDD_Mode_Type v_FDD_TDD_Cell1;

    //Initialise all cells, security and mobile parameters
    f_EUTRA_Init( c4 );//TAC is set to 1

    //Get FDD or TDD mode
    v_FDD_TDD_Cell1 := f_EUTRA_CellInfo_GetFDD_TDD ( eutra_Cell1 );

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

    //Coordinate with UTRAN component to receive UTRAN frequencies
    // Get Cell Parameters for CDMA2000 cell
    
    v_CDMA2000SysInfo := f_WaitForIRATCoOrd_SysInfo ( CDMA2000 );

    //Set Sys. info for Cell 1 according to Table 6.2.3.5.3.2-2
    //* cellReselectionPriority is already set to 3 in initialisation (cs_CarrierFreqUTRA_FDD)

    //Create and configure all cells
    f_EUTRA_CellConfig_Def ( eutra_Cell1 );

    //Bring UE to initial state
    f_EUTRA_Preamble ( eutra_Cell1, STATE2_IDLEUPDATE );
    f_EUTRA_RbEst_Def ( eutra_Cell1 );

    //Set cell power level according to T0
    f_SendIRATCoOrd ( CDMA2000, cms_IRAT_Trigger );
    f_EUTRA_SetCellPower ( eutra_Cell1, -75, cs_TimingInfo_Now );

    

    f_EUTRA_TestBody_Set ( true );

    //@siclog "Step 1" siclog@
    //Transmit RRC Connection Release message
    f_EUTRA_RRC_ConnectionRelease_Common ( eutra_Cell1,
                                           cs_RRCConnectionRelease ( v_RRC_TI,
                                                                     v_ReleaseCause,
                                                                     cs_RedirectionInfo_HRPD(cs_CarrierFreqCDMA2000(fl_ConvertBandClassInteger_ToCDMA2000(v_CDMA2000SysInfo.Cdma2000[0].BandClass),
                                                                                                                    v_CDMA2000SysInfo.Cdma2000[0].Arfcn)),
                                                                     omit  ) );

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

    f_EUTRA_TestBody_Set ( false );

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

}
