327 lines
10 KiB
C
327 lines
10 KiB
C
/*
|
|
* File: socTouchDisplay.c
|
|
*
|
|
* Code generated for Simulink model 'socTouchDisplay'.
|
|
*
|
|
* Model version : 1.111
|
|
* Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
|
|
* C/C++ source code generated on : Thu Nov 7 22:32:36 2024
|
|
*
|
|
* 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 socTouchDi_IN_waitTillNextTouch ((uint8_T)4U)
|
|
#define socTouchDis_IN_touchNotDetected ((uint8_T)3U)
|
|
#define socTouchDisplay_IN_displayError ((uint8_T)1U)
|
|
#define socTouchDisplay_IN_displaySoc ((uint8_T)2U)
|
|
|
|
/* 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;
|
|
|
|
/* 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_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);
|
|
|
|
/* Outputs for Enabled SubSystem: '<S3>/Enabled Subsystem' incorporates:
|
|
* EnablePort: '<S5>/Enable'
|
|
*/
|
|
/* Logic: '<S3>/AND' incorporates:
|
|
* Constant: '<S3>/Constant'
|
|
* RelationalOperator: '<S3>/Equal1'
|
|
*/
|
|
if ((socTouchDisplay_B.SFunction.Data[0] == 2) && rtb_Equal) {
|
|
for (i = 0; i < 8; i++) {
|
|
/* SignalConversion generated from: '<S5>/In1' */
|
|
socTouchDisplay_B.In1[i] = socTouchDisplay_B.SFunction.Data[i];
|
|
}
|
|
}
|
|
|
|
/* End of Logic: '<S3>/AND' */
|
|
/* End of Outputs for SubSystem: '<S3>/Enabled Subsystem' */
|
|
|
|
/* DataTypeConversion: '<S3>/Cast' */
|
|
rtb_Cast = socTouchDisplay_B.In1[2];
|
|
|
|
/* Memory: '<S3>/Memory' */
|
|
rtb_Memory = Memory_PreviousInput;
|
|
|
|
/* Update for Memory: '<S3>/Memory' incorporates:
|
|
* Logic: '<S3>/OR'
|
|
*/
|
|
Memory_PreviousInput = (rtb_Equal || 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_g = 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_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.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDi_IN_waitTillNextTouch;
|
|
|
|
/* 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.temporalCounter_i1 = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDi_IN_waitTillNextTouch;
|
|
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
}
|
|
break;
|
|
|
|
case socTouchDis_IN_touchNotDetected:
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
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_g = 0U;
|
|
}
|
|
|
|
if (((uint32_T)((int32_T)socTouchDisplay_DW.durationCounter_1_g * 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;
|
|
|
|
default:
|
|
/* Outport: '<Root>/op_bDisplayStatus' */
|
|
/* case IN_waitTillNextTouch: */
|
|
socTouchDisplay_Y.op_bDisplayStatus = false;
|
|
|
|
/* Outport: '<Root>/op_bErrorStatus' */
|
|
socTouchDisplay_Y.op_bErrorStatus = false;
|
|
if (socTouchDisplay_DW.temporalCounter_i1 >= 100U) {
|
|
socTouchDisplay_DW.durationCounter_2 = 0U;
|
|
socTouchDisplay_DW.durationCounter_1_g = 0U;
|
|
socTouchDisplay_DW.is_c3_socTouchDisplay =
|
|
socTouchDis_IN_touchNotDetected;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (socTouchDisplay_U.in_bTouchDetected == 1.0) {
|
|
socTouchDisplay_DW.durationCounter_1_g++;
|
|
socTouchDisplay_DW.durationCounter_2++;
|
|
} else {
|
|
socTouchDisplay_DW.durationCounter_1_g = 0U;
|
|
socTouchDisplay_DW.durationCounter_2 = 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]
|
|
*/
|