/******************************************************************************/
// @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-17 11:13:38 +0200 (Fri, 17 Sep 2010) $
// $Rev: 3954 $
/******************************************************************************/

module EUTRA_Component {
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from CommonDefs all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_ASP_TypeDefs all; // EUTRA ASPs and port definitions
  import from EUTRA_ASP_DrbDefs all;  // EUTRA ASPs and port definitions
  import from EUTRA_ASP_SrbDefs all;  // EUTRA ASPs and port definitions
  import from EUTRA_ASP_NasCtrl all;  // EUTRA ASPs and port definitions
  import from UpperTesterDefs all;    // all messages being defined to communicate with the upper tester; port definitions
  import from CommonIratDefs all;     // all messages being defined to communicate Geran/Utran components; port definitions
  import from IP_PTC_CtrlMsgs all;
  import from EUTRA_SecurityFunctions all;
  import from EUTRA_AuxiliaryFunctions all;
  import from EUTRA_CellInfo all;
  import from EPS_NAS_TypeDefs all;
  import from NAS_CommonTypeDefs all;
  import from Parameters all;
  import from EUTRA_CellInfoFrequency all;
  import from EUTRA_SRB_Templates all;
  import from EUTRA_RRC_Templates all;
  import from EUTRA_SysInfo_Templates all;
  import from EUTRA_Parameters all;
   
  
  //============================================================================
  
  type enumerated EUTRA_Default_Enum_Type {     /* refers to common default alt_EUTRA_Standard_Default;
                                                   @status    APPROVED */
    StandardDefault
  };
  
  type record EUTRA_MobileInfo_Type {                                   /* @status    APPROVED */
    NAS_Tmsi    Tmsi,
    NAS_P_Tmsi  P_Tmsi,
    UE_EUTRA_Capability EUTRA_Capability
  };
  
  type enumerated EUTRA_VerdictCtrl_Type {                              /* @status    APPROVED */
    normal,                                     /* verdict assignments as for normal L3 signalling test */
    layer2                                      /* verdict assignments for layer2 test: FAIL for unexpected events on DRB ports  */
  };
  
  type enumerated EUTRA_TimingAdvancePeriodMode_Type {     /* maintenance of timing alignment by the SS acc. to 36.523-3 cl. 7.2
                                                              @status    APPROVED */
    normal,                                     /* normal mode: At SS side TA period is 80% of "Time Alignement Timer" being signalled to the UE */
    l2Um                                        /* test mode used for UM L2 test cases: TA period is 75% of drx inactivity timer;
                                                 * this mode shall be applied on layer 2 test cases when one of the DRBs is a UM bearer
                                                 * @sic R5-101177, R5-101178, R5-101050 sic@ */
  };
  
  type record EUTRA_Ctrl_Type {                                         /* @status    APPROVED */
    default                             Default,        /* default behaviour being activated on EUTRA */
    boolean                             TestBody,       /* true:  => fail may be assigend
                                                           false: => inconc is assigned instead of fail */
    EUTRA_VerdictCtrl_Type              VerdictCtrl,    /* Control the assignment of FAIL/INCOCN in default behaviour */
    EUTRA_TimingAdvancePeriodMode_Type TimingAdvancePeriodMode
  };
  
  type record EUTRA_Global_Type {                                       /* @status    APPROVED */
    EUTRA_Ctrl_Type             Ctrl,
    EUTRA_SecurityParams_Type   Security,
    EUTRA_CellInfoList_Type     CellArray,
    EUTRA_MobileInfo_Type       MobileInfo
  };
  
  type component EUTRA_PTC {                                            /* @status    APPROVED */
    var  EUTRA_Global_Type vc_EUTRA_Global;
    
    port EUTRA_SYSTEM_PORT      SYS;
    port EUTRA_SYSIND_PORT      SYSIND;
    port EUTRA_SRB_PORT         SRB;
    port EUTRA_NASCTRL_PORT     NASCTRL;
    port EUTRA_DRB_PORT         DRB;
    
    port UT_PTC_MTC_PORT        UT;
    
    port IRAT_CO_ORD_PORT       UTRAN;
    port IRAT_CO_ORD_PORT       GERAN;
    port IRAT_CO_ORD_PORT       CDMA2000;

    port IP_RAT_CTRL_PORT       IP;                                     /* @sic R5s100135 sic@ */
  };
  
  //============================================================================
  // standard default behaviour:

  template SYSTEM_CTRL_CNF cr_SYSTEM_CTRL_CNF_Any := ?;                 /* @status    APPROVED */
  template SYSTEM_IND      cr_SYSTEM_IND_Any := ?;                      /* @status    APPROVED */
  template SRB_COMMON_IND  cr_SRB_COMMON_IND_Any := ?;                  /* @status    APPROVED */
  template NAS_CTRL_CNF    cr_NAS_CTRL_CNF_Any := ?;                    /* @status    APPROVED */
  template DRB_COMMON_IND  cr_DRB_COMMON_IND_Any := ?;                  /* @status    APPROVED */
  template UT_COMMON_CNF   cr_UT_COMMON_CNF_Any := ?;                   /* @status    APPROVED */
  
  /*
   * @desc      default behaviour does not cover coordination ports to other PTCs;
   *            this is to allow other PTCs to send sync mssages at any time:
   *            these messages are in the port's queue until being handled by the EUTRA PTC
   * @status    APPROVED
   */
  altstep a_EUTRA_StandardDefault() runs on EUTRA_PTC
  { /* @sic R5-101050: New clause in 36.523-3 "B.4.5 Verdict Assignment" => classification of FAIL/INCONC sic@ */
    var SYSTEM_IND v_SYSTEM_IND;
    var SRB_COMMON_IND v_SRB_COMMON_IND;
    var charstring v_Msg;
    
    [] SYS.receive (cr_SYSTEM_CTRL_CNF_Any) {
      /* unexpected CNF shall always result in INCONC */
      all timer.stop;
      f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "unexpected receive event at port SYS");
    }
    
    [] SYSIND.receive (cr_SYSTEM_IND_Any) -> value v_SYSTEM_IND {
      if (ischosen(v_SYSTEM_IND.Indication.HarqError) and vc_EUTRA_Global.Ctrl.TestBody == false)  { // R5s100520 Change 12
        repeat;
      }
      all timer.stop;
      if (ischosen(v_SYSTEM_IND.Indication.Error)) {
        /* error indicated by the system simulator shall always result in INCONC */
        f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "error indicated at port SYS");
      } else {
        /* L1/MAC indications: all of these indications occur only when being activated by TTCN before */
        if (ischosen(v_SYSTEM_IND.Indication.RachPreamble) or
            ischosen(v_SYSTEM_IND.Indication.SchedReq) or
            ischosen(v_SYSTEM_IND.Indication.UL_HARQ) or
            ischosen(v_SYSTEM_IND.Indication.HarqError)) {    /* @sic R5s100135 sic@ */
          /* L1 indications:
           * at layer 1 transmission errors may occur; therefore in general this is an unspecific behaviour */
          f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "unexpected L1 indication at port SYSIND");
        } else {
          /* MAC indications:
           * BSR, C_RNTI, PHR: within the test body a FAIL shall be assigned */
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "unexpected MAC indication at port SYSIND");
        }
      }
    }
    [] SRB.receive (cr_SRB_COMMON_IND_Any) -> value v_SRB_COMMON_IND {
      /* unexpected L3 signalling message */
      all timer.stop;
      if (not ispresent(v_SRB_COMMON_IND.Signalling.Rrc)) {
        /* unexpected NAS message received in ULInformationTransfer => shall cause a FAIL when received in the test body */
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "unexpected NAS PDU at port SRB");
      } else if (not ispresent(v_SRB_COMMON_IND.Signalling.Nas)) {
        /* unexpected RRC message received => shall cause a FAIL when received in the test body */
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "unexpected RRC PDU at port SRB");
      } else {
        /* unexpected RRC message with piggybacked NAS PDU received => shall cause a FAIL when received in the test body */
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "unexpected RRC PDU with piggybacked NAS PDU at port SRB");
      }
    }
    [] NASCTRL.receive (cr_NAS_CTRL_CNF_Any) {
      /* unexpected CNF shall always result in INCONC */
      all timer.stop;
      f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "unexpected receive event at port NASCTRL");
    }
    [] DRB.receive (cr_DRB_COMMON_IND_Any) {
      /* unexpected data at the DRB port */
      all timer.stop;
      
      v_Msg := "unexpected data at port DRB";
      if (vc_EUTRA_Global.Ctrl.VerdictCtrl == layer2) {         /* user plane data is part of the test purpose */
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, v_Msg);
      } else {                                                  /* user plane data is not part of the test purpose */
        f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, v_Msg);
      }
    }
    [] UT.receive (cr_UT_COMMON_CNF_Any) {
      /* unexpected reply from the UE at the UT shall always result in INCONC */
      all timer.stop;
      f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "unexpected receive event at port UT");
    }
    [] any timer.timeout {
      /* Note: there is no way to distinguish local timers in the default behaviour
       *       => there can be either an INCONC or a FAIL in the default behaviour;
       *       => we assign an INCONC - when there shall be FAIL in case of a timeout
       *          this needs to be handled where the timer is declared */
      all timer.stop;
      f_EUTRA_SetVerdictInconc(__FILE__, __LINE__, "unexpected timeout");
    }
  }
  
  //----------------------------------------------------------------------------
  /*
   * @desc      to activate the standard default behaviour
   * @param     p_Default   identifies a standard behaviour to be activated
   * @status    APPROVED
   */
  function f_EUTRA_ActivateDefault(EUTRA_Default_Enum_Type p_Default) runs on EUTRA_PTC
  {
    deactivate(vc_EUTRA_Global.Ctrl.Default);

    select (p_Default) {
      case (StandardDefault) {
        vc_EUTRA_Global.Ctrl.Default := activate(a_EUTRA_StandardDefault());
      }
      case else {
        FatalError (__FILE__, __LINE__, "unknown default behaviour");
      }
    }
  }
  //----------------------------------------------------------------------------
  /*
   * @desc      additional default behaviour to be activated on top of the standard default behaviour
   *            when periodical MeasurmentReports shall be ignored
   * @param     p_CellId
   * @param     p_RrcPdu .. shall be a periodical MeasurmentReport
   * @status    APPROVED
   */
  altstep a_EUTRA_AddDefault_PeriodicalMeasurmentReport(CellId_Type p_CellId,
                                                        template (present) UL_DCCH_Message p_RrcPdu) runs on EUTRA_PTC
  {
    [] SRB.receive( car_SRB1_RrcPdu_IND( p_CellId, p_RrcPdu ) )
      {
        repeat;
      };
  };
  
  //============================================================================
  // common functions:
  /*
   * @desc      to deal with entry and exit of the test body
   * @param     p_TestBodyFlag
   * @param     p_VerdictCtrl (optional)
   * @status    APPROVED
   */
  function f_EUTRA_TestBody_Set(boolean p_TestBodyFlag,
                                EUTRA_VerdictCtrl_Type p_VerdictCtrl := normal) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.Ctrl.TestBody := p_TestBodyFlag;
    vc_EUTRA_Global.Ctrl.VerdictCtrl := p_VerdictCtrl;
    if (p_TestBodyFlag) {
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "initial preliminary pass");
    }
  }
  
  /*
   * @desc      set information whether TimingAdvancePeriod is normal or for special L2 UM mode
   * @param     p_TimingAdvancePeriodMode
   * @status    APPROVED
   */
  function f_EUTRA_TimingAdvancePeriodMode_Set(EUTRA_TimingAdvancePeriodMode_Type p_TimingAdvancePeriodMode) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.Ctrl.TimingAdvancePeriodMode := p_TimingAdvancePeriodMode;
  }
  
  /*
   * @desc      get information whether TimingAdvancePeriod is normal or for special L2 UM mode
   * @return    EUTRA_TimingAdvancePeriodMode_Type
   * @status    APPROVED
   */
  function f_EUTRA_TimingAdvancePeriodMode_Get() runs on EUTRA_PTC return EUTRA_TimingAdvancePeriodMode_Type
  {
    return vc_EUTRA_Global.Ctrl.TimingAdvancePeriodMode;
  }

  /*
   * @desc      check whether test body is active
   * @return    boolean
   * @status    APPROVED
   */
  function fl_EUTRA_TestBody_Check() runs on EUTRA_PTC return boolean {
    return vc_EUTRA_Global.Ctrl.TestBody;
  }

  /*
   * @desc      set correct verdict: FAIL is assigned only when being in the test body
   * @param     p_FileName
   * @param     p_LineNo
   * @param     p_Msg
   * @status    APPROVED
   */
  function f_EUTRA_SetVerdictFailOrInconc(charstring p_FileName,
                                          LineNo_Type p_LineNo,
                                          charstring p_Msg) runs on EUTRA_PTC
  {
    if (fl_EUTRA_TestBody_Check()) {
      f_SetVerdict(fail, p_FileName, p_LineNo, p_Msg);
    } else {
      f_SetVerdict(inconc, p_FileName, p_LineNo, p_Msg);
    }
    self.kill;    // => test case will be terminated immediately
  }
  
  /*
   * @desc      explicitly set verdict INCONC: can be used to set an INCONC within the test body
   * @param     p_FileName
   * @param     p_LineNo
   * @param     p_Msg
   * @status    APPROVED
   */
  function f_EUTRA_SetVerdictInconc(charstring p_FileName,
                                    LineNo_Type p_LineNo,
                                    charstring p_Msg)
  {
    f_SetVerdict(inconc, p_FileName, p_LineNo, p_Msg);
    self.kill;    // => test case will be terminated immediately
  }
  
  /*
   * @desc      set correct verdict: prelininary PASS is only be assigned when being in the test body
   * @param     p_FileName
   * @param     p_LineNo
   * @param     p_Msg
   * @status    APPROVED
   */
  function f_EUTRA_PreliminaryPass(charstring p_FileName,
                                   LineNo_Type p_LineNo,
                                   charstring p_Msg) runs on EUTRA_PTC
  {
    if (fl_EUTRA_TestBody_Check()) {
      f_SetVerdict(pass, p_FileName, p_LineNo, p_Msg);
    }
  }
  
  altstep a_WatchdogTimeout_FailOrInconc(inout timer p_Watchdog,
                                         charstring p_FileName,
                                         LineNo_Type p_LineNo,
                                         charstring p_Msg := "") runs on EUTRA_PTC
  {
    [] p_Watchdog.timeout {
      f_EUTRA_SetVerdictFailOrInconc(p_FileName, p_LineNo, p_Msg);
    }
  }
  //----------------------------------------------------------------------------
  // Access to Cell Array: GET functions

  /*
   * @desc      get info of cell with given index (p_CellId)
   * @param     p_CellId
   * @return    EUTRA_CellInfo_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_Get(CellId_Type p_CellId) runs on EUTRA_PTC return EUTRA_CellInfo_Type {
    var integer v_Index := f_EUTRA_CellInfo_GetIndex(p_CellId);
    return vc_EUTRA_Global.CellArray[v_Index];
  }

  /*
   * @desc      get fdd/tdd for given cell
   * @param     p_CellId
   * @return    EUTRA_FDD_TDD_Mode_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetFDD_TDD(CellId_Type p_CellId) runs on EUTRA_PTC return EUTRA_FDD_TDD_Mode_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.FDD_TDD_Info.FDD_TDD;
  }

  /*
   * @desc      return the FDD/TDD information stored in EUTRA_CellInfo
   * @param     p_CellId
   * @return    template(value) EUTRA_FDD_TDD_CellInfo_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetFDD_TDD_Info (CellId_Type p_CellId ) runs on EUTRA_PTC return template(value) EUTRA_FDD_TDD_CellInfo_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.FDD_TDD_Info;
  }

    /*
   * @desc      return the FDD/TDD  SR configIndex information stored in EUTRA_CellInfo
   * @param     p_CellId
   * @return    SR_ConfigIndex_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetSR_ConfigIndex (CellId_Type p_CellId ) runs on EUTRA_PTC return SR_ConfigIndex_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.FDD_TDD_Info.sr_ConfigIndex;
  }

  /*
   * @desc      get PCCH_Config from the system info as stored for the given cell
   * @param     p_CellId
   * @return    PCCH_Config
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetPCCH_ConfigInSYSINFO(CellId_Type p_CellId) runs on EUTRA_PTC return PCCH_Config
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.pcch_Config;
  }

  /*
   * @desc      get sys info for given cell
   * @param     p_CellId
   * @return    EUTRA_CellSysInfo_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetSYSINFO(CellId_Type p_CellId) runs on EUTRA_PTC return EUTRA_CellSysInfo_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Sysinfo;
  }

  /*
   * @desc      Return the T300 timer value (in milli seconds) sent in  the SIB2 of the cell
   * @param     p_CellId
   * @return    integer
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetT300(CellId_Type p_CellId) runs on EUTRA_PTC return integer
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    var T300_Type v_T300;
    var integer v_T300_Integer;
    // current enumerated type in asn.1 ENUMERATED {ms100, ms200, ms400, ms600, ms1000, ms1500, ms2000, spare1},
    v_T300 := v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.ue_TimersAndConstants.t300;
    select (v_T300) {
      case (ms100) {v_T300_Integer := 100;}
      case (ms200) {v_T300_Integer := 200;}
      case (ms400) {v_T300_Integer := 400;}
      case (ms600) {v_T300_Integer := 600;}
      case (ms1000) {v_T300_Integer := 1000;}
      case (ms1500) {v_T300_Integer := 1500;}
      case (ms2000) {v_T300_Integer := 2000;}
      case else { FatalError(__FILE__, __LINE__, "T300 has unrecognizable value");}
    };
    return v_T300_Integer;
  };

  /*
   * @desc      get GUTI for given cell: Guti parameters stored in the EUTRA_CellInfo
   *            The returned PLMN is of ans.1 type PLMN_Identity
   * @param     p_CellId
   * @return    GutiParameters_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetGuti (CellId_Type p_CellId) runs on EUTRA_PTC return GutiParameters_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.NAS_Parameters.Guti_Parameters;
  };

  function f_EUTRA_CellInfo_GetGutiPLMN (CellId_Type p_CellId) runs on EUTRA_PTC return PLMN_Identity
  {
    /* Return the PLMN in the Guti parameters stored in the EUTRA_CellInfo */
    /* The returned PLMN is of ans.1 type PLMN_Identity */
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity;
  };

  /*
   * @desc      Return the TAC parameter stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    TrackingAreaCode
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetTAC (CellId_Type p_CellId) runs on EUTRA_PTC return TrackingAreaCode
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.NAS_Parameters.TrackingAreaCode;
  };

  /*
   * @desc      Return the EARFCN parameters (DL and UL) stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    CarrierFreqEUTRA
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetEARFCN (CellId_Type p_CellId) runs on EUTRA_PTC return CarrierFreqEUTRA
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Frequency.UL_DL_Earfcn;
  };

  /*
   * @desc      Return the DL EARFCN parameters DL stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    ARFCN_ValueEUTRA
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetEARFCN_DL (CellId_Type p_CellId) runs on EUTRA_PTC return ARFCN_ValueEUTRA
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Frequency.UL_DL_Earfcn.dl_CarrierFreq;
  };

  /*
   * @desc      Return the EARFCN parameters (DL and UL) stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    PhysCellId
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetPhyCellId (CellId_Type p_CellId) runs on EUTRA_PTC return PhysCellId
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.CellIds.PhysicalCellId;
  };

  /*
   * @desc      Return the EARFCN parameters (DL and UL) stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    Frequency_IE_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetFrequencyIEs (CellId_Type p_CellId) runs on EUTRA_PTC return Frequency_IE_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Frequency;
  };
  
  /*
   * @desc      return the additionalSpectrumEmission stored in SIB2 of EUTRA_CellInfo
   * @param     p_CellId
   * @return    AdditionalSpectrumEmission_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetAddSpectrumEmission (CellId_Type p_CellId) runs on EUTRA_PTC return AdditionalSpectrumEmission_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.freqInfo.additionalSpectrumEmission;
  }
  
  /*
   * @desc      return the location area id stored in EUTRA_CellInfo
   * @param     p_CellId
   * @return    NAS_Lac
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetLocationAreaCode (CellId_Type p_CellId) runs on EUTRA_PTC return NAS_Lac
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.NAS_Parameters.LocationAreaCode;
  }
  
  /*
   * @desc      return the C-RNTI stored in EUTRA_CellInfo
   * @param     p_CellId
   * @return    C_RNTI
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetC_RNTI (CellId_Type p_CellId ) runs on EUTRA_PTC return C_RNTI
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.RNTI.C_RNTI;
  }
  
  /*
   * @desc      Return the combination stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    Combination_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetCombination ( CellId_Type p_CellId ) runs on EUTRA_PTC return Combination_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get( p_CellId );
    return v_CellInfo.Sysinfo.Combination;
  }
  
  /*
   * @desc      Return the combination stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    Dl_Bandwidth_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetDL_ChBandwidth ( CellId_Type p_CellId ) runs on EUTRA_PTC return Dl_Bandwidth_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get( p_CellId );
    return v_CellInfo.Frequency.DL_ChBandwidth;
  }
  
  /*
   * @desc      Return the combination stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    Ul_Bandwidth_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetUL_ChBandwidth ( CellId_Type p_CellId ) runs on EUTRA_PTC return Ul_Bandwidth_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get( p_CellId );
    return v_CellInfo.Frequency.UL_ChBandwidth;
  }
  
  /*
   * @desc      Return the EARFCN parameters (DL and UL) stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    FrequencyBand_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetBand (CellId_Type p_CellId) runs on EUTRA_PTC return FrequencyBand_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Frequency.FrequencyBandIndicator;
  };

  /*
   * @desc      Return the RootSequenceIndex in SIB2 stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    RootSequenceIndex_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetRootSequenceIndex (CellId_Type p_CellId ) runs on EUTRA_PTC return RootSequenceIndex_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.prach_Config.rootSequenceIndex;
  }
  
  /*
   * @desc      Return the Radom Access Request Timing Advance stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    RACH_TimingAdvance_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetRAR_TA (CellId_Type p_CellId ) runs on EUTRA_PTC return RACH_TimingAdvance_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.PhysicalParameters.RAR_TA;
  }
  
  /*
   * @desc      get SR PUCCH ResourceIndex for given cell
   * @param     p_CellId
   * @return    SR_PUCCH_ResourceIndex_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetSR_PUCCH_ResourceIndex(CellId_Type p_CellId) runs on EUTRA_PTC return SR_PUCCH_ResourceIndex_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.PhysicalParameters.sr_PUCCH_ResourceIndex;
  }

  /*
   * @desc      get Cell Identity for given cell
   * @param     p_CellId
   * @return    CellIdentity
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetCellIdentity (CellId_Type p_CellId) runs on EUTRA_PTC return CellIdentity
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.CellIds.CellIdentity;
  };
  
  /*
   * @desc      get AntennaInfoCommon from the cell info as stored for the given cell
   * @param     p_CellId
   * @return    AntennaInfoCommon
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetAntennaInfoCommon (CellId_Type p_CellId) runs on EUTRA_PTC return AntennaInfoCommon
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.AntennaInfo.AntennaInfoCommon;
  }
  
  /*
   * @desc      get AntennaInfoDedicated from the cell info as stored for the given cell
   * @param     p_CellId
   * @return    PhysicalConfigDedicated_AntennaInfo_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetAntennaInfoDedicated (CellId_Type p_CellId) runs on EUTRA_PTC return PhysicalConfigDedicated_AntennaInfo_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.AntennaInfo.AntennaInfoDedicated;
  }
  
  //----------------------------------------------------------------------------
  // Access to Cell Array: SET functions
  
  /*
   * @desc      set cell info for given cell
   * @param     p_CellId
   * @param     p_CellInfo
   *            note: "template (value)" to allow a formal template being handed over;
   *                   this is to cope with parameters of set-functions being "template (omit)"
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_Set(CellId_Type p_CellId,
                                template (value) EUTRA_CellInfo_Type p_CellInfo) runs on EUTRA_PTC
  {
    var integer v_Index := f_EUTRA_CellInfo_GetIndex(p_CellId);
    vc_EUTRA_Global.CellArray[v_Index] := valueof (p_CellInfo);   /* valueof cannot be avoided here */
  }
  
  /*
   * @desc      Assign the parameterised Qrxlevmin value in SIB1 of the cell
   * @param     p_CellId
   * @param     p_Q_Rxlevmin
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_Q_Rxlevmin ( CellId_Type p_CellId,
                                                    Q_Rxlevmin_Type p_Q_Rxlevmin ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellSelectionInfo.q_RxLevMin := p_Q_Rxlevmin;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };
  
  /*
   * @desc      set TAC parameter in EUTRA_CellInfo
   * @param     p_CellId
   * @param     p_TAC
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetTAC (CellId_Type p_CellId,
                                    TrackingAreaCode p_TAC) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.NAS_Parameters.TrackingAreaCode := p_TAC;
    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.trackingAreaCode := p_TAC;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Set the Guti parameters in the EUTRA_CellInfo
   * @param     p_CellId
   * @param     p_Guti
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetGuti (CellId_Type p_CellId,
                                     template (value) GutiParameters_Type p_Guti) runs on EUTRA_PTC
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    var template (value) EUTRA_CellInfo_Type v_NewCellInfo := v_CellInfo;       /* template variable to avoid valueof */

    if (v_CellInfo.Frequency.FrequencyBandIndicator == 6 ) {
      // For Band 6: set MCC to the Japan MCC value
      v_NewCellInfo.NAS_Parameters.Guti_Parameters := p_Guti;
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_Guti.PLMN_Identity.mnc;
    } else {
      v_NewCellInfo.NAS_Parameters.Guti_Parameters := p_Guti;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := p_Guti.PLMN_Identity.mcc;  // @sic R5s100008 sic@
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_Guti.PLMN_Identity.mnc;  // @sic R5s100008 sic@
    }
    f_EUTRA_CellInfo_Set (p_CellId, v_NewCellInfo);
  };

  /*
   * @desc      Assign the parameterised T300 value in SIB2 of the cell
   * @param     p_CellId
   * @param     p_T300
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_T300 ( CellId_Type p_CellId,
                                              T300_Type p_T300 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.ue_TimersAndConstants.t300 := p_T300;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  function f_EUTRA_CellInfo_SetSysInfo_T301 ( CellId_Type p_CellId,
                                              T301_Type p_T301 ) runs on EUTRA_PTC
  {
    /* Assign the parameterised T301 value in SIB2 of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.ue_TimersAndConstants.t301 := p_T301;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised T310 value in SIB2 of the cell
   * @param     p_CellId
   * @param     p_T310
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_T310 ( CellId_Type p_CellId,
                                              T310_Type p_T310 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.ue_TimersAndConstants.t310 := p_T310;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised Preamble Transmission in the SIB2 of the cell
   * @param     p_CellId
   * @param     p_PreambleTransMax
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetPreambleTransMax (CellId_Type p_CellId,
                                                 PreambleTransMax_Type p_PreambleTransMax) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax := p_PreambleTransMax;     /* @sic R5s100135 sic@ */
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised ra-ResponseWindowSize in the SIB2 of the cell
   * @param     p_CellId
   * @param     p_Ra_RespWinSize
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetRa_ResponseWindowSize (CellId_Type p_CellId,
                                                      Ra_ResponseWindowSize_Type p_Ra_RespWinSize) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize := p_Ra_RespWinSize;     /* @sic R5s100135 sic@ */
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised Q-Hyst value in SIB3 of the cell
   * @param     p_CellId
   * @param     p_Q_Hyst
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_Q_Hyst ( CellId_Type p_CellId,
                                                Q_Hyst_Type p_Q_Hyst) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3.cellReselectionInfoCommon.q_Hyst := p_Q_Hyst;  // @sic R5s100281 sic@
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the cell configuration type of the cell
   * @param     p_CellId
   * @param     p_CellConfigCapability
   * @status    APPROVED
   */
  function f_EUTRA_SetCellConfigCapability ( CellId_Type p_CellId,
                                             CellConfigCapability_Type p_CellConfigCapability) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.CellConfigCapability := p_CellConfigCapability;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the cell configuration type of the cell
   * @param     p_CellId
   * @param     p_SB1_ValueTagChanged
   * @status    APPROVED
   */
  function f_EUTRA_SetSB1_ValueTag ( CellId_Type p_CellId,
                                     boolean p_SB1_ValueTagChanged) runs on EUTRA_PTC
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.SB1_ValueTagChanged := p_SB1_ValueTagChanged;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the cell configuration type of the cell
   * @param     p_CellId
   * @param     p_CellSysInfo
   * @status    APPROVED
   */
  function f_EUTRA_SetSysinfo ( CellId_Type p_CellId,
                                EUTRA_CellSysInfo_Type p_CellSysInfo) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo := p_CellSysInfo;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  function f_EUTRA_CellInfo_SetSysInfo_Q_RxLevMinOffset ( CellId_Type p_CellId,
                                                          Q_RxLevMinOffset_Type p_Q_RxLevMinOffset ) runs on EUTRA_PTC
  {
    /* Assign the parameterised q-RxLevMinOffset value in SIB1 of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellSelectionInfo.q_RxLevMinOffset := p_Q_RxLevMinOffset;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised t-ReselectionEUTRAN value in SIB3 of the cell
   * @param     p_CellId
   * @param     p_T_ReselectionEutran
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_T_Reselection ( CellId_Type p_CellId,
                                                       T_ReselectionEutran_Type p_T_ReselectionEutran ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3.intraFreqCellReselectionInfo.t_ReselectionEUTRA := p_T_ReselectionEutran;  // @sic R5s100281 sic@
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  function f_EUTRA_CellInfo_SetPLMN_1Entry ( CellId_Type p_CellId, template (value) PLMN_Identity p_PLMN ) runs on EUTRA_PTC  {
    /* Set the parameterised PLMN value in EUTRA Cellinfo */
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );
    var template (value) EUTRA_CellInfo_Type v_NewCellInfo := v_CellInfo;

    if (v_CellInfo.Frequency.FrequencyBandIndicator == 6 ) {
      // For Band 6: set MCC to the Japan MCC value
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity.mnc := p_PLMN.mnc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_PLMN.mnc;
    }
    else {
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity := p_PLMN;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := p_PLMN.mcc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_PLMN.mnc;
    }
    f_EUTRA_CellInfo_Set ( p_CellId, v_NewCellInfo );
  };
  
  function f_EUTRA_CellInfo_SetPLMN_2Entries ( CellId_Type                    p_CellId,
                                               template (value) PLMN_Identity p_PLMN1,
                                               template (value) PLMN_Identity p_PLMN2 ) runs on EUTRA_PTC  {
    /* Set the parameterised PLMN value in EUTRA Cellinfo */
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );
    var template (value) EUTRA_CellInfo_Type v_NewCellInfo := v_CellInfo;
    
    if (v_CellInfo.Frequency.FrequencyBandIndicator == 6 ) {
      // For Band 6: set MCC to the Japan MCC value
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity.mnc := p_PLMN1.mnc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_PLMN1.mnc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[1].plmn_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[1].plmn_Identity.mnc := p_PLMN2.mnc;
    }
    else {
      v_NewCellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity := p_PLMN1;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mcc := p_PLMN1.mcc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].plmn_Identity.mnc := p_PLMN1.mnc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[1].plmn_Identity.mcc := p_PLMN2.mcc;
      v_NewCellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[1].plmn_Identity.mnc := p_PLMN2.mnc;
    }
    f_EUTRA_CellInfo_Set ( p_CellId, v_NewCellInfo );
  };
  
  function f_EUTRA_ChangeSysinfoCombination ( CellId_Type      p_CellId,
                                              Combination_Type p_Combination ) runs on EUTRA_PTC
  {
    /* Change the sysinfo combination of the cell */
    /* This function can't be used to change the combination to c3 */
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );
    var template (value) EUTRA_CellInfo_Type v_NewCellInfo := v_CellInfo;
    var template(value) BcchInfo_Type v_Bcch_Info;
    var RootSequenceIndex_Type v_RootSequenceIndex_Type := f_InitialisePRACH_RootSequenceIndex (p_CellId, v_CellInfo.FDD_TDD_Info.FDD_TDD, LTE_AllCellsOnSamePLMN);
    
    v_Bcch_Info := f_EUTRA_InitSystemInformation  ( p_CellId,
                                                    v_CellInfo.CellIds.CellIdentity,
                                                    p_Combination,
                                                    v_CellInfo.Frequency.FrequencyBandIndicator,
                                                    v_CellInfo.Frequency.DL_ChBandwidth,
                                                    v_CellInfo.Frequency.UL_ChBandwidth,
                                                    cs_PlmnIdList_1Entry(v_CellInfo.NAS_Parameters.Guti_Parameters.PLMN_Identity),
                                                    v_CellInfo.NAS_Parameters.TrackingAreaCode,
                                                    v_CellInfo.FDD_TDD_Info,
                                                    v_RootSequenceIndex_Type
                                                    );
    v_NewCellInfo.Sysinfo.Combination := p_Combination;
    v_NewCellInfo.Sysinfo.BCCH_Info := v_Bcch_Info;
    f_EUTRA_CellInfo_Set ( p_CellId, v_NewCellInfo );
  }

  function f_EUTRA_ChangeSIB5_Combination3 ( CellId_Type    p_CellId,
                                             template (value) SystemInformationBlockType5 p_SystemInformation5 )runs on EUTRA_PTC
 {
   /* To set the sysinfo combination of a cell to c3 using the sysinfo5 passed as parameter */
    var ChannelBandwidthDependency_Type v_ChannelBandwidthDependency := f_EUTRA_BandDependentParam ( f_EUTRA_CellInfo_GetDL_ChBandwidth (p_CellId), f_EUTRA_CellInfo_GetUL_ChBandwidth (p_CellId) );
    var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(p_CellId);
    var template(omit) TDD_Config v_TDD_Config := omit;  // omitted in FDD
    var EUTRA_FDD_TDD_CellInfo_Type v_FDD_TDDInfo := valueof(f_EUTRA_CellInfo_GetFDD_TDD_Info (p_CellId)); // I don't know how to avoid this
    var template (value) BcchInfo_Type v_CellBcchInfo;
    var template (value) EUTRA_CellSysInfo_Type v_EUTRA_CellSysInfo := f_EUTRA_CellInfo_GetSYSINFO ( p_CellId );
    var template (value) BCCH_BCH_Message v_MIB := v_EUTRA_CellSysInfo.BCCH_Info.MIB;
    var template (value) BCCH_DL_SCH_Message v_SIB1;
    var template (value) BCCH_DL_SCH_Message v_SI_SIB2 := v_EUTRA_CellSysInfo.BCCH_Info.SIs[0];
    var template (value) BCCH_DL_SCH_Message v_SI_SIB3 := v_EUTRA_CellSysInfo.BCCH_Info.SIs[1];
   
    // --- Initialise variables for SIB1 ---
     if (v_FDD_TDDInfo.FDD_TDD == TDD) {  // initialise tdd-Configuration  to be used in SIB1
      v_TDD_Config := cs_TDD_ConfigDef(v_FDD_TDDInfo.TDD_SubframeAssignment);    // Value omitted in FDD
    }
    
    v_SIB1 := cs_508_SystemInformationBlockType1_Def( cs_PlmnIdList_1Entry(v_Guti_Params.PLMN_Identity),
                                                      f_EUTRA_CellInfo_GetTAC(p_CellId),
                                                      f_EUTRA_CellInfo_GetCellIdentity (p_CellId),
                                                      f_EUTRA_CellInfo_GetBand (p_CellId),
                                                      cs_SchedulingInfo_3SI (v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                             {sibType3},
                                                                             v_ChannelBandwidthDependency.SIB5_periodicity,
                                                                             {sibType5} ),
                                                      v_TDD_Config );
    v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                      v_SIB1,
                                      { v_SI_SIB2,
                                        v_SI_SIB3,
                                        cs_SystemInformation_Common( cs_SI_SIB5 ( p_SystemInformation5 ) ) }
                                      );
    f_EUTRA_CellInfo_SetBCCH_Info (p_CellId, valueof(v_CellBcchInfo));
    f_EUTRA_CellInfo_SetCombination (p_CellId, c3);
  }
  
    function f_EUTRA_CellInfo_SetCombination (CellId_Type p_CellId,
                                              Combination_Type    p_Combination) runs on EUTRA_PTC
  {
    /* Set the sysinfo combination of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    v_CellInfo.Sysinfo.Combination := p_Combination;
    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  }

    function f_EUTRA_CellInfo_SetBCCH_Info (CellId_Type p_CellId,
                                              BcchInfo_Type       p_BCCH_Info) runs on EUTRA_PTC
  {
    /* Set the BCCH sysinfo content of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    v_CellInfo.Sysinfo.BCCH_Info := p_BCCH_Info;
    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  }
  
  function f_EUTRA_CellInfo_SetLocationAreaCode (CellId_Type p_CellId,
                                                 template (value) NAS_Lac  p_LocAreaId) runs on EUTRA_PTC
  {
    /* Change the location area id of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    v_CellInfo.NAS_Parameters.LocationAreaCode := p_LocAreaId;
    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  }
  
  /*
   * @desc      Change the sC-RNTI value of the cell
   * @param     p_CellId
   * @param     p_C_RNTI
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetC_RNTI (CellId_Type p_CellId,
                                       C_RNTI  p_C_RNTI ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    v_CellInfo.RNTI.C_RNTI := p_C_RNTI;
    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  }
  
  /*
   * @desc      Assign the parameterised Preamble Transmission in the SIB2 of the cell
   * @param     p_CellId
   * @param     p_PRACH_ConfigInd
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetPRACH_ConfigurationIndex (CellId_Type p_CellId,
                                                         integer p_PRACH_ConfigInd) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    if ( (p_PRACH_ConfigInd > 63) or (p_PRACH_ConfigInd < 0) ) {
      FatalError (__FILE__, __LINE__, "Parameter PRACH Config Index out of range(0..63)");
    }

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex := p_PRACH_ConfigInd;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised Preamble Transmission in the SIB2 of the cell
   * @param     p_CellId
   * @param     p_MAC_ContResTimer
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetMAC_ContResTimer (CellId_Type p_CellId,
                                                 MAC_ContentionResolutionTimer_Type p_MAC_ContResTimer) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer := p_MAC_ContResTimer;     /* @sic R5s100135 sic@ */
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised cellBarred value in SIB1 of the cell
   * @param     p_CellId
   * @param     p_CellBarred
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_CellBarred ( CellId_Type p_CellId,
                                                    CellBarred_Type p_CellBarred ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.cellBarred := p_CellBarred;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  function f_EUTRA_CellInfo_SetSysInfo_DefaultPagingCycle ( CellId_Type p_CellId,
                                                            DefaultPagingCycle_Type p_DefaultPagingCycle ) runs on EUTRA_PTC
  {
    /* Assign the parameterised AccessBarringForEmergencyCalls value in SIB2 of the cell*/
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.pcch_Config.defaultPagingCycle := p_DefaultPagingCycle;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  };

  /*
   * @desc      Assign the parameterised cellReselectionPriority value in SIB3 of the cell
   * @param     p_CellId
   * @param     p_CellRes_Prio
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_CellRes_Prio ( CellId_Type p_CellId,
                                                      CellRes_Prio_Type p_CellRes_Prio ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3.cellReselectionServingFreqInfo.cellReselectionPriority := p_CellRes_Prio; // @sic R5s100281 sic@
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised AccessBarring in SIB2 of the cell
   * @param     p_CellId
   * @param     p_AccessBarring
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_AccessBarring ( CellId_Type p_CellId,
                                                       template (value) AccessBarringInformation_Type p_AccessBarring ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.ac_BarringInfo := p_AccessBarring;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised threshServingLow value in SIB3 of the cell
   * @param     p_CellId
   * @param     p_ReselectionThreshold
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_ThreshServingLow ( CellId_Type p_CellId,
                                                          ReselectionThreshold p_ReselectionThreshold ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3.cellReselectionServingFreqInfo.threshServingLow := p_ReselectionThreshold;  // @sic R5s100281 sic
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised Qrxlevmin value in SIB3 of the cell
   * @param     p_CellId
   * @param     p_Q_Rxlevmin
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_Intra_QRxlevmin ( CellId_Type p_CellId,
                                                         Q_Rxlevmin_Type p_Q_Rxlevmin ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3.intraFreqCellReselectionInfo.q_RxLevMin := p_Q_Rxlevmin; // @sic R5s100281 sic@
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised intraFreqReselection value in SIB1 of the cell
   * @param     p_CellId
   * @param     p_IntraFreqRes_Type
   * @status    APPROVED
   */
  function f_EUTRA_Cellinfo_SetSysInfo_IntraFreqRes ( CellId_Type p_CellId,
                                                      IntraFreqRes_Type p_IntraFreqRes_Type ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.intraFreqReselection := p_IntraFreqRes_Type;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  function f_EUTRA_CellInfo_SetSIB3 (CellId_Type p_CellId,
                                     template (value) SystemInformationBlockType3 p_SIB3 ) runs on EUTRA_PTC
  {
    /* Assign SIB3 for all combinations (C1..C10) for p_CellId */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    
    v_CellInfo.Sysinfo.BCCH_Info.SIs[1].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib3 := p_SIB3;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the parameterised SIB4 for p_CellId
   * @param     p_CellId
   * @param     p_Sib4
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB4 ( CellId_Type p_CellId,
                                      template (value) SystemInformationBlockType4 p_Sib4 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );
    
    // SIB4 is only present in combination c2 and c7 (see 36.508 cl. 4.4.3 Table 4.4.3.1.1-1 for more information)
    select ( valueof ( v_CellInfo.Sysinfo.Combination ) ) {
      case ( c2 ){
        //The combination initiation can be found in f_EUTRA_InitSystemInformation
        v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib4 := p_Sib4;
        f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
      }
      case ( c7 ){
        //FFS - this branch is not yet written in EUTRA_CellInfo -> f_EUTRA_InitSystemInformation
        //v_CellInfo.Sysinfo.BCCH_Info.SIs[?].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[?].sib4 := p_Sib4;
        //f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
    }
  }

  /*
   * @desc      Assign the parameterised cellReservedForOperatorUse value in SIB1 of the cell
   * @param     p_CellId
   * @param     p_CellReservedForOpUse_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSysInfo_CellReservedForOpUse ( CellId_Type               p_CellId,
                                                              CellReservedForOpUse_Type p_CellReservedForOpUse_Type ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.plmn_IdentityList[0].cellReservedForOperatorUse := p_CellReservedForOpUse_Type;
    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  }

  /*
   * @desc      Assign the parameterised SIB5 for p_CellId
   * @param     p_CellId
   * @param     p_SIB5
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB5 ( CellId_Type p_CellId,
                                      template (value) SystemInformationBlockType5 p_SIB5 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );

    // SIB5 is only present in combination c3 and c9 (see 36.508 cl. 4.4.3 Table 4.4.3.1.1-1 for more information)
    select ( valueof ( v_CellInfo.Sysinfo.Combination ) ) {
      case ( c3, c9 ){
        v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib5 := p_SIB5;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
    }
  }
  
  /*
   * @desc      function initialising SIB5 for multiband test cases
   * @param     p_CellId
   * @sic R5-096641 R5-104169 sic@
   */
    function f_EUTRA_SetDefaultSIB5_MultiBand ( CellId_Type  p_CellId )  runs on EUTRA_PTC
  {
    var template (value) SystemInformationBlockType5 v_SIB5;
    var Frequency_fList_Type v_Frequency_PrimaryBand := f_EUTRA_InitFrequency_f1Tof4 (px_ePrimaryFrequencyBand, px_ePrimaryBandChannelBandwidth, f_ConvertDL_BandwidthToUL(px_ePrimaryBandChannelBandwidth));
    var Frequency_fList_Type v_Frequency_SecondaryBand := f_EUTRA_InitFrequency_f1Tof4 (px_eSecondaryFrequencyBand, px_eSecondaryBandChannelBandwidth, f_ConvertDL_BandwidthToUL(px_eSecondaryBandChannelBandwidth));
    var ChannelBandwidthDependency_Type v_PrimaryChannelBandwidthDependency := f_EUTRA_BandDependentParam ( px_ePrimaryBandChannelBandwidth, f_ConvertDL_BandwidthToUL(px_ePrimaryBandChannelBandwidth) );
    var ChannelBandwidthDependency_Type v_SecondaryChannelBandwidthDependency := f_EUTRA_BandDependentParam ( px_ePrimaryBandChannelBandwidth, f_ConvertDL_BandwidthToUL(px_ePrimaryBandChannelBandwidth) );
    
    select (p_CellId) {
      case (eutra_Cell1, eutra_Cell2, eutra_Cell4, eutra_Cell11) {
        // For cell frequency of f1:         v_Frequency_PrimaryBand.f1
        // SIB5 contents: f2, f3, f5 (f1 in secondary band)
        if (v_Frequency_PrimaryBand.f2.dl_CarrierFreq != tsc_DummyFrequency ) {    // f2 is defined for the Band px_ePrimaryFrequencyBand
            if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the Band px_ePrimaryFrequencyBand
                v_SIB5 := cs_508_SystemInformationBlockType5_Def ({
                            cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f2
                            cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f3,  v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f3
                            cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1,  v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                            });
            } else {  // f2 defined but f3 not defined for the band
                v_SIB5 := cs_508_SystemInformationBlockType5_Def ({
                            cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f2
                            cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1,  v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                            });
                    }
        } else {  // f2 and f3 not defined (e.g. band 13)
               v_SIB5 := cs_508_SystemInformationBlockType5_Def ({
                            cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1,  v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                            });
                }
      }
      case (eutra_Cell3, eutra_Cell23) {
        // For cell frequency of f2:         v_Frequency_PrimaryBand.f2
        // SIB5 contents: f1, f3, f5 (f1 in secondary band)
        if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the Band
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f1
                                                              cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f3, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f3
                                                              cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1, v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                                                             });
        } else {  // f3 not defined for the band
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f1
                                                              cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1, v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                                                           });
        }
      }
      case (eutra_Cell6) {
        // For cell frequency of f3:         v_Frequency_PrimaryBand.f3
        // SIB5 contents: f1, f2, f5 (f1 in secondary band)
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f1
                                                            cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f2, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f2
                                                            cs_InterFreqCarrierFreq (v_Frequency_SecondaryBand.f1,  v_SecondaryChannelBandwidthDependency.AllowedMeasBandwidth ) //f5
                                                            });
      }
      case (eutra_Cell10) {
        // For cell frequency of f5:         v_Frequency_SecondaryBand.f1 (f5)
        // SIB5 contents: f1, f2, f3
        if (v_Frequency_PrimaryBand.f2.dl_CarrierFreq != tsc_DummyFrequency ) {    // f2 is defined for the primaryBand
            if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the primary
                v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f1
                                                                    cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f2
                                                                    cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f3, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth )   //f3
                                                                    });
            } else {  // f3 not defined for the band
                v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth ),  //f1
                                                                    cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth)
                                                                    });
                    }
        } else {  // f2 and f3 not defined in the primary band
                v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f1, v_PrimaryChannelBandwidthDependency.AllowedMeasBandwidth )  //f1
                                                                    });
                }
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value Cell Id for SIB5 intialisation");
      }
    };
    f_EUTRA_CellInfo_SetSIB5 ( p_CellId, v_SIB5);
  };
  /*
   * @desc      Assign SIB6 for p_CellId
   * @param     p_CellId
   * @param     p_SIB6
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB6 ( CellId_Type p_CellId,
                                      template (value) SystemInformationBlockType6 p_SIB6 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    select ( valueof(v_CellInfo.Sysinfo.Combination) ) {
      case ( c4, c10 ){
        v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib6 := p_SIB6;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
      case ( c9 ){
        v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[1].sib6 := p_SIB6;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
      case (c11){ // @sic R5-103363 sic@
        v_CellInfo.Sysinfo.BCCH_Info.SIs[3].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib6 := p_SIB6;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
      case else {}  // Other combinations: no change needed

    }
  }

  /*
   * @desc      Assign SIB6 in all eutra cell
   * @param     p_SIB6
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllCells ( template (value) SystemInformationBlockType6 p_SIB6 ) runs on EUTRA_PTC
  {
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell1, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell2, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell3, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell4, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell6, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell10, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell11, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell12, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell14, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_Cell23, p_SIB6 );
  };

  /*
   * @desc      Assign SIB6 in all eutra cell
   * @param     p_SIB6
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllNAS_Cells ( template (value) SystemInformationBlockType6 p_SIB6 ) runs on EUTRA_PTC
  {
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellA, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellB, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellC, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellD, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellE, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellG, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellH, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellI, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellJ, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellK, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellL, p_SIB6 );
    f_EUTRA_CellInfo_SetSIB6 ( eutra_CellM, p_SIB6 );
  };

  /*
   * @desc      Assign SIB7 for p_CellId
   * @param     p_CellId
   * @param     p_SIB7
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB7 ( CellId_Type p_CellId,
                                      template (value) SystemInformationBlockType7 p_SIB7 ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    select ( valueof(v_CellInfo.Sysinfo.Combination) ) {
      case ( c5 ){
        v_CellInfo.Sysinfo.BCCH_Info.SIs[2].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib7 := p_SIB7;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
      case ( c10 ){
        v_CellInfo.Sysinfo.BCCH_Info.SIs[3].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib7 := p_SIB7;
        f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
      }
      case else {}  // Other combinations: no change needed
    }
  }
  
  /*
   * @desc      Assign SIB8 for p_CellId
   * @param     p_CellId
   * @param     p_SIB8
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB8 ( CellId_Type p_CellId,
                                      template (value) SystemInformationBlockType8 p_SIB8 ) 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 := p_SIB8;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign SIB7 in all eutra cell
   * @param     p_SIB7
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllCells ( template (value) SystemInformationBlockType7 p_SIB7 ) runs on EUTRA_PTC
  {
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell1, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell2, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell3, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell4, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell6, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell10, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell11, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell12, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell14, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_Cell23, p_SIB7 );
  };

  /*
   * @desc      Assign SIB7 in all eutra cell
   * @param     p_SIB7
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllNAS_Cells ( template (value) SystemInformationBlockType7 p_SIB7 ) runs on EUTRA_PTC
  {
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellA, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellB, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellC, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellD, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellE, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellG, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellH, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellI, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellJ, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellK, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellL, p_SIB7 );
    f_EUTRA_CellInfo_SetSIB7 ( eutra_CellM, p_SIB7 );
  };

  /*
   * @desc      Assign SIB8 in all eutra cell
   * @param     p_SIB8
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetSIB8_FreqListFDD_AllCells ( template (value) SystemInformationBlockType8 p_SIB8 ) runs on EUTRA_PTC
  {
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell1, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell2, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell3, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell4, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell6, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell10, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell11, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell12, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell14, p_SIB8 );
    f_EUTRA_CellInfo_SetSIB8 ( eutra_Cell23, p_SIB8 );
  };


  function f_EUTRA_CellInfo_SetSysInfo_Csg_Ind ( CellId_Type p_CellId,
                                                 boolean p_Csg_Indication ) runs on EUTRA_PTC
  {
    /* Assign the parameterised csg-Indication value in SIB1 of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.csg_Indication := p_Csg_Indication;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  function f_EUTRA_CellInfo_SetSysInfo_Csg_Id ( CellId_Type p_CellId,
                                                B27_Type p_Csg_Identity ) runs on EUTRA_PTC {
    /* Assign the parameterised csg-Identity value in SIB1 of the cell */
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get ( p_CellId );

    v_CellInfo.Sysinfo.BCCH_Info.SIB1.message_.c1.systemInformationBlockType1.cellAccessRelatedInfo.csg_Identity := p_Csg_Identity;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Assign the CellInformation of the parameterized cell to the highest bandwidth (UL and DL) according to the parameterised band
   * @param     p_CellId
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetHighestBandwidth (CellId_Type p_CellId) runs on EUTRA_PTC
  {
    var FrequencyBand_Type v_FrequencyBand := f_EUTRA_CellInfo_GetBand ( p_CellId );
    var Dl_Bandwidth_Type v_Dl_Bandwidth := f_EUTRA_GetHighestDL_Bandwidth ( v_FrequencyBand  );
    var Ul_Bandwidth_Type v_Ul_Bandwidth := f_EUTRA_GetHighestUL_Bandwidth ( v_FrequencyBand  );
    var Combination_Type v_Combination   := f_EUTRA_CellInfo_GetCombination ( p_CellId );

    f_EUTRA_CellInfo_Set( p_CellId,
                          f_EUTRA_CellInfo_Init( p_CellId,
                                                 v_FrequencyBand,
                                                 v_Combination,
                                                 v_Dl_Bandwidth,
                                                 v_Ul_Bandwidth));
  }

    /*
   * @desc      Assign the CellInformation of the parameterized cell to the default 2TX parameters
   * @param     p_CellId
   */
    function f_EUTRA_CellInfo_SetMIMO_2TX (CellId_Type p_CellId
                                                ) runs on EUTRA_PTC
  {
    
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);

    /* Update the antenna information in the cell Array */
    v_CellInfo.AntennaInfo.SS_AntennaInfoCommon := cs_AntennaInfoCommon_2Port;
    v_CellInfo.AntennaInfo.AntennaInfoCommon := cs_AntennaInfoCommon_2Port;
    v_CellInfo.AntennaInfo.SS_AntennaInfoDedicated := cs_AntennaInfoDedicated_2TX;
    v_CellInfo.AntennaInfo.AntennaInfoDedicated := cs_PhysicalConfigDedicated_AntennaInfo_2TX;

    /* Update p_B parameter in the cell array */
    v_CellInfo.PhysicalParameters.PDSCH_p_b := tsc_P_b_2Tx;

    /* Modify p_b in SIB2 */
    v_CellInfo.Sysinfo.BCCH_Info.SIs[0].message_.c1.systemInformation.criticalExtensions.systemInformation_r8.sib_TypeAndInfo[0].sib2.radioResourceConfigCommon.pdsch_ConfigCommon.p_b := tsc_P_b_2Tx;

    f_EUTRA_CellInfo_Set ( p_CellId, v_CellInfo );
  };

  //----------------------------------------------------------------------------
  // Access to Power Parameters:

  /*
   * @desc      Assign the parameterised Attenuation in the EUTRA_CellInfo
   * @param     p_CellId
   * @param     p_ReferenceCellPower
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_SetCellPower ( CellId_Type p_CellId,
                                           template (value) ReferenceCellPower_Type p_ReferenceCellPower ) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);  // template variable to avoid valueof

    v_CellInfo.ReferencePower := p_ReferenceCellPower;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  /*
   * @desc      Return the Cell power parameters stored in the EUTRA_CellInfo
   * @param     p_CellId
   * @return    ReferenceCellPower_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_GetCellPower ( CellId_Type p_CellId ) runs on EUTRA_PTC return  ReferenceCellPower_Type
  {
    var EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);
    return v_CellInfo.ReferencePower;
  };
  
  /*
   * @desc      set max. reference power for a cell before the cell is created; the attenuation is "Off" in this case
   * @param     p_CellId
   * @param     p_MaxReferencePower
   * @status    APPROVED
   */
  function f_EUTRA_CellInfo_InitMaxReferencePower ( CellId_Type p_CellId,
                                                    AbsoluteCellPower_Type p_MaxReferencePower) runs on EUTRA_PTC
  {
    var template (value) EUTRA_CellInfo_Type v_CellInfo := f_EUTRA_CellInfo_Get(p_CellId);  // template variable to avoid valueof
    v_CellInfo.ReferencePower.MaxReferencePower := p_MaxReferencePower;
    v_CellInfo.ReferencePower.Attenuation.Off := true;
    f_EUTRA_CellInfo_Set (p_CellId, v_CellInfo);
  }

  //----------------------------------------------------------------------------
  // Access to Security Parameters:

  /*
   * @desc      Return security parameters
   * @return    EUTRA_SecurityParams_Type
   * @status    APPROVED
   */
  function f_EUTRA_Security_Get() runs on EUTRA_PTC return EUTRA_SecurityParams_Type
  {
    return vc_EUTRA_Global.Security;
  }

  /*
   * @desc      set security parameters
   * @param     p_Auth_Params
   * @status    APPROVED
   */
  function f_EUTRA_Security_Set(EUTRA_SecurityParams_Type p_Auth_Params) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.Security := p_Auth_Params;
  }

  /*
   * @desc      Access to the Security Parameter KSIasme
   * @return    NAS_KsiValue
   * @status    APPROVED
   */
  function f_EUTRA_SecurityKSIasme_Get() runs on EUTRA_PTC return NAS_KsiValue
  {
    return vc_EUTRA_Global.Security.KSIasme;
  }

  //----------------------------------------------------------------------------
  // Access to Mobile info Parameters:

  function f_EUTRA_MobileInfo_GetTmsi() runs on EUTRA_PTC return NAS_Tmsi
  {
    return vc_EUTRA_Global.MobileInfo.Tmsi;
  }

  function f_EUTRA_MobileInfo_GetP_Tmsi() runs on EUTRA_PTC return NAS_P_Tmsi
  {
    return vc_EUTRA_Global.MobileInfo.P_Tmsi;
  }

  function f_EUTRA_MobileInfo_GetUECapability_UECategory() runs on EUTRA_PTC return integer
  {
    return vc_EUTRA_Global.MobileInfo.EUTRA_Capability.ue_Category;
  }

  function f_EUTRA_MobileInfo_SetTmsi(NAS_Tmsi p_NAS_Tmsi) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.MobileInfo.Tmsi := p_NAS_Tmsi;
  }

  function f_EUTRA_MobileInfo_SetP_Tmsi(NAS_Tmsi p_NAS_P_Tmsi) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.MobileInfo.P_Tmsi := p_NAS_P_Tmsi;
  }

  /*
   * @desc      set UECapability
   * @param     p_Cap
   * @status    APPROVED
   */
  function f_EUTRA_MobileInfo_SetUECapability(UE_EUTRA_Capability p_Cap) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.MobileInfo.EUTRA_Capability := p_Cap;
  }


  //****************************************************************************
  // Initialisation
  //----------------------------------------------------------------------------

  type record NasInitParams_Local_Type {        /* local type definition;   @status    APPROVED */
    EUTRA_NAS_NumOfPLMN_Type CellsOnSamePLMN,
    EUTRA_NAS_CellTC_Type    CellTC_Type,
    EUTRA_NAS_CellSpecialFreq CellFreq   // @sic R5-102140 sic@
  };

  type record RrcInitParams_Local_Type {        /* local type definition;   @status    APPROVED */
    Combination_Type SysinfoCombination
  };

  type union InitParams_Local_Type {            /* local type definition;   @status    APPROVED */
    NasInitParams_Local_Type   Nas,
    RrcInitParams_Local_Type   NonNas
  };

  //----------------------------------------------------------------------------
  /*
   * @desc      Return the defined frequencies f1 to f4 depending on the band
   *            function to be used only before coordination with UTRA PTC
   * @return    IRAT_CoOrd_SysInfo_Type
   * @status    APPROVED
   * @sic R5-096440 R5-104169 sic@
   */
  function f_IRAT_ListOfFrequencies () runs on EUTRA_PTC return IRAT_CoOrd_SysInfo_Type
  {
    var template (value) IRAT_CoOrd_SysInfo_Type v_CoOrd_List :=
      cs_CoOrdEUTRA_SysInfo ( { cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell1) ),   // f1
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell3) ),    // f2
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell6) ),    // f3
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell14) )   // f4
                               }
                              ); // Initialise with all frequencies
    
    if ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell6) == tsc_DummyFrequency ) {   // f3 is NA for the band, then f4 is also NA
      v_CoOrd_List := cs_CoOrdEUTRA_SysInfo ( { cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell1) ),    // f1
                                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell3) )      // f2
                                                }
                                             );    // f3 and f4 are NA
   } else {   // f3 is having a value
      if ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell14) == tsc_DummyFrequency ) {  // f4 is NA for the band
        v_CoOrd_List := cs_CoOrdEUTRA_SysInfo ( { cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell1) ),    // f1
                                                  cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell3) ),     // f2
                                                  cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell6) )     // f3
                                                  }
                                               );    // f4 is NA
      }
    }
    return valueof (v_CoOrd_List);
  };
  
  //----------------------------------------------------------------------------
  /*
   * @desc      Return the defined frequencies f1 to f4 depending on the band
   *            function to be used only before coordination with UTRA PTC
   * @return    IRAT_CoOrd_SysInfo_Type
   * @status    APPROVED
   */
  function f_IRAT_NAS_ListOfFrequencies () runs on EUTRA_PTC return IRAT_CoOrd_SysInfo_Type
  {
    var template (value) IRAT_CoOrd_SysInfo_Type v_CoOrd_List :=
      cs_CoOrdEUTRA_SysInfo (  // EUTRA frequencies - Initialise with all frequencies
                              { cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellA) ),   // f1
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellG) ),    // f2
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellI) ),    // f3
                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellJ) ) }   // f4
                              );                                                                       // no f5 in NAS: no interBand cell used in NAS test cases

    if ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell6) == tsc_DummyFrequency ) {   // f3 is NA for the band, then f4 is also NA
      v_CoOrd_List := cs_CoOrdEUTRA_SysInfo ( { cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellA) ),    // f1
                                                cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellG) ) }    // f2
                                             );                                                                        // f3 , f4 are  NA
                                                                                                               // no f5 in NAS: no interBand cell used in NAS test cases
    } else {   // f3 is having a value
      if ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_Cell14) == tsc_DummyFrequency ) {  // f4 is NA for the band
        v_CoOrd_List := cs_CoOrdEUTRA_SysInfo ( {
            cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellA) ),   // f1
            cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellG) ),    // f2
            cs_CoOrdEUTRASysInfo ( f_EUTRA_CellInfo_GetEARFCN_DL (eutra_CellI) )}    // f3
          );                                                                       // f4 is NA
                                                                                                              // no f5 in NAS: no interBand cell used in NAS test cases
      }
    }
    return valueof (v_CoOrd_List);
  }

  /*
   * @desc      Reinitialise SIBs for I-RAT combinations
   * @param     p_SysinfoCombination
   * @status    APPROVED
   * @sic R5-095514 sic@
   */
  function fl_EUTRA_IRAT_Init ( Combination_Type p_SysinfoCombination ) runs on EUTRA_PTC
  {
    var IRAT_CoOrd_SysInfo_List_Type v_SysInfo_List;
    
    select (p_SysinfoCombination ) {
      case (c4, c9, c11 ) {     // EUTRA-UTRA SIB6 @sic R5-103363 sic@
        f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllCells (          // Assign new SIB6 in cellArray for all cells
                                                       f_EUTRA_IRAT_InitSIB6 (                                // Return SIB6 with new UTRAN FDD or TDD frequency list
                                                                              f_IRAT_InitialCoOrd(   UTRAN,                        // Coordinate with UTRA PTC: send EUTRA frequencies and return UTRA frequencies
                                                                                                     f_IRAT_ListOfFrequencies ()   // Return f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                                                                                     )
                                                                                                              )
                                                                 )
          }
      case (c5) {  // EUTRA-GERAN SIB7
        f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllCells (          // Assign new SIB7 in cellArray for all cells
          f_EUTRA_IRAT_InitSIB7 (                                // Return SIB7 with new GERAN frequency list
            f_IRAT_InitialCoOrd(   GERAN,                        // Coordinate with GERAN PTC: send EUTRA frequencies and return GERAN frequencies
                                   f_IRAT_ListOfFrequencies ()   // Return f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                   )
                                                                 )
                                                                 )
      }
      case (c6) { // EUTRA-CDMA2000
        f_EUTRA_CellInfo_SetSIB8_FreqListFDD_AllCells (          // Assign new SIB8 in cellArray for all cells
          f_EUTRA_IRAT_InitSIB8 (                                // Return SIB8 with new CDMA2000 cell information
                                 f_IRAT_InitialCoOrd(   CDMA2000,                     // Coordinate with CDMA2000 PTC: send EUTRA frequencies and return CDMA parameters
                                                        cs_CoOrdC2K_NoParams         // C2K PTC does not need to receive any information from the LTE PTC
                                )
                           )
                                                      )
          }
      case (c10) {  // EUTRA-UTRAN-GERAN  SIB6 SIB7
        v_SysInfo_List := f_IRAT_InitialCoOrd_2Ports(             // Coordinate with UTRAN and GERAN PTCs: send EUTRA frequencies and return UTRAN and GERAN info
                                                     UTRAN,
                                                     GERAN,
                                                     f_IRAT_ListOfFrequencies ()  // Return EUTRA frequencies f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                                                  );
        f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllCells (          // Assign new SIB6 in cellArray for all cells
                                                       f_EUTRA_IRAT_InitSIB6 ( v_SysInfo_List[0] )            // Return SIB6 with new UTRAN FDD or TDD frequency list
                                                                 );
        f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllCells (          // Assign new SIB7 in cellArray for all cells
                                                       f_EUTRA_IRAT_InitSIB7 ( v_SysInfo_List[1] )             // Return SIB7 with new GERAN frequency list
                                                                 );
      }
      case else {}  // Other combinations: no change needed
    }
  };
  
  /*
   * @desc      Reinitialise SIBs for I-RAT combinations
   * @param     p_SysinfoCombination
   * @status    APPROVED
   * @sic R5-095514 sic@
   */
  function fl_EUTRA_NAS_IRAT_Init ( Combination_Type p_SysinfoCombination ) runs on EUTRA_PTC
  {
    var IRAT_CoOrd_SysInfo_List_Type v_SysInfo_List;
    
    select (p_SysinfoCombination ) {
      case (c4, c9, c11 ) {     // EUTRA-UTRA SIB6 @sic R5-103363 sic@
        f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllNAS_Cells (     // Assign new SIB6 in cellArray for all cells
                                                           f_EUTRA_IRAT_InitSIB6 (                               // Return SIB6 with new UTRAN FDD or TDD frequency list
                                                                                  f_IRAT_InitialCoOrd(   UTRAN,                       // Coordinate with UTRA PTC: send EUTRA frequencies and return UTRA frequencies
                                                                                                         f_IRAT_NAS_ListOfFrequencies ()  // Return EUTRA frequencies f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                                                                                         )
                                                                                                                 )
                                                                )
          }
      case (c5) {  // EUTRA-GERAN SIB7
        f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllNAS_Cells (          // Assign new SIB7 in cellArray for all cells
                                                           f_EUTRA_IRAT_InitSIB7 (                                   // Return SIB7 with new GERAN frequency list
                                                                                  f_IRAT_InitialCoOrd(   GERAN,                           // Coordinate with GERAN PTC: send EUTRA frequencies and return GERAN frequencies
                                                                                                         f_IRAT_NAS_ListOfFrequencies ()  // Return EUTRA frequencies f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                                                                                         )
                                                                                                                     )
                                                                     )
          }
      case (c6) { // EUTRA-CDMA2000
        f_EUTRA_CellInfo_SetSIB8_FreqListFDD_AllCells (          // Assign new SIB8 in cellArray for all cells
          f_EUTRA_IRAT_InitSIB8 (                                // Return SIB8 with new CDMA2000 cell information
                                 f_IRAT_InitialCoOrd(   CDMA2000,                     // Coordinate with CDMA2000 PTC: send EUTRA frequencies and return CDMA parameters
                                                        cs_CoOrdC2K_NoParams          // C2K PTC does not need to receive any information from the LTE PTC
                                )
                           )
                                                      )
      }
      case (c10) {  // EUTRA-UTRAN-GERAN  SIB6 SIB7
        v_SysInfo_List := f_IRAT_InitialCoOrd_2Ports(             // Coordinate with UTRAN and GERAN PTCs: send EUTRA frequencies and return UTRAN and GERAN info
                                                     UTRAN,
                                                     GERAN,
                                                     f_IRAT_NAS_ListOfFrequencies ()  // Return EUTRA frequencies f1/f2/f3/f4 or f1/f2/f3 or f1/f2 depending on the band
                                                                  );
        f_EUTRA_CellInfo_SetSIB6_FreqListFDD_AllNAS_Cells (     // Assign new SIB6 in cellArray for all cells
                                                           f_EUTRA_IRAT_InitSIB6 ( v_SysInfo_List[0] )           // Return SIB6 with new UTRAN FDD or TDD frequency list
                                                                );
        f_EUTRA_CellInfo_SetSIB7_FreqListFDD_AllNAS_Cells (          // Assign new SIB7 in cellArray for all cells
                                                           f_EUTRA_IRAT_InitSIB7 ( v_SysInfo_List[1] )                // Return SIB7 with new GERAN frequency list
                                                                     );
      }
      
      case else {}  // Other combinations: no change needed
    }
  };
  
  //----------------------------------------------------------------------------
  /*
   * @desc      local initilisation
   * @param     p_Params   local parameters
   * @status    APPROVED
   */
  function fl_EUTRA_Common_Init(InitParams_Local_Type p_Params) runs on EUTRA_PTC
  {
    vc_EUTRA_Global.Ctrl.Default := null;
    vc_EUTRA_Global.Ctrl.TestBody := false;
    vc_EUTRA_Global.Ctrl.VerdictCtrl := normal;
    vc_EUTRA_Global.Ctrl.TimingAdvancePeriodMode := normal;

    // Initialise security parameters
    vc_EUTRA_Global.Security := f_EUTRA_Security_Init();
    
    // Initialise Cell array
    if (ischosen(p_Params.NonNas)) {
      vc_EUTRA_Global.CellArray := f_EUTRA_CellArray_Init(p_Params.NonNas.SysinfoCombination);
    } else {
      vc_EUTRA_Global.CellArray := f_EUTRA_NAS_CellArray_Init(p_Params.Nas.CellsOnSamePLMN, p_Params.Nas.CellTC_Type, p_Params.Nas.CellFreq);
    }
    
    //Initialise Mobile Info
    vc_EUTRA_Global.MobileInfo.Tmsi := '00000000'O;
    vc_EUTRA_Global.MobileInfo.P_Tmsi := '00000000'O;
    
    f_EUTRA_ActivateDefault(StandardDefault);
  }
  
  //----------------------------------------------------------------------------
  /*
   * @desc      common initialisation of the EUTRA_PTC
   * @param     p_SysinfoCombination   Combinations of system information blocks  (36.508 cl. 4.4.3.1.1)
   * @status    APPROVED
   */
  function f_EUTRA_Init( Combination_Type p_SysinfoCombination ) runs on EUTRA_PTC
  {
    var InitParams_Local_Type v_Params := { NonNas := {SysinfoCombination := p_SysinfoCombination} };
    
    fl_EUTRA_Common_Init(v_Params);
    fl_EUTRA_IRAT_Init ( p_SysinfoCombination );
  }
  
  /*
   * @desc      Initialise global variable for NAS test cases
   * @param     p_CellsOnSamePLMN
   * @param     p_CellTC_Type
   * @param     p_CellSpecialFreq   (default value: LTE_NAS_NormalFreq)
   * @status    APPROVED
   */
  function f_EUTRA_NAS_Init( EUTRA_NAS_NumOfPLMN_Type p_CellsOnSamePLMN,
                             EUTRA_NAS_CellTC_Type    p_CellTC_Type,
                             EUTRA_NAS_CellSpecialFreq p_CellSpecialFreq:=LTE_NAS_NormalFreq ) runs on EUTRA_PTC
  {
    var InitParams_Local_Type v_Params := {Nas := { CellsOnSamePLMN := p_CellsOnSamePLMN,
                                                    CellTC_Type     := p_CellTC_Type,
                                                    CellFreq        := p_CellSpecialFreq }};  // @sic R5-102140 sic@
    fl_EUTRA_Common_Init(v_Params);
    fl_EUTRA_NAS_IRAT_Init ( f_EUTRA_CellInfo_GetCombination (eutra_CellA));  /* Sysinfo combination from cell A
                                                                                 All cells are initalised with the same combination */
  }

} // End of module
