Browse Source

Merge branch 'V3-6060-QTF' into V3-7250-QTF

# Conflicts:
#	inc/AppConfig.h
LAPTOP-EG88H5BE\86151 2 years ago
parent
commit
8066cc3dc7

+ 1 - 1
ARMCC/Makefile

@@ -32,7 +32,7 @@ obj-y             += PLAT/project/$(TARGET)/apps/qx_app/src/app.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/SOH.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/SOC.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/BLC.o \
-						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/CM.o \
+						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/CSM.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/CDM.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/ISC.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/SOE.o \

+ 1 - 1
inc/EmbeddedCoder_inc/BCU.h

@@ -2,7 +2,7 @@
 #include "AppSignal.h"
 #include "SFM.h"
 #include "SPM.h"
-#include "CM.h"
+#include "CSM.h"
 #include "ISC.h"
 #include "TMS.h"
 #include "BCUCal.h"

+ 182 - 180
inc/EmbeddedCoder_inc/BCUDisp.h

@@ -1,180 +1,182 @@
-
-#include "rtwtypes.h"
-#include "BCUCal.h"
-
-extern uint16_T appv_V_cellU[cmnc_num_cellUNumMax];                        /* 静态电压 */
-extern uint8_T appd_st_preCyc;
-
-extern boolean_T  spmd_flg_firstRun;
-extern boolean_T  socd_flg_firstRun;
-extern boolean_T  sohd_flg_firstRun;
-extern boolean_T  blcd_flg_firstRun;
-extern boolean_T  sord_flg_firstRun;
-extern boolean_T  soed_flg_firstRun;
-extern boolean_T  iscd_flg_firstRun;
-extern boolean_T  pimd_flg_firstRun;
-extern boolean_T  sfmd_flg_firstRun;
-extern boolean_T  tmsd_flg_firstRun;
-extern boolean_T  cdmd_flg_firstRun;
-extern boolean_T  cmd_flg_firstRun;
-extern boolean_T sopd_flg_firstRun;
-
-extern uint16_T blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
-extern uint16_T blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
-extern uint32_T blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
-extern uint32_T blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
-extern boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组); */
-
-extern boolean_T ihd_flg_HVILFlt;                        /* 保护板上传的高压互锁故障 */
-extern boolean_T ihd_flg_DTCClear;                       /* 上位机发送的故障清楚指令;*/
-extern uint8_T ihd_st_authFaild;                         /* 底层诊断的认证失败故障;*/
-extern int16_T ihd_I_curr;                               /*电池包电流; */
-extern uint8_T ihd_st_chrgConnect;                       /*充电器连接状态; */
-extern uint16_T ihd_P_gas;                               /*气体浓度 */
-extern uint16_T ihd_T_ACPlugT;                           /*慢充插头温度 +40 */
-extern uint16_T ihd_T_DCPlugT;                           /*快充插头温度+40 */
-extern uint16_T ihd_T_bdtemp;                            /*板子温度 */
-extern uint16_T ihd_T_heatPanT1;                         /*加热板温度1+40 */
-extern uint16_T ihd_T_heatPanT2;                         /*加热板温度2 +40 */
-extern uint16_T ihd_T_mosT;                              /*Mos温度+40 */
-extern boolean_T ihd_flg_EESaveFlt;                      /*EE存储故障 */
-extern boolean_T ihd_flg_battULowFlt;                    /*保护板上传的总压欠压故障; */
-extern boolean_T ihd_flg_battUOverFlt;                   /*保护板上传的总压过压故障; */
-extern boolean_T ihd_flg_cellULowFlt;                    /*保护板上传的单体欠压故障; */
-extern boolean_T ihd_flg_cellUOverFlt;                   /*保护板上传的单体过压故障; */
-extern boolean_T ihd_flg_chrgCurrOverFlt;                /*保护板上传的充电过流故障; */
-extern boolean_T ihd_flg_chrgModTLowFlt;                 /*保护板上传的充电模组温度过低故障; */
-extern boolean_T ihd_flg_chrgModTOverFlt;                /*保护板上传的充电模组温度过高故障; */
-extern boolean_T ihd_flg_chrgMosClosFlt;                 /*充电Mos失效 */
-extern boolean_T ihd_flg_chrgMosTOverFlt;                /*保护板上传的充电Mos温度过高故障; */
-extern boolean_T ihd_flg_currOpenFlt;                    /*保护板上传的电流开路故障 */
-extern boolean_T ihd_flg_disChrgCurrOverFlt;             /*保护板上传的放电过流故障; */
-extern boolean_T ihd_flg_disChrgModTLowFlt;              /*保护板上传的放电模组温度过低故障; */
-extern boolean_T ihd_flg_disChrgModTOverFlt;             /*保护板上传的放电模组温度过高故障; */
-extern boolean_T ihd_flg_disChrgMosClosFlt;              /*放电Mos失效 */
-extern boolean_T ihd_flg_disChrgMosTOverFlt;             /*保护板上传的放电Mos温度过高故障; */
-extern boolean_T ihd_flg_urtRecFlt;                      /*内网通讯故障 */
-extern uint16_T ihd_pct_soc;                             /*保护板SOC */
-extern uint16_T ihd_pct_soh;                             /*保护板SOH */
-extern uint8_T ihd_st_workStat;                          /*电池工作状态 */
-extern uint16_T ihd_tm_parkTime;                         /*驻车时间; */
-extern uint16_T ihv_T_modT[cmnc_num_modTNumMax];                           /*模组温度(数组)+40 */
-extern uint16_T ihv_V_cellU[cmnc_num_cellUNumMax];                         /*电池单体电压(数组); */
-extern boolean_T ihd_st_chrgMosControl;    
-extern boolean_T ihd_st_disChrgMosControl; 
-extern boolean_T ihd_st_relayControl;    
-extern uint8_T ihd_st_heatForceControl;
-extern uint8_T ihd_st_EOLState;
-extern boolean_T ihd_flg_urtRecFlg;
-extern uint8_T ihd_st_reSet;
-
-extern int16_T sfmd_I_curr;                              /*处理后整包电流 */
-extern uint16_T sfmd_T_modTMax;                          /*处理后模组温度最小 */
-extern uint16_T sfmd_T_modTMin;                          /*处理后模组温度最大 */
-extern uint16_T sfmd_idx_modTMax;                          /*处理后模组温度最小 */
-extern uint16_T sfmd_idx_modTMin;                          /*处理后模组温度最大 */
-extern uint16_T sfmd_V_cellUAvrg;                        /*处理后单体电压平均 */
-extern uint16_T sfmd_V_cellUMax;                         /*处理后单体电压最大 */
-extern uint16_T sfmd_V_cellUMin;                         /*处理后单体电压最小 */
-extern uint16_T sfmd_idx_cellUMin;
-extern uint16_T sfmd_idx_cellUMax;
-extern boolean_T sfmd_flg_cellUDisable;                  /*单体电压有效标志位 ; 0为有效;1为无效 */
-extern boolean_T sfmd_flg_currDisable;                   /*电流有效标志位 ; 0为有效;1为无效 */
-extern boolean_T sfmd_flg_modTDisable;                   /*模组温度有效标志位 ; 0为有效;1为无效 */
-extern uint16_T sfmd_num_fltNum;                         /*故障数量 */
-extern uint8_T sfmd_st_fltAct;                           /*故障禁止指令 */
-extern uint8_T sfmd_st_fltLevel;                         /*故障等级 */
-extern uint16_T sfmv_T_modT[cmnc_num_modTNumMax];                          /*处理后模组温度 */
-extern uint16_T sfmv_V_cellU[cmnc_num_cellUNumMax];                        /*处理后单体电压 */
-extern uint16_T sfmv_idx_fltCode[20];                    /*诊断故障码(数组) */
-extern uint16_T sfmd_V_battU;                            /* 处理过后的总电压 */
-extern boolean_T sfmd_flg_mainCirClosFltEi;              /*主回路常闭故障读取量 */  
-extern boolean_T sfmd_flg_mainCirClosFltEo;              /*主回路常闭故障写入量 */  
-extern boolean_T sfmd_flg_heatCirClosFltEi;              /*加热回路常闭故障读取量 */  
-extern boolean_T sfmd_flg_heatCirClosFltEo;              /*加热回路常闭故障写入量 */  
-extern boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故障读取量 */  
-extern boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
-extern boolean_T sfmd_flg_heatRunFltEi;
-extern boolean_T sfmd_flg_heatRunFltEo;
-extern boolean_T sfmd_flg_iscFltEi;
-extern boolean_T sfmd_flg_iscFltEo;
-
-extern uint16_T socd_pct_vcuSoc;                          /*vcuSOC; */
-extern uint16_T socd_pct_ahSoc;                          /*安时SOC; */
-extern uint16_T socd_pct_estSoc;                         /*估算SOC;*/
-extern uint16_T socd_flg_EEsave;                         /*实时存储标志位;*/
-extern uint16_T socd_pct_ekfSoc;                         /*EKFSOC;*/
-extern uint16_T socd_pct_battSoc;                        /*电池真实SOC; */
-extern uint16_T socd_pct_battSocEi;                      /*电池真实SOC 读取量; */
-extern uint16_T socd_pct_battSocEo;                      /*电池真实SOC 写入量; */
-extern uint16_T socd_pct_bcuSoc;                         /*电池显示SOC; */
-extern uint16_T socd_pct_bcuSocEi;                       /*电池显示SOC读取量; */
-extern uint16_T socd_pct_bcuSocEo;                       /*电池显示SOC写入量; */
-extern uint16_T socd_pct_bcuSoc_Delay;                   /*电池显示SOC延时; */
-extern uint16_T socv_pct_cellSoc[cmnc_num_cellUNumMax];
-extern uint16_T socd_pct_cellBattSoc;
-extern boolean_T socd_flg_cellSocDisable;
-
-extern uint16_T sohd_Q_chrgEi;                           /*充入容量读取量; */
-extern uint16_T sohd_Q_chrgEo;                           /*充入容量写入量; */
-extern boolean_T sohd_flg_chrgEndEi;                     /*充电结束标志位读取量; */
-extern boolean_T sohd_flg_chrgEndEo;                     /*充电结束标志位写入量; */
-extern uint16_T sohd_pct_bcuSoh;                         /*电池SOH; */
-extern uint16_T sohd_pct_bcuSoh_Delay;                   /*电池SOH延时; */
-extern uint16_T sohd_tm_chrgStartStatEi;                 /*充电前静置时间读取量; */
-extern uint16_T sohd_tm_chrgStartStatEo;                 /*充电前静置时间写入量; */
-extern uint16_T sohv_Q_cellCap[cmnc_num_cellUNumMax];                      /*单体容量 */
-extern uint16_T sohv_Q_cellCapArrEi[cmnc_num_cellUNumMax];                 /*单体容量(数组) 读取量 */
-extern uint16_T sohv_Q_cellCapArrEo[cmnc_num_cellUNumMax];                 /*单体容量(数组) 写入量 */
-extern uint16_T sohv_Q_packCapArrEi[10];                 /*10次整包容量(数组)读取量; */
-extern uint16_T sohv_Q_packCapArrEo[10];                 /*10次整包容量(数组)写入量; */
-extern uint16_T sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
-extern uint16_T sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
-
-extern uint16_T soed_E_nowEng;
-extern uint16_T soed_pct_nowStat;
-extern uint16_T soed_E_fullEng;
-
-extern uint16_T sopd_P_chrgPMax;
-extern uint16_T sopd_P_disChrgPMax;
-extern int16_T sopd_I_chrgCurrMax;
-extern int16_T sopd_I_disChrgCurrMax;
-
-extern uint16_T sorv_ohm_cellREi[cmnc_num_cellUNumMax];
-extern uint16_T sorv_ohm_cellREo[cmnc_num_cellUNumMax];
-extern uint16_T sorv_ohm_cellR[cmnc_num_cellUNumMax];
-
-extern boolean_T iscd_flg_flt;
-extern uint16_T iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
-extern uint32_T iscd_tm_totalEi;
-extern uint16_T iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
-extern uint32_T iscd_tm_totalEo;
-
-extern uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
-
-extern uint8_T cmd_st_chrgMod;                           /* 充电模式  */
-extern uint8_T cmd_st_chrgSt;                            /* 充电状态  */
-extern int16_T cmd_I_chrgCurrReq;                       /* 充电需求电流  */
-extern uint8_T cmd_idx_chrgEndReason;                    /* 充电结束原因  */
-
-extern uint16_T cand_idx_cellNr;                          /*循环发送的单体编号; */
-extern uint16_T cand_Q_cellCap;                          /*循环发送的单体容量; */
-extern uint16_T cand_V_chrgStartStat;                    /*循环发送的充电前单体电压; */
-extern uint16_T cand_Q_blcReqCp;                            /*循环发送的单体需求均衡容量; */
-extern uint16_T cand_Q_blcTotalCp;                          /*循环发送的单体累计均衡容量; */
-
-extern int16_T  cdmv_V_deltOCV[cmnc_num_cellUNumMax];
-extern int16_T  cdmv_ohm_deltR[cmnc_num_cellUNumMax];
-extern boolean_T cdmd_flg_deltOCVDisable;
-
-extern uint16_T pimd_V_ocv;
-extern uint16_T pimd_R_ohm;
-extern uint16_T pimd_R_polar;
-extern uint16_T pimd_F_polar;
-
-extern uint16_T test_cellCap[cmnc_num_cellUNumMax];
-extern uint16_T test_countEn;
-extern int16_T test_deltU;
-
-
-

+
+#include "rtwtypes.h"
+#include "BCUCal.h"
+
+extern uint16_T appv_V_cellU[cmnc_num_cellUNumMax];                        /* 静态电压 */
+extern uint8_T appd_st_preCyc;
+
+extern boolean_T  spmd_flg_firstRun;
+extern boolean_T  socd_flg_firstRun;
+extern boolean_T  sohd_flg_firstRun;
+extern boolean_T  blcd_flg_firstRun;
+extern boolean_T  sord_flg_firstRun;
+extern boolean_T  soed_flg_firstRun;
+extern boolean_T  iscd_flg_firstRun;
+extern boolean_T  pimd_flg_firstRun;
+extern boolean_T  sfmd_flg_firstRun;
+extern boolean_T  tmsd_flg_firstRun;
+extern boolean_T  cdmd_flg_firstRun;
+extern boolean_T  csmd_flg_firstRun;
+extern boolean_T  sopd_flg_firstRun;
+
+extern uint16_T  blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
+extern uint16_T  blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
+extern uint32_T  blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
+extern uint32_T  blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
+extern boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组); */
+
+extern boolean_T ihd_flg_HVILFlt;                        /* 保护板上传的高压互锁故障 */
+extern boolean_T ihd_flg_DTCClear;                       /* 上位机发送的故障清楚指令;*/
+extern uint8_T   ihd_st_authFaild;                         /* 底层诊断的认证失败故障;*/
+extern int16_T   ihd_I_curr;                               /*电池包电流; */
+extern uint8_T   ihd_st_chrgConnect;                       /*充电器连接状态; */
+extern uint16_T  ihd_P_gas;                               /*气体浓度 */
+extern uint16_T  ihd_T_ACPlugT;                           /*慢充插头温度 +40 */
+extern uint16_T  ihd_T_DCPlugT;                           /*快充插头温度+40 */
+extern uint16_T  ihd_T_bdtemp;                            /*板子温度 */
+extern uint16_T  ihd_T_heatPanT1;                         /*加热板温度1+40 */
+extern uint16_T  ihd_T_heatPanT2;                         /*加热板温度2 +40 */
+extern uint16_T  ihd_T_mosT;                              /*Mos温度+40 */
+extern boolean_T ihd_flg_EESaveFlt;                      /*EE存储故障 */
+extern boolean_T ihd_flg_battULowFlt;                    /*保护板上传的总压欠压故障; */
+extern boolean_T ihd_flg_battUOverFlt;                   /*保护板上传的总压过压故障; */
+extern boolean_T ihd_flg_cellULowFlt;                    /*保护板上传的单体欠压故障; */
+extern boolean_T ihd_flg_cellUOverFlt;                   /*保护板上传的单体过压故障; */
+extern boolean_T ihd_flg_chrgCurrOverFlt;                /*保护板上传的充电过流故障; */
+extern boolean_T ihd_flg_chrgModTLowFlt;                 /*保护板上传的充电模组温度过低故障; */
+extern boolean_T ihd_flg_chrgModTOverFlt;                /*保护板上传的充电模组温度过高故障; */
+extern boolean_T ihd_flg_chrgMosClosFlt;                 /*充电Mos失效 */
+extern boolean_T ihd_flg_chrgMosTOverFlt;                /*保护板上传的充电Mos温度过高故障; */
+extern boolean_T ihd_flg_currOpenFlt;                    /*保护板上传的电流开路故障 */
+extern boolean_T ihd_flg_disChrgCurrOverFlt;             /*保护板上传的放电过流故障; */
+extern boolean_T ihd_flg_disChrgModTLowFlt;              /*保护板上传的放电模组温度过低故障; */
+extern boolean_T ihd_flg_disChrgModTOverFlt;             /*保护板上传的放电模组温度过高故障; */
+extern boolean_T ihd_flg_disChrgMosClosFlt;              /*放电Mos失效 */
+extern boolean_T ihd_flg_disChrgMosTOverFlt;             /*保护板上传的放电Mos温度过高故障; */
+extern boolean_T ihd_flg_urtRecFlt;                      /*内网通讯故障 */
+extern uint16_T  ihd_pct_soc;                             /*保护板SOC */
+extern uint16_T  ihd_pct_soh;                             /*保护板SOH */
+extern uint8_T   ihd_st_workStat;                          /*电池工作状态 */
+extern uint16_T  ihd_tm_parkTime;                         /*驻车时间; */
+extern uint16_T  ihv_T_modT[cmnc_num_modTNumMax];                           /*模组温度(数组)+40 */
+extern uint16_T  ihv_V_cellU[cmnc_num_cellUNumMax];                         /*电池单体电压(数组); */
+extern boolean_T ihd_st_chrgMosControl;    
+extern boolean_T ihd_st_disChrgMosControl; 
+extern boolean_T ihd_st_relayControl;    
+extern uint8_T   ihd_st_heatForceControl;
+extern uint8_T   ihd_st_EOLState;
+extern boolean_T ihd_flg_urtRecFlg;
+extern uint8_T   ihd_st_reSet;
+
+extern int16_T   sfmd_I_curr;                              /*处理后整包电流 */
+extern uint16_T  sfmd_T_modTMax;                          /*处理后模组温度最小 */
+extern uint16_T  sfmd_T_modTMin;                          /*处理后模组温度最大 */
+extern uint16_T  sfmd_idx_modTMax;                          /*处理后模组温度最小 */
+extern uint16_T  sfmd_idx_modTMin;                          /*处理后模组温度最大 */
+extern uint16_T  sfmd_V_cellUAvrg;                        /*处理后单体电压平均 */
+extern uint16_T  sfmd_V_cellUMax;                         /*处理后单体电压最大 */
+extern uint16_T  sfmd_V_cellUMin;                         /*处理后单体电压最小 */
+extern uint16_T  sfmd_idx_cellUMin;
+extern uint16_T  sfmd_idx_cellUMax;
+extern boolean_T sfmd_flg_cellUInval;                  /*单体电压有效标志位 ; 0为有效;1为无效 */
+extern boolean_T sfmd_flg_currInval;                   /*电流有效标志位 ; 0为有效;1为无效 */
+extern boolean_T sfmd_flg_modTInval;                   /*模组温度有效标志位 ; 0为有效;1为无效 */
+extern uint16_T  sfmd_num_fltNum;                         /*故障数量 */
+extern uint8_T   sfmd_st_fltAct;                           /*故障禁止指令 */
+extern uint8_T   sfmd_st_fltLevel;                         /*故障等级 */
+extern uint16_T  sfmv_T_modT[cmnc_num_modTNumMax];                          /*处理后模组温度 */
+extern uint16_T  sfmv_V_cellU[cmnc_num_cellUNumMax];                        /*处理后单体电压 */
+extern uint16_T  sfmv_idx_fltCode[20];                    /*诊断故障码(数组) */
+extern uint16_T  sfmd_V_battU;                            /* 处理过后的总电压 */
+extern boolean_T sfmd_flg_mainCirClosFltEi;              /*主回路常闭故障读取量 */  
+extern boolean_T sfmd_flg_mainCirClosFltEo;              /*主回路常闭故障写入量 */  
+extern boolean_T sfmd_flg_heatCirClosFltEi;              /*加热回路常闭故障读取量 */  
+extern boolean_T sfmd_flg_heatCirClosFltEo;              /*加热回路常闭故障写入量 */  
+extern boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故障读取量 */  
+extern boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
+extern boolean_T sfmd_flg_heatRunFltEi;
+extern boolean_T sfmd_flg_heatRunFltEo;
+extern boolean_T sfmd_flg_iscFltEi;
+extern boolean_T sfmd_flg_iscFltEo;
+
+extern uint16_T  socd_pct_vcuSoc;                          /*vcuSOC; */
+extern uint16_T  socd_pct_ahSoc;                          /*安时SOC; */
+extern uint16_T  socd_pct_estSoc;                         /*估算SOC;*/
+extern uint16_T  socd_flg_EEsave;                         /*实时存储标志位;*/
+extern uint16_T  socd_pct_ekfSoc;                         /*EKFSOC;*/
+extern uint16_T  socd_pct_battSoc;                        /*电池真实SOC; */
+extern uint16_T  socd_pct_battSocEi;                      /*电池真实SOC 读取量; */
+extern uint16_T  socd_pct_battSocEo;                      /*电池真实SOC 写入量; */
+extern uint16_T  socd_pct_bcuSoc;                         /*电池显示SOC; */
+extern uint16_T  socd_pct_bcuSocEi;                       /*电池显示SOC读取量; */
+extern uint16_T  socd_pct_bcuSocEo;                       /*电池显示SOC写入量; */
+extern uint16_T  socv_pct_cellSoc[cmnc_num_cellUNumMax];
+extern uint16_T  socd_pct_cellBattSoc;
+extern boolean_T socd_flg_cellSocDisable;
+
+extern uint16_T  sohd_Q_chrgEi;                           /*充入容量读取量; */
+extern uint16_T  sohd_Q_chrgEo;                           /*充入容量写入量; */
+extern boolean_T sohd_flg_chrgEndEi;                     /*充电结束标志位读取量; */
+extern boolean_T sohd_flg_chrgEndEo;                     /*充电结束标志位写入量; */
+extern uint16_T  sohd_pct_bcuSoh;                         /*电池SOH; */
+extern uint16_T  sohd_tm_chrgStartStatEi;                 /*充电前静置时间读取量; */
+extern uint16_T  sohd_tm_chrgStartStatEo;                 /*充电前静置时间写入量; */
+extern uint16_T  sohv_Q_cellCap[cmnc_num_cellUNumMax];                      /*单体容量 */
+extern uint16_T  sohv_Q_cellCapArrEi[cmnc_num_cellUNumMax];                 /*单体容量(数组) 读取量 */
+extern uint16_T  sohv_Q_cellCapArrEo[cmnc_num_cellUNumMax];                 /*单体容量(数组) 写入量 */
+extern uint16_T  sohv_Q_packCapArrEi[10];                 /*10次整包容量(数组)读取量; */
+extern uint16_T  sohv_Q_packCapArrEo[10];                 /*10次整包容量(数组)写入量; */
+extern uint16_T  sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
+extern uint16_T  sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
+
+extern uint16_T soed_E_nowEng;
+extern uint16_T soed_pct_nowStat;
+extern uint16_T soed_E_fullEng;
+
+extern uint16_T sopd_P_chrgPMax;
+extern uint16_T sopd_P_disChrgPMax;
+extern int16_T  sopd_I_chrgCurrMax;
+extern int16_T  sopd_I_disChrgCurrMax;
+
+extern uint16_T sorv_R_cellEi[cmnc_num_cellUNumMax];
+extern uint16_T sorv_R_cellEo[cmnc_num_cellUNumMax];
+extern uint16_T sorv_R_cell[cmnc_num_cellUNumMax];
+
+extern boolean_T iscd_flg_flt;
+extern uint16_T  iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
+extern uint32_T  iscd_tm_totalEi;
+extern uint16_T  iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
+extern uint32_T  iscd_tm_totalEo;
+
+extern uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
+
+extern uint8_T csmd_st_chrgMod;                           /* 充电模式  */
+extern uint8_T csmd_st_chrgSt;                            /* 充电状态  */
+extern int16_T csmd_I_chrgCurrReq;                       /* 充电需求电流  */
+extern uint8_T csmd_idx_chrgEndReason;                    /* 充电结束原因  */
+
+extern uint16_T cand_idx_cellNr;                          /*循环发送的单体编号; */
+extern uint16_T cand_Q_cellCap;                          /*循环发送的单体容量; */
+extern uint16_T cand_V_chrgStartStat;                    /*循环发送的充电前单体电压; */
+extern uint16_T cand_Q_blcReqCp;                            /*循环发送的单体需求均衡容量; */
+extern uint16_T cand_Q_blcTotalCp;                          /*循环发送的单体累计均衡容量; */
+
+extern int16_T   cdmv_V_deltOCV[cmnc_num_cellUNumMax];
+extern int16_T   cdmv_R_deltOhm[cmnc_num_cellUNumMax];
+extern boolean_T cdmv_flg_inval[cmnc_num_cellUNumMax];
+
+
+extern uint16_T  pimd_V_ocv;
+extern uint16_T  pimd_R_ohm;
+extern uint16_T  pimd_R_polar;
+extern uint16_T  pimd_F_polar;
+extern uint16_T  pimv_V_cellOcv[cmnc_num_cellUNumMax];
+extern uint16_T  pimv_R_cellOhm[cmnc_num_cellUNumMax];
+extern uint16_T  pimd_pct_battSoc;
+extern uint16_T  pimv_pct_cellSoc[cmnc_num_cellUNumMax];
+extern boolean_T pimv_flg_inval[cmnc_num_cellUNumMax];
+
+extern uint16_T test_cellCap[cmnc_num_cellUNumMax];
+extern uint16_T test_countEn;
+extern int16_T  test_deltU;
+extern int16_T test_data[200][3];

+ 2 - 2
inc/EmbeddedCoder_inc/CM.h → inc/EmbeddedCoder_inc/CSM.h

@@ -4,7 +4,7 @@
 #include "numeric.h"
 #include "funlib.h"
 
-extern void CM_Init(void);
-extern void CM(void);
+extern void CSM_Init(void);
+extern void CSM(void);
 
 

+ 8 - 8
src/AppTaskTcp.c

@@ -577,16 +577,16 @@ static void TcpDataInfoAssembleSend()
         }
         else
         {
-            sprintf((char *)rbuf, "B-%d,%d,%d,%d,%d,%d,%d,,\
-                                %d,%d,%d,%d,%d,,\
+            sprintf((char *)rbuf, "B-%d,%d,%d,%d,,\
                                 %d,%d,%d,%d,%d,%d,,\
+                                %d,%d,%d,%d,,\
                                 %d,%d,%d,%d,%d,,\
-                                %d,%d,%d,%d",
-                    socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_vcuSoc, socd_pct_cellBattSoc, sohv_Q_packCapArrEo[9], cdmv_ohm_deltR[cand_idx_cellNr - 1],
-                    sfmd_I_curr, maxCellVol, minCellVol, sfmd_V_cellUAvrg, sfmv_V_cellU[1],
-                    cand_idx_cellNr, cand_Q_cellCap, cand_V_chrgStartStat, ihd_tm_parkTime, sohd_Q_chrgEo, sohd_flg_chrgEndEo,
-                    pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar,test_deltU,
-                    sopd_I_chrgCurrMax,sopd_P_chrgPMax,sopd_I_disChrgCurrMax,sopd_P_disChrgPMax);
+                                %d,%d,%d,%d,%d,%d",
+                    socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_vcuSoc,
+                    sfmd_I_curr, maxCellVol, minCellVol, sfmv_V_cellU[0], sfmv_V_cellU[1], sfmv_V_cellU[2],
+                    cand_idx_cellNr, cand_Q_cellCap, ihd_tm_parkTime, sohd_Q_chrgEo,
+                    pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar,
+                    pimv_V_cellOcv[0],pimv_V_cellOcv[1],pimv_V_cellOcv[2],pimv_R_cellOhm[0],pimv_R_cellOhm[1],pimv_R_cellOhm[2]);
         }
         Debugcounter++;
         if (Debugcounter > 100)

+ 1 - 1
src/AppTaskUart.c

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-16 21:43:30
+ * @LastEditTime : 2021-11-16 21:38:19
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskUart.c
  */

+ 4 - 4
src/EmbeddedCoder_src/BCU.c

@@ -51,7 +51,7 @@ void BCU(void)
             memcpy(sohv_Q_packCapArrEi, BcuDataInfo.sohv_Q_packCapArrE, sizeof(sohv_Q_packCapArrEi));
             memcpy(sohv_Q_cellCapArrEi, BcuDataInfo.sohv_Q_cellCapArrE, sizeof(sohv_Q_cellCapArrEi));
             memcpy(iscv_Q_remainCpEi, BcuDataInfo.iscv_Q_remainCpE, sizeof(iscv_Q_remainCpEi));
-            memcpy(sorv_ohm_cellREi, BcuDataInfo.sorv_ohm_cellRE, sizeof(sorv_ohm_cellREi));
+            memcpy(sorv_R_cellEi, BcuDataInfo.sorv_ohm_cellRE, sizeof(sorv_R_cell));
             iscd_tm_totalEi = BcuDataInfo.iscd_tm_totalE;
             sfmd_flg_mainCirClosFltEi = BcuDataInfo.sfmd_flg_mainCirClosFltE;
             sfmd_flg_heatCirClosFltEi = BcuDataInfo.sfmd_flg_heatCirClosFltE;
@@ -135,7 +135,7 @@ void BCU(void)
                     //调用算法
                     SFM();
                     TMS();
-                    CM();
+                    CSM();
                     SPM();
                     ISC();
                     //实时存储
@@ -205,7 +205,7 @@ void BCU_Init(void)
 {
     SFM_Init();
     TMS_Init();
-    CM_Init();
+    CSM_Init();
     SPM_Init();
     ISC_Init();
 }
@@ -238,7 +238,7 @@ void BCUEEDataSave(void)
     memcpy(BcuDataInfo.sohv_Q_packCapArrE, sohv_Q_packCapArrEo, sizeof(sohv_Q_packCapArrEo));
     memcpy(BcuDataInfo.sohv_Q_cellCapArrE, sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
     memcpy(BcuDataInfo.iscv_Q_remainCpE, iscv_Q_remainCpEo, sizeof(iscv_Q_remainCpEo));
-    memcpy(BcuDataInfo.sorv_ohm_cellRE, sorv_ohm_cellREo, sizeof(sorv_ohm_cellREo));
+    memcpy(BcuDataInfo.sorv_ohm_cellRE, sorv_R_cellEo, sizeof(sorv_R_cellEo));
     BcuDataInfo.iscd_tm_totalE = iscd_tm_totalEo;
     BcuDataInfo.sfmd_flg_mainCirClosFltE = sfmd_flg_mainCirClosFltEo;
     BcuDataInfo.sfmd_flg_heatCirClosFltE = sfmd_flg_heatCirClosFltEo;

+ 386 - 180
src/EmbeddedCoder_src/BCUDisp.c

@@ -1,180 +1,386 @@
-
-
-#include "BCUDisp.h"
-
-uint16_T appv_V_cellU[cmnc_num_cellUNumMax];
-uint8_T appd_st_preCyc;
-boolean_T  spmd_flg_firstRun;
-boolean_T  socd_flg_firstRun;
-boolean_T  sohd_flg_firstRun;
-boolean_T  blcd_flg_firstRun;
-boolean_T  sord_flg_firstRun;
-boolean_T  soed_flg_firstRun;
-boolean_T  iscd_flg_firstRun;
-boolean_T  pimd_flg_firstRun;
-boolean_T  sfmd_flg_firstRun;
-boolean_T  tmsd_flg_firstRun;
-boolean_T  cdmd_flg_firstRun;
-boolean_T sopd_flg_firstRun;
-
-boolean_T  cmd_flg_firstRun;
-
-uint16_T blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
-uint16_T blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
-uint32_T blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
-uint32_T blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
-boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组) */
-
-boolean_T ihd_flg_HVILFlt;
-boolean_T ihd_flg_DTCClear;
-uint8_T ihd_st_authFaild;                         
-int16_T ihd_I_curr;                               /*电池包电流; */
-uint8_T ihd_st_chrgConnect;                       /*充电器连接状态; */
-uint16_T ihd_P_gas;                               /*气体浓度 */
-uint16_T ihd_T_ACPlugT;                           /*慢充插头温度 +40 */
-uint16_T ihd_T_DCPlugT;                           /*快充插头温度+40 */
-uint16_T ihd_T_bdtemp;                            /*板子温度 */
-uint16_T ihd_T_heatPanT1;                         /*加热板温度1+40 */
-uint16_T ihd_T_heatPanT2;                         /*加热板温度2 +40 */
-uint16_T ihd_T_mosT;                              /*Mos温度+40 */
-boolean_T ihd_flg_EESaveFlt;                      /*EE存储故障 */
-boolean_T ihd_flg_battULowFlt;                    /*保护板上传的总压欠压故障; */
-boolean_T ihd_flg_battUOverFlt;                   /*保护板上传的总压过压故障; */
-boolean_T ihd_flg_cellULowFlt;                    /*保护板上传的单体欠压故障; */
-boolean_T ihd_flg_cellUOverFlt;                   /*保护板上传的单体过压故障; */
-boolean_T ihd_flg_chrgCurrOverFlt;                /*保护板上传的充电过流故障; */
-boolean_T ihd_flg_chrgModTLowFlt;                 /*保护板上传的充电模组温度过低故障; */
-boolean_T ihd_flg_chrgModTOverFlt;                /*保护板上传的充电模组温度过高故障; */
-boolean_T ihd_flg_chrgMosClosFlt;                 /*充电Mos失效 */
-boolean_T ihd_flg_chrgMosTOverFlt;                /*保护板上传的充电Mos温度过高故障; */
-boolean_T ihd_flg_currOpenFlt;                    /*保护板上传的电流开路故障 */
-boolean_T ihd_flg_disChrgCurrOverFlt;             /*保护板上传的放电过流故障; */
-boolean_T ihd_flg_disChrgModTLowFlt;              /*保护板上传的放电模组温度过低故障; */
-boolean_T ihd_flg_disChrgModTOverFlt;             /*保护板上传的放电模组温度过高故障; */
-boolean_T ihd_flg_disChrgMosClosFlt;              /*放电Mos失效 */
-boolean_T ihd_flg_disChrgMosTOverFlt;             /*保护板上传的放电Mos温度过高故障; */
-boolean_T ihd_flg_urtRecFlt;                      /*内网通讯故障 */
-uint16_T ihd_pct_soc;                             /*保护板SOC */
-uint16_T ihd_pct_soh;                             /*保护板SOH */
-uint8_T ihd_st_workStat;                          /*电池工作状态 */
-uint16_T ihd_tm_parkTime;                         /*驻车时间; */
-uint16_T ihv_T_modT[cmnc_num_modTNumMax];         /*模组温度(数组)+40 */
-uint16_T ihv_V_cellU[cmnc_num_cellUNumMax];       /*电池单体电压(数组); */
-boolean_T ihd_st_chrgMosControl;                  /* Mos控制指令 ;0-断开,1-导通*/
-boolean_T ihd_st_disChrgMosControl; 
-boolean_T ihd_st_relayControl;    
-uint8_T ihd_st_heatForceControl;             
-uint8_T ihd_st_EOLState;                   
-boolean_T ihd_flg_urtRecFlg;
-uint8_T ihd_st_reSet;
-
-int16_T sfmd_I_curr;                              /*处理后整包电流 */
-uint16_T sfmd_T_modTMax;                          /*处理后模组温度最小 */
-uint16_T sfmd_T_modTMin;                          /*处理后模组温度最大 */
-uint16_T sfmd_idx_modTMax;                          /*处理后模组温度最小 */
-uint16_T sfmd_idx_modTMin;                          /*处理后模组温度最大 */
-uint16_T sfmd_V_cellUAvrg;                        /*处理后单体电压平均 */
-uint16_T sfmd_V_cellUMax;                         /*处理后单体电压最大 */
-uint16_T sfmd_V_cellUMin;                         /*处理后单体电压最小 */
-uint16_T sfmd_idx_cellUMin;
-uint16_T sfmd_idx_cellUMax;
-boolean_T sfmd_flg_cellUDisable;                  /*单体电压有效标志位 ; 0为有效;1为无效 */
-boolean_T sfmd_flg_currDisable;                   /*电流有效标志位 ; 0为有效;1为无效 */
-boolean_T sfmd_flg_modTDisable;                   /*模组温度有效标志位 ; 0为有效;1为无效 */
-uint16_T sfmd_num_fltNum;                         /*故障数量 */
-uint8_T sfmd_st_fltAct;                           /*故障禁止指令 */
-uint8_T sfmd_st_fltLevel;                         /*故障等级 */
-uint16_T sfmv_T_modT[cmnc_num_modTNumMax];                          /*处理后模组温度 */
-uint16_T sfmv_V_cellU[cmnc_num_cellUNumMax];                        /*处理后单体电压 */
-uint16_T sfmv_idx_fltCode[20];                    /*诊断故障码(数组) */
-uint16_T sfmd_V_battU;  
-boolean_T sfmd_flg_mainCirClosFltEi;              /*主回路常闭故障读取量 */  
-boolean_T sfmd_flg_mainCirClosFltEo;              /*主回路常闭故障写入量 */  
-boolean_T sfmd_flg_heatCirClosFltEi;              /*加热回路常闭故障读取量 */  
-boolean_T sfmd_flg_heatCirClosFltEo;              /*加热回路常闭故障写入量 */  
-boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故障读取量 */  
-boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
-boolean_T sfmd_flg_heatRunFltEi;
-boolean_T sfmd_flg_heatRunFltEo;
-boolean_T sfmd_flg_iscFltEi;
-boolean_T sfmd_flg_iscFltEo;
-
-
-uint16_T socd_pct_vcuSoc;                          /*vcuSOC; */
-uint16_T socd_pct_ahSoc;                          /*安时SOC; */
-uint16_T socd_pct_estSoc;                         /*估算SOC;*/
-uint16_T socd_flg_EEsave;                         /*实时存储标志位;*/
-uint16_T socd_pct_ekfSoc;                         /*EKFSOC;*/
-uint16_T socd_pct_battSoc;                        /*电池真实SOC; */
-uint16_T socd_pct_battSocEi;                      /*电池真实SOC 读取量; */
-uint16_T socd_pct_battSocEo;                      /*电池真实SOC 写入量; */
-uint16_T socd_pct_bcuSoc;                         /*电池显示SOC; */
-uint16_T socd_pct_bcuSocEi;                       /*电池显示SOC读取量; */
-uint16_T socd_pct_bcuSocEo;                       /*电池显示SOC写入量; */
-uint16_T socd_pct_bcuSoc_Delay;                   /*电池显示SOC延时; */
-uint16_T socv_pct_cellSoc[cmnc_num_cellUNumMax];
-uint16_T socd_pct_cellBattSoc;
-boolean_T socd_flg_cellSocDisable;
-
-uint16_T sohd_Q_chrgEi;                           /*充入容量读取量; */
-uint16_T sohd_Q_chrgEo;                           /*充入容量写入量; */
-boolean_T sohd_flg_chrgEndEi;                     /*充电结束标志位读取量; */
-boolean_T sohd_flg_chrgEndEo;                     /*充电结束标志位写入量; */
-uint16_T sohd_pct_bcuSoh;                         /*电池SOH; */
-uint16_T sohd_pct_bcuSoh_Delay;                   /*电池SOH延时; */
-uint16_T sohd_tm_chrgStartStatEi;                 /*充电前静置时间读取量; */
-uint16_T sohd_tm_chrgStartStatEo;                 /*充电前静置时间写入量; */
-uint16_T sohv_Q_cellCap[cmnc_num_cellUNumMax];                      /*单体容量 */
-uint16_T sohv_Q_cellCapArrEi[cmnc_num_cellUNumMax];                 /*单体容量(数组) 读取量 */
-uint16_T sohv_Q_cellCapArrEo[cmnc_num_cellUNumMax];                 /*单体容量(数组) 写入量 */
-uint16_T sohv_Q_packCapArrEi[10];                 /*10次整包容量(数组)读取量; */
-uint16_T sohv_Q_packCapArrEo[10];                 /*10次整包容量(数组)写入量; */
-uint16_T sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
-uint16_T sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
-
-uint16_T soed_E_nowEng;
-uint16_T soed_pct_nowStat;
-uint16_T soed_E_fullEng;
-
-uint16_T sopd_P_chrgPMax;
-uint16_T sopd_P_disChrgPMax;
-int16_T sopd_I_chrgCurrMax;
-int16_T sopd_I_disChrgCurrMax;
-
-	
-uint16_T sorv_ohm_cellREi[cmnc_num_cellUNumMax];
-uint16_T sorv_ohm_cellREo[cmnc_num_cellUNumMax];
-uint16_T sorv_ohm_cellR[cmnc_num_cellUNumMax];
-
-boolean_T iscd_flg_flt;
-uint16_T iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
-uint32_T iscd_tm_totalEi;
-uint16_T iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
-uint32_T iscd_tm_totalEo;
-
-uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
-
-uint8_T cmd_st_chrgMod;                           /* 充电模式  */
-uint8_T cmd_st_chrgSt;                           /* 充电状态  */
-int16_T cmd_I_chrgCurrReq;                       /* 充电需求电流  */
-uint8_T cmd_idx_chrgEndReason;                    /* 充电结束原因  */
-        
-uint16_T cand_idx_cellNr;                          /*循环发送的单体编号; */
-uint16_T cand_Q_cellCap;                          /*循环发送的单体容量; */
-uint16_T cand_V_chrgStartStat;                    /*循环发送的充电前单体电压; */
-uint16_T cand_Q_blcReqCp;                            /*循环发送的单体需求均衡容量; */
-uint16_T cand_Q_blcTotalCp;                          /*循环发送的单体累计均衡容量; */
-
-int16_T  cdmv_V_deltOCV[cmnc_num_cellUNumMax] = {0};
-int16_T  cdmv_ohm_deltR[cmnc_num_cellUNumMax] = {0};
-boolean_T cdmd_flg_deltOCVDisable;
-
-uint16_T pimd_V_ocv;
-uint16_T pimd_R_ohm;
-uint16_T pimd_R_polar;
-uint16_T pimd_F_polar;
-
-uint16_T test_cellCap[cmnc_num_cellUNumMax] ;
-uint16_T test_countEn;
-int16_T test_deltU;
-
+
+#include "BCUdisp.h"
+
+uint16_T appv_V_cellU[cmnc_num_cellUNumMax];                        /* 静态电压 */
+uint8_T  appd_st_preCyc;
+
+boolean_T  spmd_flg_firstRun;
+boolean_T  socd_flg_firstRun;
+boolean_T  sohd_flg_firstRun;
+boolean_T  blcd_flg_firstRun;
+boolean_T  sord_flg_firstRun;
+boolean_T  soed_flg_firstRun;
+boolean_T  iscd_flg_firstRun;
+boolean_T  pimd_flg_firstRun;
+boolean_T  sfmd_flg_firstRun;
+boolean_T  tmsd_flg_firstRun;
+boolean_T  cdmd_flg_firstRun;
+boolean_T  csmd_flg_firstRun;
+boolean_T  sopd_flg_firstRun;
+
+uint16_T  blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
+uint16_T  blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
+uint32_T  blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
+uint32_T  blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
+boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组); */
+
+boolean_T ihd_flg_HVILFlt;                        /* 保护板上传的高压互锁故障 */
+boolean_T ihd_flg_DTCClear;                       /* 上位机发送的故障清楚指令;*/
+uint8_T   ihd_st_authFaild;                         /* 底层诊断的认证失败故障;*/
+int16_T   ihd_I_curr;                               /*电池包电流; */
+uint8_T   ihd_st_chrgConnect;                       /*充电器连接状态; */
+uint16_T  ihd_P_gas;                               /*气体浓度 */
+uint16_T  ihd_T_ACPlugT;                           /*慢充插头温度 +40 */
+uint16_T  ihd_T_DCPlugT;                           /*快充插头温度+40 */
+uint16_T  ihd_T_bdtemp;                            /*板子温度 */
+uint16_T  ihd_T_heatPanT1;                         /*加热板温度1+40 */
+uint16_T  ihd_T_heatPanT2;                         /*加热板温度2 +40 */
+uint16_T  ihd_T_mosT;                              /*Mos温度+40 */
+boolean_T ihd_flg_EESaveFlt;                      /*EE存储故障 */
+boolean_T ihd_flg_battULowFlt;                    /*保护板上传的总压欠压故障; */
+boolean_T ihd_flg_battUOverFlt;                   /*保护板上传的总压过压故障; */
+boolean_T ihd_flg_cellULowFlt;                    /*保护板上传的单体欠压故障; */
+boolean_T ihd_flg_cellUOverFlt;                   /*保护板上传的单体过压故障; */
+boolean_T ihd_flg_chrgCurrOverFlt;                /*保护板上传的充电过流故障; */
+boolean_T ihd_flg_chrgModTLowFlt;                 /*保护板上传的充电模组温度过低故障; */
+boolean_T ihd_flg_chrgModTOverFlt;                /*保护板上传的充电模组温度过高故障; */
+boolean_T ihd_flg_chrgMosClosFlt;                 /*充电Mos失效 */
+boolean_T ihd_flg_chrgMosTOverFlt;                /*保护板上传的充电Mos温度过高故障; */
+boolean_T ihd_flg_currOpenFlt;                    /*保护板上传的电流开路故障 */
+boolean_T ihd_flg_disChrgCurrOverFlt;             /*保护板上传的放电过流故障; */
+boolean_T ihd_flg_disChrgModTLowFlt;              /*保护板上传的放电模组温度过低故障; */
+boolean_T ihd_flg_disChrgModTOverFlt;             /*保护板上传的放电模组温度过高故障; */
+boolean_T ihd_flg_disChrgMosClosFlt;              /*放电Mos失效 */
+boolean_T ihd_flg_disChrgMosTOverFlt;             /*保护板上传的放电Mos温度过高故障; */
+boolean_T ihd_flg_urtRecFlt;                      /*内网通讯故障 */
+uint16_T  ihd_pct_soc;                             /*保护板SOC */
+uint16_T  ihd_pct_soh;                             /*保护板SOH */
+uint8_T   ihd_st_workStat;                          /*电池工作状态 */
+uint16_T  ihd_tm_parkTime;                         /*驻车时间; */
+uint16_T  ihv_T_modT[cmnc_num_modTNumMax];                           /*模组温度(数组)+40 */
+uint16_T  ihv_V_cellU[cmnc_num_cellUNumMax];                         /*电池单体电压(数组); */
+boolean_T ihd_st_chrgMosControl;    
+boolean_T ihd_st_disChrgMosControl; 
+boolean_T ihd_st_relayControl;    
+uint8_T   ihd_st_heatForceControl;
+uint8_T   ihd_st_EOLState;
+boolean_T ihd_flg_urtRecFlg;
+uint8_T   ihd_st_reSet;
+
+int16_T   sfmd_I_curr;                              /*处理后整包电流 */
+uint16_T  sfmd_T_modTMax;                          /*处理后模组温度最小 */
+uint16_T  sfmd_T_modTMin;                          /*处理后模组温度最大 */
+uint16_T  sfmd_idx_modTMax;                          /*处理后模组温度最小 */
+uint16_T  sfmd_idx_modTMin;                          /*处理后模组温度最大 */
+uint16_T  sfmd_V_cellUAvrg;                        /*处理后单体电压平均 */
+uint16_T  sfmd_V_cellUMax;                         /*处理后单体电压最大 */
+uint16_T  sfmd_V_cellUMin;                         /*处理后单体电压最小 */
+uint16_T  sfmd_idx_cellUMin;
+uint16_T  sfmd_idx_cellUMax;
+boolean_T sfmd_flg_cellUInval;                  /*单体电压有效标志位 ; 0为有效;1为无效 */
+boolean_T sfmd_flg_currInval;                   /*电流有效标志位 ; 0为有效;1为无效 */
+boolean_T sfmd_flg_modTInval;                   /*模组温度有效标志位 ; 0为有效;1为无效 */
+uint16_T  sfmd_num_fltNum;                         /*故障数量 */
+uint8_T   sfmd_st_fltAct;                           /*故障禁止指令 */
+uint8_T   sfmd_st_fltLevel;                         /*故障等级 */
+uint16_T  sfmv_T_modT[cmnc_num_modTNumMax];                          /*处理后模组温度 */
+uint16_T  sfmv_V_cellU[cmnc_num_cellUNumMax];                        /*处理后单体电压 */
+uint16_T  sfmv_idx_fltCode[20];                    /*诊断故障码(数组) */
+uint16_T  sfmd_V_battU;                            /* 处理过后的总电压 */
+boolean_T sfmd_flg_mainCirClosFltEi;              /*主回路常闭故障读取量 */  
+boolean_T sfmd_flg_mainCirClosFltEo;              /*主回路常闭故障写入量 */  
+boolean_T sfmd_flg_heatCirClosFltEi;              /*加热回路常闭故障读取量 */  
+boolean_T sfmd_flg_heatCirClosFltEo;              /*加热回路常闭故障写入量 */  
+boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故障读取量 */  
+boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
+boolean_T sfmd_flg_heatRunFltEi;
+boolean_T sfmd_flg_heatRunFltEo;
+boolean_T sfmd_flg_iscFltEi;
+boolean_T sfmd_flg_iscFltEo;
+
+uint16_T  socd_pct_vcuSoc;                          /*vcuSOC; */
+uint16_T  socd_pct_ahSoc;                          /*安时SOC; */
+uint16_T  socd_pct_estSoc;                         /*估算SOC;*/
+uint16_T  socd_flg_EEsave;                         /*实时存储标志位;*/
+uint16_T  socd_pct_ekfSoc;                         /*EKFSOC;*/
+uint16_T  socd_pct_battSoc;                        /*电池真实SOC; */
+uint16_T  socd_pct_battSocEi;                      /*电池真实SOC 读取量; */
+uint16_T  socd_pct_battSocEo;                      /*电池真实SOC 写入量; */
+uint16_T  socd_pct_bcuSoc;                         /*电池显示SOC; */
+uint16_T  socd_pct_bcuSocEi;                       /*电池显示SOC读取量; */
+uint16_T  socd_pct_bcuSocEo;                       /*电池显示SOC写入量; */
+uint16_T  socv_pct_cellSoc[cmnc_num_cellUNumMax];
+uint16_T  socd_pct_cellBattSoc;
+boolean_T socd_flg_cellSocDisable;
+
+uint16_T  sohd_Q_chrgEi;                           /*充入容量读取量; */
+uint16_T  sohd_Q_chrgEo;                           /*充入容量写入量; */
+boolean_T sohd_flg_chrgEndEi;                     /*充电结束标志位读取量; */
+boolean_T sohd_flg_chrgEndEo;                     /*充电结束标志位写入量; */
+uint16_T  sohd_pct_bcuSoh;                         /*电池SOH; */
+uint16_T  sohd_tm_chrgStartStatEi;                 /*充电前静置时间读取量; */
+uint16_T  sohd_tm_chrgStartStatEo;                 /*充电前静置时间写入量; */
+uint16_T  sohv_Q_cellCap[cmnc_num_cellUNumMax];                      /*单体容量 */
+uint16_T  sohv_Q_cellCapArrEi[cmnc_num_cellUNumMax];                 /*单体容量(数组) 读取量 */
+uint16_T  sohv_Q_cellCapArrEo[cmnc_num_cellUNumMax];                 /*单体容量(数组) 写入量 */
+uint16_T  sohv_Q_packCapArrEi[10];                 /*10次整包容量(数组)读取量; */
+uint16_T  sohv_Q_packCapArrEo[10];                 /*10次整包容量(数组)写入量; */
+uint16_T  sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
+uint16_T  sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
+
+uint16_T  soed_E_nowEng;
+uint16_T  soed_pct_nowStat;
+uint16_T  soed_E_fullEng;
+
+uint16_T  sopd_P_chrgPMax;
+uint16_T  sopd_P_disChrgPMax;
+int16_T   sopd_I_chrgCurrMax;
+int16_T   sopd_I_disChrgCurrMax;
+
+uint16_T  sorv_R_cellEi[cmnc_num_cellUNumMax];
+uint16_T  sorv_R_cellEo[cmnc_num_cellUNumMax];
+uint16_T  sorv_R_cell[cmnc_num_cellUNumMax];
+
+boolean_T iscd_flg_flt;
+uint16_T  iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
+uint32_T  iscd_tm_totalEi;
+uint16_T  iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
+uint32_T  iscd_tm_totalEo;
+
+uint8_T   tmsd_st_heatAct;                          /*热管理请求状态; */
+
+uint8_T   csmd_st_chrgMod;                           /* 充电模式  */
+uint8_T   csmd_st_chrgSt;                            /* 充电状态  */
+int16_T   csmd_I_chrgCurrReq;                       /* 充电需求电流  */
+uint8_T   csmd_idx_chrgEndReason;                    /* 充电结束原因  */
+
+uint16_T  cand_idx_cellNr;                          /*循环发送的单体编号; */
+uint16_T  cand_Q_cellCap;                          /*循环发送的单体容量; */
+uint16_T  cand_V_chrgStartStat;                    /*循环发送的充电前单体电压; */
+uint16_T  cand_Q_blcReqCp;                            /*循环发送的单体需求均衡容量; */
+uint16_T  cand_Q_blcTotalCp;                          /*循环发送的单体累计均衡容量; */
+
+int16_T   cdmv_V_deltOCV[cmnc_num_cellUNumMax];
+int16_T   cdmv_R_deltOhm[cmnc_num_cellUNumMax];
+boolean_T cdmv_flg_inval[cmnc_num_cellUNumMax];
+
+uint16_T   pimd_V_ocv;
+uint16_T   pimd_R_ohm;
+uint16_T   pimd_R_polar;
+uint16_T   pimd_F_polar;
+uint16_T   pimv_V_cellOcv[cmnc_num_cellUNumMax];
+uint16_T   pimv_R_cellOhm[cmnc_num_cellUNumMax];
+uint16_T   pimd_pct_battSoc;
+uint16_T   pimv_pct_cellSoc[cmnc_num_cellUNumMax];
+boolean_T  pimv_flg_inval[cmnc_num_cellUNumMax];
+
+uint16_T test_cellCap[cmnc_num_cellUNumMax];
+uint16_T test_countEn;
+int16_T  test_deltU;
+int16_T test_data[200][3]={{0,4141,4144},
+{0,4141,4144},
+{0,4141,4144},
+{0,4141,4144},
+{0,4141,4144},
+{-135,4077,4115},
+{-135,4077,4115},
+{-40,4125,4136},
+{-189,4070,4113},
+{-189,4070,4113},
+{-123,4095,4123},
+{-187,4094,4115},
+{-4,4136,4140},
+{-84,4108,4128},
+{-84,4108,4128},
+{-134,4092,4119},
+{-6,4134,4139},
+{-6,4134,4139},
+{-175,4078,4112},
+{-57,4114,4131},
+{-57,4114,4131},
+{-74,4110,4129},
+{-107,4102,4121},
+{-99,4106,4128},
+{-44,4115,4132},
+{-44,4115,4132},
+{-51,4100,4122},
+{-51,4100,4122},
+{-85,4109,4124},
+{-64,4106,4128},
+{-109,4093,4123},
+{-55,4125,4127},
+{-90,4082,4113},
+{-90,4082,4113},
+{-140,4083,4116},
+{0,4135,4138},
+{-239,4056,4102},
+{0,4134,4137},
+{0,4134,4137},
+{-16,4131,4136},
+{56,4155,4147},
+{56,4155,4147},
+{16,4146,4143},
+{0,4136,4139},
+{0,4136,4139},
+{0,4136,4139},
+{-2,4136,4140},
+{7,4139,4141},
+{2,4138,4140},
+{2,4138,4140},
+{-146,4092,4118},
+{-272,4045,4099},
+{-272,4045,4099},
+{-272,4045,4099},
+{-159,4070,4108},
+{-192,4065,4107},
+{-199,4064,4106},
+{-199,4064,4106},
+{-175,4091,4106},
+{62,4132,4146},
+{62,4132,4146},
+{62,4132,4146},
+{-241,4051,4098},
+{-241,4051,4098},
+{-217,4056,4101},
+{-144,4074,4113},
+{34,4158,4146},
+{-122,4091,4116},
+{-122,4091,4116},
+{-102,4103,4115},
+{-140,4088,4109},
+{-138,4096,4117},
+{0,4130,4134},
+{0,4131,4134},
+{-233,4059,4101},
+{0,4132,4134},
+{0,4132,4134},
+{-96,4092,4121},
+{-166,4076,4110},
+{-166,4076,4110},
+{-112,4086,4119},
+{-9,4127,4133},
+{-164,4074,4111},
+{-81,4103,4121},
+{-81,4103,4121},
+{-82,4099,4121},
+{-62,4127,4132},
+{-62,4127,4132},
+{72,4155,4144},
+{0,4131,4134},
+{0,4131,4134},
+{-112,4069,4123},
+{-112,4069,4123},
+{-87,4109,4120},
+{-158,4135,4111},
+{-158,4135,4111},
+{36,4144,4141},
+{-149,4080,4112},
+{46,4146,4141},
+{-170,4073,4106},
+{-170,4073,4106},
+{-167,4071,4108},
+{65,4152,4143},
+{65,4152,4143},
+{-177,4067,4107},
+{-115,4079,4115},
+{-115,4079,4115},
+{-182,4067,4108},
+{-182,4067,4108},
+{-150,4072,4112},
+{-136,4066,4109},
+{-136,4066,4109},
+{-94,4083,4117},
+{-97,4092,4118},
+{-97,4092,4118},
+{-97,4092,4118},
+{-98,4093,4116},
+{-98,4093,4116},
+{24,4111,4124},
+{24,4111,4124},
+{-40,4089,4117},
+{-64,4106,4120},
+{-64,4106,4120},
+{-6,4128,4130},
+{-6,4128,4130},
+{-6,4126,4131},
+{-150,4082,4109},
+{-150,4082,4109},
+{-120,4089,4115},
+{-96,4091,4117},
+{-96,4091,4117},
+{-96,4091,4117},
+{-52,4112,4122},
+{-49,4115,4123},
+{-55,4111,4121},
+{-55,4111,4121},
+{-49,4115,4123},
+{-36,4115,4126},
+{-36,4115,4126},
+{-36,4115,4127},
+{-6,4126,4131},
+{-6,4126,4131},
+{66,4153,4143},
+{66,4153,4143},
+{-115,4075,4111},
+{61,4151,4143},
+{61,4151,4143},
+{54,4148,4142},
+{47,4126,4119},
+{47,4126,4119},
+{-82,4117,4129},
+{-51,4108,4122},
+{-138,4094,4118},
+{-133,4091,4111},
+{-133,4091,4111},
+{-154,4077,4109},
+{-63,4094,4123},
+{-63,4094,4123},
+{-125,4085,4109},
+{-125,4085,4109},
+{-133,4089,4110},
+{-49,4114,4122},
+{-49,4114,4122},
+{-38,4114,4127},
+{-24,4115,4127},
+{-24,4115,4127},
+{0,4128,4131},
+{0,4128,4132},
+{60,4150,4141},
+{-198,4061,4102},
+{-198,4061,4102},
+{-196,4057,4103},
+{-149,4076,4108},
+{-149,4076,4108},
+{-149,4076,4108},
+{12,4093,4127},
+{12,4093,4127},
+{-202,4053,4103},
+{-126,4083,4111},
+{-32,4115,4126},
+{52,4152,4141},
+{52,4152,4141},
+{0,4127,4130},
+{56,4147,4140},
+{56,4147,4140},
+{48,4141,4139},
+{0,4127,4130},
+{0,4127,4130},
+{-31,4148,4114},
+{-31,4148,4114},
+{-133,4077,4109},
+{-47,4114,4122},
+{-47,4114,4122},
+{-37,4104,4125},
+{-67,4122,4121},
+{-46,4107,4124},
+{-46,4107,4124},
+{-46,4107,4124},
+{-46,4107,4124},
+{0,4128,4131}};
+
+
+
+

+
+

+

+ 1 - 1
src/EmbeddedCoder_src/BLC.c

@@ -58,7 +58,7 @@ void BLC(void)
     //=========================================================================
     if(blcd_flg_firstRun)
     {
-		blcn_flg_judge	= (ihd_tm_parkTime >= cmnc_tm_parkTime)&& !sfmd_flg_cellUDisable && (sfmd_I_curr > -10 && sfmd_I_curr < 10);
+		blcn_flg_judge	= (ihd_tm_parkTime >= cmnc_tm_parkTime)&& !sfmd_flg_cellUInval && (sfmd_I_curr > -10 && sfmd_I_curr < 10);
     }
     blcn_flg_enable = ((sfmd_st_fltAct >> 7) & 0x01) != 1;
 

+ 110 - 69
src/EmbeddedCoder_src/CDM.c

@@ -1,5 +1,5 @@
 #include "CDM.h"
-
+#define cdmd_L_rls 51
 void CDM_Init(void)
 {
     cdmd_flg_firstRun = true;
@@ -7,102 +7,143 @@ void CDM_Init(void)
 
 void CDM(void)
 {
-    real_T cmdn_V_cellUDelt[cmnc_num_cellUNumMax];
-    real_T cdmn_I_curr;
-    static real_T cdmn_M_P[4][cmnc_num_cellUNumMax];
-    real_T P[4][cmnc_num_cellUNumMax];
+    real_T temp_curr;
+    real_T cmdn_V_cellUDelt;
+    static real_T cdmn_M_P[2][2][cmnc_num_cellUNumMax];
+    real_T P[2][2];
+	real_T A[2];
+	real_T K[2];
+	real_T arf;
+	real_T theta[2];
     static real_T deltaE[cmnc_num_cellUNumMax];
     static real_T deltaR[cmnc_num_cellUNumMax];
-    static real_T deltaES[cmnc_num_cellUNumMax];
-    static real_T deltaRS[cmnc_num_cellUNumMax];
-    static real_T cdmn_f_Lambda;
-    real_T K[2];
-    real_T arf[cmnc_num_cellUNumMax];
+	static int16_T cdmn_I_curr[cdmd_L_rls];
     uint16_T i;
     static uint8_T cmdn_st_workStat_Delay;
     static uint8_T cdmn_num_Cnt;
 
-    //
+
+
+   
+    //------模式切换后重置--------------------
     if (cmdn_st_workStat_Delay != 1 && ihd_st_workStat == 1)
     {
         cdmd_flg_firstRun = true;
     }
-    
-    //
-    if (cdmd_flg_firstRun)
+	
+   //初值归零---------------------------------
+   if (cdmd_flg_firstRun)
+   {
+	   cdmn_num_Cnt = 0;
+	   for (i = 0; i < cmnc_num_cellUNum; i++)
+	   {
+		   cdmn_M_P[0][0][i] = 10;
+		   cdmn_M_P[0][1][i] = 0;
+		   cdmn_M_P[1][0][i] = 0;
+		   cdmn_M_P[1][1][i] = 10;
+		   deltaE[i] = 0;
+		   deltaR[i] = 0;
+		   cdmv_flg_inval[i] = 1;
+	   }
+   }
+
+   sfmd_I_curr =test_data[cdmn_num_Cnt][0];
+   sfmv_V_cellU[0] =test_data[cdmn_num_Cnt][1];
+   sfmv_V_cellU[1] =test_data[cdmn_num_Cnt][2];
+   ihd_st_workStat =1;
+
+
+
+
+   //记忆区间-----------------------------------
+   	if (pimd_flg_firstRun)
     {
-        for (i = 0; i < cmnc_num_cellUNum; i++)
+        for (i = 0; i < cdmd_L_rls; i++)
         {
-            cdmn_M_P[0][i] = 10;
-            cdmn_M_P[1][i] = 0;
-            cdmn_M_P[2][i] = 0;
-            cdmn_M_P[3][i] = 10;
-            cdmn_f_Lambda = 0.991;
-            deltaE[i] = 0;
-            deltaR[i] = 0;
-            deltaES[i] = 0;
-            deltaRS[i] = 0;
-            cdmn_num_Cnt = 0;
+            cdmn_I_curr[i] = sfmd_I_curr;
         }
-    }
-    //
-    if (ihd_st_workStat == 1) 
+	}
+    else
     {
-        for (i = 0; i < cmnc_num_cellUNum; i++)
+        for (i = 0; i < cdmd_L_rls - 1; i++)
         {
-            cmdn_V_cellUDelt[i] = (real_T)(sfmv_V_cellU[i] - sfmd_V_cellUAvrg) * 0.001;
+            cdmn_I_curr[i] = cdmn_I_curr[i+1];
         }
-        cdmn_I_curr = (real_T)sfmd_I_curr * 0.1;
-        //
-        cdmd_flg_deltOCVDisable = false;
-        for (i = 0; i < cmnc_num_cellUNum; i++)
+        cdmn_I_curr[i] = sfmd_I_curr;
+    }
+	
+
+    //放电使能----------------------------------------
+    if (ihd_st_workStat == 1) 
+    { 
+        for (i = 1; i < 2; i++)
         {
-            K[0] = (cdmn_M_P[0][i] + cdmn_I_curr * cdmn_M_P[1][i]) / (cdmn_f_Lambda + cdmn_M_P[0][i] + cdmn_I_curr * cdmn_M_P[2][i] + (cdmn_M_P[1][i] + cdmn_I_curr * cdmn_M_P[3][i]) * cdmn_I_curr);
-            K[1] = (cdmn_M_P[2][i] + cdmn_I_curr * cdmn_M_P[3][i]) / (cdmn_f_Lambda + cdmn_M_P[0][i] + cdmn_I_curr * cdmn_M_P[2][i] + (cdmn_M_P[1][i] + cdmn_I_curr * cdmn_M_P[3][i]) * cdmn_I_curr);
-            arf[i] = cmdn_V_cellUDelt[i] - (deltaE[i] + cdmn_I_curr * deltaR[i]);
-            deltaE[i] = deltaE[i] + K[0] * arf[i];
-            deltaR[i] = deltaR[i] + K[1] * arf[i];
-            P[0][i] = ((1 - K[0]) * cdmn_M_P[0][i] - cdmn_M_P[2][i] * K[0] * cdmn_I_curr)  / cdmn_f_Lambda;
-            P[1][i] = ((1 - K[0]) * cdmn_M_P[1][i] - cdmn_M_P[3][i] * K[0] * cdmn_I_curr)  / cdmn_f_Lambda;
-            P[2][i] = (-K[1] * cdmn_M_P[0][i] + cdmn_M_P[2][i] * (1 - K[1] * cdmn_I_curr)) / cdmn_f_Lambda;
-            P[3][i] = (-K[1] * cdmn_M_P[1][i] + cdmn_M_P[3][i] * (1 - K[1] * cdmn_I_curr)) / cdmn_f_Lambda;
-
-            cdmn_M_P[0][i] = P[0][i];
-            cdmn_M_P[1][i] = P[1][i];
-            cdmn_M_P[2][i] = P[2][i];
-            cdmn_M_P[3][i] = P[3][i];
-            if (arf[i] > 0.04 || arf[i] < -0.04)
+            //新增
+            cmdn_V_cellUDelt =  (real_T)(sfmv_V_cellU[i] - sfmv_V_cellU[0]) * 0.001;   // #0单体为基准
+            A[0] = 1;
+			A[1] = (real_T)cdmn_I_curr[cdmd_L_rls - 1] * 0.1;
+
+            theta[0] = deltaE[i];
+		    theta[1] = deltaR[i];
+            K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );
+			K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );	
+
+		
+            arf = cmdn_V_cellUDelt - (theta[0] * A[0] + theta[1] * A[1]);
+			theta[0] = theta[0] + K[0] * arf;
+			theta[1] = theta[1] + K[1] * arf;
+
+
+			P[0][0] = cdmn_M_P[0][0][i] - K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+			P[0][1] = cdmn_M_P[0][1][i] - K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
+			P[1][0] = cdmn_M_P[1][0][i] - K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);	
+			P[1][1] = cdmn_M_P[1][1][i] - K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
+
+            cdmn_M_P[0][0][i] = P[0][0];
+            cdmn_M_P[0][1][i] = P[0][1];
+            cdmn_M_P[1][0][i] = P[1][0];
+            cdmn_M_P[1][1][i] = P[1][1];
+
+			//删去
+            if(cdmn_num_Cnt > cdmd_L_rls)
             {
-                cdmd_flg_deltOCVDisable = true;
+            	A[0] = 1;
+				A[1] = (real_T)cdmn_I_curr[0] * 0.1;
+	         	K[0] = (cdmn_M_P[0][0][i] * A[0] + cdmn_M_P[0][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );
+				K[1] = (cdmn_M_P[1][0][i] * A[0] + cdmn_M_P[1][1][i] * A[1])/(1 + (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]) * A[0] +  (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]) * A[1] );	
+			  
+				P[0][0] = cdmn_M_P[0][0][i] + K[0] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);
+				P[0][1] = cdmn_M_P[0][1][i] + K[0] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
+				P[1][0] = cdmn_M_P[1][0][i] + K[1] * (A[0] * cdmn_M_P[0][0][i] + A[1] * cdmn_M_P[1][0][i]);	
+				P[1][1] = cdmn_M_P[1][1][i] + K[1] * (A[0] * cdmn_M_P[0][1][i] + A[1] * cdmn_M_P[1][1][i]);	
+		
+            	cdmn_M_P[0][0][i] = P[0][0];
+            	cdmn_M_P[0][1][i] = P[0][1];
+            	cdmn_M_P[1][0][i] = P[1][0];
+            	cdmn_M_P[1][1][i] = P[1][1];
             }
-        }
-        //
-        cdmn_num_Cnt = cdmn_num_Cnt + 1;
-        for (i = 0; i < cmnc_num_cellUNum; i++)
-        {
-            deltaES[i] = deltaES[i] + deltaE[i];
-            deltaRS[i] = deltaRS[i] + deltaR[i];
-        }
-
-        if (cdmn_num_Cnt >= 10)
-        {
-            for (i = 0; i < cmnc_num_cellUNum; i++)
+            if (arf> 0.04 || arf< -0.04)
             {
-                cdmv_V_deltOCV[i] = (int16_T)(deltaES[i] / cdmn_num_Cnt * 1000);
-                cdmv_ohm_deltR[i] = (int16_T)(deltaRS[i] / cdmn_num_Cnt * 1000 * 1000);
-                deltaES[i] = 0;
-                deltaRS[i] = 0;
+                cdmv_flg_inval[i] = true;
             }
-            cdmn_num_Cnt = 0;
+			
+			deltaE[i] = theta[0];
+            deltaR[i] = theta[1];
+			
+			cdmv_V_deltOCV[i] = (int16_T)(deltaE[i]  * 1000);
+            cdmv_R_deltOhm[i] = (int16_T)(deltaR[i]  * 1000 * 1000);
         }
+        //
+        cdmn_num_Cnt = cdmn_num_Cnt + 1;
     }
     else
     {
-        cdmd_flg_deltOCVDisable = true;
+        memset(cdmv_flg_inval,0,sizeof(cdmv_V_deltOCV));
 		memset(cdmv_V_deltOCV,0,sizeof(cdmv_V_deltOCV));
-		memset(cdmv_ohm_deltR,0,sizeof(cdmv_ohm_deltR));
+		memset(cdmv_R_deltOhm,0,sizeof(cdmv_R_deltOhm));
     }
 	
+	
     cdmd_flg_firstRun = false;
 	cmdn_st_workStat_Delay = ihd_st_workStat;
 }

+ 51 - 51
src/EmbeddedCoder_src/CM.c → src/EmbeddedCoder_src/CSM.c

@@ -1,35 +1,35 @@
-#include "CM.h"
+#include "CSM.h"
 
 
-void CM_Init(void)
+void CSM_Init(void)
 {
-    cmd_flg_firstRun = true;
+    csmd_flg_firstRun = true;
 }
 
-void CM(void)
+void CSM(void)
 {
-    static uint16_T cmn_V_cellUMax;
-    static uint16_T cmn_V_cellUMin;
+    static uint16_T csmn_V_cellUMax;
+    static uint16_T csmn_V_cellUMin;
     static uint16_T chrgFulCnt;
-    static boolean_T cmn_flg_chrgFul;
+    static boolean_T csmn_flg_chrgFul;
     static uint16_T chrgCnt;
     static uint16_T noChrgCnt;
-    uint16_T cmd_I_chrgCurrReq1 = 0;
-    uint16_T cmd_I_chrgCurrReq2 = 0;
-    uint16_T cmd_I_chrgCurrReq3 = 0;
-    uint16_T cmd_I_chrgCurrReq4 = 0;
+    uint16_T csmd_I_chrgCurrReq1 = 0;
+    uint16_T csmd_I_chrgCurrReq2 = 0;
+    uint16_T csmd_I_chrgCurrReq3 = 0;
+    uint16_T csmd_I_chrgCurrReq4 = 0;
 	static boolean_T First;
-    static uint8_T cmd_st_chrgSt_end;
+    static uint8_T csmd_st_chrgSt_end;
 	static boolean_T chrgFul;
-    if(cmd_flg_firstRun)
+    if(csmd_flg_firstRun)
     {
-        cmn_V_cellUMax = 0;
-        cmn_V_cellUMin = 0;
+        csmn_V_cellUMax = 0;
+        csmn_V_cellUMin = 0;
         chrgFulCnt = 0;
         chrgCnt = 0;
         noChrgCnt = 0;
-        cmn_flg_chrgFul = false;
-		cmd_st_chrgSt = 0;
+        csmn_flg_chrgFul = false;
+		csmd_st_chrgSt = 0;
 		chrgFul = 0;
     }
     //=====================================================================
@@ -37,104 +37,104 @@ void CM(void)
     //=====================================================================
     if(ihd_st_chrgConnect > 0)
     {
-        cmd_st_chrgMod = 1;
+        csmd_st_chrgMod = 1;
     }
     else
     {
-        cmd_st_chrgMod = 0;
+        csmd_st_chrgMod = 0;
     }
 	
     //=====================================================================
     //============================充电需求电流=============================
     //=====================================================================
-    if (cmd_st_chrgMod)
+    if (csmd_st_chrgMod)
     {
-        if(sfmd_V_cellUMin > cmn_V_cellUMin)
+        if(sfmd_V_cellUMin > csmn_V_cellUMin)
         {
-            cmn_V_cellUMin = sfmd_V_cellUMin;
+            csmn_V_cellUMin = sfmd_V_cellUMin;
         }
-        if(sfmd_V_cellUMax > cmn_V_cellUMax)
+        if(sfmd_V_cellUMax > csmn_V_cellUMax)
         {
-            cmn_V_cellUMax = sfmd_V_cellUMax;
+            csmn_V_cellUMax = sfmd_V_cellUMax;
         }
-        cmd_I_chrgCurrReq1 = look2_u16u16tu16(cmn_V_cellUMin,sfmd_T_modTMin,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
-        cmd_I_chrgCurrReq2 = look2_u16u16tu16(cmn_V_cellUMax,sfmd_T_modTMin,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
-        cmd_I_chrgCurrReq3 = look2_u16u16tu16(cmn_V_cellUMin,sfmd_T_modTMax,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
-        cmd_I_chrgCurrReq4 = look2_u16u16tu16(cmn_V_cellUMax,sfmd_T_modTMax,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
-		cmd_I_chrgCurrReq =  min( min(cmd_I_chrgCurrReq1, cmd_I_chrgCurrReq2),min(cmd_I_chrgCurrReq3,cmd_I_chrgCurrReq4));
+        csmd_I_chrgCurrReq1 = look2_u16u16tu16(csmn_V_cellUMin,sfmd_T_modTMin,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
+        csmd_I_chrgCurrReq2 = look2_u16u16tu16(csmn_V_cellUMax,sfmd_T_modTMin,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
+        csmd_I_chrgCurrReq3 = look2_u16u16tu16(csmn_V_cellUMin,sfmd_T_modTMax,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
+        csmd_I_chrgCurrReq4 = look2_u16u16tu16(csmn_V_cellUMax,sfmd_T_modTMax,cmm_V_ChrgCurr,cmm_T_ChrgCurr,cmm_I_ChrgCurr,6,3);
+		csmd_I_chrgCurrReq =  min( min(csmd_I_chrgCurrReq1, csmd_I_chrgCurrReq2),min(csmd_I_chrgCurrReq3,csmd_I_chrgCurrReq4));
     }
     else
     {
-        cmd_I_chrgCurrReq = 0;
+        csmd_I_chrgCurrReq = 0;
     }
 	
     //=====================================================================
     //============================充电状态=================================
     //=====================================================================
-    if (cmd_st_chrgMod > 0)
+    if (csmd_st_chrgMod > 0)
     {
         noChrgCnt = 0; 
         if (sfmd_I_curr > 1)
         {
-            cmd_st_chrgSt = 1;
+            csmd_st_chrgSt = 1;
         } 
 		if(JudgeTimeSystem(1,sfmd_V_cellUMax >= cmnc_V_chrgFul ,&chrgFulCnt ,20))
 		{
 		   chrgFul = true;
-           cmn_flg_chrgFul = true;
+           csmn_flg_chrgFul = true;
 		} 
-        if(cmn_flg_chrgFul)
+        if(csmn_flg_chrgFul)
         {
-            cmd_st_chrgSt = 2;
-            cmd_I_chrgCurrReq = 0;
+            csmd_st_chrgSt = 2;
+            csmd_I_chrgCurrReq = 0;
         }
 
 		//
-        if (cmd_st_chrgSt != 2 && JudgeTimeSystem(1,sfmd_I_curr < 1 ,&chrgCnt ,100) )
+        if (csmd_st_chrgSt != 2 && JudgeTimeSystem(1,sfmd_I_curr < 1 ,&chrgCnt ,100) )
         {
-            cmd_st_chrgSt = 3;
-            cmd_I_chrgCurrReq = 0;
+            csmd_st_chrgSt = 3;
+            csmd_I_chrgCurrReq = 0;
         }
 		//
         if((sfmd_st_fltAct >> 6) & 0x01)
         {
-            cmd_st_chrgSt = 3;
-            cmd_I_chrgCurrReq = 0; 
+            csmd_st_chrgSt = 3;
+            csmd_I_chrgCurrReq = 0; 
         }
 
 
 
 
 		
-		cmd_st_chrgSt_end = cmd_st_chrgSt;
+		csmd_st_chrgSt_end = csmd_st_chrgSt;
     }
     else
     {   
-        cmn_flg_chrgFul = false;
+        csmn_flg_chrgFul = false;
         chrgCnt = 0;
         noChrgCnt ++;
-        if(cmd_st_chrgSt_end == 1  && noChrgCnt <= 100 )
+        if(csmd_st_chrgSt_end == 1  && noChrgCnt <= 100 )
         {
-            cmd_st_chrgSt = 3;
+            csmd_st_chrgSt = 3;
         }
         else
         {
-            cmd_st_chrgSt = 0;
+            csmd_st_chrgSt = 0;
         }
     }
 	
     // ===================================================================
     // =================故障结束原因========================================
     // ===================================================================
-    if(cmd_st_chrgSt == 3 )
+    if(csmd_st_chrgSt == 3 )
     {
         if (ihd_st_chrgConnect == 0 && First)
         {
-            cmd_idx_chrgEndReason = 1 ; // 用户主动停止
+            csmd_idx_chrgEndReason = 1 ; // 用户主动停止
         }
         if((sfmd_st_fltAct >> 6) & 0x01 && First)
         {
-            cmd_idx_chrgEndReason = 2 ; // 因电池故障限制充电;
+            csmd_idx_chrgEndReason = 2 ; // 因电池故障限制充电;
         }
 
         First = false;
@@ -142,10 +142,10 @@ void CM(void)
     else
     {
         First = true ;
-        cmd_idx_chrgEndReason = 0;
+        csmd_idx_chrgEndReason = 0;
     }
 
-    cmd_flg_firstRun = false;
+    csmd_flg_firstRun = false;
 	//printf("fltAct:%d,chrgMod:%d,chrgSt:%d,chrgCurrReq:%d,chrgEndReason:%d\n\n",sfmd_st_fltAct,cmd_st_chrgMod,cmd_st_chrgSt,cmd_I_chrgCurrReq,cmd_idx_chrgEndReason);
 }
 

+ 52 - 31
src/EmbeddedCoder_src/PIM.c

@@ -19,42 +19,28 @@ void PIM(void)
     static real_T  pimn_R_polar;
     static real_T  pimn_F_polar;
     
-    static uint16_T pimn_N_ctn;
+    static uint16_T pimn_num_cnt;
     static real_T pimn_M_P[4][4];
-    static real_T theta[4];
+    real_T theta[4];
     real_T P[4][4];
     real_T A[4];
     real_T K[4];
     real_T temp;
+	boolean_T pimn_flg_inval;
 	
-    //重置
+    //重置--------------------
     if (pimn_st_workStat_Delay != 1 && ihd_st_workStat == 1)
     {
         pimd_flg_firstRun = true;
     }
-    
-    //初值
-    if (pimd_flg_firstRun)
-    {
-        pimn_M_P[0][0] = 10; pimn_M_P[0][1] =  0;  pimn_M_P[0][2] =  0;  pimn_M_P[0][3] =  0;
-        pimn_M_P[1][0] =  0; pimn_M_P[1][1] = 10;  pimn_M_P[1][2] =  0;  pimn_M_P[1][3] =  0;
-        pimn_M_P[2][0] =  0; pimn_M_P[2][1] =  0;  pimn_M_P[2][2] = 10;  pimn_M_P[2][3] =  0;
-        pimn_M_P[3][0] =  0; pimn_M_P[3][1] =  0;  pimn_M_P[3][2] =  0;  pimn_M_P[3][3] = 10;
-        
-        pimn_V_ocv   = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_V_ocv,   13) * 0.001;
-        pimn_R_ohm   = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_R_ohm,   13) * 0.001 * 0.001;
-        pimn_R_polar = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_R_polar, 13) * 0.001 * 0.001;;
-        pimn_F_polar = 5;
-        pimn_N_ctn = 0;  
-		pimn_st_workStat_Delay = 0;
-    }
+   
 
-    //限定记忆长度
+    //限定记忆长度------------------------
     if (pimd_flg_firstRun)
     {
         for (i = 0; i < pimd_L_rls; i++)
         {
-            pimn_V_volt[i] = sfmv_V_cellU[0];
+            pimn_V_volt[i] = sfmv_V_cellU[0];   //和CMD匹配
             pimn_I_curr[i] = sfmd_I_curr;
         }
 	}
@@ -68,11 +54,27 @@ void PIM(void)
         pimn_V_volt[i] = sfmv_V_cellU[0];
         pimn_I_curr[i] = sfmd_I_curr;
     }
-    //
+	
+	//初值-------------------
+    if (pimd_flg_firstRun)
+    {
+        pimn_M_P[0][0] = 10; pimn_M_P[0][1] =  0;  pimn_M_P[0][2] =  0;  pimn_M_P[0][3] =  0;
+        pimn_M_P[1][0] =  0; pimn_M_P[1][1] = 10;  pimn_M_P[1][2] =  0;  pimn_M_P[1][3] =  0;
+        pimn_M_P[2][0] =  0; pimn_M_P[2][1] =  0;  pimn_M_P[2][2] = 10;  pimn_M_P[2][3] =  0;
+        pimn_M_P[3][0] =  0; pimn_M_P[3][1] =  0;  pimn_M_P[3][2] =  0;  pimn_M_P[3][3] = 10;
+        
+        pimn_V_ocv   = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_V_ocv,   13) * 0.001;
+        pimn_R_ohm   = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_R_ohm,   13) * 0.001 * 0.001;
+        pimn_R_polar = (real_T)look1_u16tu16(socd_pct_battSoc, cmnm_pct_soc, cmnm_R_polar, 13) * 0.001 * 0.001;;
+        pimn_F_polar = 5;
+        pimn_num_cnt = 0;  
+		pimn_st_workStat_Delay = 0;
+    }
+    //放电使能
     if(pimn_st_workStat_Delay == 1)
     {
-        pimn_N_ctn = pimn_N_ctn + 1;
-        //输入
+        pimn_num_cnt = pimn_num_cnt + 1;
+        //新增-------------------
         A[0] = (real_T)pimn_V_volt[pimd_L_rls - 2] * 0.001;
         A[1] = (real_T)pimn_I_curr[pimd_L_rls - 1] * 0.1;
         A[2] =-(real_T)pimn_I_curr[pimd_L_rls - 2] * 0.1;
@@ -96,6 +98,10 @@ void PIM(void)
         //参数更新
         
         temp = (real_T)pimn_V_volt[pimd_L_rls - 1] * 0.001 - (theta[0] * A[0] + theta[1] * A[1] + theta[2] * A[2] + theta[3] * A[3]);
+		if (temp > 0.03 || temp < -0.03)
+		{
+             pimn_flg_inval = 1;
+		}
 		test_deltU = (int16_T)(temp * 1000);
         for(i = 0;i < 4;i++)
         {
@@ -117,12 +123,11 @@ void PIM(void)
             for(j = 0;j < 4;j++)
             {
                 pimn_M_P[i][j] = P[i][j];
-            }
-            
+            } 
         }
         
-        //=======================================================================
-        if(pimn_N_ctn > pimd_L_rls)
+        //删去---------------
+        if(pimn_num_cnt > pimd_L_rls)
         {
             //输入
             A[0] = (real_T)pimn_V_volt[0] * 0.001;
@@ -154,8 +159,7 @@ void PIM(void)
                 for(j = 0;j < 4;j++)
                 {
                     pimn_M_P[i][j] = P[i][j];
-                }
-                
+                }  
             }
         }
         //参数求解
@@ -170,11 +174,11 @@ void PIM(void)
 		//pimn_F_polar = Saturation_r(pimn_V_ocv,0, 200);
 
 
-		
         pimd_V_ocv   = (uint16_T)(pimn_V_ocv   * 1000);
         pimd_R_ohm   = (uint16_T)(pimn_R_ohm   * 1000 * 1000);
         pimd_R_polar = (uint16_T)(pimn_R_polar * 1000 * 1000);
         pimd_F_polar = (uint16_T)(pimn_F_polar * 1000);
+		
     }
 	else
 	{
@@ -182,8 +186,25 @@ void PIM(void)
         pimd_R_ohm   = 0;
         pimd_R_polar = 0;
         pimd_F_polar = 0;
+		pimn_flg_inval = 0;
 	}
 
+	//全部单体参数---------------------
+    for(i = 0;i < cmnc_num_cellUNum;i++)
+    {
+        if(!pimn_flg_inval && !cdmv_flg_inval[i])
+        {
+            pimv_flg_inval[i]   = 0;
+            pimv_V_cellOcv[i]   = pimd_V_ocv + cdmv_V_deltOCV[i];
+			pimv_R_cellOhm[i]   = pimd_R_ohm + cdmv_R_deltOhm[i];
+			pimv_pct_cellSoc[i] = look1_u16tu16(pimv_V_cellOcv[i], cmnm_V_ocv, cmnm_pct_soc, 13);
+        }
+		else
+		{
+           pimv_flg_inval[i]   = 1;
+		}
+	
+    }
     //
     pimn_st_workStat_Delay = ihd_st_workStat;
     pimd_flg_firstRun = false; 

+ 229 - 223
src/EmbeddedCoder_src/SFM.c

@@ -1,4 +1,6 @@
 #include "SFM.h"
+#define FltArrLen 200
+#define FltDispArrLen 20
 
 DiagThrstruct DiagThr;
 DiagTimestruct DiagTime;
@@ -10,72 +12,72 @@ void SFM_Init(void)
 
 void SFM(void)
 {
-    boolean_T sfmd_flg_interComFlt;
-    boolean_T sfmd_flg_authFlt;
-    boolean_T sfmd_flg_HVILFlt;
-    boolean_T sfmd_flg_chrgMosClosFlt;
-    boolean_T sfmd_flg_disChrgMosClosFlt;
-
-    static uint16_T Time0Cntl;
+	static uint8_T	 sfmn_num_Cnt;
+	boolean_T sfmn_flg_interComFlt;
+    boolean_T sfmn_flg_authFlt;
+    boolean_T sfmn_flg_HVILFlt;
+    boolean_T sfmn_flg_chrgMosClosFlt;
+    boolean_T sfmn_flg_disChrgMosClosFlt;
+
+    static uint16_T Time0Cnt;
     static uint16_T modTMaxArr[10];
     static uint16_T SumT0;
-    static uint16_T Time1Cntl;
+    static uint16_T Time1Cnt;
     static uint16_T heatT1Arr[10];
     static uint16_T SumT1;
-    static uint16_T Time2Cntl;
+    static uint16_T Time2Cnt;
     static uint16_T heatT2Arr[10];
     static uint16_T SumT2;
-    boolean_T deltaTEn1;
-    boolean_T deltaTEn2;
 
-    static uint8_T Cntl;
-    static uint16_T CellUArry[4][cmnc_num_cellUNumMax];
-    static uint8_T ErrNr[cmnc_num_cellUNumMax];
-    static uint8_T RecNr[cmnc_num_cellUNumMax];
+    
+    static uint16_T  CellUArry[4][cmnc_num_cellUNumMax];
+    static uint8_T   ErrNr[cmnc_num_cellUNumMax];
+    static uint8_T   RecNr[cmnc_num_cellUNumMax];
     static boolean_T sfmv_flg_cellUOpenFlt[cmnc_num_cellUNumMax];
     static boolean_T ErrUFlg[cmnc_num_cellUNumMax];
-    uint32_T SumU;
-    uint16_T UNum;
+    uint32_T  SumU;
+    uint16_T  UNum;
     boolean_T sfmd_flg_volFlt;
     boolean_T Enable1;
     boolean_T Enable2;
 
     static uint8_T modTOpenNr[cmnc_num_modTNumMax];
-    static uint8_T modTRationNr[cmnc_num_modTNumMax];
     boolean_T sfmd_flg_modTOpenFlt;
     boolean_T sfmv_flg_modTOpenFlt[cmnc_num_modTNumMax];
     boolean_T sfmd_flg_chrgMosTOpenFlt;
     boolean_T sfmd_flg_DCPlugTOpenFlt;
     boolean_T sfmd_flg_ACPlugTOpenFlt;
-    static boolean_T sfmd_flg_heatPanT1OpenFlt;
-    static boolean_T sfmd_flg_heatPanT2OpenFlt;
-    boolean_T sfmd_flg_modTRationFlt;
-    boolean_T sfmv_flg_modTRationFlt[cmnc_num_modTNumMax];
+    boolean_T sfmd_flg_heatPanT1OpenFlt;
+    boolean_T sfmd_flg_heatPanT2OpenFlt;
 
     static uint16_T modTArr[cmnc_num_modTNumMax];
     uint16_T Tnum;
     uint32_T SumT;
-    boolean_T sfmd_flg_chrgMosTRationFlt;
-    boolean_T sfmd_flg_DCPlugTRationFlt;
-    boolean_T sfmd_flg_ACPlugTRationFlt;
-    static boolean_T sfmd_flg_heatPanT1RationFlt;
-    static boolean_T sfmd_flg_heatPanT2RationFlt;
-    boolean_T sfmd_flg_chrgMosTRationFltOnce;
-    boolean_T sfmd_flg_DCPlugTRationFltOnce;
-    boolean_T sfmd_flg_ACPlugTRationFltOnce;
-    boolean_T sfmd_flg_heatPanT1RationFltOnce;
-    boolean_T sfmd_flg_heatPanT2RationFltOnce;
-    static uint16_T ihd_T_mosT_Delay;
-    static uint16_T ihd_T_DCPlugT_Delay;
-    static uint16_T ihd_T_ACPlugT_Delay;
-    static uint16_T ihd_T_heatPanT1_Delay;
-    static uint16_T ihd_T_heatPanT2_Delay;
-    static uint16_T ihd_T_heatPanT1_Delay1;
-    static uint16_T ihd_T_heatPanT2_Delay1;
+	
+	static uint8_T modTRatNr[cmnc_num_modTNumMax];
+    boolean_T sfmd_flg_modTRatFlt;
+    boolean_T sfmv_flg_modTRatFlt[cmnc_num_modTNumMax];
+    boolean_T sfmd_flg_chrgMosTRatFlt;
+    boolean_T sfmd_flg_DCPlugTRatFlt;
+    boolean_T sfmd_flg_ACPlugTRatFlt;
+    boolean_T sfmd_flg_heatPanT1RatFlt;
+    boolean_T sfmd_flg_heatPanT2RatFlt;
+    boolean_T sfmn_flg_chrgMosTRatFltOnce;
+    boolean_T sfmn_flg_DCPlugTRatFltOnce;
+    boolean_T sfmn_flg_ACPlugTRatFltOnce;
+    boolean_T sfmn_flg_heatPanT1RatFltOnce;
+    boolean_T sfmn_flg_heatPanT2RatFltOnce;
+    static uint16_T sfmn_T_mosT_Delay;
+    static uint16_T sfmn_T_DCPlugT_Delay;
+    static uint16_T sfmn_T_ACPlugT_Delay;
+    static uint16_T sfmn_T_heatPanT1_Delay;
+    static uint16_T sfmn_T_heatPanT2_Delay;
+    static uint16_T sfmn_T_heatPanT1_Delay1;
+    static uint16_T sfmn_T_heatPanT2_Delay1;
     boolean_T sfmd_flg_modTAllFlt;
     boolean_T sfmd_flg_heatPanTAllFlt;
     boolean_T sfmd_flg_currOpenFlt;
-    uint16_T sfmd_I_currAbs;
+    uint16_T  sfmn_I_currAbs;
     static boolean_T sfmd_flg_cellUOverFlt2;
     static boolean_T sfmd_flg_cellUOverFlt1;
     static boolean_T sfmd_flg_cellULowFlt2;
@@ -86,6 +88,7 @@ void SFM(void)
     static boolean_T sfmd_flg_battUOverFlt1;
     static boolean_T sfmd_flg_battULowFlt2;
     static boolean_T sfmd_flg_battULowFlt1;
+	
     boolean_T chrgFlg;
     boolean_T disChrgFlg;
     static boolean_T sfmd_flg_chrgModTOverFlt2;
@@ -111,9 +114,10 @@ void SFM(void)
     boolean_T sfmd_flg_heatPanTOverFlt2;
     static boolean_T sfmd_flg_heatPanTOverFlt1_1;
     static boolean_T sfmd_flg_heatPanTOverFlt1_2;
-    static boolean_T sfmd_flg_heatPanTOverFlt1;
+    boolean_T sfmd_flg_heatPanTOverFlt1;
     static boolean_T sfmd_flg_chrgCurrOverFlt;
     static boolean_T sfmd_flg_disChrgCurrOverFlt;
+	
     boolean_T sfmd_flg_chrgCurrOverMisFlt;
     boolean_T sfmd_flg_disChrgCurrOverMisFlt;
     boolean_T sfmd_flg_battULowMisFlt;
@@ -130,46 +134,46 @@ void SFM(void)
     boolean_T sfmd_flg_sohMisFlt;
     boolean_T sfmd_flg_socJumpFlt;
     boolean_T sfmd_flg_EEsaveFlt;
-    static uint16_T socd_pct_bcuSoc_Delay;
+    static uint16_T sfmn_pct_bcuSoc_Delay;
 
     static uint16_T noDisChrgCnt;
     static int16_T sfmd_I_curr_Delay;
-    static boolean_T sfmd_flg_Udrop;
+    static boolean_T sfmn_flg_Udrop;
     static boolean_T sfmd_flg_heatclear;
-    static boolean_T sfmd_flg_volFlt_keep;
+    static boolean_T sfmn_flg_volFlt_keep;
     static uint16_T CntA;
     static uint16_T ModTStor[4][cmnc_num_modTNumMax];
-    static boolean_T sfmd_flg_Tup;
-    static boolean_T sfmd_flg_modTOpenFlt_keep;
+    static boolean_T sfmn_flg_Tup;
+    static boolean_T sfmn_flg_modTOpenFlt_keep;
     static uint16_T CntB;
-    static boolean_T ihd_flg_urtRecFlt_Delay = false;
+    static boolean_T sfmn_flg_urtRecFlt_Delay = false;
 
     int32_T SumR;
     int32_T SumRR;
     boolean_T sfmd_flg_deltRFlt;
     static uint8_T deltRFltNr[cmnc_num_cellUNumMax];
-    boolean_T FltFlg[200];
-    uint16_T FltLevel[200];
-    uint8_T FltAct[200];
-    uint16_T FltCodeArr[20];
-    uint16_T FltLevelArr[20];
-    uint8_T FltActArr[20];
+	
+    boolean_T FltFlg[FltArrLen];
+    uint16_T  FltLevel[FltArrLen];
+    uint8_T   FltAct[FltArrLen];
+    uint16_T  FltCodeArr[FltDispArrLen];
+    uint16_T  FltLevelArr[FltDispArrLen];
+    uint8_T   FltActArr[FltDispArrLen];
     uint16_T i;
     uint16_T j;
     uint16_T k;
 
-    if (ihd_flg_urtRecFlt_Delay)
+    if (sfmn_flg_urtRecFlt_Delay)
     {
         sfmd_flg_firstRun = true;
     }
-    ihd_flg_urtRecFlt_Delay = ihd_flg_urtRecFlt;
+    sfmn_flg_urtRecFlt_Delay = ihd_flg_urtRecFlt;
     //初值
     if (sfmd_flg_firstRun)
     {
-
+        sfmn_num_Cnt = 10;
         memset(&DiagThr, 0, sizeof(DiagThr));
         memset(&DiagTime, 0, sizeof(DiagTime));
-        Cntl = 10;
         memset(heatT1Arr, 0, sizeof(heatT1Arr));
         memset(heatT2Arr, 0, sizeof(heatT2Arr));
         memset(ErrNr, 0, sizeof(ErrNr));
@@ -177,7 +181,7 @@ void SFM(void)
         memset(ErrUFlg, 0, sizeof(ErrUFlg));
         memset(RecNr, 0, sizeof(RecNr));
         memset(modTOpenNr, 0, sizeof(modTOpenNr));
-        memset(modTRationNr, 0, sizeof(modTRationNr));
+        memset(modTRatNr, 0, sizeof(modTRatNr));
         memset(deltRFltNr, 0, sizeof(deltRFltNr));
         sfmd_flg_cellUOverFlt2 = false;
         sfmd_flg_cellUOverFlt1 = false;
@@ -216,22 +220,22 @@ void SFM(void)
 
         noDisChrgCnt = 0;
         sfmd_I_curr_Delay = ihd_I_curr;
-        sfmd_flg_Udrop = false;
+        sfmn_flg_Udrop = false;
         sfmd_flg_heatclear = false;
-        sfmd_flg_volFlt_keep = false;
+        sfmn_flg_volFlt_keep = false;
         CntA = 10;
-        sfmd_flg_Tup = false;
-        sfmd_flg_modTOpenFlt_keep = false;
+        sfmn_flg_Tup = false;
+        sfmn_flg_modTOpenFlt_keep = false;
         CntB = 0;
 
-        ihd_T_mosT_Delay = ihd_T_mosT;
-        ihd_T_DCPlugT_Delay = ihd_T_DCPlugT;
-        ihd_T_ACPlugT_Delay = ihd_T_ACPlugT;
-        ihd_T_heatPanT1_Delay = ihd_T_heatPanT1;
-        ihd_T_heatPanT2_Delay = ihd_T_heatPanT2;
-        ihd_T_heatPanT1_Delay1 = ihd_T_heatPanT1;
-        ihd_T_heatPanT2_Delay1 = ihd_T_heatPanT2;
-        socd_pct_bcuSoc_Delay = socd_pct_bcuSoc;
+        sfmn_T_mosT_Delay = ihd_T_mosT;
+        sfmn_T_DCPlugT_Delay = ihd_T_DCPlugT;
+        sfmn_T_ACPlugT_Delay = ihd_T_ACPlugT;
+        sfmn_T_heatPanT1_Delay = ihd_T_heatPanT1;
+        sfmn_T_heatPanT2_Delay = ihd_T_heatPanT2;
+        sfmn_T_heatPanT1_Delay1 = ihd_T_heatPanT1;
+        sfmn_T_heatPanT2_Delay1 = ihd_T_heatPanT2;
+        sfmn_pct_bcuSoc_Delay = socd_pct_bcuSoc;
     }
 
     // 故障清楚指令
@@ -256,42 +260,42 @@ void SFM(void)
     // 1 内网通信故障
     if (ihd_flg_urtRecFlt)
     {
-        sfmd_flg_interComFlt = true;
+        sfmn_flg_interComFlt = true;
     }
     else
     {
-        sfmd_flg_interComFlt = false;
+        sfmn_flg_interComFlt = false;
     }
 
     // 5 认证失败故障
-    sfmd_flg_authFlt = (ihd_st_authFaild == 1) && (!sfmd_flg_interComFlt);
+    sfmn_flg_authFlt = (ihd_st_authFaild == 1) && (!sfmn_flg_interComFlt);
 
     // 11 高压互锁故障
     if (ihd_flg_HVILFlt)
     {
-        sfmd_flg_HVILFlt = true;
+        sfmn_flg_HVILFlt = true;
     }
     else
     {
-        sfmd_flg_HVILFlt = false;
+        sfmn_flg_HVILFlt = false;
     }
     // 16
     sfmd_flg_iscFltEo = iscd_flg_flt || sfmd_flg_iscFltEi || sfmd_flg_iscFltEo;
 
     // 22 充电Mos失效故障
-    sfmd_flg_chrgMosClosFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_flg_chrgMosClosFlt, &DiagTime.N22, 2);
+    sfmn_flg_chrgMosClosFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_flg_chrgMosClosFlt, &DiagTime.N22, 2);
 
     // 24 放电Mos失效故障
-    sfmd_flg_disChrgMosClosFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_flg_disChrgMosClosFlt, &DiagTime.N24, 2);
+    sfmn_flg_disChrgMosClosFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_flg_disChrgMosClosFlt, &DiagTime.N24, 2);
 
     // 34 主回路常闭故障   //(充电MOS及放电MOS,主继电器断开  使能)
     sfmd_flg_mainCirClosFltEo = JudgeTimeSystem(!ihd_st_chrgMosControl && !ihd_st_disChrgMosControl && !ihd_st_relayControl, sfmd_I_curr > 5 || sfmd_I_curr < -5, &DiagTime.N34, 5) || sfmd_flg_mainCirClosFltEo || sfmd_flg_mainCirClosFltEi;
 
     // 52 电压开路故障
-    Cntl = Cntl + 1;
-    if (!sfmd_flg_interComFlt && Cntl >= 0)
+    sfmn_num_Cnt = sfmn_num_Cnt + 1;
+    if (!sfmn_flg_interComFlt && sfmn_num_Cnt >= 0)
     {
-        Cntl = 0;
+        sfmn_num_Cnt = 0;
         // 矩阵更新
         for (j = 0; j < 4 && sfmd_flg_firstRun; j++)
         {
@@ -342,7 +346,7 @@ void SFM(void)
         }
     }
     //
-    if (!sfmd_flg_interComFlt)
+    if (!sfmn_flg_interComFlt)
     {
         sfmd_V_cellUMax = 0;
         sfmd_V_cellUMin = 10000;
@@ -413,7 +417,7 @@ void SFM(void)
     sfmd_flg_volFlt = false;
     for (i = 0; i < cmnc_num_cellUNum; i++)
     {
-        if (ErrUFlg[i] && !sfmd_flg_interComFlt)
+        if (ErrUFlg[i] && !sfmn_flg_interComFlt)
         {
             sfmv_V_cellU[i] = sfmd_V_cellUAvrg;
         }
@@ -431,7 +435,7 @@ void SFM(void)
     sfmd_flg_modTOpenFlt = false;
     for (i = 0; i < cmnc_num_modTNum; i++)
     {
-        if (ihv_T_modT[i] == 10 && !sfmd_flg_interComFlt) //-30℃
+        if (ihv_T_modT[i] == 10 && !sfmn_flg_interComFlt) //-30℃
         {
             modTOpenNr[i] = (modTOpenNr[i] + 1) > 200 ? 200 : (modTOpenNr[i] + 1);
         }
@@ -452,92 +456,92 @@ void SFM(void)
     }
 
     // 54 Mos温度开路故障
-    sfmd_flg_chrgMosTOpenFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_T_mosT == 10, &DiagTime.N54, 2);
+    sfmd_flg_chrgMosTOpenFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_T_mosT == 10, &DiagTime.N54, 2);
 
     // 56 快充插头温度开路故障
-    sfmd_flg_DCPlugTOpenFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_T_DCPlugT == 0, &DiagTime.N56, 2);
+    sfmd_flg_DCPlugTOpenFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_T_DCPlugT == 0, &DiagTime.N56, 2);
     // 57 慢充插头温度开路故障
-    sfmd_flg_ACPlugTOpenFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_T_ACPlugT == 0, &DiagTime.N57, 2);
+    sfmd_flg_ACPlugTOpenFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_T_ACPlugT == 0, &DiagTime.N57, 2);
     // 58 加热板#1温度开路故障
-    sfmd_flg_heatPanT1OpenFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_T_heatPanT1 == 0, &DiagTime.N58, 2);
+    sfmd_flg_heatPanT1OpenFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_T_heatPanT1 == 0, &DiagTime.N58, 2);
     // 59 加热板#2温度开路故障
-    sfmd_flg_heatPanT2OpenFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_T_heatPanT2 == 0, &DiagTime.N59, 2);
+    sfmd_flg_heatPanT2OpenFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, ihd_T_heatPanT2 == 0, &DiagTime.N59, 2);
 
     // 61 模组温度合理性故障
-    sfmd_flg_modTRationFlt = false;
+    sfmd_flg_modTRatFlt = false;
     for (i = 0; i < cmnc_num_modTNum && sfmd_flg_firstRun; i++)
     {
         modTArr[i] = ihv_T_modT[i];
     }
     for (i = 0; i < cmnc_num_modTNum; i++)
     {
-        if (!sfmv_flg_modTOpenFlt[i] && ((int16_T)(modTArr[i] - ihv_T_modT[i]) > 10 || (int16_T)(modTArr[i] - ihv_T_modT[i]) < -20) && !sfmd_flg_interComFlt)
+        if (!sfmv_flg_modTOpenFlt[i] && ((int16_T)(modTArr[i] - ihv_T_modT[i]) > 10 || (int16_T)(modTArr[i] - ihv_T_modT[i]) < -20) && !sfmn_flg_interComFlt)
         {
-            modTRationNr[i] = (modTRationNr[i] + 1) > 200 ? 200 : (modTRationNr[i] + 1);
+            modTRatNr[i] = (modTRatNr[i] + 1) > 200 ? 200 : (modTRatNr[i] + 1);
         }
         else
         {
-            modTRationNr[i] = 0;
+            modTRatNr[i] = 0;
             modTArr[i] = ihv_T_modT[i];
         }
-        if (modTRationNr[i] >= 2)
+        if (modTRatNr[i] >= 2)
         {
-            sfmv_flg_modTRationFlt[i] = true;
+            sfmv_flg_modTRatFlt[i] = true;
         }
         else
         {
-            sfmv_flg_modTRationFlt[i] = false;
+            sfmv_flg_modTRatFlt[i] = false;
         }
 
-        sfmd_flg_modTRationFlt = sfmd_flg_modTRationFlt || sfmv_flg_modTRationFlt[i];
+        sfmd_flg_modTRatFlt = sfmd_flg_modTRatFlt || sfmv_flg_modTRatFlt[i];
     }
 
-    // printf("%d,%d,%d,%d\n",ihd_T_mosT_Delay,ihd_T_mosT,FirstRun_SFM,ihd_flg_urtRecFlt);
+    // printf("%d,%d,%d,%d\n",sfmn_T_mosT_Delay,ihd_T_mosT,FirstRun_SFM,ihd_flg_urtRecFlt);
     // 62 充电Mos 温度合理性故障
-    sfmd_flg_chrgMosTRationFltOnce = !sfmd_flg_interComFlt && !sfmd_flg_chrgMosTOpenFlt && ((int16_T)(ihd_T_mosT - ihd_T_mosT_Delay) < -10 || (int16_T)(ihd_T_mosT - ihd_T_mosT_Delay) > 20);
-    if (!sfmd_flg_chrgMosTRationFltOnce)
+    sfmn_flg_chrgMosTRatFltOnce = !sfmn_flg_interComFlt && !sfmd_flg_chrgMosTOpenFlt && ((int16_T)(ihd_T_mosT - sfmn_T_mosT_Delay) < -10 || (int16_T)(ihd_T_mosT - sfmn_T_mosT_Delay) > 20);
+    if (!sfmn_flg_chrgMosTRatFltOnce)
     {
-        ihd_T_mosT_Delay = ihd_T_mosT;
+        sfmn_T_mosT_Delay = ihd_T_mosT;
     }
-    sfmd_flg_chrgMosTRationFlt = JudgeTimeSystem(1, sfmd_flg_chrgMosTRationFltOnce, &DiagTime.N62, 2);
+    sfmd_flg_chrgMosTRatFlt = JudgeTimeSystem(1, sfmn_flg_chrgMosTRatFltOnce, &DiagTime.N62, 2);
 
     // 64 快充插头温度合理性故障
-    sfmd_flg_DCPlugTRationFltOnce = !sfmd_flg_interComFlt && !sfmd_flg_DCPlugTOpenFlt && ((int16_T)(ihd_T_DCPlugT - ihd_T_DCPlugT_Delay) < -10 || (int16_T)(ihd_T_DCPlugT - ihd_T_DCPlugT_Delay) > 20);
-    if (!sfmd_flg_DCPlugTRationFltOnce)
+    sfmn_flg_DCPlugTRatFltOnce = !sfmn_flg_interComFlt && !sfmd_flg_DCPlugTOpenFlt && ((int16_T)(ihd_T_DCPlugT - sfmn_T_DCPlugT_Delay) < -10 || (int16_T)(ihd_T_DCPlugT - sfmn_T_DCPlugT_Delay) > 20);
+    if (!sfmn_flg_chrgMosTRatFltOnce)
     {
-        ihd_T_DCPlugT_Delay = ihd_T_DCPlugT;
+        sfmn_T_DCPlugT_Delay = ihd_T_DCPlugT;
     }
-    sfmd_flg_DCPlugTRationFlt = JudgeTimeSystem(1, sfmd_flg_DCPlugTRationFltOnce, &DiagTime.N64, 2);
+    sfmd_flg_DCPlugTRatFlt = JudgeTimeSystem(1, sfmn_flg_DCPlugTRatFltOnce, &DiagTime.N64, 2);
 
     // 65 慢插头温度合理性故障
-    sfmd_flg_ACPlugTRationFltOnce = !sfmd_flg_interComFlt && !sfmd_flg_ACPlugTOpenFlt && ((int16_T)(ihd_T_ACPlugT - ihd_T_ACPlugT_Delay) < -10 || (int16_T)(ihd_T_ACPlugT - ihd_T_ACPlugT_Delay) > 20);
-    if (!sfmd_flg_ACPlugTRationFltOnce)
+    sfmn_flg_ACPlugTRatFltOnce = !sfmn_flg_interComFlt && !sfmd_flg_ACPlugTOpenFlt && ((int16_T)(ihd_T_ACPlugT - sfmn_T_ACPlugT_Delay) < -10 || (int16_T)(ihd_T_ACPlugT - sfmn_T_ACPlugT_Delay) > 20);
+    if (!sfmn_flg_ACPlugTRatFltOnce)
     {
-        ihd_T_ACPlugT_Delay = ihd_T_ACPlugT;
+        sfmn_T_ACPlugT_Delay = ihd_T_ACPlugT;
     }
-    sfmd_flg_ACPlugTRationFlt = JudgeTimeSystem(1, sfmd_flg_ACPlugTRationFltOnce, &DiagTime.N65, 2);
+    sfmd_flg_ACPlugTRatFlt = JudgeTimeSystem(1, sfmn_flg_ACPlugTRatFltOnce, &DiagTime.N65, 2);
 
     // 66 加热板#1 温度合理性故障
-    sfmd_flg_heatPanT1RationFltOnce = !sfmd_flg_interComFlt && !sfmd_flg_heatPanT1OpenFlt && ((int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay) < -10 || (int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay) > 20);
-    if (!sfmd_flg_heatPanT1RationFltOnce)
+    sfmn_flg_heatPanT1RatFltOnce = !sfmn_flg_interComFlt && !sfmd_flg_heatPanT1OpenFlt && ((int16_T)(ihd_T_heatPanT1 - sfmn_T_heatPanT1_Delay) < -10 || (int16_T)(ihd_T_heatPanT1 - sfmn_T_heatPanT1_Delay) > 20);
+    if (!sfmn_flg_heatPanT1RatFltOnce)
     {
-        ihd_T_heatPanT1_Delay = ihd_T_heatPanT1;
+        sfmn_T_heatPanT1_Delay = ihd_T_heatPanT1;
     }
-    sfmd_flg_heatPanT1RationFlt = JudgeTimeSystem(1, sfmd_flg_heatPanT1RationFltOnce, &DiagTime.N66, 2);
+    sfmd_flg_heatPanT1RatFlt = JudgeTimeSystem(1, sfmn_flg_heatPanT1RatFltOnce, &DiagTime.N66, 2);
 
     // 67 加热板#2 温度合理性故障
-    sfmd_flg_heatPanT2RationFltOnce = !sfmd_flg_interComFlt && !sfmd_flg_heatPanT2OpenFlt && ((int16_T)(ihd_T_heatPanT2 - ihd_T_heatPanT2_Delay) < -10 || (int16_T)(ihd_T_heatPanT2 - ihd_T_heatPanT2_Delay) > 20);
-    if (!sfmd_flg_heatPanT2RationFltOnce)
+    sfmn_flg_heatPanT2RatFltOnce = !sfmn_flg_interComFlt && !sfmd_flg_heatPanT2OpenFlt && ((int16_T)(ihd_T_heatPanT2 - sfmn_T_heatPanT2_Delay) < -10 || (int16_T)(ihd_T_heatPanT2 - sfmn_T_heatPanT2_Delay) > 20);
+    if (!sfmn_flg_heatPanT2RatFltOnce)
     {
-        ihd_T_heatPanT2_Delay = ihd_T_heatPanT2;
+        sfmn_T_heatPanT2_Delay = ihd_T_heatPanT2;
     }
-    sfmd_flg_heatPanT2RationFlt = JudgeTimeSystem(1, sfmd_flg_heatPanT2RationFltOnce, &DiagTime.N67, 2);
+    sfmd_flg_heatPanT2RatFlt = JudgeTimeSystem(1, sfmn_flg_heatPanT2RatFltOnce, &DiagTime.N67, 2);
 
     // 68 模组温度全部不可用
     sfmd_flg_modTAllFlt = true;
     for (i = 0; i < cmnc_num_modTNum; i++)
     {
-        sfmd_flg_modTAllFlt = sfmd_flg_modTAllFlt && (sfmv_flg_modTOpenFlt[i] || sfmv_flg_modTRationFlt[i]);
+        sfmd_flg_modTAllFlt = sfmd_flg_modTAllFlt && (sfmv_flg_modTOpenFlt[i] || sfmv_flg_modTRatFlt[i]);
     }
 
     // 温度处理
@@ -549,7 +553,7 @@ void SFM(void)
     {
         for (i = 0; i < cmnc_num_modTNum; i++)
         {
-            if (!sfmv_flg_modTRationFlt[i] && !sfmv_flg_modTOpenFlt[i])
+            if (!sfmv_flg_modTRatFlt[i] && !sfmv_flg_modTOpenFlt[i])
             {
                 SumT = SumT + ihv_T_modT[i];
                 Tnum = Tnum + 1;
@@ -567,7 +571,7 @@ void SFM(void)
         }
         for (i = 0; i < cmnc_num_modTNum; i++)
         {
-            if (!sfmv_flg_modTRationFlt[i] && !sfmv_flg_modTOpenFlt[i])
+            if (!sfmv_flg_modTRatFlt[i] && !sfmv_flg_modTOpenFlt[i])
             {
                 sfmv_T_modT[i] = ihv_T_modT[i];
             }
@@ -579,145 +583,148 @@ void SFM(void)
     }
 
     // 69 加热板温度全部开路故障
-    sfmd_flg_heatPanTAllFlt = (sfmd_flg_heatPanT1OpenFlt || sfmd_flg_heatPanT1RationFlt) && (sfmd_flg_heatPanT2OpenFlt || sfmd_flg_heatPanT2RationFlt);
+    sfmd_flg_heatPanTAllFlt = (sfmd_flg_heatPanT1OpenFlt || sfmd_flg_heatPanT1RatFlt) && (sfmd_flg_heatPanT2OpenFlt || sfmd_flg_heatPanT2RatFlt);
 
     // 71 电流传感器故障
     sfmd_flg_currOpenFlt = false;
     sfmd_I_curr = ihd_I_curr;
     // 81 单体过压故障2级
-    sfmd_flg_cellUOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt, sfmd_V_cellUMax, sfmc_V_cellUOverThrFlt2, sfmc_V_cellUOverThrRec2, 2, 2, &DiagThr.fltNum81, &DiagThr.recNum81, &sfmd_flg_cellUOverFlt2);
+    sfmd_flg_cellUOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt, sfmd_V_cellUMax, sfmc_V_cellUOverThrFlt2, sfmc_V_cellUOverThrRec2, 2, 2, &DiagThr.fltNum81, &DiagThr.recNum81, &sfmd_flg_cellUOverFlt2);
     // 82 单体过压故障1级
-    sfmd_flg_cellUOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt, sfmd_V_cellUMax, sfmc_V_cellUOverThrFlt1, sfmc_V_cellUOverThrRec1, 2, 2, &DiagThr.fltNum82, &DiagThr.recNum82, &sfmd_flg_cellUOverFlt1) && !sfmd_flg_cellUOverFlt2;
+    sfmd_flg_cellUOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt, sfmd_V_cellUMax, sfmc_V_cellUOverThrFlt1, sfmc_V_cellUOverThrRec1, 2, 2, &DiagThr.fltNum82, &DiagThr.recNum82, &sfmd_flg_cellUOverFlt1) && !sfmd_flg_cellUOverFlt2;
 
     // 83 单体欠压故障2级
-    sfmd_flg_cellULowFlt2 = DiagThrSystem2(1, !sfmd_flg_interComFlt, sfmd_V_cellUMin, sfmc_V_cellULowThrFlt2, sfmc_V_cellULowThrRec2, 2, 2, &DiagThr.fltNum83, &DiagThr.recNum83, &sfmd_flg_cellULowFlt2);
+    sfmd_flg_cellULowFlt2 = DiagThrSystem2(1, !sfmn_flg_interComFlt, sfmd_V_cellUMin, sfmc_V_cellULowThrFlt2, sfmc_V_cellULowThrRec2, 2, 2, &DiagThr.fltNum83, &DiagThr.recNum83, &sfmd_flg_cellULowFlt2);
     // 84 单体欠压故障1级
-    sfmd_flg_cellULowFlt1 = DiagThrSystem2(0, !sfmd_flg_interComFlt, sfmd_V_cellUMin, sfmc_V_cellULowThrFlt1, sfmc_V_cellULowThrRec1, 2, 2, &DiagThr.fltNum84, &DiagThr.recNum84, &sfmd_flg_cellULowFlt1) && !sfmd_flg_cellULowFlt2;
+    sfmd_flg_cellULowFlt1 = DiagThrSystem2(0, !sfmn_flg_interComFlt, sfmd_V_cellUMin, sfmc_V_cellULowThrFlt1, sfmc_V_cellULowThrRec1, 2, 2, &DiagThr.fltNum84, &DiagThr.recNum84, &sfmd_flg_cellULowFlt1) && !sfmd_flg_cellULowFlt2;
 
     // 85 压差过大2级
-    sfmd_flg_cellUDiffFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && socd_pct_battSoc > 200, sfmd_V_cellUMax - sfmd_V_cellUMin, sfmc_flg_cellUDiffThrFlt2, sfmc_flg_cellUDiffThrRec2, 2, 2, &DiagThr.fltNum85, &DiagThr.recNum85, &sfmd_flg_cellUDiffFlt2);
+    sfmd_flg_cellUDiffFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && socd_pct_battSoc > 200, sfmd_V_cellUMax - sfmd_V_cellUMin, sfmc_flg_cellUDiffThrFlt2, sfmc_flg_cellUDiffThrRec2, 2, 2, &DiagThr.fltNum85, &DiagThr.recNum85, &sfmd_flg_cellUDiffFlt2);
     // 86 压差过大1级
-    sfmd_flg_cellUDiffFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && socd_pct_battSoc > 200, sfmd_V_cellUMax - sfmd_V_cellUMin, sfmc_flg_cellUDiffThrFlt1, sfmc_flg_cellUDiffThrRec1, 2, 2, &DiagThr.fltNum86, &DiagThr.recNum86, &sfmd_flg_cellUDiffFlt1) && !sfmd_flg_cellUDiffFlt2;
+    sfmd_flg_cellUDiffFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && socd_pct_battSoc > 200, sfmd_V_cellUMax - sfmd_V_cellUMin, sfmc_flg_cellUDiffThrFlt1, sfmc_flg_cellUDiffThrRec1, 2, 2, &DiagThr.fltNum86, &DiagThr.recNum86, &sfmd_flg_cellUDiffFlt1) && !sfmd_flg_cellUDiffFlt2;
 
     // 87 总压过压2级
-    sfmd_flg_battUOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt, sfmd_V_battU, sfmc_V_battUOverThrFlt2, sfmc_V_battUOverThrRec2, 2, 2, &DiagThr.fltNum87, &DiagThr.recNum87, &sfmd_flg_battUOverFlt2);
+    sfmd_flg_battUOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt, sfmd_V_battU, sfmc_V_battUOverThrFlt2, sfmc_V_battUOverThrRec2, 2, 2, &DiagThr.fltNum87, &DiagThr.recNum87, &sfmd_flg_battUOverFlt2);
     // 88 总压过压1级
-    sfmd_flg_battUOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt, sfmd_V_battU, sfmc_V_battUOverThrFlt1, sfmc_V_battUOverThrRec1, 2, 2, &DiagThr.fltNum88, &DiagThr.recNum88, &sfmd_flg_battUOverFlt1) && !sfmd_flg_battUOverFlt2;
+    sfmd_flg_battUOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt, sfmd_V_battU, sfmc_V_battUOverThrFlt1, sfmc_V_battUOverThrRec1, 2, 2, &DiagThr.fltNum88, &DiagThr.recNum88, &sfmd_flg_battUOverFlt1) && !sfmd_flg_battUOverFlt2;
 
     // 89 总压欠压2级
-    sfmd_flg_battULowFlt2 = DiagThrSystem2(1, !sfmd_flg_interComFlt, sfmd_V_battU, sfmc_V_battULowThrFlt2, sfmc_V_battULowThrRec2, 2, 2, &DiagThr.fltNum89, &DiagThr.recNum89, &sfmd_flg_battULowFlt2);
+    sfmd_flg_battULowFlt2 = DiagThrSystem2(1, !sfmn_flg_interComFlt, sfmd_V_battU, sfmc_V_battULowThrFlt2, sfmc_V_battULowThrRec2, 2, 2, &DiagThr.fltNum89, &DiagThr.recNum89, &sfmd_flg_battULowFlt2);
     // 90 总压欠压1级
-    sfmd_flg_battULowFlt1 = DiagThrSystem2(0, !sfmd_flg_interComFlt, sfmd_V_battU, sfmc_V_battULowThrFlt1, sfmc_V_battULowThrRec1, 2, 2, &DiagThr.fltNum90, &DiagThr.recNum90, &sfmd_flg_battULowFlt1) && !sfmd_flg_battULowFlt2;
+    sfmd_flg_battULowFlt1 = DiagThrSystem2(0, !sfmn_flg_interComFlt, sfmd_V_battU, sfmc_V_battULowThrFlt1, sfmc_V_battULowThrRec1, 2, 2, &DiagThr.fltNum90, &DiagThr.recNum90, &sfmd_flg_battULowFlt1) && !sfmd_flg_battULowFlt2;
 
     chrgFlg = ihd_st_workStat == 2;
     disChrgFlg = ihd_st_workStat != 2;
 
     // 97 模组充电温度过高2级故障
-    sfmd_flg_chrgModTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_chrgModTOverThrFlt2, sfmc_T_chrgModTOverThrRec2, 3, 3, &DiagThr.fltNum97, &DiagThr.recNum97, &sfmd_flg_chrgModTOverFlt2);
+    sfmd_flg_chrgModTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_chrgModTOverThrFlt2, sfmc_T_chrgModTOverThrRec2, 3, 3, &DiagThr.fltNum97, &DiagThr.recNum97, &sfmd_flg_chrgModTOverFlt2);
     // 98 模组充电温度过高1级故障
-    sfmd_flg_chrgModTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_chrgModTOverThrFlt1, sfmc_T_chrgModTOverThrRec1, 3, 3, &DiagThr.fltNum98, &DiagThr.recNum98, &sfmd_flg_chrgModTOverFlt1) && !sfmd_flg_chrgModTOverFlt2;
+    sfmd_flg_chrgModTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_chrgModTOverThrFlt1, sfmc_T_chrgModTOverThrRec1, 3, 3, &DiagThr.fltNum98, &DiagThr.recNum98, &sfmd_flg_chrgModTOverFlt1) && !sfmd_flg_chrgModTOverFlt2;
     // 99 模组充电温度过低2级故障
-    sfmd_flg_chrgModTLowFlt2 = DiagThrSystem2(0, !sfmd_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_chrgModTLowThrFlt2, sfmc_T_chrgModTLowThrRec2, 3, 3, &DiagThr.fltNum99, &DiagThr.recNum99, &sfmd_flg_chrgModTLowFlt2);
+    sfmd_flg_chrgModTLowFlt2 = DiagThrSystem2(0, !sfmn_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_chrgModTLowThrFlt2, sfmc_T_chrgModTLowThrRec2, 3, 3, &DiagThr.fltNum99, &DiagThr.recNum99, &sfmd_flg_chrgModTLowFlt2);
     // 100 模组充电温度过低1级故障
-    sfmd_flg_chrgModTLowFlt1 = DiagThrSystem2(0, !sfmd_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_chrgModTLowThrFlt1, sfmc_T_chrgModTLowThrRec1, 3, 3, &DiagThr.fltNum100, &DiagThr.recNum100, &sfmd_flg_chrgModTLowFlt1) && !sfmd_flg_chrgModTLowFlt2;
+    sfmd_flg_chrgModTLowFlt1 = DiagThrSystem2(0, !sfmn_flg_interComFlt && chrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_chrgModTLowThrFlt1, sfmc_T_chrgModTLowThrRec1, 3, 3, &DiagThr.fltNum100, &DiagThr.recNum100, &sfmd_flg_chrgModTLowFlt1) && !sfmd_flg_chrgModTLowFlt2;
 
     // 101 模组放电温度过高2级故障
-    sfmd_flg_disChrgModTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_disChrgModTOverThrFlt2, sfmc_T_disChrgModTOverThrRec2, 3, 3, &DiagThr.fltNum101, &DiagThr.recNum101, &sfmd_flg_disChrgModTOverFlt2);
+    sfmd_flg_disChrgModTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_disChrgModTOverThrFlt2, sfmc_T_disChrgModTOverThrRec2, 3, 3, &DiagThr.fltNum101, &DiagThr.recNum101, &sfmd_flg_disChrgModTOverFlt2);
     // 102 模组放电温度过高1级故障
-    sfmd_flg_disChrgModTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_disChrgModTOverThrFlt1, sfmc_T_disChrgModTOverThrRec1, 3, 3, &DiagThr.fltNum102, &DiagThr.recNum102, &sfmd_flg_disChrgModTOverFlt1) && !sfmd_flg_disChrgModTOverFlt2;
+    sfmd_flg_disChrgModTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMax, sfmc_T_disChrgModTOverThrFlt1, sfmc_T_disChrgModTOverThrRec1, 3, 3, &DiagThr.fltNum102, &DiagThr.recNum102, &sfmd_flg_disChrgModTOverFlt1) && !sfmd_flg_disChrgModTOverFlt2;
     // 103 模组放电温度过低2级故障
-    sfmd_flg_disChrgModTLowFlt2 = DiagThrSystem2(0, !sfmd_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_disChrgModTLowThrFlt2, sfmc_T_disChrgModTLowThrRec2, 3, 3, &DiagThr.fltNum103, &DiagThr.recNum103, &sfmd_flg_disChrgModTLowFlt2);
+    sfmd_flg_disChrgModTLowFlt2 = DiagThrSystem2(0, !sfmn_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_disChrgModTLowThrFlt2, sfmc_T_disChrgModTLowThrRec2, 3, 3, &DiagThr.fltNum103, &DiagThr.recNum103, &sfmd_flg_disChrgModTLowFlt2);
     // 104 模组放电温度过低1级故障
-    sfmd_flg_disChrgModTLowFlt1 = DiagThrSystem2(0, !sfmd_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_disChrgModTLowThrFlt1, sfmc_T_disChrgModTLowThrRec1, 3, 3, &DiagThr.fltNum104, &DiagThr.recNum104, &sfmd_flg_disChrgModTLowFlt1) && !sfmd_flg_disChrgModTLowFlt2;
+    sfmd_flg_disChrgModTLowFlt1 = DiagThrSystem2(0, !sfmn_flg_interComFlt && disChrgFlg && !sfmd_flg_modTAllFlt, sfmd_T_modTMin, sfmc_T_disChrgModTLowThrFlt1, sfmc_T_disChrgModTLowThrRec1, 3, 3, &DiagThr.fltNum104, &DiagThr.recNum104, &sfmd_flg_disChrgModTLowFlt1) && !sfmd_flg_disChrgModTLowFlt2;
 
     //
     // 105 模组温差2级故障
-    sfmd_flg_modTDiffFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && !sfmd_flg_modTAllFlt, sfmd_T_modTMax - sfmd_T_modTMin, sfmc_T_modTDiffThrFlt2, sfmc_T_modTDiffThrRec2, 3, 3, &DiagThr.fltNum105, &DiagThr.recNum105, &sfmd_flg_modTDiffFlt2);
+    sfmd_flg_modTDiffFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && !sfmd_flg_modTAllFlt, sfmd_T_modTMax - sfmd_T_modTMin, sfmc_T_modTDiffThrFlt2, sfmc_T_modTDiffThrRec2, 3, 3, &DiagThr.fltNum105, &DiagThr.recNum105, &sfmd_flg_modTDiffFlt2);
     // 106 模组温差1级故障
-    sfmd_flg_modTDiffFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && !sfmd_flg_modTAllFlt, sfmd_T_modTMax - sfmd_T_modTMin, sfmc_T_modTDiffThrFlt1, sfmc_T_modTDiffThrRec1, 3, 3, &DiagThr.fltNum106, &DiagThr.recNum106, &sfmd_flg_modTDiffFlt1) && !sfmd_flg_modTDiffFlt2;
+    sfmd_flg_modTDiffFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && !sfmd_flg_modTAllFlt, sfmd_T_modTMax - sfmd_T_modTMin, sfmc_T_modTDiffThrFlt1, sfmc_T_modTDiffThrRec1, 3, 3, &DiagThr.fltNum106, &DiagThr.recNum106, &sfmd_flg_modTDiffFlt1) && !sfmd_flg_modTDiffFlt2;
 
     // 107 充电Mos温度过高2级故障
-    sfmd_flg_chrgMosTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && chrgFlg && sfmd_flg_chrgMosTRationFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_chrgMosTOverThrFlt2, sfmc_T_chrgMosTOverThrRec2, 3, 3, &DiagThr.fltNum107, &DiagThr.recNum107, &sfmd_flg_chrgMosTOverFlt2);
+    sfmd_flg_chrgMosTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && chrgFlg && sfmd_flg_chrgMosTRatFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_chrgMosTOverThrFlt2, sfmc_T_chrgMosTOverThrRec2, 3, 3, &DiagThr.fltNum107, &DiagThr.recNum107, &sfmd_flg_chrgMosTOverFlt2);
     // 108 充电Mos温度过高1级故障
-    sfmd_flg_chrgMosTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && chrgFlg && sfmd_flg_chrgMosTRationFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_chrgMosTOverThrFlt1, sfmc_T_chrgMosTOverThrRec1, 3, 3, &DiagThr.fltNum108, &DiagThr.recNum108, &sfmd_flg_chrgMosTOverFlt1) && !sfmd_flg_chrgMosTOverFlt2;
+    sfmd_flg_chrgMosTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && chrgFlg && sfmd_flg_chrgMosTRatFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_chrgMosTOverThrFlt1, sfmc_T_chrgMosTOverThrRec1, 3, 3, &DiagThr.fltNum108, &DiagThr.recNum108, &sfmd_flg_chrgMosTOverFlt1) && !sfmd_flg_chrgMosTOverFlt2;
     // 109 放电Mos温度过高2级故障
-    sfmd_flg_disChrgMosTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && disChrgFlg && sfmd_flg_chrgMosTRationFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_disChrgMosTOverThrFlt2, sfmc_T_disChrgMosTOverThrRec2, 3, 3, &DiagThr.fltNum109, &DiagThr.recNum109, &sfmd_flg_disChrgMosTOverFlt2);
+    sfmd_flg_disChrgMosTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && disChrgFlg && sfmd_flg_chrgMosTRatFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_disChrgMosTOverThrFlt2, sfmc_T_disChrgMosTOverThrRec2, 3, 3, &DiagThr.fltNum109, &DiagThr.recNum109, &sfmd_flg_disChrgMosTOverFlt2);
     // 110 放电Mos温度过高1级故障
-    sfmd_flg_disChrgMosTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && disChrgFlg && sfmd_flg_chrgMosTRationFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_disChrgMosTOverThrFlt1, sfmc_T_disChrgMosTOverThrRec1, 3, 3, &DiagThr.fltNum110, &DiagThr.recNum110, &sfmd_flg_disChrgMosTOverFlt1) && !sfmd_flg_disChrgMosTOverFlt2;
+    sfmd_flg_disChrgMosTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && disChrgFlg && sfmd_flg_chrgMosTRatFlt && sfmd_flg_chrgMosTOpenFlt, ihd_T_mosT, sfmc_T_disChrgMosTOverThrFlt1, sfmc_T_disChrgMosTOverThrRec1, 3, 3, &DiagThr.fltNum110, &DiagThr.recNum110, &sfmd_flg_disChrgMosTOverFlt1) && !sfmd_flg_disChrgMosTOverFlt2;
 
     // 111 快充插头温度过高2级故障
-    sfmd_flg_DCPlugTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && sfmd_flg_DCPlugTRationFlt && sfmd_flg_DCPlugTOpenFlt, ihd_T_DCPlugT, sfmc_T_DCPlugTOverThrFlt2, sfmc_T_DCPlugTOverThrRec2, 3, 3, &DiagThr.fltNum111, &DiagThr.recNum111, &sfmd_flg_DCPlugTOverFlt2);
+    sfmd_flg_DCPlugTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && sfmd_flg_DCPlugTRatFlt && sfmd_flg_DCPlugTOpenFlt, ihd_T_DCPlugT, sfmc_T_DCPlugTOverThrFlt2, sfmc_T_DCPlugTOverThrRec2, 3, 3, &DiagThr.fltNum111, &DiagThr.recNum111, &sfmd_flg_DCPlugTOverFlt2);
     // 112 快充插头温度过高1级故障
-    sfmd_flg_DCPlugTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && sfmd_flg_DCPlugTRationFlt && sfmd_flg_DCPlugTOpenFlt, ihd_T_DCPlugT, sfmc_T_DCPlugTOverThrFlt1, sfmc_T_DCPlugTOverThrRec1, 3, 3, &DiagThr.fltNum112, &DiagThr.recNum112, &sfmd_flg_DCPlugTOverFlt1) && !sfmd_flg_DCPlugTOverFlt2;
+    sfmd_flg_DCPlugTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && sfmd_flg_DCPlugTRatFlt && sfmd_flg_DCPlugTOpenFlt, ihd_T_DCPlugT, sfmc_T_DCPlugTOverThrFlt1, sfmc_T_DCPlugTOverThrRec1, 3, 3, &DiagThr.fltNum112, &DiagThr.recNum112, &sfmd_flg_DCPlugTOverFlt1) && !sfmd_flg_DCPlugTOverFlt2;
     // 113 慢充插头温度过高2级故障
-    sfmd_flg_ACPlugTOverFlt2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && sfmd_flg_ACPlugTRationFlt && sfmd_flg_ACPlugTOpenFlt, ihd_T_ACPlugT, sfmc_T_ACPlugTOverThrFlt2, sfmc_T_ACPlugTOverThrRec2, 3, 3, &DiagThr.fltNum113, &DiagThr.recNum113, &sfmd_flg_ACPlugTOverFlt2);
+    sfmd_flg_ACPlugTOverFlt2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && sfmd_flg_ACPlugTRatFlt && sfmd_flg_ACPlugTOpenFlt, ihd_T_ACPlugT, sfmc_T_ACPlugTOverThrFlt2, sfmc_T_ACPlugTOverThrRec2, 3, 3, &DiagThr.fltNum113, &DiagThr.recNum113, &sfmd_flg_ACPlugTOverFlt2);
     // 114 慢充插头温度过高1级故障
-    sfmd_flg_ACPlugTOverFlt1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && sfmd_flg_ACPlugTRationFlt && sfmd_flg_ACPlugTOpenFlt, ihd_T_ACPlugT, sfmc_T_ACPlugTOverThrFlt1, sfmc_T_ACPlugTOverThrRec1, 3, 3, &DiagThr.fltNum114, &DiagThr.recNum114, &sfmd_flg_ACPlugTOverFlt1) && !sfmd_flg_ACPlugTOverFlt2;
+    sfmd_flg_ACPlugTOverFlt1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && sfmd_flg_ACPlugTRatFlt && sfmd_flg_ACPlugTOpenFlt, ihd_T_ACPlugT, sfmc_T_ACPlugTOverThrFlt1, sfmc_T_ACPlugTOverThrRec1, 3, 3, &DiagThr.fltNum114, &DiagThr.recNum114, &sfmd_flg_ACPlugTOverFlt1) && !sfmd_flg_ACPlugTOverFlt2;
 
     // 115 加热板温度过高2级故障
-    sfmd_flg_heatPanTOverFlt2_1 = DiagThrSystem1(1, !sfmd_flg_interComFlt && sfmd_flg_heatPanT1RationFlt && sfmd_flg_heatPanT1OpenFlt, ihd_T_heatPanT1, sfmc_T_heatPanTOverThrFlt2, sfmc_T_heatPanTOverThrRec2, 3, 3, &DiagThr.fltNum115_1, &DiagThr.recNum115_1, &sfmd_flg_heatPanTOverFlt2_1);
-    sfmd_flg_heatPanTOverFlt2_2 = DiagThrSystem1(1, !sfmd_flg_interComFlt && sfmd_flg_heatPanT2RationFlt && sfmd_flg_heatPanT2OpenFlt, ihd_T_heatPanT2, sfmc_T_heatPanTOverThrFlt2, sfmc_T_heatPanTOverThrRec2, 3, 3, &DiagThr.fltNum115_2, &DiagThr.recNum115_2, &sfmd_flg_heatPanTOverFlt2_2);
+    sfmd_flg_heatPanTOverFlt2_1 = DiagThrSystem1(1, !sfmn_flg_interComFlt && sfmd_flg_heatPanT1RatFlt && sfmd_flg_heatPanT1OpenFlt, ihd_T_heatPanT1, sfmc_T_heatPanTOverThrFlt2, sfmc_T_heatPanTOverThrRec2, 3, 3, &DiagThr.fltNum115_1, &DiagThr.recNum115_1, &sfmd_flg_heatPanTOverFlt2_1);
+    sfmd_flg_heatPanTOverFlt2_2 = DiagThrSystem1(1, !sfmn_flg_interComFlt && sfmd_flg_heatPanT2RatFlt && sfmd_flg_heatPanT2OpenFlt, ihd_T_heatPanT2, sfmc_T_heatPanTOverThrFlt2, sfmc_T_heatPanTOverThrRec2, 3, 3, &DiagThr.fltNum115_2, &DiagThr.recNum115_2, &sfmd_flg_heatPanTOverFlt2_2);
     sfmd_flg_heatPanTOverFlt2 = sfmd_flg_heatPanTOverFlt2_1 || sfmd_flg_heatPanTOverFlt2_2;
     // 116 加热板温度过高1级故障
-    sfmd_flg_heatPanTOverFlt1_1 = DiagThrSystem1(0, !sfmd_flg_interComFlt && sfmd_flg_heatPanT1RationFlt && sfmd_flg_heatPanT1OpenFlt, ihd_T_heatPanT1, sfmc_T_heatPanTOverThrFlt1, sfmc_T_heatPanTOverThrRec1, 3, 3, &DiagThr.fltNum116_1, &DiagThr.recNum116_1, &sfmd_flg_heatPanTOverFlt1_1) && !sfmd_flg_heatPanTOverFlt2;
-    sfmd_flg_heatPanTOverFlt1_2 = DiagThrSystem1(0, !sfmd_flg_interComFlt && sfmd_flg_heatPanT2RationFlt && sfmd_flg_heatPanT2OpenFlt, ihd_T_heatPanT2, sfmc_T_heatPanTOverThrFlt1, sfmc_T_heatPanTOverThrRec1, 3, 3, &DiagThr.fltNum116_2, &DiagThr.recNum116_2, &sfmd_flg_heatPanTOverFlt1_2) && !sfmd_flg_heatPanTOverFlt2;
+    sfmd_flg_heatPanTOverFlt1_1 = DiagThrSystem1(0, !sfmn_flg_interComFlt && sfmd_flg_heatPanT1RatFlt && sfmd_flg_heatPanT1OpenFlt, ihd_T_heatPanT1, sfmc_T_heatPanTOverThrFlt1, sfmc_T_heatPanTOverThrRec1, 3, 3, &DiagThr.fltNum116_1, &DiagThr.recNum116_1, &sfmd_flg_heatPanTOverFlt1_1) && !sfmd_flg_heatPanTOverFlt2;
+    sfmd_flg_heatPanTOverFlt1_2 = DiagThrSystem1(0, !sfmn_flg_interComFlt && sfmd_flg_heatPanT2RatFlt && sfmd_flg_heatPanT2OpenFlt, ihd_T_heatPanT2, sfmc_T_heatPanTOverThrFlt1, sfmc_T_heatPanTOverThrRec1, 3, 3, &DiagThr.fltNum116_2, &DiagThr.recNum116_2, &sfmd_flg_heatPanTOverFlt1_2) && !sfmd_flg_heatPanTOverFlt2;
     sfmd_flg_heatPanTOverFlt1 = sfmd_flg_heatPanTOverFlt1_1 || sfmd_flg_heatPanTOverFlt1_2;
 
     sfmd_I_curr = ihd_I_curr;
-    sfmd_I_currAbs = (uint16_T)(sfmd_I_curr > 0 ? sfmd_I_curr : -sfmd_I_curr);
+    sfmn_I_currAbs = (uint16_T)(sfmd_I_curr > 0 ? sfmd_I_curr : -sfmd_I_curr);
     // 131 充电电流过高
-    sfmd_flg_chrgCurrOverFlt = DiagThrSystem1(1, !sfmd_flg_interComFlt && chrgFlg && !sfmd_flg_currOpenFlt, sfmd_I_currAbs, sfmc_I_chrgCurrOverThr, sfmc_I_chrgCurrOverThr, 2, 2, &DiagThr.fltNum131, &DiagThr.recNum131, &sfmd_flg_chrgCurrOverFlt);
+    sfmd_flg_chrgCurrOverFlt = DiagThrSystem1(1, !sfmn_flg_interComFlt && chrgFlg && !sfmd_flg_currOpenFlt, sfmn_I_currAbs, sfmc_I_chrgCurrOverThr, sfmc_I_chrgCurrOverThr, 2, 2, &DiagThr.fltNum131, &DiagThr.recNum131, &sfmd_flg_chrgCurrOverFlt);
     // 132 放电电流过高
-    sfmd_flg_disChrgCurrOverFlt = DiagThrSystem1(1, !sfmd_flg_interComFlt && disChrgFlg && !sfmd_flg_currOpenFlt, sfmd_I_currAbs, sfmc_I_disChrgCurrOverThr, sfmc_I_disChrgCurrOverThr, 2, 2, &DiagThr.fltNum132, &DiagThr.recNum132, &sfmd_flg_disChrgCurrOverFlt);
+    sfmd_flg_disChrgCurrOverFlt = DiagThrSystem1(1, !sfmn_flg_interComFlt && disChrgFlg && !sfmd_flg_currOpenFlt, sfmn_I_currAbs, sfmc_I_disChrgCurrOverThr, sfmc_I_disChrgCurrOverThr, 2, 2, &DiagThr.fltNum132, &DiagThr.recNum132, &sfmd_flg_disChrgCurrOverFlt);
 
     // 151 充电过流故障不匹配
-    sfmd_flg_chrgCurrOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_chrgCurrOverFlt != ihd_flg_chrgCurrOverFlt, &DiagTime.N151, 2);
+    sfmd_flg_chrgCurrOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_chrgCurrOverFlt != ihd_flg_chrgCurrOverFlt, &DiagTime.N151, 2);
     // 152 放电过流故障不匹配
-    sfmd_flg_disChrgCurrOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_disChrgCurrOverFlt != ihd_flg_disChrgCurrOverFlt, &DiagTime.N152, 2);
+    sfmd_flg_disChrgCurrOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_disChrgCurrOverFlt != ihd_flg_disChrgCurrOverFlt, &DiagTime.N152, 2);
     // 153 总压欠压不匹配
-    sfmd_flg_battULowMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_battULowFlt2 != ihd_flg_battULowFlt, &DiagTime.N153, 2);
+    sfmd_flg_battULowMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_battULowFlt2 != ihd_flg_battULowFlt, &DiagTime.N153, 2);
     // 154 总压过压不匹配
-    sfmd_flg_battUOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_battUOverFlt2 != ihd_flg_battUOverFlt, &DiagTime.N154, 2);
+    sfmd_flg_battUOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_battUOverFlt2 != ihd_flg_battUOverFlt, &DiagTime.N154, 2);
 
     // 155 单体欠压故障不匹配
-    sfmd_flg_cellULowMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_cellULowFlt2 != ihd_flg_cellULowFlt, &DiagTime.N155, 2);
+    sfmd_flg_cellULowMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_cellULowFlt2 != ihd_flg_cellULowFlt, &DiagTime.N155, 2);
     // 156 单体过压故障不匹配
-    sfmd_flg_cellUOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_cellUOverFlt2 != ihd_flg_cellUOverFlt, &DiagTime.N156, 2);
+    sfmd_flg_cellUOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_cellUOverFlt2 != ihd_flg_cellUOverFlt, &DiagTime.N156, 2);
 
     // 157 充电模组过温故障不匹配
-    sfmd_flg_chrgModTOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_chrgModTOverFlt2 != ihd_flg_chrgModTOverFlt, &DiagTime.N157, 2);
+    sfmd_flg_chrgModTOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_chrgModTOverFlt2 != ihd_flg_chrgModTOverFlt, &DiagTime.N157, 2);
     // 158 充电模组低温故障不匹配
-    sfmd_flg_chrgModTLowMisFlt = JudgeTimeSystem(0 && !sfmd_flg_interComFlt, sfmd_flg_chrgModTLowFlt2 != ihd_flg_chrgModTLowFlt, &DiagTime.N158, 2);
+    sfmd_flg_chrgModTLowMisFlt = JudgeTimeSystem(0 && !sfmn_flg_interComFlt, sfmd_flg_chrgModTLowFlt2 != ihd_flg_chrgModTLowFlt, &DiagTime.N158, 2);
     // 159 放电模组过温故障不匹配
-    sfmd_flg_disChrgModTOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_disChrgModTOverFlt2 != ihd_flg_disChrgModTOverFlt, &DiagTime.N159, 2);
+    sfmd_flg_disChrgModTOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_disChrgModTOverFlt2 != ihd_flg_disChrgModTOverFlt, &DiagTime.N159, 2);
     // 160 放电模组低温故障不匹配
-    sfmd_flg_disChrgModTLowMisFlt = JudgeTimeSystem(0 && !sfmd_flg_interComFlt, sfmd_flg_disChrgModTLowFlt2 != ihd_flg_disChrgModTLowFlt, &DiagTime.N160, 2);
+    sfmd_flg_disChrgModTLowMisFlt = JudgeTimeSystem(0 && !sfmn_flg_interComFlt, sfmd_flg_disChrgModTLowFlt2 != ihd_flg_disChrgModTLowFlt, &DiagTime.N160, 2);
 
     // 161 充电Mos过温故障不匹配
-    sfmd_flg_chrgMosTOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_chrgMosTOverFlt2 != ihd_flg_chrgMosTOverFlt, &DiagTime.N161, 2);
+    sfmd_flg_chrgMosTOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_chrgMosTOverFlt2 != ihd_flg_chrgMosTOverFlt, &DiagTime.N161, 2);
     // 162 放电Mos过温故障不匹配
-    sfmd_flg_disChrgMosTOverMisFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, sfmd_flg_disChrgMosTOverFlt2 != ihd_flg_disChrgMosTOverFlt, &DiagTime.N162, 2);
+    sfmd_flg_disChrgMosTOverMisFlt = JudgeTimeSystem(!sfmn_flg_interComFlt, sfmd_flg_disChrgMosTOverFlt2 != ihd_flg_disChrgMosTOverFlt, &DiagTime.N162, 2);
 
     // 163 soc不匹配
-    sfmd_flg_socMisFlt = 0 && !sfmd_flg_firstRun && (!sfmd_flg_interComFlt) && ((int16_T)(socd_pct_vcuSoc - ihd_pct_soc) > 100 || (int16_T)(socd_pct_vcuSoc - ihd_pct_soc) < -100);
+    sfmd_flg_socMisFlt = 0 && !sfmd_flg_firstRun && (!sfmn_flg_interComFlt) && ((int16_T)(socd_pct_vcuSoc - ihd_pct_soc) > 100 || (int16_T)(socd_pct_vcuSoc - ihd_pct_soc) < -100);
     // 164 SOH 不匹配
-    sfmd_flg_sohMisFlt = !sfmd_flg_firstRun && (!sfmd_flg_interComFlt) && ((int16_T)(sohd_pct_bcuSoh - ihd_pct_soh) > 50 || (int16_T)(sohd_pct_bcuSoh - ihd_pct_soh) < -50);
+    sfmd_flg_sohMisFlt = !sfmd_flg_firstRun && (!sfmn_flg_interComFlt) && ((int16_T)(sohd_pct_bcuSoh - ihd_pct_soh) > 50 || (int16_T)(sohd_pct_bcuSoh - ihd_pct_soh) < -50);
 
     // 178
     sfmd_flg_deltRFlt = false;
-    if (!cdmd_flg_deltOCVDisable && !sfmd_flg_interComFlt)
+    if (!sfmn_flg_interComFlt)
     {
         SumR = 0;
         SumRR = 0;
         for (i = 0; i < cmnc_num_cellUNum; i++)
         {
-            SumR = SumR + cdmv_ohm_deltR[i];
-            SumRR = SumRR + cdmv_ohm_deltR[i] * cdmv_ohm_deltR[i];
+            if(!cdmv_flg_inval[i])
+            {
+                SumR = SumR + cdmv_R_deltOhm[i];
+                SumRR = SumRR + cdmv_R_deltOhm[i] * cdmv_R_deltOhm[i];
+            }
         }
 
         for (i = 0; i < cmnc_num_cellUNum; i++)
         {
-            if ((cdmv_ohm_deltR[i] - SumR / cmnc_num_cellUNum) / (sqrt(SumRR / cmnc_num_cellUNum)) > 3 && (cdmv_ohm_deltR[i] - SumR / cmnc_num_cellUNum) > 500)
+            if (!cdmv_flg_inval[i] && (cdmv_R_deltOhm[i] - SumR / cmnc_num_cellUNum) / (sqrt(SumRR / cmnc_num_cellUNum)) > 3 && (cdmv_R_deltOhm[i] - SumR / cmnc_num_cellUNum) > 500)
             {
                 deltRFltNr[i] = (deltRFltNr[i] + 1) > 200 ? 200 : (deltRFltNr[i] + 1);
             }
@@ -726,6 +733,7 @@ void SFM(void)
                 deltRFltNr[i] = 0;
             }
         }
+		
         for (i = 0; i < cmnc_num_cellUNum; i++)
         {
             if (deltRFltNr[i] > 60)
@@ -736,8 +744,8 @@ void SFM(void)
     }
 
     // 179 soc跳变
-    sfmd_flg_socJumpFlt = ((int16_T)(socd_pct_bcuSoc - socd_pct_bcuSoc_Delay) > 50 || (int16_T)(socd_pct_bcuSoc - socd_pct_bcuSoc_Delay) < -50) && JudgeTimeSystem(1, 1, &DiagTime.N179, 2);
-    socd_pct_bcuSoc_Delay = socd_pct_bcuSoc;
+    sfmd_flg_socJumpFlt = ((int16_T)(socd_pct_bcuSoc - sfmn_pct_bcuSoc_Delay) > 50 || (int16_T)(socd_pct_bcuSoc - sfmn_pct_bcuSoc_Delay) < -50) && JudgeTimeSystem(1, 1, &DiagTime.N179, 2);
+    sfmn_pct_bcuSoc_Delay = socd_pct_bcuSoc;
     // 180 EE失效
     sfmd_flg_EEsaveFlt = ihd_flg_EESaveFlt;
 
@@ -758,22 +766,22 @@ void SFM(void)
         {
             if ((int16_T)(CellUArry[3][i] - CellUArry[0][i]) < -100)
             {
-                sfmd_flg_Udrop = true;
+                sfmn_flg_Udrop = true;
             }
         }
         if (sfmd_flg_heatclear)
         {
-            sfmd_flg_Udrop = false;
+            sfmn_flg_Udrop = false;
         }
     }
     ////
     if (sfmd_flg_volFlt)
     {
-        sfmd_flg_volFlt_keep = true;
+        sfmn_flg_volFlt_keep = true;
     }
     if (sfmd_flg_heatclear)
     {
-        sfmd_flg_volFlt_keep = false;
+        sfmn_flg_volFlt_keep = false;
     }
     //
     CntA = CntA + 1;
@@ -802,30 +810,30 @@ void SFM(void)
         {
             if ((int16_T)(ModTStor[3][i] - ModTStor[2][i]) > 2 && (int16_T)(ModTStor[2][i] - ModTStor[1][i]) > 2 && (int16_T)(ModTStor[1][i] - ModTStor[0][i]) > 2)
             {
-                sfmd_flg_Tup = true;
+                sfmn_flg_Tup = true;
             }
         }
         if (sfmd_flg_heatclear)
         {
-            sfmd_flg_Tup = false;
+            sfmn_flg_Tup = false;
         }
     }
 
     //
     if (sfmd_flg_modTOpenFlt)
     {
-        sfmd_flg_modTOpenFlt_keep = true;
+        sfmn_flg_modTOpenFlt_keep = true;
     }
     if (sfmd_flg_heatclear)
     {
-        sfmd_flg_modTOpenFlt_keep = false;
+        sfmn_flg_modTOpenFlt_keep = false;
     }
     //////
-    if (sfmd_flg_Udrop || sfmd_flg_volFlt_keep || sfmd_flg_Tup || sfmd_flg_modTOpenFlt_keep)
+    if (sfmn_flg_Udrop || sfmn_flg_volFlt_keep || sfmn_flg_Tup || sfmn_flg_modTOpenFlt_keep)
     {
         CntB = (CntB + 1) > 200 ? 200 : (CntB + 1);
     }
-    if ((((sfmd_flg_Udrop && sfmd_flg_Tup) || (sfmd_flg_Udrop && sfmd_flg_modTOpenFlt_keep) || (sfmd_flg_volFlt_keep && sfmd_flg_Tup)) && CntB <= 180) || sfmd_flg_heatRunFltEi)
+    if ((((sfmn_flg_Udrop && sfmn_flg_Tup) || (sfmn_flg_Udrop && sfmn_flg_modTOpenFlt_keep) || (sfmn_flg_volFlt_keep && sfmn_flg_Tup)) && CntB <= 180) || sfmd_flg_heatRunFltEi)
     {
         sfmd_flg_heatRunFltEo = true;
     }
@@ -848,24 +856,24 @@ void SFM(void)
             {
                 modTMaxArr[i] = sfmd_T_modTMax;
             }
-            Time0Cntl = 0;
+            Time0Cnt = 0;
             SumT0 = 0;
         }
-        Time0Cntl++;
+        Time0Cnt++;
         SumT0 = SumT0 + sfmd_T_modTMax;
-        if (Time0Cntl >= 60)
+        if (Time0Cnt >= 60)
         {
             for (i = 0; i < 9; i++)
             {
                 modTMaxArr[i] = modTMaxArr[i + 1];
             }
-            modTMaxArr[9] = SumT0 / Time0Cntl;
-            Time0Cntl = 0;
+            modTMaxArr[9] = SumT0 / Time0Cnt;
+            Time0Cnt = 0;
             SumT0 = 0;
         }
     }
 
-    if (!sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RationFlt && (int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay1) > -10 && (int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay1) < 20)
+    if (!sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RatFlt && (int16_T)(ihd_T_heatPanT1 - sfmn_T_heatPanT1_Delay1) > -10 && (int16_T)(ihd_T_heatPanT1 - sfmn_T_heatPanT1_Delay1) < 20)
     {
         if (sfmd_flg_firstRun)
         {
@@ -873,25 +881,25 @@ void SFM(void)
             {
                 heatT1Arr[i] = ihd_T_heatPanT1;
             }
-            Time1Cntl = 0;
+            Time1Cnt = 0;
             SumT1 = 0;
         }
-        Time1Cntl++;
+        Time1Cnt++;
         SumT1 = SumT1 + ihd_T_heatPanT1;
-        if (Time1Cntl >= 60)
+        if (Time1Cnt >= 60)
         {
             for (i = 0; i < 9; i++)
             {
                 heatT1Arr[i] = heatT1Arr[i + 1];
             }
-            heatT1Arr[9] = SumT1 / Time1Cntl;
-            Time1Cntl = 0;
+            heatT1Arr[9] = SumT1 / Time1Cnt;
+            Time1Cnt = 0;
             SumT1 = 0;
         }
     }
-    ihd_T_heatPanT1_Delay1 = ihd_T_heatPanT1;
+    sfmn_T_heatPanT1_Delay1 = ihd_T_heatPanT1;
 
-    if (!sfmd_flg_heatPanT2OpenFlt && !sfmd_flg_heatPanT2RationFlt && (int16_T)(ihd_T_heatPanT2 - ihd_T_heatPanT2_Delay1) > -10 && (int16_T)(ihd_T_heatPanT2 - ihd_T_heatPanT2_Delay1) < 20)
+    if (!sfmd_flg_heatPanT2OpenFlt && !sfmd_flg_heatPanT2RatFlt && (int16_T)(ihd_T_heatPanT2 - sfmn_T_heatPanT2_Delay1) > -10 && (int16_T)(ihd_T_heatPanT2 - sfmn_T_heatPanT2_Delay1) < 20)
     {
         if (sfmd_flg_firstRun)
         {
@@ -899,27 +907,25 @@ void SFM(void)
             {
                 heatT2Arr[i] = ihd_T_heatPanT2;
             }
-            Time2Cntl = 0;
+            Time2Cnt = 0;
             SumT2 = 0;
         }
-        Time2Cntl++;
+        Time2Cnt++;
         SumT2 = SumT2 + ihd_T_heatPanT2;
-        if (Time2Cntl >= 60)
+        if (Time2Cnt >= 60)
         {
             for (i = 0; i < 9; i++)
             {
                 heatT2Arr[i] = heatT2Arr[i + 1];
             }
-            heatT2Arr[9] = SumT2 / Time2Cntl;
-            Time2Cntl = 0;
+            heatT2Arr[9] = SumT2 / Time2Cnt;
+            Time2Cnt = 0;
             SumT2 = 0;
         }
     }
-    ihd_T_heatPanT2_Delay1 = ihd_T_heatPanT2;
+    sfmn_T_heatPanT2_Delay1 = ihd_T_heatPanT2;
 
     // 32 加热回路常闭故障
-    // deltaTEn1  = !sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT1 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT1 > ihd_T_DCPlugT + 5));
-    // deltaTEn2  = !sfmd_flg_heatPanT2OpenFlt && !sfmd_flg_heatPanT2RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT2 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT2 > ihd_T_DCPlugT + 5));
     Enable1 = JudgeTimeSystem(1, tmsd_st_heatAct == 0, &DiagTime.N32, 600);
     sfmd_flg_heatCirClosFltEo = (((int16_T)(heatT2Arr[9] - heatT2Arr[0]) > 5 || (int16_T)(heatT1Arr[9] - heatT1Arr[0]) > 5) && (modTMaxArr[9] > modTMaxArr[0] + 4) && Enable1) || sfmd_flg_heatCirClosFltEo || sfmd_flg_heatCirClosFltEi;
 
@@ -935,7 +941,7 @@ void SFM(void)
     memset(FltLevel, 0, sizeof(FltLevel));
     memset(FltAct, 0, sizeof(FltAct));
 
-    FltFlg[0] = sfmd_flg_interComFlt;
+    FltFlg[0] = sfmn_flg_interComFlt;
     FltLevel[0] = 2;
     FltAct[0] = 2; // 1 内网通讯故障
 
@@ -951,7 +957,7 @@ void SFM(void)
     FltLevel[3] = 0;
     FltAct[3] = 0; // 4 通讯天线故障
 
-    FltFlg[4] = sfmd_flg_authFlt;
+    FltFlg[4] = sfmn_flg_authFlt;
     FltLevel[4] = 4;
     FltAct[4] = 34; // 5 认证失败
 
@@ -975,7 +981,7 @@ void SFM(void)
     FltLevel[9] = 0;
     FltAct[9] = 0; // 10 预留#1
 
-    FltFlg[10] = sfmd_flg_HVILFlt;
+    FltFlg[10] = sfmn_flg_HVILFlt;
     FltLevel[10] = 0;
     FltAct[10] = 0; // 11 高压互锁
 
@@ -1019,7 +1025,7 @@ void SFM(void)
     FltLevel[20] = 5;
     FltAct[20] = 255; // 21 热失控;
 
-    FltFlg[21] = sfmd_flg_chrgMosClosFlt;
+    FltFlg[21] = sfmn_flg_chrgMosClosFlt;
     FltLevel[21] = 4;
     FltAct[21] = 106; // 22充电MOS常闭故障
 
@@ -1027,7 +1033,7 @@ void SFM(void)
     FltLevel[22] = 0;
     FltAct[22] = 0; // 23充电MOS常开故障
 
-    FltFlg[23] = sfmd_flg_disChrgMosClosFlt;
+    FltFlg[23] = sfmn_flg_disChrgMosClosFlt;
     FltLevel[23] = 4;
     FltAct[23] = 106; // 24 放电Mos常闭故障
 
@@ -1175,11 +1181,11 @@ void SFM(void)
     FltLevel[59] = 0;
     FltAct[59] = 0;
 
-    FltFlg[60] = sfmd_flg_modTRationFlt;
+    FltFlg[60] = sfmd_flg_modTRatFlt;
     FltLevel[60] = 2;
     FltAct[60] = 2; // 61模组温度合理性故障
 
-    FltFlg[61] = sfmd_flg_chrgMosTRationFlt;
+    FltFlg[61] = sfmd_flg_chrgMosTRatFlt;
     FltLevel[61] = 2;
     FltAct[61] = 130; // 62mos温度合理性故障
 
@@ -1187,19 +1193,19 @@ void SFM(void)
     FltLevel[62] = 0;
     FltAct[62] = 0;
 
-    FltFlg[63] = sfmd_flg_DCPlugTRationFlt;
+    FltFlg[63] = sfmd_flg_DCPlugTRatFlt;
     FltLevel[63] = 2;
     FltAct[63] = 2; // 64快充插头温度合理性故障
 
-    FltFlg[64] = sfmd_flg_ACPlugTRationFlt;
+    FltFlg[64] = sfmd_flg_ACPlugTRatFlt;
     FltLevel[64] = 2;
     FltAct[64] = 2; // 65慢充插头温度合理性故障
 
-    FltFlg[65] = sfmd_flg_heatPanT1RationFlt;
+    FltFlg[65] = sfmd_flg_heatPanT1RatFlt;
     FltLevel[65] = 2;
     FltAct[65] = 2; // 66加热板#1温度合理性故障
 
-    FltFlg[66] = sfmd_flg_heatPanT2RationFlt;
+    FltFlg[66] = sfmd_flg_heatPanT2RatFlt;
     FltLevel[66] = 2;
     FltAct[66] = 2; // 67加热板#2温度合理性故障
 
@@ -1661,7 +1667,7 @@ void SFM(void)
     memset(FltActArr, 0, sizeof(FltActArr));
     sfmd_num_fltNum = 0;
 
-    for (i = 0; i < 200 && sfmd_num_fltNum < 20; i++)
+    for (i = 0; i < FltArrLen && sfmd_num_fltNum < FltDispArrLen; i++)
     {
         if (FltFlg[i])
         {
@@ -1712,7 +1718,7 @@ void SFM(void)
             {
                 for (j = 0; j < cmnc_num_modTNum; j++)
                 {
-                    if (sfmv_flg_modTRationFlt[j])
+                    if (sfmv_flg_modTRatFlt[j])
                     {
                         FltCodeArr[sfmd_num_fltNum] = 3201 + j;
                         FltLevelArr[sfmd_num_fltNum] = FltLevel[i];
@@ -1749,9 +1755,9 @@ void SFM(void)
     ///=====================================================================
     //======================================================================
 
-    sfmd_flg_cellUDisable = sfmd_flg_interComFlt || sfmd_flg_volFlt;
-    sfmd_flg_currDisable = sfmd_flg_interComFlt || sfmd_flg_currOpenFlt;
-    sfmd_flg_modTDisable = sfmd_flg_interComFlt || sfmd_flg_modTOpenFlt || sfmd_flg_modTRationFlt;
+    sfmd_flg_cellUInval = sfmn_flg_interComFlt || sfmd_flg_volFlt;
+    sfmd_flg_currInval  = sfmn_flg_interComFlt || sfmd_flg_currOpenFlt;
+    sfmd_flg_modTInval  = sfmn_flg_interComFlt || sfmd_flg_modTOpenFlt || sfmd_flg_modTRatFlt;
     sfmd_flg_firstRun = false;
 }
 

+ 4 - 4
src/EmbeddedCoder_src/SOC.c

@@ -277,7 +277,7 @@ void SOC(void)
     socd_pct_ekfSoc = (uint16_T)(((1 - (real_T)(factor * 0.01)) * (real_T)(EKFSOCMin * 0.1) + (real_T)(factor * 0.01) * (real_T)(EKFSOCMax * 0.1)) * 10);
    
    //printf("4----socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
-
+/*
    //-------------------------EKFavrg---------------------------------------
     if (socd_flg_firstRun)
     {
@@ -358,7 +358,7 @@ void SOC(void)
     }
     socd_pct_cellBattSoc = (uint16_T)(((1 - (real_T)(factor * 0.01)) * (real_T)(cellSocMin * 0.1) + (real_T)(factor * 0.01) * (real_T)(cellSocMax * 0.1)) * 10);
     
-
+*/
     //======================================================================
     ////////////////////////AhSOC//////////////////////////////////////////
     //======================================================================
@@ -447,9 +447,9 @@ void SOC(void)
         overFlg = false;
         fulFlg = false;
         fulCntl = 0;
-		if (!cdmd_flg_deltOCVDisable)
+		if (!pimv_flg_inval[sfmd_idx_cellUMin])
 		{
-		    socn_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3) + (uint16_T)(sfmd_I_curr * (cdmv_ohm_deltR[sfmd_idx_cellUMin]) * 0.001 * 0.1);
+		    socn_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3) + (uint16_T)(sfmd_I_curr * (pimv_R_cellOhm[sfmd_idx_cellUMin]) * 0.001 * 0.1);
 		}
 		else
 		{

+ 3 - 3
src/EmbeddedCoder_src/SOH.c

@@ -101,7 +101,7 @@ void SOH(void)
  		//=======================================================================================
         //--------------------------计算使能-------------------------------------------------------
         //=======================================================================================
-        if(ihd_tm_parkTime >= cmnc_tm_parkTime && sohn_flg_chrgEndEE && sohn_Q_chrgEE > sohc_Q_countThr && !sfmd_flg_cellUDisable && sfmd_I_curr < 10 && sfmd_I_curr > -10)
+        if(ihd_tm_parkTime >= cmnc_tm_parkTime && sohn_flg_chrgEndEE && sohn_Q_chrgEE > sohc_Q_countThr && !sfmd_flg_cellUInval && sfmd_I_curr < 10 && sfmd_I_curr > -10)
         {
             sohn_flg_countEn = true;
         }
@@ -180,7 +180,7 @@ void SOH(void)
      	 memcpy(sohn_V_chrgStartStat,appv_V_cellU, sizeof(appv_V_cellU));
      }
      
-     if(sfmd_I_curr < 10 && sfmd_I_curr > -10 && !sfmd_flg_cellUDisable)
+     if(sfmd_I_curr < 10 && sfmd_I_curr > -10 && !sfmd_flg_cellUInval)
      {
          memcpy(sohn_V_chrgStartStat,sfmv_V_cellU, sizeof(sfmv_V_cellU));
      }
@@ -201,7 +201,7 @@ void SOH(void)
         tmp_0 = (int16_T)(Ahincr/3600 * 10);
 		
         sohd_Q_chrgEo = tmp_0 > 0 ? (uint16_T)tmp_0 : 0;  
-        if(sfmd_flg_currDisable)
+        if(sfmd_flg_currInval)
         {
             sfmn_flg_currFlt_keep = true;
         }

+ 10 - 10
src/EmbeddedCoder_src/SOR.c

@@ -7,8 +7,8 @@ void SOR_Init(void)
 //-------------------------------------------------------------------------
 void SOR(void)
 {
-    static uint16_T sorn_ohm_cellREE[cmnc_num_cellUNumMax];
-    static uint16_T sorn_ohm_cellREEArr[5][cmnc_num_cellUNumMax];
+    static uint16_T sorn_R_cellEE[cmnc_num_cellUNumMax];
+    static uint16_T sorn_R_cellEEArr[5][cmnc_num_cellUNumMax];
     uint16_T sorn_ohm_cellRSum[cmnc_num_cellUNumMax];
 	static uint16_T sorn_V_cellU[cmnc_num_cellUNumMax];
 	static uint8_T sorn_num_ctn;
@@ -25,13 +25,13 @@ void SOR(void)
     }
     if(sord_flg_firstRun)
     {
-        if(ArrMax(sorv_ohm_cellREi, cmnc_num_cellUNum) > 65000)
+        if(ArrMax(sorv_R_cellEi, cmnc_num_cellUNum) > 65000)
         {
-            memset(sorn_ohm_cellREE,0, sizeof(sorn_ohm_cellREE));
+            memset(sorn_R_cellEE,0, sizeof(sorn_R_cellEE));
         }
         else
         {
-            memcpy(sorn_ohm_cellREE,sorv_ohm_cellREi, sizeof(sorv_ohm_cellREi));
+            memcpy(sorn_R_cellEE,sorv_R_cellEi, sizeof(sorv_R_cellEi));
         }
     }
 
@@ -42,7 +42,7 @@ void SOR(void)
         {
             for(i = 0;i < cmnc_num_cellUNum;i++)
             {
-                sorn_ohm_cellREEArr[sorn_num_ctn][i] = (uint16_T)( ((real_T)(sorn_V_cellU[i] - sfmv_V_cellU[i]) * 0.001) / ((real_T)(sorn_I_curr - sfmd_I_curr) * 0.1) * 1000000 );
+                sorn_R_cellEEArr[sorn_num_ctn][i] = (uint16_T)( ((real_T)(sorn_V_cellU[i] - sfmv_V_cellU[i]) * 0.001) / ((real_T)(sorn_I_curr - sfmd_I_curr) * 0.1) * 1000000 );
             }
             sorn_num_ctn = sorn_num_ctn + 1;
             memset(sorn_ohm_cellRSum,0, sizeof(sorn_ohm_cellRSum));
@@ -50,14 +50,14 @@ void SOR(void)
             {
                 for(j = 0;j < sorn_num_ctn;j++)
                 {
-                    sorn_ohm_cellRSum[i] =  sorn_ohm_cellRSum[i] + sorn_ohm_cellREEArr[j][i];
+                    sorn_ohm_cellRSum[i] =  sorn_ohm_cellRSum[i] + sorn_R_cellEEArr[j][i];
                 }
-                sorn_ohm_cellREE[i] = sorn_ohm_cellRSum[i]/sorn_num_ctn;
+                sorn_R_cellEE[i] = sorn_ohm_cellRSum[i]/sorn_num_ctn;
             }
         } 
     }
-	memcpy(sorv_ohm_cellR,sorn_ohm_cellREE, sizeof(sorn_ohm_cellREE));
-    memcpy(sorv_ohm_cellREo,sorn_ohm_cellREE, sizeof(sorn_ohm_cellREE));
+	memcpy(sorv_R_cell,sorn_R_cellEE, sizeof(sorn_R_cellEE));
+    memcpy(sorv_R_cellEo,sorn_R_cellEE, sizeof(sorn_R_cellEE));
 	
 	sorn_I_curr = sfmd_I_curr;
     memcpy(sorn_V_cellU,sfmv_V_cellU, sizeof(sfmv_V_cellU));