/*
* File: AppSwcSoc.c
*
* Code generated for Simulink model 'AppSwcSoc'.
*
* Model version : 1.91
* Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
* C/C++ source code generated on : Wed Jan 9 22:12:00 2019
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "AppSwcSoc.h"
#include "AppSwcSoc_private.h"
#include "ASW_RTE.h"
/* Named constants for Chart: '<S16>/Chart' */
#define AppSwcSoc_IN_initial ((uint8_T)1U)
#define AppSwcSoc_IN_tempblow_0 ((uint8_T)2U)
#define AppSwcSoc_IN_tempblow_10 ((uint8_T)3U)
#define AppSwcSoc_IN_tempblow_25 ((uint8_T)4U)
#define AppSwcSoc_IN_tempblow_30 ((uint8_T)5U)
#define AppSwcSoc_IN_tempblow_35 ((uint8_T)6U)
#define AppSwcSoc_IN_tempupper0 ((uint8_T)7U)
#define AppSwcSoc_IN_tempupper01 ((uint8_T)8U)
#define AppSwcSoc_IN_tempupper02 ((uint8_T)9U)
#define AppSwcSoc_IN_tempupper03 ((uint8_T)10U)
#define AppSwcSoc_IN_tempupper04 ((uint8_T)11U)
#define AppSwcSoc_IN_tempupper55 ((uint8_T)12U)
/* Named constants for Chart: '<S9>/Chart' */
#define AppSwcSoc_IN_SOCSwVer_Valid ((uint8_T)1U)
#define AppSwcSoc_IN_try ((uint8_T)2U)
/* Named constants for Chart: '<S9>/Module1SOCinitalPart1' */
#define AppSwcSoc_IN_EEPROMNtValid ((uint8_T)1U)
#define AppSwcSoc_IN_EEROMValid ((uint8_T)2U)
#define AppSwcSoc_IN_InitialCompleted ((uint8_T)1U)
#define AppSwcSoc_IN_Initial_Parameter1 ((uint8_T)1U)
#define AppSwcSoc_IN_KOTNtValid ((uint8_T)1U)
#define AppSwcSoc_IN_KOTnotValid ((uint8_T)1U)
#define AppSwcSoc_IN_NO_ACTIVE_CHILD_m ((uint8_T)0U)
#define AppSwcSoc_IN_OCVNtValid ((uint8_T)1U)
#define AppSwcSoc_IN_OCVValid ((uint8_T)2U)
#define AppSwcSoc_IN_SwVerValid ((uint8_T)2U)
#define AppSwcSoc_IN_defult ((uint8_T)3U)
#define AppSwcSoc_IN_defult_a ((uint8_T)2U)
/* Named constants for Chart: '<S53>/Chart' */
#define AppSwcSoc_IN_Ah_Integral ((uint8_T)1U)
#define AppSwcSoc_IN_UKF ((uint8_T)2U)
/* Named constants for Chart: '<S53>/SOC_ModuleSwitch_Module' */
#define AppSwcSoc_IN_Ah_Integral_g ((uint8_T)1U)
#define AppSwcSoc_IN_SOC_Initial ((uint8_T)2U)
#define AppSwcSoc_IN_SOC_Module_InValid ((uint8_T)3U)
#define AppSwcSoc_IN_UKF_I_Invalid ((uint8_T)5U)
#define AppSwcSoc_IN_UKF_j ((uint8_T)4U)
/* Named constants for Chart: '<S77>/Chart' */
#define AppSwcSoc_IN_fix_step ((uint8_T)1U)
#define AppSwcSoc_IN_normal_step ((uint8_T)2U)
/* Named constants for Chart: '<S78>/Chart' */
#define AppSwcSoc_IN_normalblock ((uint8_T)1U)
#define AppSwcSoc_IN_overmaxlmt ((uint8_T)2U)
#define AppSwcSoc_IN_overminlmt ((uint8_T)3U)
/* Named constants for Chart: '<S9>/Chart3' */
#define AppSwcSoc_IN_EOL ((uint8_T)1U)
#define AppSwcSoc_IN_blank ((uint8_T)2U)
/* Named constants for Chart: '<S10>/Chart' */
#define AppSwcSoc_IN_AvgVaild_Step ((uint8_T)1U)
#define AppSwcSoc_IN_Both_InValid ((uint8_T)2U)
#define AppSwcSoc_IN_Frist_Step ((uint8_T)3U)
#define AppSwcSoc_IN_PosVaild_Step ((uint8_T)4U)
/* Named constants for Chart: '<S10>/Pack_Crnt_Select_Module' */
#define AppSwcSoc_IN_Both_InValid_c ((uint8_T)1U)
#define AppSwcSoc_IN_CAB_InValid ((uint8_T)2U)
#define AppSwcSoc_IN_Initial_Step ((uint8_T)3U)
/* Named constants for Chart: '<S10>/Pack_Temp_Select_Module' */
#define AppSwcSoc_IN_Both_Valid ((uint8_T)2U)
#define AppSwcSoc_IN_TempHigherThan35 ((uint8_T)4U)
#define AppSwcSoc_IN_TempHigherThan_10 ((uint8_T)5U)
#define AppSwcSoc_IN_TempLowerThan30 ((uint8_T)6U)
#define AppSwcSoc_IN_TempLowerThan_15 ((uint8_T)7U)
#define AppSwcSoc_IN_TempMaxInValid ((uint8_T)8U)
#define AppSwcSoc_IN_TempMinInValid ((uint8_T)9U)
/* Named constants for Chart: '<S10>/Pack_Temp_Select_Module1' */
#define AppSwcSoc_IN_delfult ((uint8_T)1U)
#define AppSwcSoc_IN_tempgapbig ((uint8_T)2U)
/* Named constants for Chart: '<S10>/Pack_Volt_Select_Module' */
#define AppS_IN_CellMax_CellAvg_InValid ((uint8_T)2U)
#define AppS_IN_CellMax_CellMin_InValid ((uint8_T)4U)
#define AppS_IN_CellMin_CellAvg_InValid ((uint8_T)6U)
#define AppSwcSoc_IN_CellMaxVol_InValid ((uint8_T)1U)
#define AppSwcSoc_IN_CellMinVol_InValid ((uint8_T)5U)
#define AppSwcSoc_IN_Initial_Step_n ((uint8_T)7U)
#define IN_CellMax_CellMin_CellAvg_Inva ((uint8_T)3U)
/* Named constants for Chart: '<S11>/BatModEnableMod' */
#define AppSwcS_IN_BatModEnable_Disable ((uint8_T)1U)
#define AppSwcSo_IN_BatModEnable_Enable ((uint8_T)2U)
#define AppSwc_IN_BatModEnable_Initial_ ((uint8_T)3U)
/* Named constants for Chart: '<S11>/Chart' */
#define AppSwcSo_IN_UKFEnable_MaxEnable ((uint8_T)2U)
#define AppSwcSo_IN_UKFEnable_MinEnable ((uint8_T)3U)
#define AppSwcSoc_IN_UKFEnable_Initial ((uint8_T)1U)
/* Block signals (auto storage) */
B_AppSwcSoc_T AppSwcSoc_B;
/* Block states (auto storage) */
DW_AppSwcSoc_T AppSwcSoc_DW;
real32_T SOClook2_iflf_binlxpw(real32_T u0, real32_T u1, const real32_T bp0[],
const real32_T bp1[], const real32_T table[], const uint32_T maxIndex[],
uint32_T stride)
{
real32_T frac;
uint32_T bpIndices[2];
real32_T fractions[2];
real32_T yL_1d;
uint32_T iRght;
uint32_T bpIdx;
uint32_T iLeft;
/* Lookup 2-D
Canonical function name: look2_iflf_binlxpw
Search method: 'binary'
Use previous index: 'off'
Interpolation method: 'Linear'
Extrapolation method: 'Linear'
Use last breakpoint for index at or above upper limit: 'off'
Remove protection against out-of-range input in generated code: 'off'
*/
/* Prelookup - Index and Fraction
Index Search method: 'binary'
Extrapolation method: 'Linear'
Use previous index: 'off'
Use last breakpoint for index at or above upper limit: 'off'
Remove protection against out-of-range input in generated code: 'off'
*/
if (u0 <= bp0[0U]) {
iLeft = 0U;
frac = (u0 - bp0[0U]) / (bp0[1U] - bp0[0U]);
} else if (u0 < bp0[maxIndex[0U]]) {
/* Binary Search */
bpIdx = maxIndex[0U] >> 1U;
iLeft = 0U;
iRght = maxIndex[0U];
while (iRght - iLeft > 1U) {
if (u0 < bp0[bpIdx]) {
iRght = bpIdx;
} else {
iLeft = bpIdx;
}
bpIdx = (iRght + iLeft) >> 1U;
}
frac = (u0 - bp0[iLeft]) / (bp0[iLeft + 1U] - bp0[iLeft]);
} else {
iLeft = maxIndex[0U] - 1U;
frac = (u0 - bp0[maxIndex[0U] - 1U]) / (bp0[maxIndex[0U]] - bp0[maxIndex[0U]
- 1U]);
}
fractions[0U] = frac;
bpIndices[0U] = iLeft;
/* Prelookup - Index and Fraction
Index Search method: 'binary'
Extrapolation method: 'Linear'
Use previous index: 'off'
Use last breakpoint for index at or above upper limit: 'off'
Remove protection against out-of-range input in generated code: 'off'
*/
if (u1 <= bp1[0U]) {
iLeft = 0U;
frac = (u1 - bp1[0U]) / (bp1[1U] - bp1[0U]);
} else if (u1 < bp1[maxIndex[1U]]) {
/* Binary Search */
bpIdx = maxIndex[1U] >> 1U;
iLeft = 0U;
iRght = maxIndex[1U];
while (iRght - iLeft > 1U) {
if (u1 < bp1[bpIdx]) {
iRght = bpIdx;
} else {
iLeft = bpIdx;
}
bpIdx = (iRght + iLeft) >> 1U;
}
frac = (u1 - bp1[iLeft]) / (bp1[iLeft + 1U] - bp1[iLeft]);
} else {
iLeft = maxIndex[1U] - 1U;
frac = (u1 - bp1[maxIndex[1U] - 1U]) / (bp1[maxIndex[1U]] - bp1[maxIndex[1U]
- 1U]);
}
/* Interpolation 2-D
Canonical function name: intrp2d_fu32fl_pw
Interpolation method: 'Linear'
Use last breakpoint for index at or above upper limi