Challenge

Project 2-Highway Assistant-Lane Changing Assistant

Project 2-Highway Assistant-Lane Changing Assistant

1) Simulink Data Dictionary

2)Simulink model

Port for input and output in state flow

3) Changing coder to Autosar.tlc

4)Open the App Autosar component

Open code mapping

Update SR interface, Data Elements, Sender port and Receiver port with respective prefixes

Port Mapping

Model is validated with Autosar Compliance

5) Code Generated

.c and .h files

/*
 * File: Project_2_Lane_Changing_final.c
 *
 * Code generated for Simulink model 'Project_2_Lane_Changing_final'.
 *
 * Model version                  : 2.1
 * Simulink Coder version         : 9.8 (R2022b) 13-May-2022
 * C/C++ source code generated on : Tue Jul 25 16:58:48 2023
 *
 * Target selection: autosar.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives:
 *    1. Execution efficiency
 *    2. RAM efficiency
 * Validation result: Not run
 */

#include "Project_2_Lane_Changing_final.h"
#include "rtwtypes.h"

/* Named constants for Chart: '/Highway_Display_Logic' */
#define IN_Condition_1                 ((uint8)1U)
#define IN_Condition_2                 ((uint8)2U)

/* Named constants for Chart: '/Lane_Display_Logic' */
#define IN_Mode_1                      ((uint8)1U)
#define IN_Mode_2                      ((uint8)2U)

/* PublicStructure Variables for Internal Data */
ARID_DEF rtARID_DEF;                   /* '/Lane_Display_Logic' */

/* Model step function */
void Project_2_Lane_Changing_final_Step(void)
{
  /* local block i/o variables */
  uint8 Lane_Display_Mode_1;
  uint8 Lane_Display_Mode_2;
  uint8 Lane_Display_Mode_3;
  uint8 Lane_Display_Mode_4;
  uint8 Highway_Display_Mode_1;
  uint8 Highway_Display_Mode_2;
  uint8 Highway_Display_Mode_3;
  uint8 Highway_Display_Mode_4;
  float64 tmp_0;
  uint8 tmp;

  /* Chart: '/Highway_Display_Logic' incorporates:
   *  Inport: '/Enable_Display'
   *  Inport: '/Highway_Input_Signal'
   *  Inport: '/Input_Switch'
   */
  if (rtARID_DEF.is_active_c3_Project_2_Lane_Cha == 0U) {
    rtARID_DEF.is_active_c3_Project_2_Lane_Cha = 1U;
    rtARID_DEF.is_c3_Project_2_Lane_Changing_f = IN_Condition_1;
    Highway_Display_Mode_1 = 232U;
    Highway_Display_Mode_2 = 183U;
    Highway_Display_Mode_3 = 41U;
    Highway_Display_Mode_4 = 94U;
  } else if (rtARID_DEF.is_c3_Project_2_Lane_Changing_f == IN_Condition_1) {
    if ((Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
         () == 1.0) &&
        (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Enable_Display_DE_Enable_Display
         () == 1.0) &&
        (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Input_Switch_DE_Input_Switch
         () == 1.0)) {
      rtARID_DEF.is_c3_Project_2_Lane_Changing_f = IN_Condition_2;
      Highway_Display_Mode_1 = 213U;
      Highway_Display_Mode_2 = 183U;
      Highway_Display_Mode_3 = 9U;
      Highway_Display_Mode_4 = 94U;
    } else {
      Highway_Display_Mode_1 = 232U;
      Highway_Display_Mode_2 = 183U;
      Highway_Display_Mode_3 = 41U;
      Highway_Display_Mode_4 = 94U;
    }

    /* case IN_Condition_2: */
  } else if
      ((Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
        () == 1.0) &&
       (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Enable_Display_DE_Enable_Display
        () == 0.0) &&
       (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Input_Switch_DE_Input_Switch
        () == 1.0)) {
    rtARID_DEF.is_c3_Project_2_Lane_Changing_f = IN_Condition_1;
    Highway_Display_Mode_1 = 232U;
    Highway_Display_Mode_2 = 183U;
    Highway_Display_Mode_3 = 41U;
    Highway_Display_Mode_4 = 94U;
  } else {
    Highway_Display_Mode_1 = 213U;
    Highway_Display_Mode_2 = 183U;
    Highway_Display_Mode_3 = 9U;
    Highway_Display_Mode_4 = 94U;
  }

  /* End of Chart: '/Highway_Display_Logic' */

  /* Chart: '/Lane_Display_Logic' incorporates:
   *  Inport: '/Enable_Display'
   *  Inport: '/Input_Switch'
   *  Inport: '/Lane_Input_Signal'
   */
  if (rtARID_DEF.is_active_c1_Project_2_Lane_Cha == 0U) {
    rtARID_DEF.is_active_c1_Project_2_Lane_Cha = 1U;
    rtARID_DEF.is_c1_Project_2_Lane_Changing_f = IN_Mode_1;
    Lane_Display_Mode_1 = 132U;
    Lane_Display_Mode_2 = 185U;
    Lane_Display_Mode_3 = 54U;
    Lane_Display_Mode_4 = 67U;
  } else if (rtARID_DEF.is_c1_Project_2_Lane_Changing_f == IN_Mode_1) {
    if ((Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
         () == 6.0) &&
        (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Enable_Display_DE_Enable_Display
         () == 1.0) &&
        (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Input_Switch_DE_Input_Switch
         () == 1.0)) {
      rtARID_DEF.is_c1_Project_2_Lane_Changing_f = IN_Mode_2;
      Lane_Display_Mode_1 = 127U;
      Lane_Display_Mode_2 = 248U;
      Lane_Display_Mode_3 = 186U;
      Lane_Display_Mode_4 = 84U;
    } else {
      Lane_Display_Mode_1 = 132U;
      Lane_Display_Mode_2 = 185U;
      Lane_Display_Mode_3 = 54U;
      Lane_Display_Mode_4 = 67U;
    }

    /* case IN_Mode_2: */
  } else if
      ((Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
        () == 6.0) &&
       (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Enable_Display_DE_Enable_Display
        () == 0.0) &&
       (Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Input_Switch_DE_Input_Switch
        () == 1.0)) {
    rtARID_DEF.is_c1_Project_2_Lane_Changing_f = IN_Mode_1;
    Lane_Display_Mode_1 = 132U;
    Lane_Display_Mode_2 = 185U;
    Lane_Display_Mode_3 = 54U;
    Lane_Display_Mode_4 = 67U;
  } else {
    Lane_Display_Mode_1 = 127U;
    Lane_Display_Mode_2 = 248U;
    Lane_Display_Mode_3 = 186U;
    Lane_Display_Mode_4 = 84U;
  }

  /* End of Chart: '/Lane_Display_Logic' */

  /* Switch: '/Switch' incorporates:
   *  Inport: '/Highway_Input_Signal'
   *  Switch: '/Switch1'
   *  Switch: '/Switch2'
   *  Switch: '/Switch3'
   */
  tmp_0 =
    Rte_IRead_Project_2_Lane_Changing_final_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
    ();
  if (tmp_0 > 0.0) {
    tmp = Highway_Display_Mode_1;
  } else {
    tmp = Lane_Display_Mode_1;
  }

  /* Outport: '/Display_Mode_1  ' incorporates:
   *  Switch: '/Switch'
   */
  Rte_IWrite_Project_2_Lane_Changing_final_Step_Pp_Display_Mode_1_DE_Display_Mode_1
    (tmp);

  /* Switch: '/Switch1' */
  if (tmp_0 > 0.0) {
    tmp = 183U;
  } else {
    tmp = Lane_Display_Mode_2;
  }

  /* Outport: '/Display_Mode_2' incorporates:
   *  Switch: '/Switch1'
   */
  Rte_IWrite_Project_2_Lane_Changing_final_Step_Pp_Display_Mode_2_DE_Display_Mode_2
    (tmp);

  /* Switch: '/Switch2' */
  if (tmp_0 > 0.0) {
    tmp = Highway_Display_Mode_3;
  } else {
    tmp = Lane_Display_Mode_3;
  }

  /* Outport: '/Display_Mode_3' incorporates:
   *  Switch: '/Switch2'
   */
  Rte_IWrite_Project_2_Lane_Changing_final_Step_Pp_Display_Mode_3_DE_Display_Mode_3
    (tmp);

  /* Switch: '/Switch3' */
  if (tmp_0 > 0.0) {
    tmp = 94U;
  } else {
    tmp = Lane_Display_Mode_4;
  }

  /* Outport: '/Display_Mode_4' incorporates:
   *  Switch: '/Switch3'
   */
  Rte_IWrite_Project_2_Lane_Changing_final_Step_Pp_Display_Mode_4_DE_Display_Mode_4
    (tmp);
}

/* Model initialize function */
void Project_2_Lane_Changing_final_Init(void)
{
  /* (no initialization code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]

6)Model Advisor report

No failed checks

All the requirements has been completed and project is completed

The simulink model file, sldd file, code generation files(.c and .h) and model advisor reports are attached as files.

This project was not complted on time because project was stopped in between as my matlab license given by skill lync was expired.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.