/* output_to_TIU_API_Pkg::handleBrakeCommand */
void handleBrakeCommand_output_to_TIU_API_Pkg(
  /* output_to_TIU_API_Pkg::handleBrakeCommand::in_brake_command */ Brake_command_T_TIU_Types_Pkg *in_brake_command,
  outC_handleBrakeCommand_output_to_TIU_API_Pkg *outC)
{
  /* output_to_TIU_API_Pkg::handleBrakeCommand */
  static Brake_command_T_TIU_Types_Pkg tmp;
  
  /* last_init_ck_in_brake_command */ if (outC->init) {
    outC->init = kcg_false;
    kcg_copy_Brake_command_T_TIU_Types_Pkg(
      &tmp,
      (Brake_command_T_TIU_Types_Pkg *) &cEmptyBrakeCmd);
  }
  else {
    kcg_copy_Brake_command_T_TIU_Types_Pkg(&tmp, &outC->rem_in_brake_command);
  }
  /* 1 */ if ((*in_brake_command).valid &
    !kcg_comp_Brake_command_T_TIU_Types_Pkg(in_brake_command, &tmp)) {
    kcg_copy_Brake_command_T_TIU_Types_Pkg(
      &outC->out_brake_command,
      in_brake_command);
  }
  else {
    kcg_copy_Brake_command_T_TIU_Types_Pkg(
      &outC->out_brake_command,
      (Brake_command_T_TIU_Types_Pkg *) &cEmptyBrakeCmd);
  }
  kcg_copy_Brake_command_T_TIU_Types_Pkg(
    &outC->rem_in_brake_command,
    in_brake_command);
}
/* manage_DMI_Output_Pkg::sendBrakesToDMI */
void sendBrakesToDMI_manage_DMI_Output_Pkg(
  /* manage_DMI_Output_Pkg::sendBrakesToDMI::brakeCommand */ Brake_command_T_TIU_Types_Pkg *brakeCommand,
  /* manage_DMI_Output_Pkg::sendBrakesToDMI::inSystemTime */ T_internal_Type_Obu_BasicTypes_Pkg inSystemTime,
  outC_sendBrakesToDMI_manage_DMI_Output_Pkg *outC)
{
  /* manage_DMI_Output_Pkg::sendBrakesToDMI */
  static M_brake_signal_command_T_TIU_Types_Pkg tmp;
  /* manage_DMI_Output_Pkg::sendBrakesToDMI::IfBlock1::else */
  static kcg_bool else_clock_IfBlock1;
  /* manage_DMI_Output_Pkg::sendBrakesToDMI::applyBrake */
  static kcg_bool applyBrake;
  /* manage_DMI_Output_Pkg::sendBrakesToDMI::changeBrakeCommand */
  static kcg_bool changeBrakeCommand;
  
  /* last_init_ck_loc_brakeCommand */ if (outC->init) {
    outC->init = kcg_false;
    tmp = cInitBrakeCommand_manage_DMI_Output_Pkg.m_emergencybrake_cm;
  }
  else {
    tmp = outC->rem_brakeCommand.m_emergencybrake_cm;
  }
  changeBrakeCommand = (*brakeCommand).m_emergencybrake_cm != tmp;
  applyBrake = changeBrakeCommand & (apply_brake_TIU_Types_Pkg ==
      (*brakeCommand).m_emergencybrake_cm) & (*brakeCommand).valid;
  /* ck_applyBrake */ if (applyBrake) {
    kcg_copy_DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg(
      &outC->dmi_iconRequest,
      (DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg *)
        &cIconRequestEB_manage_DMI_Output_Pkg);
    outC->dmi_iconRequest.system_clock = inSystemTime;
  }
  else {
    else_clock_IfBlock1 = (*brakeCommand).valid &
      ((*brakeCommand).m_emergencybrake_cm == release_brake_TIU_Types_Pkg) &
      changeBrakeCommand;
    /* ck_anon_activ */ if (else_clock_IfBlock1) {
      kcg_copy_DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg(
        &outC->dmi_iconRequest,
        (DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg *)
          &cIconClearEB_manage_DMI_Output_Pkg);
      outC->dmi_iconRequest.system_clock = inSystemTime;
    }
    else {
      kcg_copy_DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg(
        &outC->dmi_iconRequest,
        (DMI_Icons_T_DMI_Messages_EVC_to_DMI_Pkg *)
          &cEmptyIconRequest_manage_DMI_Output_Pkg);
    }
  }
  kcg_copy_Brake_command_T_TIU_Types_Pkg(&outC->rem_brakeCommand, brakeCommand);
}
/* output_to_TIU_API_Pkg::manageTIU_output */
void manageTIU_output_output_to_TIU_API_Pkg(
  /* output_to_TIU_API_Pkg::manageTIU_output::in_IsolationStatus */Isolation_Status_T_TIU_Types_Pkg *in_IsolationStatus,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_brake_command */Brake_command_T_TIU_Types_Pkg *in_brake_command,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_brake_inhibition */Brake_inhibition_command_T_TIU_Types_Pkg *in_brake_inhibition,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_train_commands */Type_I_train_commands_T_TIU_Types_Pkg *in_train_commands,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_change_traction_system */Change_traction_system_T_TIU_Types_Pkg *in_change_traction_system,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_passenger_door_control_info */Passenger_door_control_info_T_TIU_Types_Pkg *in_passenger_door_control_info,
  /* output_to_TIU_API_Pkg::manageTIU_output::in_change_of_allowed_current_consumption */Change_of_allowed_current_consumption_T_TIU_Types_Pkg *in_change_of_allowed_current_consumption,
  outC_manageTIU_output_output_to_TIU_API_Pkg *outC)
{
  /* 1 */
  handleBrakeCommand_output_to_TIU_API_Pkg(in_brake_command, &outC->Context_1);
  outC->outTIU_to_API.valid = (*in_IsolationStatus).valid |
    outC->Context_1.out_brake_command.valid | (*in_brake_inhibition).valid |
    (*in_train_commands).valid | (*in_change_traction_system).valid |
    (*in_passenger_door_control_info).valid |
    (*in_change_of_allowed_current_consumption).valid;
  kcg_copy_Isolation_Status_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.isolation_status,
    in_IsolationStatus);
  kcg_copy_Brake_command_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.brake_command,
    &outC->Context_1.out_brake_command);
  kcg_copy_Brake_inhibition_command_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.brake_inhibition,
    in_brake_inhibition);
  kcg_copy_Type_I_train_commands_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.type_I_train_commands,
    in_train_commands);
  kcg_copy_Change_traction_system_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.change_traction_system,
    in_change_traction_system);
  kcg_copy_Passenger_door_control_info_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.passenger_door_control_info,
    in_passenger_door_control_info);
  kcg_copy_Change_of_allowed_current_consumption_T_TIU_Types_Pkg(
    &outC->outTIU_to_API.info.change_of_allowed_current_consumption,
    in_change_of_allowed_current_consumption);
  /* 1 */
  getTIUStatusFromCommand_output_to_TIU_API_Pkg(
    in_IsolationStatus,
    in_brake_command,
    &outC->outCommandStatusforEVC);
}
/* SDM_Commands_Pkg::SDM_Commands */
void SDM_Commands_SDM_Commands_Pkg(
  /* SDM_Commands_Pkg::SDM_Commands::allTargets */ TargetCollection_T_TargetManagement_types *allTargets,
  /* SDM_Commands_Pkg::SDM_Commands::trainLocations */ trainPosition_T_TrainPosition_Types_Pck *trainLocations,
  /* SDM_Commands_Pkg::SDM_Commands::speeds */ Speeds_T_SDM_Types_Pkg *speeds,
  /* SDM_Commands_Pkg::SDM_Commands::locations */ SDM_Locations_T_SDM_Types_Pkg *locations,
  /* SDM_Commands_Pkg::SDM_Commands::mrdt */ Target_T_TargetManagement_types *mrdt,
  /* SDM_Commands_Pkg::SDM_Commands::floiIsSB1 */ kcg_bool floiIsSB1,
  /* SDM_Commands_Pkg::SDM_Commands::MLrequestSB */ kcg_bool MLrequestSB,
  /* SDM_Commands_Pkg::SDM_Commands::MLrequestEB */ kcg_bool MLrequestEB,
  /* SDM_Commands_Pkg::SDM_Commands::NationalValues */ P3_NationalValues_T_Packet_Types_Pkg *NationalValues,
  /* SDM_Commands_Pkg::SDM_Commands::TrainData_int */ trainData_internal_t_SDM_Types_Pkg *TrainData_int,
  outC_SDM_Commands_SDM_Commands_Pkg *outC)
{
  /* SDM_Commands_Pkg::SDM_Commands::_L11 */
  static SupervisionStatus_T_SDM_Types_Pkg _L11;
  /* SDM_Commands_Pkg::SDM_Commands::_L7 */
  static SDM_Types_T_SDM_Types_Pkg _L7;
  /* SDM_Commands_Pkg::SDM_Commands::_L27 */
  static kcg_bool _L27;
  /* SDM_Commands_Pkg::SDM_Commands::_L26 */
  static kcg_bool _L26;
  /* SDM_Commands_Pkg::SDM_Commands::_L25 */
  static kcg_bool _L25;
  /* SDM_Commands_Pkg::SDM_Commands::_L24 */
  static kcg_bool _L24;
  /* SDM_Commands_Pkg::SDM_Commands::_L23 */
  static kcg_bool _L23;
  /* SDM_Commands_Pkg::SDM_Commands::_L22 */
  static kcg_bool _L22;
  /* SDM_Commands_Pkg::SDM_Commands::_L67 */
  static L_internal_Type_Obu_BasicTypes_Pkg _L67;
  /* SDM_Commands_Pkg::SDM_Commands::_L68 */
  static V_odometry_Type_Obu_BasicTypes_Pkg _L68;
  /* SDM_Commands_Pkg::SDM_Commands::_L69 */
  static V_odometry_Type_Obu_BasicTypes_Pkg _L69;
  /* SDM_Commands_Pkg::SDM_Commands::_L70 */
  static V_odometry_Type_Obu_BasicTypes_Pkg _L70;
  /* SDM_Commands_Pkg::SDM_Commands::_L71 */
  static V_odometry_Type_Obu_BasicTypes_Pkg _L71;
  
  outC->sdmCmd.valid = kcg_true;
  /* 1 */
  CmdTrainSupervisionStatus_SDM_Commands_Pkg(
    (*allTargets).updatedTargetList,
    speeds,
    locations,
    mrdt,
    trainLocations,
    floiIsSB1,
    TrainData_int,
    &outC->Context_1);
  outC->sdmCmd.revokedSupervisionStatus =
    outC->Context_1.revokedSupervisionStatus;
  outC->sdmCmd.triggeredSupervisionStatus =
    outC->Context_1.triggeredSupervisionStatus;
  outC->sdmCmd.revokedEB = outC->Context_1.revokedEB;
  outC->sdmCmd.triggeredEB = outC->Context_1.triggeredEB;
  outC->sdmCmd.revokedTCO = outC->Context_1.revokedTCO;
  outC->sdmCmd.triggeredTCO = outC->Context_1.triggeredTCO;
  outC->sdmCmd.ebCmd = outC->Context_1.ebCmd | MLrequestEB;
  _L11 = outC->Context_1.supVisStatus;
  outC->sdmCmd.supervisionStatus = _L11;
  _L7 = outC->Context_1.sdmType;
  outC->sdmCmd.sdmType = _L7;
  /* 1 */
  CalcDriverOutput_SDM_Commands_Pkg(
    _L7,
    _L11,
    mrdt,
    speeds,
    locations,
    &outC->sdmCmd.estimatedSpeed,
    &_L22,
    &_L71,
    &_L23,
    &_L70,
    &_L25,
    &_L69,
    &_L26,
    &_L68,
    &_L24,
    &_L67,
    &_L27);
  outC->sdmCmd.valid_v_est = _L22;
  outC->sdmCmd.permittedSpeed = _L71;
  outC->sdmCmd.valid_v_permitted = _L23;
  outC->sdmCmd.releaseSpeed = _L70;
  outC->sdmCmd.valid_v_release = _L25;
  outC->sdmCmd.mrdtSpeed = _L69;
  outC->sdmCmd.valid_v_mrdt = _L26;
  outC->sdmCmd.sbiSpeed = _L68;
  outC->sdmCmd.valid_v_sbi = _L24;
  outC->sdmCmd.targetDistance = _L67;
  outC->sdmCmd.valid_targetDistance = _L27;
  /* 2 */
  MergeMLRequests_SDM_Commands_Pkg(
    outC->Context_1.revokedSB,
    MLrequestSB,
    outC->Context_1.triggeredSB,
    &outC->Context_2);
  outC->sdmCmd.revokedSB = outC->Context_2.revokedSB;
  outC->sdmCmd.triggeredSB = outC->Context_2.triggeredSB;
  /* CalcModeTransOutput */
  CalcModeTransOutput_SDM_Commands_Pkg(
    trainLocations,
    locations,
    speeds,
    TrainData_int,
    &outC->eoaOverpassed,
    &outC->targetSpeedReached);
  /* 1 */
  CalcDMI_output_SDM_Commands_Pkg(
    &outC->sdmCmd,
    locations,
    trainLocations,
    &outC->sdmToDMI);
  /* 1 */
  CalcBrakeCmd_SDM_Commands_Pkg(
    &outC->sdmCmd,
    speeds,
    NationalValues,
    TrainData_int,
    &outC->_1_Context_1);
  kcg_copy_Brake_command_T_TIU_Types_Pkg(
    &outC->brakeCmd,
    &outC->_1_Context_1.brakeCmd);
}
/* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration */
void SpeedSupervision_Integration_SpeedSupervision_Integration_Pkg(
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MRSP */ MRSP_Profile_t *MRSP,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MA */ MAs_t *MA,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::NationalValues */ P3_NationalValues_T_Packet_Types_Pkg *NationalValues,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::TrainPosition */ trainPosition_T_TrainPosition_Types_Pck *TrainPosition,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::odometry */ odometry_T_Obu_BasicTypes_Pkg *odometry,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::m_level */ M_LEVEL m_level,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::trainProps */ trainProperties_T_TrainPosition_Types_Pck *trainProps,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MA_updated */ kcg_bool MA_updated,
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MRSP_updated */ kcg_bool MRSP_updated,
  outC_SpeedSupervision_Integration_SpeedSupervision_Integration_Pkg *outC)
{
  Speeds_T_SDM_Types_Pkg tmp;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::odometry_internal */ Odometry_real_T_SDM_Types_Pkg odometry_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::V_ura_internal */ V_internal_real_Type_SDM_Types_Pkg V_ura_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::targetCollection */ TargetCollection_T_TargetManagement_types targetCollection;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::Trainlocations_internal */ TrainLocations_real_T_SDM_Types_Pkg Trainlocations_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MRSP_internal */ MRSP_internal_T_TargetManagement_types MRSP_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::v_mrsp_internal */ V_internal_real_Type_SDM_Types_Pkg v_mrsp_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::v_target_internal */ V_internal_real_Type_SDM_Types_Pkg v_target_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::mrt_internal */ Target_real_T_TargetManagement_types mrt_internal;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::v_p_sbd */ V_internal_real_Type_SDM_Types_Pkg v_p_sbd;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::v_p_ebd */ V_internal_real_Type_SDM_Types_Pkg v_p_ebd;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::v_p_ebd_valid */ kcg_bool v_p_ebd_valid;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L27 */ M_LEVEL _L27;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L55 */ MAs_real_T_TargetManagement_types _L55;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L70 */ NationalValues_real_T_SDM_Types_Pkg _L70;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L74 */ V_internal_real_Type_SDM_Types_Pkg _L74;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L113 */ kcg_bool _L113;
  /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L111 */ SDM_Locations_T_SDM_Types_Pkg _L111;
  
  /* 1 */
  SDM_InputWrapper_SDM_Input_Wrappers(
    NationalValues,
    TrainPosition,
    odometry,
    m_level,
    trainProps,
    MRSP,
    MA,
    MA_updated,
    MRSP_updated,
    &_L27,
    &MRSP_internal,
    &_L55,
    &odometry_internal,
    &V_ura_internal,
    &Trainlocations_internal,
    &v_p_ebd_valid,
    &_L113,
    &_L70);
  /* 2 */
  TargetManagement_TargetManagement_pkg(
    &MRSP_internal,
    _L113,
    &_L55,
    v_p_ebd_valid,
    &Trainlocations_internal,
    &outC->Context_2);
  kcg_copy_TargetCollection_T_TargetManagement_types(
    &targetCollection,
    &outC->Context_2.targetCollection);
  _L74 = /* 1 */
    ReleaseSpeed_Selection_SDM_ReleaseSoeed_Selection_pkg(
      outC->Context_2.V_releaseFromMA,
      &_L70,
      outC->Context_2.V_releaseFromMAValid);
  /* 1 */
  CalcBrakingCurves_integration_CalcBrakingCurves_Pkg(
    (ASafe_T_CalcBrakingCurves_types *) &TestcaseA_safe_CalcBrakingCurves_Pkg,
    &Trainlocations_internal,
    &targetCollection,
    &outC->Context_1);
  /* 4 */
  SDMLimitLocations_TargetLimits_Pkg(
    &MRSP_internal,
    &odometry_internal,
    &Trainlocations_internal,
    &targetCollection,
    &outC->Context_1.curveCollection,
    _L74,
    V_ura_internal,
    _L70.q_nvinhsmicperm,
    kcg_false,
    0.0,
    0.0,
    0.0,
    &_L111,
    &mrt_internal,
    &_L113,
    &v_target_internal,
    &v_mrsp_internal,
    &v_p_sbd,
    &v_p_ebd,
    &v_p_ebd_valid);
  /* 1 */
  CalcSpeeds_SDM_Types_Pkg(
    &odometry_internal,
    v_mrsp_internal,
    _L74,
    v_target_internal,
    &mrt_internal,
    v_p_ebd,
    v_p_sbd,
    v_p_ebd_valid,
    _L111.FLOI_of_V_est,
    &tmp);
  /* 1 */
  SDM_Commands_SDM_Commands_Pkg(
    &targetCollection,
    &odometry_internal,
    &tmp,
    &_L111,
    kcg_true,
    _L27,
    &mrt_internal,
    &Trainlocations_internal,
    _L113,
    &outC->_1_Context_1);
  /* 1 */
  SDM_OutputWrapper_SDM_OutputWrapper(
    &outC->_1_Context_1.sdmCmd,
    outC->_1_Context_1.targetSpeedReached,
    outC->_1_Context_1.eoaOverpassed,
    0.0,
    &mrt_internal,
    &odometry_internal,
    &_L70,
    kcg_false,
    &outC->_2_Context_1);
  kcg_copy_speedSupervisionForDMI_T_DMI_Types_Pkg(
    &outC->sdmToDMI,
    &outC->_2_Context_1.sdmToDMI);
  kcg_copy_Target_T_TargetManagement_types(
    &outC->target,
    &outC->_2_Context_1.out_target);
  kcg_copy_SDM_Commands_T_SDM_Types_Pkg(
    &outC->sdmCommands,
    &outC->_2_Context_1.sdmCommands);
  kcg_copy_Brake_command_T_TIU_Types_Pkg(
    &outC->brakeCmd,
    &outC->_2_Context_1.brakeCmd);
  outC->EOA_overpassed = outC->_2_Context_1.EOA_overpassed;
  outC->Target_Speed_Reached = outC->_2_Context_1.Target_Speed_Reached;
}
/* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration */
void SpeedSupervision_Integration_SpeedSupervision_Integration_Pkg(
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::NationalValues */ P3_NationalValues_T_Packet_Types_Pkg *NationalValues,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::TrainPosition */ trainPosition_T_TrainPosition_Types_Pck *TrainPosition,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::odometry */ odometry_T_Obu_BasicTypes_Pkg *odometry,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::trainProps */ trainProperties_T_TrainPosition_Types_Pck *trainProps,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::trainData */ trainData_T_TIU_Types_Pkg *trainData,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::dataFromTrackAtlas */ DataForSupervision_nextGen_t_TrackAtlasTypes *dataFromTrackAtlas,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::Service_brake_requested_by_modes_and_levels */ kcg_bool Service_brake_requested_by_modes_and_levels,
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::Emergency_brake_requested_by_modes_and_levels */ kcg_bool Emergency_brake_requested_by_modes_and_levels,
    outC_SpeedSupervision_Integration_SpeedSupervision_Integration_Pkg *outC)
{
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration */
    static ASafe_T_CalcBrakingCurves_types tmp1;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration */
    static ASafe_T_CalcBrakingCurves_types tmp;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::targetCollection */
    static TargetCollection_T_TargetManagement_types targetCollection;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::Trainlocations_internal */
    static TrainLocations_real_T_SDM_Types_Pkg Trainlocations_internal;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MRSP_internal */
    static MRSP_internal_T_TargetManagement_types MRSP_internal;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::MA_internal */
    static MA_section_real_T_TargetManagement_types MA_internal;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::trainData_extras */
    static trainData_internal_t_SDM_Types_Pkg trainData_extras;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::T_b */
    static t_Brake_t_SDMModelPkg T_b;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L114 */
    static kcg_bool _L114;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L112 */
    static SDM_Locations_T_SDM_Types_Pkg _L112;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L111 */
    static Speeds_T_SDM_Types_Pkg _L111;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L187 */
    static ASafe_T_CalcBrakingCurves_types _L187;
    /* SpeedSupervision_Integration_Pkg::SpeedSupervision_Integration::_L190 */
    static A_gradient_t_SDM_GradientAcceleration_types _L190;

    trainData_extras.isSB_CmdAvailable = kcg_true;
    trainData_extras.isTCOAvailable = kcg_true;
    trainData_extras.T_traction_cut_off = 800;
    /* 1 */
    SDM_InputWrapper_SDM_Input_Wrappers(
        TrainPosition,
        trainProps,
        dataFromTrackAtlas,
        &outC->Context_1);
    trainData_extras.offsetAntennaL1 = outC->Context_1.offsetAntennaL1;
    kcg_copy_MRSP_internal_T_TargetManagement_types(
        &MRSP_internal,
        &outC->Context_1.mrsp_out);
    kcg_copy_MA_section_real_T_TargetManagement_types(
        &MA_internal,
        &outC->Context_1.ma_out);
    kcg_copy_TrainLocations_real_T_SDM_Types_Pkg(
        &Trainlocations_internal,
        &outC->Context_1.trainLocations);
    /* 2 */
    TargetManagement_TargetManagement_pkg(
        &MRSP_internal,
        outC->Context_1.mrsp_update_out,
        &MA_internal,
        outC->Context_1.ma_update_out,
        &Trainlocations_internal,
        &outC->Context_2);
    kcg_copy_TargetCollection_T_TargetManagement_types(
        &targetCollection,
        &outC->Context_2.targetCollection);
    /* 1 */
    ABrakeFactory_SDMModelPkg(trainData, NationalValues, &T_b, &tmp, &_L187);
    /* 1 */
    AGradient_SDM_GradientAcceleration_Pkg(
        &Trainlocations_internal,
        &outC->Context_1.gp_out,
        outC->Context_1.gp_update_out,
        trainData,
        &targetCollection,
        &outC->_1_Context_1);
    kcg_copy_A_gradient_t_SDM_GradientAcceleration_types(
        &_L190,
        &outC->_1_Context_1.A_gradient);
    switch ((*NationalValues).q_nvsbfbperm) {
    case Q_NVSBFBPERM_Yes :
        trainData_extras.isSB_FBAvailable = kcg_true;
        break;

    default :
        trainData_extras.isSB_FBAvailable = kcg_false;
    }
    /* 3 */ addGradient_SDMModelPkg(&tmp, &_L190, &tmp1);
    /* 1 */ addGradient_SDMModelPkg(&_L187, &_L190, &tmp);
    /* 1 */
    CalcBrakingCurves_integration_CalcBrakingCurves_Pkg(
        &Trainlocations_internal,
        &targetCollection,
        &tmp1,
        &tmp,
        &outC->_2_Context_1);
    /* 4 */
    SDMLimitLocations_TargetLimits_Pkg(
        &MRSP_internal,
        odometry,
        &Trainlocations_internal,
        &targetCollection,
        &outC->_2_Context_1.curveCollection,
        &MA_internal,
        &T_b,
        NationalValues,
        &trainData_extras,
        &_L111,
        &_L112,
        &outC->target,
        &_L114);
    /* 1 */
    SDM_Commands_SDM_Commands_Pkg(
        &targetCollection,
        TrainPosition,
        &_L111,
        &_L112,
        &outC->target,
        _L114,
        Service_brake_requested_by_modes_and_levels,
        (kcg_bool)
        (Emergency_brake_requested_by_modes_and_levels | /* 1 */
         SimpleValidityCheck_SDM_Input_Wrappers(
             NationalValues,
             odometry,
             TrainPosition,
             trainData,
             dataFromTrackAtlas)),
        NationalValues,
        &trainData_extras,
        &outC->_3_Context_1);
    kcg_copy_speedSupervisionForDMI_T_DMI_Types_Pkg(
        &outC->sdmToDMI,
        &outC->_3_Context_1.sdmToDMI);
    kcg_copy_SDM_Commands_T_SDM_Types_Pkg(
        &outC->sdmCommands,
        &outC->_3_Context_1.sdmCmd);
    outC->Target_Speed_Reached = outC->_3_Context_1.targetSpeedReached;
    outC->EOA_overpassed = outC->_3_Context_1.eoaOverpassed;
    kcg_copy_Brake_command_T_TIU_Types_Pkg(
        &outC->brakeCmd,
        &outC->_3_Context_1.brakeCmd);
}