Browse Source

Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev

zhuxi 2 years ago
parent
commit
7de769ca35

+ 3 - 3
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSBatInterShort.py

@@ -120,11 +120,11 @@ class BatInterShort():
     def _celldeltsoc_get(self,cellvolt_list,dict_baltime,capacity): 
         cellsoc=[]
         celldeltsoc=[]
-        for j in range(1, self.param.CellVoltNums+1):   #获取每个电芯电压对应的SOC值
-            cellvolt=cellvolt_list[j+1]
+        for j in range(self.param.CellVoltNums):    #获取每个电芯电压对应的SOC值
+            cellvolt=cellvolt_list[j]
             ocv_soc=np.interp(cellvolt,self.param.LookTab_OCV,self.param.LookTab_SOC)
             if j in dict_baltime.keys():
-                ocv_soc=ocv_soc+dict_baltime[j]*self.param.BalCurrent/(capacity*3600)   #补偿均衡电流
+                ocv_soc=ocv_soc+dict_baltime[j+1]*self.param.BalCurrent/(capacity*3600)   #补偿均衡电流
             else:
                 pass
             cellsoc.append(ocv_soc)

+ 64 - 10
LIB/MIDDLE/CellStateEstimation/Common/V1_0_1/BatParam.py

@@ -4,11 +4,7 @@ class BatParam:
     def __init__(self,celltype):
 
         #公用参数................................................................................................................................................
-        self.CellTempUpLmt=119
-        self.CellTempLwLmt=-39
-        self.CellTempRate=5
-
-       #热失控参数
+        #热失控参数
         self.TrwTempHigh=60
         self.TrwTempRate=20
         self.TrwTempDiff=15
@@ -16,6 +12,14 @@ class BatParam:
         self.TrwCellVoltFall=1
         self.TrwCellVoltLow=1.5
         self.TrwPackVoltFall=1.5
+        
+        #故障诊断参数
+        self.CellTempUpLmt=119
+        self.CellTempLwLmt=-39
+        self.CellTempRate=5
+
+        self.temp_time=60
+        self.volt_time=60
 
         self.SocJump=10
         self.SocClamp=0.1
@@ -37,7 +41,18 @@ class BatParam:
                                     [0,0,  0.1,0.3,  0.7, 1,  1,   1],
                                     [0,0,  0.2,0.3,  0.8, 1,  1,   1]]
 
-
+        #采样诊断参数
+        self.CellMaxUSBTemp=55
+        self.AllowChgMinTemp=0
+        self.AllowDsChgTemp=-5
+        self.AvgVolGap=1
+        self.AvgCellTempGap=10
+        self.PackOTlmt=65
+        self.PackUTlmt=-20
+        self.OtherOTlmt=91
+        self.OtherUTlmt=-20        
+        self.FaultCount=100
+        
         if celltype==1: #6040
             self.Capacity = 41
             self.PackFullChrgVolt=69.99
@@ -77,6 +92,12 @@ class BatParam:
             self.CellTempDiffLv2=15
 
             self.TrwVoltRate=-1
+            
+            self.DifVolGap = 3
+            self.CellOVlmt=5
+            self.CellUVlmt=2
+            self.CantChrgVol=3
+            self.AvgOtherTempGap=99
         elif celltype==2: #4840
             self.Capacity = 41
             self.PackFullChrgVolt=69.99
@@ -116,6 +137,12 @@ class BatParam:
             self.CellTempDiffLv2=15
 
             self.TrwVoltRate=-1
+            
+            self.DifVolGap = 3
+            self.CellOVlmt=5
+            self.CellUVlmt=2
+            self.CantChrgVol=3
+            self.AvgOtherTempGap=99   
         elif celltype==3:   #力信50ah三元电芯
             self.Capacity = 51
             self.PackFullChrgVolt=80
@@ -154,7 +181,13 @@ class BatParam:
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15  
 
-            self.TrwVoltRate=-1         
+            self.TrwVoltRate=-1
+            
+            self.DifVolGap = 3
+            self.CellOVlmt=5
+            self.CellUVlmt=2
+            self.CantChrgVol=3
+            self.AvgOtherTempGap=40         
         elif celltype==4:   #CATL 50ah三元电芯
             self.Capacity = 50
             self.PackFullChrgVolt=80
@@ -196,7 +229,13 @@ class BatParam:
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15   
 
-            self.TrwVoltRate=-1        
+            self.TrwVoltRate=-1    
+            
+            self.DifVolGap = 3
+            self.CellOVlmt=5
+            self.CellUVlmt=2
+            self.CantChrgVol=3
+            self.AvgOtherTempGap=40    
         elif celltype==99:   #60ah磷酸铁锂电芯
             self.Capacity = 54
             self.PackFullChrgVolt=69.99
@@ -246,7 +285,14 @@ class BatParam:
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15   
 
-            self.TrwVoltRate=-8                    
+            self.TrwVoltRate=-8
+            
+            
+            self.DifVolGap = 3
+            self.CellOVlmt=4
+            self.CellUVlmt=2
+            self.CantChrgVol=2.6
+            self.AvgOtherTempGap=99                    
         elif celltype==100:
             self.Capacity = 228*2
             self.PackFullChrgVolt=3.65*192
@@ -257,6 +303,7 @@ class BatParam:
             self.OcvInflexionAbove=3.4
             self.CellVoltNums=384
             self.CellTempNums=64
+            self.OtherTempNums=0
             self.FullChrgSoc=98
             self.PeakSoc=59
             self.PeakVoltLowLmt=3.35
@@ -292,8 +339,15 @@ class BatParam:
             self.CellTempDiffLv1=28
             self.CellTempDiffLv2=32   
 
-            self.TrwVoltRate=-8                         
+            self.TrwVoltRate=-8  
             
+                                   
+            self.DifVolGap = 3
+            self.CellOVlmt=4
+            self.CellUVlmt=2
+            self.CantChrgVol=2.6
+            self.AvgOtherTempGap=40
+ 
         else:
             print('未找到对应电池编号!!!')
             # sys.exit()

+ 6 - 1
LIB/MIDDLE/SaftyCenter/Common/DBDownload.py

@@ -46,13 +46,18 @@ class DBDownload:
         if self.mode==1:
             self.cursor.execute("select %s from %s where sn='%s' order by id desc limit 1" %(str,tablename,sn))
         elif self.mode==0:
-            self.cursor.execute("select %s from %s where sn='%s' and %s between '%s' and '%s'" %(str,tablename,sn,timename,st,sp))
+            if len(sn)>1:
+                self.cursor.execute("select %s from %s where sn='%s' and %s between '%s' and '%s'" %(str,tablename,sn,timename,st,sp))
+            else:
+                self.cursor.execute("select %s from %s where %s between '%s' and '%s'" %(str,tablename,timename,st,sp))
         elif self.mode==2:
             self.cursor.execute("select %s from %s where factory='%s'" %(str,tablename,factory))
         elif self.mode==3:
             self.cursor.execute("select %s from %s" %(str,tablename))
         elif self.mode==4:
             self.cursor.execute("select %s from %s where qrcode='%s' order by id desc limit 1" %(str,tablename,sn))
+        elif self.mode==5:
+            self.cursor.execute("select %s from %s where info='%s'" %(str,tablename,timename))
         res = self.cursor.fetchall()
         df_res = pd.DataFrame(res, columns=param)
         df_res = df_res.reset_index(drop=True)

+ 8 - 2
LIB/MIDDLE/SaftyCenter/Common/QX_BatteryParam.py

@@ -5,7 +5,7 @@ class BatteryInfo():
         self.AllowDsChgTemp=-5
         self.AvgVolGap=1
         self.AvgCellTempGap=10
-        self.AvgOtherTempGap=40
+        
         self.PackOTlmt=65
         self.PackUTlmt=-20
         self.OtherOTlmt=91
@@ -31,6 +31,7 @@ class BatteryInfo():
             self.CellOVlmt=5
             self.CellUVlmt=2
             self.CantChrgVol=3
+            self.AvgOtherTempGap=99
           
         elif celltype==2: #4840
             self.Capacity = 41
@@ -48,7 +49,8 @@ class BatteryInfo():
             self.DifVolGap = 3
             self.CellOVlmt=5
             self.CellUVlmt=2
-            self.CantChrgVol=3        
+            self.CantChrgVol=3
+            self.AvgOtherTempGap=99        
 
         elif  celltype==3:   #力信50ah三元电芯
             self.Capacity = 51
@@ -67,6 +69,7 @@ class BatteryInfo():
             self.CellOVlmt=5
             self.CellUVlmt=2
             self.CantChrgVol=3
+            self.AvgOtherTempGap=40
 
         elif celltype==4:   #CATL 50ah三元电芯
             self.Capacity = 50
@@ -85,6 +88,7 @@ class BatteryInfo():
             self.CellOVlmt=5
             self.CellUVlmt=2
             self.CantChrgVol=3
+            self.AvgOtherTempGap=40
           
 
         elif celltype==99:   #60ah磷酸铁锂电芯
@@ -111,6 +115,7 @@ class BatteryInfo():
             self.CellOVlmt=4
             self.CellUVlmt=2
             self.CantChrgVol=2.6
+            self.AvgOtherTempGap=99
  
 
         elif celltype==100:
@@ -137,6 +142,7 @@ class BatteryInfo():
             self.CellOVlmt=4
             self.CellUVlmt=2
             self.CantChrgVol=2.6
+            self.AvgOtherTempGap=40
  
 
         else:

+ 150 - 97
LIB/MIDDLE/SaftyCenter/DataDiag_Static/CBMSBatDiag.py

@@ -55,9 +55,17 @@ class BatDiag:
         ah_accum=0  #SOC卡滞初始参数
         as_chg=0    #过流诊断初始参数
         as_dis=0    #过流诊断初始参数
-        time1=self.bmstime[0]   #温升速率初始参数
-        temp1=np.array(self._celltemp_get(0))   #温升速率初始参数
-        temprate_cnt=0
+        # time1=self.bmstime[0]   #温升速率初始参数
+        # temp1=np.array(self._celltemp_get(0))   #温升速率初始参数
+        # temprate_cnt=0
+        ot_time=0
+        ut_time=0
+        dt_time=0
+        cov_time=0
+        cuv_time=0
+        cdv_time=0
+        pov_time=0
+        puv_time=0
         
         end_time='0000-00-00 00:00:00'
             
@@ -76,19 +84,22 @@ class BatDiag:
             else:  
                 celltempvalid=1
            
-
             if celltempvalid==1:
                 #过温判断.............................................................................................................
                 if not 4 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if celltempmax0>self.param.CellTempHighLv2 and celltempmax1>self.param.CellTempHighLv2:    #二级高温进入
-                        time=self.bmstime[i]
-                        code=4
-                        faultlv=3
-                        faultinfo='温度{}高温二级'.format(celltemp1.index(celltempmax1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        ot_time=ot_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if ot_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=4
+                            faultlv=3
+                            faultinfo='温度{}高温二级'.format(celltemp1.index(celltempmax1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        ot_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if celltempmax0<self.param.CellTempHighLv1-5 and celltempmax1<self.param.CellTempHighLv1-5:    #二级高温恢复
                         time=self.bmstime[i]
@@ -99,14 +110,18 @@ class BatDiag:
                 #欠温判断.................................................................................................................
                 if not 6 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if celltempmin0<self.param.CellTempLowLv2 and celltempmin1<self.param.CellTempLowLv2:  #二级低温进入
-                        time=self.bmstime[i]
-                        code=6
-                        faultlv=3
-                        faultinfo='温度{}低温二级'.format(celltemp1.index(celltempmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        ut_time=ut_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if ut_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=6
+                            faultlv=3
+                            faultinfo='温度{}低温二级'.format(celltemp1.index(celltempmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        ut_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if celltempmax0>self.param.CellTempLowLv1+2 and celltempmax1>self.param.CellTempLowLv1+2:    #二级高温恢复
                         time=self.bmstime[i]
@@ -117,14 +132,18 @@ class BatDiag:
                 #温差判断.............................................................................................................................
                 if not 8 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if (celltempmax0-celltempmin0)>self.param.CellTempDiffLv2 and (celltempmax1-celltempmin1)>self.param.CellTempDiffLv2:  #二级温差进入
-                        time=self.bmstime[i]
-                        code=8
-                        faultlv=3
-                        faultinfo='温度{}和{}温差大二级'.format(celltemp1.index(celltempmax1)+1,celltemp1.index(celltempmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        dt_time=dt_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if dt_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=8
+                            faultlv=3
+                            faultinfo='温度{}和{}温差大二级'.format(celltemp1.index(celltempmax1)+1,celltemp1.index(celltempmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        dt_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if (celltempmax0-celltempmin0)<self.param.CellTempDiffLv1-2 and (celltempmax1-celltempmax0)>self.param.CellTempDiffLv1-2:  #二级温差恢复
                         time=self.bmstime[i]
@@ -161,9 +180,11 @@ class BatDiag:
             #     else:
             #         pass
             
-            # else:
-            #     pass
-            
+            else:
+                ot_time=0
+                ut_time=0
+                dt_time=0
+                    
             #电压诊断功能.................................................................................................
             cellvolt0=self._cellvolt_get(i-1)
             cellvolt1=self._cellvolt_get(i)
@@ -181,14 +202,18 @@ class BatDiag:
                 #过压诊断.............................................................................................................
                 if not 12 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if cellvoltmax0>self.param.CellOvLv2 and cellvoltmax1>self.param.CellOvLv2:  #二级过压进入
-                        time=self.bmstime[i]
-                        code=12
-                        faultlv=4
-                        faultinfo='电芯{}过压二级'.format(cellvolt1.index(cellvoltmax1)+1)
-                        faultadvice='联系用户询问用车场景,技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cov_time=cov_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cov_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=12
+                            faultlv=4
+                            faultinfo='电芯{}过压二级'.format(cellvolt1.index(cellvoltmax1)+1)
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cov_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if cellvoltmax0<self.param.CellOvLv1-0.05 and cellvoltmax1<self.param.CellOvLv1-0.05:   #二级过压故障恢复
                         time=self.bmstime[i]
@@ -200,14 +225,18 @@ class BatDiag:
                 #欠压诊断.................................................................................................................
                 if not 14 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if cellvoltmin0<self.param.CellUvLv2 and cellvoltmin1<self.param.CellUvLv2:  #二级欠压
-                        time=self.bmstime[i]
-                        code=14
-                        faultlv=3
-                        faultinfo='电芯{}欠压二级'.format(cellvolt1.index(cellvoltmin1)+1)
-                        faultadvice='联系用户询问用车场景,技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cuv_time=cuv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cuv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=14
+                            faultlv=3
+                            faultinfo='电芯{}欠压二级'.format(cellvolt1.index(cellvoltmin1)+1)
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cuv_time=0
                 else:
                     if cellvoltmin0>self.param.CellUvLv1+0.1 and cellvoltmin1>self.param.CellUvLv1+0.1:
                         time=self.bmstime[i]
@@ -218,14 +247,18 @@ class BatDiag:
                 #电芯压差大.....................................................................................................................................................
                 if not 16 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if (cellvoltmax0-cellvoltmin0)>self.param.CellVoltDiffLv2 and (cellvoltmax1-cellvoltmin1)>self.param.CellVoltDiffLv2:  #二级电芯压差
-                        time=self.bmstime[i]
-                        code=16
-                        faultlv=3
-                        faultinfo='电芯{}和{}压差大二级'.format(cellvolt1.index(cellvoltmax1)+1,cellvolt1.index(cellvoltmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cdv_time=cdv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cdv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=16
+                            faultlv=3
+                            faultinfo='电芯{}和{}压差大二级'.format(cellvolt1.index(cellvoltmax1)+1,cellvolt1.index(cellvoltmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cdv_time=0
                 else:
                     if (cellvoltmax0-cellvoltmin0)<self.param.CellVoltDiffLv1-0.05 and (cellvoltmax1-cellvoltmin1)<self.param.CellVoltDiffLv1-0.05: #二级欠压恢复
                         time=self.bmstime[i]
@@ -233,43 +266,61 @@ class BatDiag:
                     else:
                         pass
             else:
-                pass
+                cov_time=0
+                cuv_time=0
+                cdv_time=0
                 
             #电池包诊断.....................................................................................................................................
-            if not 18 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if self.packvolt[i-1]>self.param.PackVoltOvLv2 and self.packvolt[i]>self.param.PackVoltOvLv2:   #电池包过压二级进入
-                    time=self.bmstime[i]
-                    code=18
-                    faultlv=4
-                    faultinfo='电池包过压二级'
-                    faultadvice='联系用户询问用车场景,技术介入诊断'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
-                else:
-                    pass
+            if self.packvolt[i-1]<2*self.param.CellVoltNums and self.packvolt[i]>4.5*self.param.CellVoltNums:   #电池包电压有效性
+                packvoltvalid=0
             else:
-                if self.packvolt[i-1]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums and self.packvolt[i]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums: #电池包过压二级恢复
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==18].index, 'end_time'] = time
+                packvoltvalid=1
+
+            if packvoltvalid==1:
+                if not 18 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if self.packvolt[i-1]>self.param.PackVoltOvLv2 and self.packvolt[i]>self.param.PackVoltOvLv2:   #电池包过压二级进入
+                        pov_time=pov_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if pov_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=18
+                            faultlv=4
+                            faultinfo='电池包过压二级'
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
+                    else:
+                        pov_time=0
                 else:
-                    pass
+                    if self.packvolt[i-1]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums and self.packvolt[i]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums: #电池包过压二级恢复
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==18].index, 'end_time'] = time
+                    else:
+                        pass
           
-            #电池包诊断.....................................................................................................................................
-            if not 20 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if self.packvolt[i-1]<self.param.PackVoltUvLv2 and self.packvolt[i]<self.param.PackVoltUvLv2:   #电池包二级欠压进入
-                    time=self.bmstime[i]
-                    code=20
-                    faultlv=3
-                    faultinfo='电池包欠压二级'
-                    faultadvice='联系用户询问用车场景,技术介入诊断'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                if not 20 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if self.packvolt[i-1]<self.param.PackVoltUvLv2 and self.packvolt[i]<self.param.PackVoltUvLv2:   #电池包二级欠压进入
+                        puv_time=puv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if puv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=20
+                            faultlv=3
+                            faultinfo='电池包欠压二级'
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
+                    else:
+                        puv_time=0
                 else:
-                    pass
+                    if self.packvolt[i-1]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums and self.packvolt[i]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums:   #电池包二级欠压恢复
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==20].index, 'end_time'] = time
+                    else:
+                        pass
             else:
-                if self.packvolt[i-1]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums and self.packvolt[i]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums:   #电池包二级欠压恢复
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==20].index, 'end_time'] = time
-                else:
-                    pass
+                pov_time=0
+                puv_time=0
             
             #电流过流诊断.......................................................................................................................
             step=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
@@ -322,26 +373,28 @@ class BatDiag:
             else:
                 pass
             #SOC卡滞............................................................................................................
-            bmssoc_now=float(self.bms_soc[i])
-            if not 27 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if abs(ah_accum)>self.param.Capacity*0.05 and abs(bmssoc_now-bmssoc_st)<self.param.SocClamp:   #SOC卡滞故障进入
-                    bmssoc_st=bmssoc_now
-                    ah_accum=0
-                    time=self.bmstime[i]
-                    code=27
-                    faultlv=1
-                    faultinfo='电池SOC卡滞'
-                    faultadvice='技术介入诊断,检修电池BMS软件'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+            if abs(ah_accum)>self.param.Capacity*0.1:   
+                bmssoc_now=float(self.bms_soc[i])
+                if not 27 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if abs(bmssoc_now-bmssoc_st)<self.param.SocClamp:   #SOC卡滞故障进入
+                        time=self.bmstime[i]
+                        code=27
+                        faultlv=1
+                        faultinfo='电池SOC卡滞'
+                        faultadvice='技术介入诊断,检修电池BMS软件'
+                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                    else:
+                        pass
                 else:
-                    pass
+                    if abs(bmssoc_now-bmssoc_st)>self.param.SocClamp:   #SOC卡滞故障退出
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==27].index, 'end_time'] = time
+                    else:
+                        pass
+                bmssoc_st=bmssoc_now
+                ah_accum=0
             else:
-                if abs(bmssoc_now-bmssoc_st)>self.param.SocClamp:   #SOC卡滞故障退出
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==27].index, 'end_time'] = time
-                else:
-                    pass
-            
+                pass
 
             #SOC跳变....................................................................................................................
             bmssoc_last=float(self.bms_soc[i-1])

+ 20 - 15
LIB/MIDDLE/SaftyCenter/DataDiag_Static/main.py

@@ -13,7 +13,7 @@ from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload as DBDownloa
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import log
 from pandas.core.frame import DataFrame
 import datacompy
-from LIB.MIDDLE.SaftyCenter.Common import QX_BatteryParam
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam as QX_BatteryParam
 from LIB.MIDDLE.SaftyCenter.Common import DBDownload as DBDw
 
 #...................................电池包电芯安全诊断函数......................................................................................................................
@@ -61,7 +61,7 @@ def diag_cal():
             print('SN:{},未找到对应电池类型!!!'.format(sn))
             continue
             # sys.exit()
-        param=QX_BatteryParam.BatteryInfo(celltype)   
+        param=QX_BatteryParam.BatParam(celltype)   
         #读取原始数据库数据........................................................................................................................................................
         dbManager = DBManager.DBManager()
         df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
@@ -123,20 +123,25 @@ def DaTa_Sta_Week_Task():
     task_on=1
     factory_info=['骑享','金茂换电']
     all_period_fault_info=DataFrame(columns=['factory','week','level1_count','level2_count','level3_count','level4_count','level5_count','solve_rate'])
-    toweek='Week'+time.strftime('%W')
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='safety_platform'
-    user='qx_algo_readonly'
-    password='qx@123456'
-    mode=2
-    tablename1='all_fault_info'
-    DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
-    with DBRead as DBRead:
-        df_fltinfo=DBRead.getdata('product_id','level','code','start_time','end_time','batpos','factory',tablename=tablename1,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+    df_fltinfopt=DataFrame(columns=['product_id','level','code','start_time','end_time','batpos','factory'])
+    for i in range (0,len(factory_info)):
+        host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+        port=3306
+        db='safety_platform'
+        user='qx_algo_readonly'
+        password='qx@123456'
+        mode=2
+        tablename1='all_fault_info'
+        DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
+        with DBRead as DBRead:
+            df_fltinfo=DBRead.getdata('product_id','level','code','start_time','end_time','batpos','factory',tablename=tablename1,factory=factory_info[i],sn='',timename='',st='',sp='')#dbdownload经过了改编
+        df_fltinfopt=df_fltinfopt.append(df_fltinfo)
+        df_fltinfopt=df_fltinfopt.reset_index(drop=True)
+        print(df_fltinfopt)
 #............................获取数据................................
     for j in range(0,len(factory_info)):
-        df_fltinfo=df_fltinfo[df_fltinfo['factory']==factory_info[j]]
+        toweek='Week'+time.strftime('%W')
+        df_fltinfo=df_fltinfopt[df_fltinfopt['factory']==factory_info[j]]
         #............................获取时间................................      
         end_time=datetime.datetime.now()
         # end_time=datetime.datetime.strptime(end_time,'%Y-%m-%d')
@@ -154,7 +159,7 @@ def DaTa_Sta_Week_Task():
         all_period_fault_info.loc[j,'week']=toweek
         all_period_fault_info.loc[j,'solve_rate']=FltAlarmInfo.loc[0,'OprationManageRate']
         all_period_fault_info.fillna(0,inplace=False)
-
+        print(all_period_fault_info)
         task_on=0
 def DaTa_Sta_Minutes_Task():
     task_on=1

BIN
all_statistic_info.xlsx