/* Internal_Tests::TestP041_specific */
void TestP041_specific_Internal_Tests(void)
{
  static P41_LevelTransistionOrders_T_Packet_Types_Pkg tmp;
  static kcg_bool noname;
  
  kcg_copy_P041_trackside_int_T_TM(
    &Ctxt_TestP041_specific_Internal_Tests._L5,
    (P041_trackside_int_T_TM *) &BG356_P041_Packets426);
  kcg_copy_CompressedPackets_T_Common_Types_Pkg(
    &Ctxt_TestP041_specific_Internal_Tests._L4,
    (CompressedPackets_T_Common_Types_Pkg *)
      &DEFAULT_CompressedPackets_Internal_Tests);
  /* 1 */
  Write_P041_TM_trackside(
    &Ctxt_TestP041_specific_Internal_Tests._L5,
    &Ctxt_TestP041_specific_Internal_Tests._L4,
    &Ctxt_TestP041_specific_Internal_Tests.Context_1);
  Ctxt_TestP041_specific_Internal_Tests._L2 =
    Ctxt_TestP041_specific_Internal_Tests.Context_1.Error;
  kcg_copy_CompressedPackets_T_Common_Types_Pkg(
    &Ctxt_TestP041_specific_Internal_Tests._L3,
    &Ctxt_TestP041_specific_Internal_Tests.Context_1.RadioPacketsOut);
  /* 1 */
  Read_P041_TM(
    &Ctxt_TestP041_specific_Internal_Tests._L3,
    &Ctxt_TestP041_specific_Internal_Tests._1_Context_1);
  Ctxt_TestP041_specific_Internal_Tests._L1 =
    Ctxt_TestP041_specific_Internal_Tests._1_Context_1.received;
  kcg_copy_P041_OBU_T_TM(
    &Ctxt_TestP041_specific_Internal_Tests._L6,
    &Ctxt_TestP041_specific_Internal_Tests._1_Context_1.P041_OBU_out);
  Ctxt_TestP041_specific_Internal_Tests.tmp =
    Ctxt_TestP041_specific_Internal_Tests._L1;
  if (Ctxt_TestP041_specific_Internal_Tests.tmp) {
    /* 1 */
    C_P041_to_legacy_t_TM_conversions(
      &Ctxt_TestP041_specific_Internal_Tests._L6,
      &Ctxt_TestP041_specific_Internal_Tests._2_Context_1);
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &tmp,
      &Ctxt_TestP041_specific_Internal_Tests._2_Context_1.P041_legacy_out);
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &Ctxt_TestP041_specific_Internal_Tests._L7,
      &tmp);
  }
  else {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &Ctxt_TestP041_specific_Internal_Tests._L7,
      (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
        &DEFAULT_P041_legacy_TM_specific);
  }
  kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
    &PacketOut,
    &Ctxt_TestP041_specific_Internal_Tests._L7);
  noname = Ctxt_TestP041_specific_Internal_Tests._L2;
}
/* TM_specific::Read_P041_Legacy */
void Read_P041_Legacy_TM_specific(
  /* TM_specific::Read_P041_Legacy::Message_IN */ CompressedPackets_T_Common_Types_Pkg *Message_IN,
  /* TM_specific::Read_P041_Legacy::P041_legacy_out */ P41_LevelTransistionOrders_T_Packet_Types_Pkg *P041_legacy_out)
{
  /* TM_specific::Read_P041_Legacy::_L2 */ P041_OBU_T_TM _L2;
  /* TM_specific::Read_P041_Legacy::_L1 */ kcg_bool _L1;
  
  /* 1 */ Read_P041_TM(Message_IN, &_L1, &_L2);
  /* ck__L1 */ if (_L1) {
    /* 1 */ C_P041_to_legacy_t_TM_conversions(&_L2, P041_legacy_out);
  }
  else {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      P041_legacy_out,
      (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
        &DEFAULT_P041_legacy_TM_specific);
  }
}
/* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */
void MEM_dataForLevelTransition_EVC_MEM_Support_Pkg(
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::actualMessage */ ReceivedMessage_T_Common_Types_Pkg *actualMessage,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::storedData */ dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *storedData,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::trainPosition */ trainPosition_T_TrainPosition_Types_Pck *trainPosition,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::positionNeeded */ kcg_bool positionNeeded,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::actualLevel */ M_LEVEL actualLevel,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::trainProperties */ trainProperties_T_TrainPosition_Types_Pck *trainProperties,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::outstoredData */ dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *outstoredData,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::outPositionNeeded */ kcg_bool *outPositionNeeded)
{
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */
  static kcg_bool tmp1;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */
  static P27_InternationalStaticSpeedProfile_T_Packet_Types_Pkg tmp;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */
  static kcg_bool op_call;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::ntcRequested */
  static kcg_bool ntcRequested;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L3 */
  static kcg_bool _L3;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L4 */
  static P015_OBU_T_TM _L4;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L18 */
  static P41_LevelTransistionOrders_T_Packet_Types_Pkg _L18;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L21 */
  static P021_OBU_T_TM _L21;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L20 */
  static kcg_bool _L20;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L71 */
  static kcg_bool _L71;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L116 */
  static NID_LRBG _L116;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L130 */
  static P080_OBU_T_TM _L130;
  
  tmp1 = /* 2 */
    packetValid_xdebugSupport_Pkg(
      &(*actualMessage).packets.PacketHeaders,
      cp041_Level_Transition_Order_Id_Pkg);
  /* 1 */ Read_P080_TM(&(*actualMessage).packets, &op_call, &_L130);
  _L71 = positionNeeded | tmp1 | op_call;
  /* ck_p41Valid */ if (tmp1) {
    _L116 = /* 1 */ getLRBGFromMsg_xdebugSupport_Pkg(actualMessage);
  }
  else {
    _L116 = (*storedData).LRBG;
  }
  /* 1 */ Read_P015_TM(&(*actualMessage).packets, &_L3, &_L4);
  /* 1 */ Read_P041_Legacy_TM_specific(&(*actualMessage).packets, &_L18);
  /* 1 */ Read_P021_TM(&(*actualMessage).packets, &_L20, &_L21);
  kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
    outstoredData,
    storedData);
  /* 2 */ if (tmp1) {
    ntcRequested = /* 1 */ checkNTCPriority_xdebugSupport_Pkg(&_L18);
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p41,
      &_L18);
  }
  else {
    ntcRequested = kcg_false;
    /* 3 */ if (actualLevel == M_LEVEL_Level_0) {
      kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
        &(*outstoredData).p41,
        (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
          &cNoP41_EVC_MEM_Support_Pkg);
    }
    else {
      kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
        &(*outstoredData).p41,
        &(*storedData).p41);
    }
  }
  /* 4 */ if (op_call) {
    /* 1 */ MEM_convertP80_EVC_MEM_Support_Pkg(&_L130, &(*outstoredData).p80);
  }
  else {
    kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
      &(*outstoredData).p80,
      &(*storedData).p80);
  }
  tmp1 = /* 1 */
    packetValid_xdebugSupport_Pkg(
      &(*actualMessage).packets.PacketHeaders,
      cp046_Conditional_Level_Transition_Order_Id_Pkg);
  /* 1 */ if (tmp1) {
    /* 1 */
    Read_P046_Legacy_TM_specific(
      &(*actualMessage).packets,
      &(*outstoredData).p46);
  }
  else {
    kcg_copy_P46_ConditionalLevelTransitionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p46,
      &(*storedData).p46);
  }
  (*outstoredData).p15_received = _L3 | (*storedData).p15_received |
    ntcRequested;
  (*outstoredData).p21_received = _L20 | (*storedData).p21_received;
  /* 1 */
  Read_P027V1_Legacy_for_ML_TM_specific(&(*actualMessage).packets, &tmp);
  (*outstoredData).p27_received = tmp.valid | (*storedData).p27_received |
    ntcRequested;
  (*outstoredData).LRBG = _L116;
  /* ck__L71 */ if (_L71) {
    /* 1 */
    MEM_locationOfReferenceLRBG_EVC_MEM_Support_Pkg(
      _L116,
      trainPosition,
      trainProperties,
      &(*outstoredData).referenceLocation,
      &op_call);
    *outPositionNeeded = !op_call;
  }
  else {
    (*outstoredData).referenceLocation = (*storedData).referenceLocation;
    *outPositionNeeded = !positionNeeded;
  }
}
/* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */
void MEM_dataForLevelTransition_EVC_MEM_Support_Pkg(
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::actualMessage */ ReceivedMessage_T_Common_Types_Pkg *actualMessage,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::storedData */ dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *storedData,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::trainPosition */ trainPosition_T_TrainPosition_Types_Pck *trainPosition,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::positionNeeded */ kcg_bool positionNeeded,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::actualLevel */ M_LEVEL actualLevel,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::trainProperties */ trainProperties_T_TrainPosition_Types_Pck *trainProperties,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::nationalValues */ P003_OBU_T_TM *nationalValues,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::outstoredData */ dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *outstoredData,
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::outPositionNeeded */ kcg_bool *outPositionNeeded)
{
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */ M_LEVEL tmp2;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */ kcg_bool tmp1;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition */ P27_InternationalStaticSpeedProfile_T_Packet_Types_Pkg tmp;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::ntcRequested */ kcg_bool ntcRequested;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::p80Valid */ kcg_bool p80Valid;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::isMsg3 */ kcg_bool isMsg3;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::levelStored */ M_LEVEL levelStored;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L3 */ kcg_bool _L3;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L4 */ P015_OBU_T_TM _L4;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L18 */ P41_LevelTransistionOrders_T_Packet_Types_Pkg _L18;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L21 */ P021_OBU_T_TM _L21;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L20 */ kcg_bool _L20;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L71 */ kcg_bool _L71;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L116 */ NID_LRBG _L116;
  /* EVC_MEM_Support_Pkg::MEM_dataForLevelTransition::_L130 */ P080_OBU_T_TM _L130;
  
  isMsg3 = /* 2 */
    packetValid_xdebugSupport_Pkg(
      &(*actualMessage).packets.PacketHeaders,
      cp041_Level_Transition_Order_Id_Pkg);
  /* 1 */ Read_P041_Legacy_TM_specific(&(*actualMessage).packets, &_L18);
  /* ck_p41Valid */ if (isMsg3) {
    levelStored = /* 1 */ getP41Level_xdebugSupport_Pkg(&(*storedData).p41);
    tmp2 = /* 2 */ getP41Level_xdebugSupport_Pkg(&_L18);
    ntcRequested = /* 1 */ checkNTCPriority_xdebugSupport_Pkg(&_L18);
  }
  else {
    levelStored = M_LEVEL_Level_0;
    tmp2 = M_LEVEL_Level_0;
    ntcRequested = kcg_false;
  }
  tmp1 = isMsg3 & (tmp2 != levelStored);
  isMsg3 = cm03_Movement_Authority_Id_Pkg ==
    (*actualMessage).Radio_Common_Header.nid_message;
  _L71 = positionNeeded | tmp1 | isMsg3;
  _L3 = isMsg3 | tmp1;
  /* ck__L169 */ if (_L3) {
    _L116 = /* 1 */ getLRBGFromMsg_xdebugSupport_Pkg(actualMessage);
  }
  else {
    _L116 = (*storedData).LRBG;
  }
  /* 1 */ Read_P015_TM(&(*actualMessage).packets, &_L3, &_L4);
  /* 1 */ Read_P021_TM(&(*actualMessage).packets, &_L20, &_L21);
  /* 1 */ Read_P080_TM(&(*actualMessage).packets, &p80Valid, &_L130);
  kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
    outstoredData,
    storedData);
  /* 2 */ if (tmp1) {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p41,
      &_L18);
  }
  else /* 3 */ if (actualLevel == levelStored) {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p41,
      (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
        &cNoP41_EVC_MEM_Support_Pkg);
  }
  else {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p41,
      &(*storedData).p41);
  }
  /* 4 */ if (p80Valid) {
    /* 1 */
    MEM_convertP80_EVC_MEM_Support_Pkg(
      &_L130,
      nationalValues,
      &(*outstoredData).p80);
  }
  else /* 5 */ if (isMsg3) {
    kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
      &(*outstoredData).p80,
      (P80_ModeProfiles_T_Packet_Types_Pkg *)
        &Default_P80_legacy_EVC_MEM_Support_Pkg);
  }
  else {
    kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
      &(*outstoredData).p80,
      &(*storedData).p80);
  }
  tmp1 = /* 1 */
    packetValid_xdebugSupport_Pkg(
      &(*actualMessage).packets.PacketHeaders,
      cp046_Conditional_Level_Transition_Order_Id_Pkg);
  /* 1 */ if (tmp1) {
    /* 1 */
    Read_P046_Legacy_TM_specific(
      &(*actualMessage).packets,
      &(*outstoredData).p46);
  }
  else {
    kcg_copy_P46_ConditionalLevelTransitionOrders_T_Packet_Types_Pkg(
      &(*outstoredData).p46,
      &(*storedData).p46);
  }
  (*outstoredData).p15_received = _L3 | (*storedData).p15_received |
    ntcRequested;
  (*outstoredData).p21_received = _L20 | (*storedData).p21_received;
  /* 1 */
  Read_P027V1_Legacy_for_ML_TM_specific(&(*actualMessage).packets, &tmp);
  (*outstoredData).p27_received = tmp.valid | (*storedData).p27_received |
    ntcRequested;
  (*outstoredData).LRBG = _L116;
  /* ck__L71 */ if (_L71) {
    /* 1 */
    MEM_locationOfReferenceLRBG_EVC_MEM_Support_Pkg(
      _L116,
      trainPosition,
      trainProperties,
      &(*outstoredData).referenceLocation,
      &isMsg3);
    *outPositionNeeded = !isMsg3;
  }
  else {
    (*outstoredData).referenceLocation = (*storedData).referenceLocation;
    *outPositionNeeded = positionNeeded;
  }
}
/* EVC_MEM_Support_Pkg::MEM_combineForLevelChange */
void MEM_combineForLevelChange_EVC_MEM_Support_Pkg(
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::actualMessage */ ReceivedMessage_T_Common_Types_Pkg *actualMessage,
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::ModeLevel */ T_Mode_Level_Level_And_Mode_Types_Pkg *ModeLevel,
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::trainPosition */ trainPosition_T_TrainPosition_Types_Pck *trainPosition,
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::trainProperties */ trainProperties_T_TrainPosition_Types_Pck *trainProperties,
  outC_MEM_combineForLevelChange_EVC_MEM_Support_Pkg *outC)
{
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::IfBlock1::else */
  static kcg_bool else_clock_IfBlock1;
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::LRBGpositionNeeded */
  static kcg_bool last_LRBGpositionNeeded;
  /* EVC_MEM_Support_Pkg::MEM_combineForLevelChange::_L240 */
  static dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg _L240;
  
  kcg_copy_P12_Level1MovementAuthorities_T_Packet_Types_Pkg(
    &outC->Data_From_Track_Packets_at_ML.P_12,
    (P12_Level1MovementAuthorities_T_Packet_Types_Pkg *)
      &Default_P12_legacy_EVC_MEM_Support_Pkg);
  kcg_copy_P135_StopShuntingOnDeskOpening_T_Packet_Types_Pkg(
    &outC->Data_From_Track_Packets_at_ML.P_135,
    (P135_StopShuntingOnDeskOpening_T_Packet_Types_Pkg *)
      &Default_P135_legacy_EVC_MEM_Support_Pkg);
  kcg_copy_P63_ListofBalisesinSRAuthority_T_Packet_Types_Pkg(
    &outC->Data_From_Track_Packets_at_ML.P_63,
    (P63_ListofBalisesinSRAuthority_T_Packet_Types_Pkg *)
      &Default_P63_legacy_EVC_MEM_Support_Pkg);
  /* last_init_ck_LRBGpositionNeeded */ if (outC->init) {
    kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
      &_L240,
      (dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *)
        &cNoML_EVC_MEM_Support_Pkg);
    outC->init = kcg_false;
    last_LRBGpositionNeeded = kcg_true;
  }
  else {
    kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
      &_L240,
      &outC->infoForLevelTransition);
    last_LRBGpositionNeeded = outC->LRBGpositionNeeded;
  }
  /* ck_msgToCheck */ if ((*actualMessage).valid) {
    /* MEM_dataForLevelTransition */
    MEM_dataForLevelTransition_EVC_MEM_Support_Pkg(
      actualMessage,
      &_L240,
      trainPosition,
      last_LRBGpositionNeeded,
      (*ModeLevel).level,
      trainProperties,
      &outC->infoForLevelTransition,
      &outC->LRBGpositionNeeded);
  }
  else {
    else_clock_IfBlock1 = (*ModeLevel).newLevel | ((*ModeLevel).newMode &
        ((*ModeLevel).Mode == M_MODE_Trip));
    /* ck_anon_activ */ if (else_clock_IfBlock1) {
      outC->LRBGpositionNeeded = kcg_false;
      kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
        &outC->infoForLevelTransition,
        (dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg *)
          &cNoML_EVC_MEM_Support_Pkg);
      kcg_copy_P46_ConditionalLevelTransitionOrders_T_Packet_Types_Pkg(
        &outC->infoForLevelTransition.p46,
        &_L240.p46);
      /* 5 */ if ((*ModeLevel).newMode & _L240.p80[0].valid) {
        kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
          &outC->infoForLevelTransition.p80,
          (P80_ModeProfiles_T_Packet_Types_Pkg *)
            &Default_P80_legacy_EVC_MEM_Support_Pkg);
      }
      else {
        kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
          &outC->infoForLevelTransition.p80,
          &_L240.p80);
      }
    }
    else {
      kcg_copy_dataCollectionForLevelTransition_T_EVC_MEM_Support_Pkg(
        &outC->infoForLevelTransition,
        &_L240);
      outC->LRBGpositionNeeded = last_LRBGpositionNeeded;
    }
  }
  kcg_copy_P46_ConditionalLevelTransitionOrders_T_Packet_Types_Pkg(
    &outC->Data_From_Track_Packets_at_ML.P_46,
    &outC->infoForLevelTransition.p46);
  kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
    &outC->Data_From_Track_Packets_at_ML.P_80,
    &outC->infoForLevelTransition.p80);
  outC->Data_From_Track_Packets_at_ML.LRBG = outC->infoForLevelTransition.LRBG;
  outC->Data_From_Track_Packets_at_ML.referenceLocation =
    outC->infoForLevelTransition.referenceLocation;
  /* 1 */
  Read_P137_Legacy_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_137);
  /* 1 */
  Read_P138_Legacy_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_138);
  /* 1 */
  Read_P139_Legacy_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_139);
  /* 1 */
  Read_P015_Legacy_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_15);
  /* 1 */
  Read_P021_Legacy_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_21);
  /* 1 */
  Read_P027V1_Legacy_for_ML_TM_specific(
    &(*actualMessage).packets,
    &outC->Data_From_Track_Packets_at_ML.P_27);
  /* 4 */ if (outC->LRBGpositionNeeded) {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &outC->Data_From_Track_Packets_at_ML.P_41,
      (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
        &cNoP41_EVC_MEM_Support_Pkg);
  }
  else {
    kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
      &outC->Data_From_Track_Packets_at_ML.P_41,
      &outC->infoForLevelTransition.p41);
  }
}
/* xdebugSupport_Pkg::combineForLevelChange */
void combineForLevelChange_xdebugSupport_Pkg(
    /* xdebugSupport_Pkg::combineForLevelChange::actualMessage */ ReceivedMessage_T_Common_Types_Pkg *actualMessage,
    /* xdebugSupport_Pkg::combineForLevelChange::ModeLevel */ T_Mode_Level_Level_And_Mode_Types_Pkg *ModeLevel,
    /* xdebugSupport_Pkg::combineForLevelChange::transitionPositionPassed */ kcg_bool transitionPositionPassed,
    /* xdebugSupport_Pkg::combineForLevelChange::trainPosition */ trainPosition_T_TrainPosition_Types_Pck *trainPosition,
    /* xdebugSupport_Pkg::combineForLevelChange::inFilterEvents */ filterRelatedEvents_T_Common_Types_Pkg *inFilterEvents,
    outC_combineForLevelChange_xdebugSupport_Pkg *outC)
{
    /* xdebugSupport_Pkg::combineForLevelChange */
    static M_LEVEL tmp2;
    /* xdebugSupport_Pkg::combineForLevelChange */
    static kcg_bool tmp1;
    /* xdebugSupport_Pkg::combineForLevelChange */
    static kcg_bool tmp;
    /* xdebugSupport_Pkg::combineForLevelChange::_L108 */
    static kcg_bool _L108;
    /* xdebugSupport_Pkg::combineForLevelChange::infoForLevelTransition */
    static dataCollectionForLevelTransition_T_xdebugSupport_Pkg last_infoForLevelTransition;

    kcg_copy_P12_Level1MovementAuthorities_T_Packet_Types_Pkg(
        &outC->Data_to_From_Track_Packets_at_ML.P_12,
        (P12_Level1MovementAuthorities_T_Packet_Types_Pkg *)
        &Default_P12_legacy_xdebugSupport_Pkg);
    kcg_copy_P135_StopShuntingOnDeskOpening_T_Packet_Types_Pkg(
        &outC->Data_to_From_Track_Packets_at_ML.P_135,
        (P135_StopShuntingOnDeskOpening_T_Packet_Types_Pkg *)
        &Default_P135_legacy_xdebugSupport_Pkg);
    kcg_copy_P63_ListofBalisesinSRAuthority_T_Packet_Types_Pkg(
        &outC->Data_to_From_Track_Packets_at_ML.P_63,
        (P63_ListofBalisesinSRAuthority_T_Packet_Types_Pkg *)
        &Default_P63_legacy_xdebugSupport_Pkg);
    kcg_copy_P80_ModeProfiles_T_Packet_Types_Pkg(
        &outC->Data_to_From_Track_Packets_at_ML.P_80,
        (P80_ModeProfiles_T_Packet_Types_Pkg *)
        &Default_P80_legacy_xdebugSupport_Pkg);
    /* ck_msgToCheck */ if ((*actualMessage).valid) {
    }
    else {
        /* last_init_ck_level */ if (outC->init) {
            tmp2 = M_LEVEL_Level_0;
        }
        else {
            tmp2 = outC->rem_level;
        }
        tmp1 = ((*ModeLevel).level != tmp2) | transitionPositionPassed;
    }
    /* last_init_ck_LRBGpositionNeeded */ if (outC->init) {
        kcg_copy_dataCollectionForLevelTransition_T_xdebugSupport_Pkg(
            &last_infoForLevelTransition,
            (dataCollectionForLevelTransition_T_xdebugSupport_Pkg *)
            &cNoML_xdebugSupport_Pkg);
        outC->init = kcg_false;
        tmp = kcg_true;
    }
    else {
        kcg_copy_dataCollectionForLevelTransition_T_xdebugSupport_Pkg(
            &last_infoForLevelTransition,
            &outC->infoForLevelTransition);
        tmp = outC->LRBGpositionNeeded;
    }
    /* ck_msgToCheck */ if ((*actualMessage).valid) {
        /* dataForLevelTransition */
        dataForLevelTransition_xdebugSupport_Pkg(
            actualMessage,
            &last_infoForLevelTransition,
            trainPosition,
            tmp,
            (*ModeLevel).level,
            &outC->infoForLevelTransition,
            &outC->LRBGpositionNeeded);
    }
    else /* ck_anon_activ */ if (tmp1) {
        outC->LRBGpositionNeeded = kcg_false;
        kcg_copy_dataCollectionForLevelTransition_T_xdebugSupport_Pkg(
            &outC->infoForLevelTransition,
            (dataCollectionForLevelTransition_T_xdebugSupport_Pkg *)
            &cNoML_xdebugSupport_Pkg);
    }
    else {
        kcg_copy_dataCollectionForLevelTransition_T_xdebugSupport_Pkg(
            &outC->infoForLevelTransition,
            &last_infoForLevelTransition);
        outC->LRBGpositionNeeded = tmp;
    }
    kcg_copy_P46_ConditionalLevelTransitionOrders_T_Packet_Types_Pkg(
        &outC->Data_to_From_Track_Packets_at_ML.P_46,
        &outC->infoForLevelTransition.p46);
    outC->Data_to_From_Track_Packets_at_ML.LRBG =
        outC->infoForLevelTransition.LRBG;
    outC->Data_to_From_Track_Packets_at_ML.referenceLocation =
        outC->infoForLevelTransition.referenceLocation;
    outC->forLevelManagement.P12_received =
        outC->infoForLevelTransition.p12_received;
    outC->forLevelManagement.P15_received =
        outC->infoForLevelTransition.p15_received;
    outC->forLevelManagement.P21_received =
        outC->infoForLevelTransition.p21_received;
    outC->forLevelManagement.P27_received =
        outC->infoForLevelTransition.p27_received;
    /* 6 */ if (outC->infoForLevelTransition.p41[0].valid) {
        tmp1 = outC->infoForLevelTransition.p41[0].m_leveltr == M_LEVELTR_Level_2;
        tmp = outC->infoForLevelTransition.p41[0].m_leveltr == M_LEVELTR_Level_3;
    }
    else {
        tmp = kcg_false;
        tmp1 = kcg_false;
    }
    _L108 = tmp1 | tmp;
    kcg_copy_filterRelatedEvents_T_Common_Types_Pkg(
        &outC->outFilterEvents,
        inFilterEvents);
    outC->outFilterEvents.pendingL12L3Transition = _L108;
    outC->outFilterEvents.SPPAndGradientOnBoard = _L108;
    /* 5 */ if (outC->infoForLevelTransition.p41[0].valid) {
        outC->outFilterEvents.pendingL1Transition =
            outC->infoForLevelTransition.p41[0].m_leveltr == M_LEVELTR_Level_1;
    }
    else {
        outC->outFilterEvents.pendingL1Transition = kcg_false;
    }
    /* 1 */
    Read_P137_Legacy_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_137);
    /* 1 */
    Read_P138_Legacy_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_138);
    /* 1 */
    Read_P139_Legacy_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_139);
    /* 1 */
    Read_P015_Legacy_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_15);
    /* 1 */
    Read_P021_Legacy_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_21);
    /* 1 */
    Read_P027V1_Legacy_for_ML_TM_specific(
        &(*actualMessage).packets,
        &outC->Data_to_From_Track_Packets_at_ML.P_27);
    /* 8 */ if (outC->LRBGpositionNeeded) {
        kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
            &outC->Data_to_From_Track_Packets_at_ML.P_41,
            (P41_LevelTransistionOrders_T_Packet_Types_Pkg *)
            &cNoP41_xdebugSupport_Pkg);
    }
    else {
        kcg_copy_P41_LevelTransistionOrders_T_Packet_Types_Pkg(
            &outC->Data_to_From_Track_Packets_at_ML.P_41,
            &outC->infoForLevelTransition.p41);
    }
    outC->rem_level = (*ModeLevel).level;
}