398 lines
13 KiB
C
398 lines
13 KiB
C
/*
|
|
* File: socTouchDisplay.c
|
|
*
|
|
* Code generated for Simulink model 'socTouchDisplay'.
|
|
*
|
|
* Model version : 1.140
|
|
* Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
|
|
* C/C++ source code generated on : Mon Jan 20 13:31:03 2025
|
|
*
|
|
* Target selection: ert.tlc
|
|
* Embedded hardware selection: Intel->x86-64 (Windows64)
|
|
* Code generation objectives: Unspecified
|
|
* Validation result: Not run
|
|
*/
|
|
|
|
#include "socTouchDisplay.h"
|
|
#include "rtwtypes.h"
|
|
#include <math.h>
|
|
#include "socTouchDisplay_private.h"
|
|
|
|
/* Named constants for Chart: '<Root>/Chart' */
|
|
#define socTouchDis_IN_touchNotDetected ((uint8_T)4U)
|
|
#define socTouchDisp_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
|
|
#define socTouchDisplay_IN_HideSoc ((uint8_T)1U)
|
|
#define socTouchDisplay_IN_chargingMode ((uint8_T)1U)
|
|
#define socTouchDisplay_IN_dispalySoc ((uint8_T)2U)
|
|
#define socTouchDisplay_IN_displayError ((uint8_T)2U)
|
|
#define socTouchDisplay_IN_displaySoc ((uint8_T)3U)
|
|
|
|
/* Named constants for Chart: '<Root>/Chart1' */
|
|
#define socTouchDisplay_IN_bmsPresent ((uint8_T)1U)
|
|
#define socTouchDisplay_IN_init ((uint8_T)2U)
|
|
|
|
/* Block signals (default storage) */
|
|
B_socTouchDisplay_T socTouchDisplay_B = {0};
|
|
|
|
/* Block states (default storage) */
|
|
DW_socTouchDisplay_T socTouchDisplay_DW;
|
|
|
|
/* External inputs (root inport signals with default storage) */
|
|
ExtU_socTouchDisplay_T socTouchDisplay_U;
|
|
|
|
/* External outputs (root outports fed by signals with default storage) */
|
|
ExtY_socTouchDisplay_T socTouchDisplay_Y;
|
|
|
|
/* Real-time model */
|
|
static RT_MODEL_socTouchDisplay_T socTouchDisplay_M_;
|
|
RT_MODEL_socTouchDisplay_T *const socTouchDisplay_M = &socTouchDisplay_M_;
|
|
|
|
/* Model step function */
|
|
void socTouchDisplay_step(void)
|
|
{
|
|
int32_T i;
|
|
int32_T s3_iter;
|
|
uint32_T tmp;
|
|
uint8_T rtb_Cast;
|
|
boolean_T Memory_PreviousInput;
|
|
boolean_T rtb_AND;
|
|
boolean_T rtb_Equal;
|
|
boolean_T rtb_Memory;
|
|
|
|
/* Outputs for Iterator SubSystem: '<Root>/canMsgDecode' incorporates:
|
|
* ForIterator: '<S3>/For Iterator'
|
|
*/
|
|
/* InitializeConditions for Memory: '<S3>/Memory' */
|
|
Memory_PreviousInput = false;
|
|
for (s3_iter = 0; s3_iter < 10; s3_iter++) {
|
|
/* Selector: '<S3>/Selector' incorporates:
|
|
* Inport: '<Root>/Input'
|
|
*/
|
|
socTouchDisplay_B.Selector = socTouchDisplay_U.Input[s3_iter];
|
|
|
|
/* S-Function (canReceive): '<S3>/S-Function' */
|
|
canReceive_Outputs_wrapper(&socTouchDisplay_B.Selector.ID,
|
|
&socTouchDisplay_B.Selector.Length, &socTouchDisplay_B.Selector.Data[0],
|
|
&socTouchDisplay_B.SFunction);
|
|
|
|
/* RelationalOperator: '<S3>/Equal' incorporates:
|
|
* Inport: '<Root>/ip_u32canId'
|
|
*/
|
|
rtb_Equal = (socTouchDisplay_B.SFunction.ID == socTouchDisplay_U.ip_u32canId);
|
|
|
|
/* Logic: '<S3>/AND' incorporates:
|
|
* Constant: '<S3>/Constant'
|
|
* RelationalOperator: '<S3>/Equal1'
|
|
*/
|
|
rtb_AND = (rtb_Equal && (socTouchDisplay_B.SFunction.Data[0] == 2));
|
|
|
|
/* Memory: '<S3>/Memory' */
|
|
rtb_Memory = Memory_PreviousInput;
|
|
|
|
/* Outputs for Enabled SubSystem: '<S3>/Enabled Subsystem' incorporates:
|
|
* EnablePort: '<S5>/Enable'
|
|
*/
|
|
if (rtb_AND) {
|
|
for (i = 0; i < 8; i++) {
|
|
/* SignalConversion generated from: '<S5>/In1' */
|
|
socTouchDisplay_B.In1[i] = socTouchDisplay_B.SFunction.Data[i];
|
|
}
|
|
}
|
|
|
|
/* End of Outputs for SubSystem: '<S3>/Enabled Subsystem' */
|
|
|
|
/* DataTypeConversion: '<S3>/Cast' */
|
|
rtb_Cast = socTouchDisplay_B.In1[2];
|
|
|
|
/* Outputs for Enabled SubSystem: '<S3>/Enabled Subsystem1' incorporates:
|
|
* EnablePort: '<S6>/Enable'
|
|
*/
|
|
/* Logic: '<S3>/AND1' incorporates:
|
|
* Constant: '<S3>/Constant1'
|
|
* RelationalOperator: '<S3>/Equal2'
|
|
*/
|
|
if (rtb_Equal && (socTouchDisplay_B.SFunction.Data[0] == 1)) {
|
|
/* RelationalOperator: '<S7>/Compare' incorporates:
|
|
* Constant: '<S7>/Constant'
|
|
*/
|
|
socTouchDisplay_B.Compare = (socTouchDisplay_B.SFunction.Data[6] == 4);
|
|
}
|
|
|
|
/* End of Logic: '<S3>/AND1' */
|
|
/* End of Outputs for SubSystem: '<S3>/Enabled Subsystem1' */
|
|
|
|
/* Update for Memory: '<S3>/Memory' incorporates:
|
|
* Logic: '<S3>/OR'
|
|
*/
|
|
Memory_PreviousInput = (rtb_AND || Memory_PreviousInput);
|
|
}
|
|
|
|
/* End of Outputs for SubSystem: '<Root>/canMsgDecode' */
|
|
|
|
/* Chart: '<Root>/Chart1' */
|
|
if (socTouchDisplay_DW.is_active_c1_socTouchDisplay == 0U) {
|
|
socTouchDisplay_DW.is_active_c1_socTouchDisplay = 1U;
|
|
socTouchDisplay_DW.is_c1_socTouchDisplay = socTouchDisplay_IN_init;
|
|
Memory_PreviousInput = false;
|
|
} else if (socTouchDisplay_DW.is_c1_socTouchDisplay ==
|
|
socTouchDisplay_IN_bmsPresent) {
|
|
Memory_PreviousInput = true;
|
|
if (rtb_Memory) {
|
|
socTouchDisplay_DW.durationCounter_1 = 0U;
|
|
}
|
|
|
|
if (socTouchDisplay_DW.durationCounter_1 > 150U) {
|
|
socTouchDisplay_DW.is_c1_socTouchDisplay = socTouchDisplay_IN_init;
|
|
Memory_PreviousInput = false;
|
|
}
|
|
} else {
|
|
/* case IN_init: */
|
|
Memory_PreviousInput = false;
|
|
if (rtb_Memory) {
|
|
socTouchDisplay_DW.durationCounter_1 = 0U;
|
|
socTouchDisplay_DW.is_c1_socTouchDisplay = socTouchDisplay_IN_bmsPresent;
|
|
Memory_PreviousInput = true;
|
|
}
|
|
}
|
|
|
|
if (!rtb_Memory) {
|
|
socTouchDisplay_DW.durationCounter_1++;
|
|
} else {
|
|
socTouchDisplay_DW.durationCounter_1 = 0U;
|
|
}
|
|
|
|
/* End of Chart: '<Root>/Chart1' */
|
|
|
|
/* Chart: '<Root>/Chart' incorporates:
|
|
* Inport: '<Root>/in_bTouchDetected'
|
|
* Inport: '<Root>/ip_u32DisplayDuration_msec'
|
|
* Inport: '<Root>/ip_u32TouchDuration_msec'
|
|
*/
|
|
if (socTouchDisplay_DW.temporalCounter_i1 < MAX_uint32_T) {
|
|
socTouchDisplay_DW.temporalCounter_i1++;
|
|
}
|
|
|
|
if (socTouchDisplay_DW.is_active_c3_socTouchDisplay == 0U) {
|
|
socTouchDisplay_DW.is_active_c3_socTouchDisplay = 1U;
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay = socTouchDis_IN_touchNotDetected;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
} else {
|
|
switch (socTouchDisplay_DW.is_c3_socTouchDisplay) {
|
|
case socTouchDisplay_IN_chargingMode:
|
|
if (socTouchDisplay_B.Compare) {
|
|
socTouchDisplay_DW.durationCounter_1_a = 0U;
|
|
}
|
|
|
|
if ((socTouchDisplay_DW.durationCounter_1_a > 20U) ||
|
|
(!Memory_PreviousInput)) {
|
|
socTouchDisplay_DW.is_chargingMode = socTouchDisp_IN_NO_ACTIVE_CHILD;
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDis_IN_touchNotDetected;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
} else if (socTouchDisplay_DW.is_chargingMode ==
|
|
socTouchDisplay_IN_HideSoc) {
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
if (socTouchDisplay_DW.temporalCounter_i1 >= 20U) {
|
|
socTouchDisplay_DW.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_chargingMode = socTouchDisplay_IN_dispalySoc;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = true;
|
|
}
|
|
} else {
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
/* case IN_dispalySoc: */
|
|
socTouchDisplay_Y.op_bDisplayStatus = true;
|
|
if (socTouchDisplay_DW.temporalCounter_i1 >= 20U) {
|
|
socTouchDisplay_DW.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_chargingMode = socTouchDisplay_IN_HideSoc;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case socTouchDisplay_IN_displayError:
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = true;
|
|
if ((uint32_T)((int32_T)socTouchDisplay_DW.temporalCounter_i1 * 100) >=
|
|
(uint32_T)ceil(socTouchDisplay_U.ip_u32DisplayDuration_msec)) {
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDis_IN_touchNotDetected;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
}
|
|
break;
|
|
|
|
case socTouchDisplay_IN_displaySoc:
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = true;
|
|
if ((uint32_T)((int32_T)socTouchDisplay_DW.temporalCounter_i1 * 100) >=
|
|
(uint32_T)ceil(socTouchDisplay_U.ip_u32DisplayDuration_msec)) {
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDis_IN_touchNotDetected;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
/* case IN_touchNotDetected: */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
if (socTouchDisplay_B.Compare && Memory_PreviousInput) {
|
|
socTouchDisplay_DW.durationCounter_1_a = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDisplay_IN_chargingMode;
|
|
socTouchDisplay_DW.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_chargingMode = socTouchDisplay_IN_dispalySoc;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = true;
|
|
} else {
|
|
rtb_Memory = !(socTouchDisplay_U.in_bTouchDetected == 1.0);
|
|
if (rtb_Memory) {
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
}
|
|
|
|
tmp = (uint32_T)ceil(socTouchDisplay_U.ip_u32TouchDuration_msec);
|
|
if (((uint32_T)((int32_T)socTouchDisplay_DW.durationCounter_2 * 100) >
|
|
tmp) && Memory_PreviousInput) {
|
|
socTouchDisplay_DW.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDisplay_IN_displaySoc;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = true;
|
|
} else {
|
|
if (rtb_Memory) {
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
}
|
|
|
|
if (((uint32_T)((int32_T)socTouchDisplay_DW.durationCounter_1_l * 100)
|
|
> tmp) && (!Memory_PreviousInput)) {
|
|
socTouchDisplay_DW.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDisplay_IN_displayError;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = true;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (socTouchDisplay_U.in_bTouchDetected == 1.0) {
|
|
socTouchDisplay_DW.durationCounter_1_l++;
|
|
socTouchDisplay_DW.durationCounter_2++;
|
|
} else {
|
|
socTouchDisplay_DW.durationCounter_1_l = 0U;
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
}
|
|
|
|
if (!socTouchDisplay_B.Compare) {
|
|
socTouchDisplay_DW.durationCounter_1_a++;
|
|
} else {
|
|
socTouchDisplay_DW.durationCounter_1_a = 0U;
|
|
}
|
|
|
|
/* End of Chart: '<Root>/Chart' */
|
|
|
|
/* Outputs for Atomic SubSystem: '<Root>/displayData' */
|
|
/* Switch: '<S4>/Switch1' incorporates:
|
|
* Outport: '<Root>/op_bErrorStatus'
|
|
* Switch: '<S4>/Switch'
|
|
* Switch: '<S4>/Switch2'
|
|
*/
|
|
if (socTouchDisplay_Y.op_bErrorStatus) {
|
|
/* Outport: '<Root>/op_u8TensPlace' incorporates:
|
|
* Constant: '<S4>/Constant3'
|
|
*/
|
|
socTouchDisplay_Y.op_u8TensPlace = 114U;
|
|
|
|
/* Outport: '<Root>/op_u8OnesPlace' incorporates:
|
|
* Constant: '<S4>/Constant4'
|
|
*/
|
|
socTouchDisplay_Y.op_u8OnesPlace = 114U;
|
|
|
|
/* Outport: '<Root>/op_u8HundredsPlace' incorporates:
|
|
* Constant: '<S4>/Constant2'
|
|
*/
|
|
socTouchDisplay_Y.op_u8HundredsPlace = 69U;
|
|
} else {
|
|
/* Outport: '<Root>/op_u8TensPlace' incorporates:
|
|
* Constant: '<S4>/Constant'
|
|
* Math: '<S4>/Mod1'
|
|
* Product: '<S4>/Divide'
|
|
*/
|
|
socTouchDisplay_Y.op_u8TensPlace = (uint8_T)((int32_T)(rtb_Cast / 10U) % 10);
|
|
|
|
/* Outport: '<Root>/op_u8OnesPlace' incorporates:
|
|
* Math: '<S4>/Mod2'
|
|
*/
|
|
socTouchDisplay_Y.op_u8OnesPlace = (uint8_T)(rtb_Cast % 10);
|
|
|
|
/* Outport: '<Root>/op_u8HundredsPlace' incorporates:
|
|
* Constant: '<S4>/Constant1'
|
|
* Math: '<S4>/Mod'
|
|
* Product: '<S4>/Divide1'
|
|
*/
|
|
socTouchDisplay_Y.op_u8HundredsPlace = (uint8_T)((int32_T)(rtb_Cast / 100U) %
|
|
10);
|
|
}
|
|
|
|
/* End of Switch: '<S4>/Switch1' */
|
|
/* End of Outputs for SubSystem: '<Root>/displayData' */
|
|
}
|
|
|
|
/* Model initialize function */
|
|
void socTouchDisplay_initialize(void)
|
|
{
|
|
/* (no initialization code required) */
|
|
}
|
|
|
|
/* Model terminate function */
|
|
void socTouchDisplay_terminate(void)
|
|
{
|
|
/* (no terminate code required) */
|
|
}
|
|
|
|
/*
|
|
* File trailer for generated code.
|
|
*
|
|
* [EOF]
|
|
*/
|