Project 1- Traffic Jam Assistant Feature
Project:-1








/*
* File: trafficJAM.c
*
* Code generated for Simulink model 'trafficJAM'.
*
* Model version : 1.4
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Fri Jun 30 23:55:36 2023
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "trafficJAM.h"
#include "trafficJAM_private.h"
/* External inputs (root inport signals with default storage) */
ExtU_trafficJAM_T trafficJAM_U;
/* External outputs (root outports fed by signals with default storage) */
ExtY_trafficJAM_T trafficJAM_Y;
/* Real-time model */
static RT_MODEL_trafficJAM_T trafficJAM_M_;
RT_MODEL_trafficJAM_T *const trafficJAM_M = &trafficJAM_M_;
/* Model step function */
void trafficJAM_step(void)
{
uint8_T tmp;
/* Switch: '<S2>/Switch' incorporates:
* Constant: '<S3>/Constant'
* Constant: '<S3>/Constant1'
* Inport: '<Root>/Input_Switch'
* Inport: '<Root>/Input_Voltage'
* Logic: '<S2>/AND'
* Logic: '<S2>/NOT'
* Logic: '<S3>/Logical Operator'
* RelationalOperator: '<S3>/Relational Operator'
* RelationalOperator: '<S3>/Relational Operator1'
*/
if ((!trafficJAM_U.Input_Switch) && ((trafficJAM_U.Input_Voltage >= 30) &&
(trafficJAM_U.Input_Voltage <= 50)) &&
trafficJAM_ConstB.RelationalOperator) {
/* Saturate: '<S2>/Saturation' incorporates:
* Inport: '<Root>/Enable_Display'
*/
if (trafficJAM_U.Enable_Display < 7) {
tmp = trafficJAM_U.Enable_Display;
} else {
tmp = 7U;
}
/* End of Saturate: '<S2>/Saturation' */
/* MultiPortSwitch: '<S2>/Multiport Switch' */
switch (tmp) {
case 0:
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant'
*/
trafficJAM_Y.Output_Display = 1U;
break;
case 1:
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant'
*/
trafficJAM_Y.Output_Display = 1U;
break;
case 2:
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant1'
*/
trafficJAM_Y.Output_Display = 2U;
break;
case 3:
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant1'
*/
trafficJAM_Y.Output_Display = 2U;
break;
default:
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant2'
*/
trafficJAM_Y.Output_Display = 3U;
break;
}
/* End of MultiPortSwitch: '<S2>/Multiport Switch' */
} else {
/* Outport: '<Root>/Output_Display' incorporates:
* Constant: '<S2>/Constant3'
*/
trafficJAM_Y.Output_Display = 0U;
}
/* End of Switch: '<S2>/Switch' */
}
/* Model initialize function */
void trafficJAM_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void trafficJAM_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/