/* MessageLibBaseline2::Send_P005 */
void Send_P005_MessageLibBaseline2(
  /* MessageLibBaseline2::Send_P005::B_data_in */CompressedPackets_T_Common_Types_Pkg *B_data_in,
  /* MessageLibBaseline2::Send_P005::P005 */P005_trackside_int_T_TM *P005,
  /* MessageLibBaseline2::Send_P005::B_data_out */CompressedPackets_T_Common_Types_Pkg *B_data_out)
{
  /* TM_trackside::Write_P005::_L21 */
  static kcg_int _L21_1;
  /* TM_trackside::Write_P005::_L22 */
  static kcg_int _L22_1;
  /* TM_trackside::Write_P005::_L44 */
  static CompressedPacketData_T_Common_Types_Pkg _L44_1;
  /* TM_trackside::Write_P005::_L43 */
  static MetadataElement_T_Common_Types_Pkg _L43_1;
  
  if ((*P005).valid) {
    /* 1_1 */ C_P005_tracksim_compr_TM_conversions(P005, &_L43_1, &_L44_1);
    /* 1_1 */
    SEND_WriteBaliseMessageHeader_TM_lib_internal(
      &(*B_data_in).PacketHeaders,
      &_L43_1,
      &(*B_data_out).PacketHeaders,
      &_L21_1,
      &_L22_1);
    /* 1_1 */
    SEND_MessageData_TM_lib_internal(
      _L21_1,
      _L22_1,
      &(*B_data_in).PacketData,
      &_L44_1,
      &(*B_data_out).PacketData);
  }
  else {
    kcg_copy_CompressedPackets_T_Common_Types_Pkg(B_data_out, B_data_in);
  }
}
/* TM_trackside::Write_P021 */
void Write_P021_TM_trackside(
  /* TM_trackside::Write_P021::Packet21 */P021_trackside_int_T_TM *Packet21,
  /* TM_trackside::Write_P021::Packets */CompressedPackets_T_Common_Types_Pkg *Packets,
  /* TM_trackside::Write_P021::Error */kcg_bool *Error,
  /* TM_trackside::Write_P021::RadioPacketsOut */CompressedPackets_T_Common_Types_Pkg *RadioPacketsOut)
{
  /* TM_trackside::Write_P021::_L21 */
  static kcg_int _L21;
  /* TM_trackside::Write_P021::_L22 */
  static kcg_int _L22;
  /* TM_trackside::Write_P021::_L44 */
  static CompressedPacketData_T_Common_Types_Pkg _L44;
  /* TM_trackside::Write_P021::_L43 */
  static MetadataElement_T_Common_Types_Pkg _L43;
  
  *Error = kcg_false;
  /* 1 */ C_P021_tracksim_compr_TM_conversions(Packet21, &_L43, &_L44);
  /* 1 */
  SEND_WriteBaliseMessageHeader_TM_lib_internal(
    &(*Packets).PacketHeaders,
    &_L43,
    &(*RadioPacketsOut).PacketHeaders,
    &_L21,
    &_L22);
  /* 1 */
  SEND_MessageData_TM_lib_internal(
    _L21,
    _L22,
    &(*Packets).PacketData,
    &_L44,
    &(*RadioPacketsOut).PacketData);
}
/* TM_trackside_baseline2::Write_P136 */
void Write_P136_TM_trackside_baseline2(
  inC_Write_P136_TM_trackside_baseline2 *inC,
  outC_Write_P136_TM_trackside_baseline2 *outC)
{
  /* TM_trackside_baseline2::Write_P136::_L21 */ kcg_int _L21;
  /* TM_trackside_baseline2::Write_P136::_L22 */ kcg_int _L22;
  /* TM_trackside_baseline2::Write_P136::_L44 */ CompressedPacketData_T_Common_Types_Pkg _L44;
  /* TM_trackside_baseline2::Write_P136::_L43 */ MetadataElement_T_Common_Types_Pkg _L43;
  
  /* 1 */ C_P136_tracksim_compr_TM_conversions(&inC->Packet136, &_L43, &_L44);
  /* 1 */
  SEND_WriteBaliseMessageHeader_TM_lib_internal(
    &inC->Packets.PacketHeaders,
    &_L43,
    &outC->RadioPacketsOut.PacketHeaders,
    &_L21,
    &_L22);
  /* 1 */
  SEND_MessageData_TM_lib_internal(
    _L21,
    _L22,
    &inC->Packets.PacketData,
    &_L44,
    &outC->RadioPacketsOut.PacketData);
  outC->Error = kcg_false;
}
/* TM_trackside_baseline2::Write_P003V1 */
void Write_P003V1_TM_trackside_baseline2(
  /* TM_trackside_baseline2::Write_P003V1::Packet003V1 */P003V1_trackside_int_T_TM_baseline2 *Packet003V1,
  /* TM_trackside_baseline2::Write_P003V1::Packets */CompressedPackets_T_Common_Types_Pkg *Packets,
  outC_Write_P003V1_TM_trackside_baseline2 *outC)
{
  kcg_copy_CompressedPackets_T_Common_Types_Pkg(&outC->_L40, Packets);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L42,
    &outC->_L40.PacketData);
  kcg_copy_P003V1_trackside_int_T_TM_baseline2(&outC->_L1, Packet003V1);
  /* 1 */
  C_P003V1_tracksim_compr_TM_conversions_baseline2(
    &outC->_L1,
    &outC->Context_1);
  kcg_copy_MetadataElement_T_Common_Types_Pkg(
    &outC->_L43,
    &outC->Context_1.Header);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L44,
    &outC->Context_1.P003V1_compressed);
  kcg_copy_Metadata_T_Common_Types_Pkg(&outC->_L41, &outC->_L40.PacketHeaders);
  /* 1 */
  SEND_WriteBaliseMessageHeader_TM_lib_internal(
    &outC->_L41,
    &outC->_L43,
    &outC->_1_Context_1);
  kcg_copy_Metadata_T_Common_Types_Pkg(
    &outC->_L4,
    &outC->_1_Context_1.HeadersOut);
  outC->_L21 = outC->_1_Context_1.NewStartAddr;
  outC->_L22 = outC->_1_Context_1.NewEndAddr;
  /* 1 */
  SEND_MessageData_TM_lib_internal(
    outC->_L21,
    outC->_L22,
    &outC->_L42,
    &outC->_L44,
    &outC->_2_Context_1);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L10,
    &outC->_2_Context_1.DataOut);
  kcg_copy_Metadata_T_Common_Types_Pkg(&outC->_L39.PacketHeaders, &outC->_L4);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L39.PacketData,
    &outC->_L10);
  outC->_L18 = kcg_false;
  outC->Error = outC->_L18;
  kcg_copy_CompressedPackets_T_Common_Types_Pkg(
    &outC->RadioPacketsOut,
    &outC->_L39);
}