Browse Source

内短路算法优化,删除趋势检验,增加充电电压等效性判断

qingfeng 2 years ago
parent
commit
9bd5859d94

+ 69 - 54
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy.py

@@ -4,18 +4,19 @@ __author__ = 'lmstack'
 import os
 import datetime
 import pandas as pd
-from LIB.BACKEND import DBManager, Log
+from LIB.BACKEND import DBManager
 from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker
-import time, datetime
+import datetime
 import traceback
-from LIB.MIDDLE.CellStateEstimation.Common import log
 from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSSafetyWarning
 from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatInterShort
 from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatUniform
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import VoltStray
+# from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import VoltStray
 from urllib import parse
 import pymysql
+import logging
+import logging.handlers
 
 from apscheduler.schedulers.blocking import BlockingScheduler
 
@@ -28,7 +29,7 @@ def saftywarning_cal():
     global df_warning_ram3
     global df_lfp_ram
     global df_lfp_ram1
-
+    global df_chrgvolt_ram
     
     
     # 读取结果数据库
@@ -60,9 +61,9 @@ def saftywarning_cal():
     conn_cas = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
     cursor_cas = conn_cas.cursor()
     
-    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info", db_safety_platform_engine)
-    result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
-    df_fault_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']==110)]
+    df_fault_ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info where end_time={} and code={}".format('0000-00-00 00:00:00','C490'), db_safety_platform_engine)
+    # result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
+    # df_fault_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']=='C490')]
     
     now_time=datetime.datetime.now()
     start_time=now_time-datetime.timedelta(hours=6)
@@ -104,7 +105,7 @@ def saftywarning_cal():
             df_soh = pd.read_sql("select time_st,sn,soh,cellsoh from cellstateestimation_soh where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
             df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
             df_uniform.loc[0,'cellvolt_rank']=str([1]*20)
-            df_voltsigma=pd.DataFrame()
+            # df_voltsigma=pd.DataFrame()
             #读取原始数据库数据................................................................................id........................................................................
             dbManager = DBManager.DBManager()
             df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
@@ -118,11 +119,12 @@ def saftywarning_cal():
                 df_warning_ram_sn1=df_warning_ram1[df_warning_ram1['sn']==sn]
                 df_warning_ram_sn2=df_warning_ram2[df_warning_ram2['sn']==sn]
                 df_warning_ram_sn3=df_warning_ram3[df_warning_ram3['sn']==sn]
+                df_chrgvolt_ram_sn=df_chrgvolt_ram[df_chrgvolt_ram['sn']==sn]
                 df_warning_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
                 df_warning_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
                 df_warning_ram_sn2.reset_index(inplace=True,drop=True)     #重置索引
                 df_warning_ram_sn3.reset_index(inplace=True,drop=True)     #重置索引
-                if celltype>50 and (not df_lfp_ram.empty):
+                if not df_lfp_ram.empty:
                     df_lfp_ram_sn=df_lfp_ram[df_lfp_ram['sn']==sn]
                     df_lfp_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
                 else:
@@ -137,8 +139,8 @@ def saftywarning_cal():
                     df_lfp_ram1=pd.DataFrame(columns=df_bms.columns.tolist()+['sn'])
                 
                 #内短路计算..................................................................................................................................................
-                BatShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh,df_warning_ram_sn,df_warning_ram_sn1,df_warning_ram_sn2,df_warning_ram_sn3,df_lfp_ram_sn)
-                df_short_res, df_ram_res, df_ram_res1, df_ram_res2, df_ram_res3, df_ram_res4=BatShort.intershort() 
+                BatShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh,df_warning_ram_sn,df_warning_ram_sn1,df_warning_ram_sn2,df_warning_ram_sn3,df_lfp_ram_sn,df_chrgvolt_ram_sn)
+                df_short_res, df_ram_res, df_ram_res1, df_ram_res2, df_ram_res3, df_ram_res4, df_chrgvolt_ram_sn=BatShort.intershort() 
 
                 if not df_short_res.empty:
                     df_short_res.columns = ['time_st', 'time_sp', 'sn', 'method', 'short_current', 'baltime']
@@ -152,9 +154,9 @@ def saftywarning_cal():
                     df_rank_res.to_sql("cellstateestimation_uniform_socvoltdiff",con=db_qxcas_engine, if_exists="append",index=False)
                 
                 #电压离群.....................................................................................................................................................
-                df_voltsigma=VoltStray.main(sn,df_bms,celltype)
-                if not df_voltsigma.empty:
-                    df_voltsigma.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
+                # df_voltsigma=VoltStray.main(sn,df_bms,celltype)
+                # if not df_voltsigma.empty:
+                #     df_voltsigma.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
 
 
                 #内短路ram处理.........................................................
@@ -162,15 +164,18 @@ def saftywarning_cal():
                 df_warning_ram1=df_warning_ram1.drop(df_warning_ram1[df_warning_ram1.sn==sn].index)
                 df_warning_ram2=df_warning_ram2.drop(df_warning_ram2[df_warning_ram2.sn==sn].index)
                 df_warning_ram3=df_warning_ram3.drop(df_warning_ram3[df_warning_ram3.sn==sn].index)
+                df_chrgvolt_ram=df_chrgvolt_ram.drop(df_chrgvolt_ram[df_chrgvolt_ram.sn==sn].index)
 
                 df_warning_ram=pd.concat([df_warning_ram,df_ram_res],ignore_index=True)
                 df_warning_ram1=pd.concat([df_warning_ram1,df_ram_res1],ignore_index=True)
                 df_warning_ram2=pd.concat([df_warning_ram2,df_ram_res2],ignore_index=True)
                 df_warning_ram3=pd.concat([df_warning_ram3,df_ram_res3],ignore_index=True)
+                df_chrgvolt_ram=pd.concat([df_chrgvolt_ram,df_chrgvolt_ram_sn],ignore_index=True)
+
+                df_lfp_ram=df_lfp_ram.drop(df_lfp_ram[df_lfp_ram.sn==sn].index)
+                df_lfp_ram=pd.concat([df_lfp_ram,df_ram_res4],ignore_index=True)
                 
                 if celltype>50:
-                    df_lfp_ram=df_lfp_ram.drop(df_lfp_ram[df_lfp_ram.sn==sn].index)
-                    df_lfp_ram=pd.concat([df_lfp_ram,df_ram_res4],ignore_index=True)
                     df_lfp_ram1=df_lfp_ram1.drop(df_lfp_ram1[df_lfp_ram1.sn==sn].index)
                     df_lfp_ram1=pd.concat([df_lfp_ram1,df_ram_res5],ignore_index=True)
                     
@@ -179,34 +184,28 @@ def saftywarning_cal():
             df_short = pd.read_sql("select time_sp,sn,short_current from cellstateestimation_intershort where sn = '{}' and time_sp between '{}' and '{}'".format(sn,start_time1,end_time), db_qxcas_engine)
             # df_liplated = pd.read_sql("select time,sn,liplated,liplated_amount from mechanism_liplated where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
             df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
-            df_voltsigma = pd.read_sql("select time,sn,VolOl_Uni,VolChng_Uni from outlier_voltchangeratio where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
+            # df_voltsigma = pd.read_sql("select time,sn,VolOl_Uni,VolChng_Uni from outlier_voltchangeratio where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
 
             #获取sn的故障RAM
             df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
+            df_fault_ram_sn.reset_index(inplace=True, drop=True)
             
             #热安全预警
-            if df_fault_ram_sn.empty:
-                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_voltsigma,df_soh)
-                df_warning_res=BatWarning.diag()
-                #当前热失控故障写入数据库
-                if not df_warning_res.empty:
-                    df_warning_res['add_time'] = datetime.datetime.now()
-                    df_warning_res['factory'] = factory
-                    df_warning_res.to_sql("all_fault_info",con=db_safety_platform_engine, if_exists="append",index=False)
-                    conn_platform.commit()
-            else:
-                fault_time=datetime.datetime.strptime(df_fault_ram_sn.iloc[-1]['start_time'], '%Y-%m-%d %H:%M:%S')
-                if (now_time-fault_time).total_seconds()>3*24*3600:   #df_warning_end历史故障筛选并更改数据库故障结束时间
-                    df_fault_ram_sn['end_time']=end_time
-                    df_fault_ram_sn['Batpos']=1
-                    try:
-                        cursor_platform.execute('''
-                                update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00'
-                                '''.format(datetime.datetime.now(), df_fault_ram_sn.iloc[-1]['end_time'], df_fault_ram_sn.iloc[-1]['Batpos'],sn, 110))
-                        conn_platform.commit()
-                    except:
-                        logger.error(traceback.format_exc)
-                        logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
+            BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_soh,df_fault_ram_sn)
+            df_res_new, df_res_chg=BatWarning.diag()
+            #新增内短路故障写入数据库
+            if not df_res_new.empty:
+                df_res_new['add_time'] = datetime.datetime.now()
+                df_res_new['factory'] = factory
+                df_res_new.to_sql("all_fault_info",con=db_safety_platform_engine, if_exists="append",index=False)
+                conn_platform.commit()
+            #内短路结束故障更新数据库
+            if not df_res_chg.empty:
+                df_res_chg['Batpos']=1
+                cursor_platform.execute('''
+                        update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00'
+                        '''.format(datetime.datetime.now(), df_res_chg.iloc[-1]['end_time'], df_res_chg.iloc[-1]['Batpos'],sn, 'C490'))
+                conn_platform.commit()
         except:
             logger.error(traceback.format_exc)
             logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
@@ -220,6 +219,34 @@ def saftywarning_cal():
 
 #...................................................主进程...........................................................................................................
 if __name__ == "__main__":
+
+     # 日志
+    log_path = 'log/'
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+    logger = logging.getLogger("main")
+    logger.setLevel(logging.DEBUG)
+    
+     # 根据日期滚动(每天产生1个文件)
+    fh = logging.handlers.TimedRotatingFileHandler(filename='{}/main_info.log'.format(log_path), when="D", interval=1, backupCount=30,
+                                                    encoding="utf-8")
+    formatter = logging.Formatter("%(asctime)s - %(name)s-%(levelname)s %(message)s")
+    fh.suffix = "%Y-%m-%d_%H-%M-%S"
+    fh.extMatch = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}")
+    fh.setFormatter(formatter)
+    fh.setLevel(logging.INFO)
+    logger.addHandler(fh)
+
+    fh = logging.handlers.TimedRotatingFileHandler(filename='{}/main_error.log'.format(log_path), when="D", interval=1, backupCount=30,
+                                                    encoding="utf-8")
+    formatter = logging.Formatter("%(asctime)s - %(name)s-%(levelname)s %(message)s")
+    fh.suffix = "%Y-%m-%d_%H-%M-%S"
+    fh.extMatch = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}")
+    fh.setFormatter(formatter)
+    fh.setLevel(logging.ERROR)
+    logger.addHandler(fh)
+
+    logger.info("pid is {}".format(os.getpid()))
     
     # 时间设置
     # now_time = datetime.datetime.now()
@@ -260,19 +287,6 @@ if __name__ == "__main__":
     # 运行历史数据配置
     
     df_first_data_time = pd.read_sql("select * from bat_first_data_time", db_engine)
-
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='batsafetyWarning', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
     
     # 算法参数
     host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
@@ -291,9 +305,10 @@ if __name__ == "__main__":
     df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
     df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
     df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
-    df_warning_ram3=pd.DataFrame(columns=['sn','time3','standingtime','standingtime1','standingtime2'])
+    df_warning_ram3=pd.DataFrame(columns=['sn','time3','standingtime','standingtime1','standingtime2','standingtime3'])
     df_lfp_ram=pd.DataFrame()
     df_lfp_ram1=pd.DataFrame()
+    df_chrgvolt_ram=pd.DataFrame(columns=['sn','time','deltvolt','packcrnt_avg','temp_avg'])
 
     # now_time='2021-10-15 00:00:00'
     # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')

+ 302 - 170
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSBatInterShort.py

@@ -6,9 +6,9 @@ import datetime
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
 class BatInterShort():
-    def __init__(self,sn,celltype,df_bms,df_soh,df_last,df_last1,df_last2,df_last3,df_lfp):  #参数初始化
+    def __init__(self,sn,celltype,df_bms,df_soh,df_last,df_last1,df_last2,df_last3,df_lfp,df_chrgvolt_ram_sn):  #参数初始化
 
-        if (not df_lfp.empty) and celltype>50:
+        if (not df_lfp.empty):
             df_lfp.drop(['sn'],axis=1)
             df_bms=pd.concat([df_lfp, df_bms], ignore_index=True)
         else:
@@ -30,18 +30,19 @@ class BatInterShort():
         self.df_last2=df_last2
         self.df_last3=df_last3
         self.df_lfp=df_lfp
+        self.df_chrgvolt_ram_sn=df_chrgvolt_ram_sn
 
         self.cellvolt_name=['单体电压'+str(x) for x in range(1,self.param.CellVoltNums+1)]
         self.celltemp_name=['单体温度'+str(x) for x in range(1,self.param.CellTempNums+1)]
     
     def intershort(self):
         if self.celltype<=50:
-            df_res, df_ram_last, df_ram_last1, df_ram_last3=self._ncm_intershort()
-            return df_res, df_ram_last, df_ram_last1,self.df_last2, df_ram_last3,self.df_lfp
+            df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt=self._ncm_intershort()
+            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt
             
         else:
-            df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp=self._lfp_intershort()
-            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp
+            df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt=self._lfp_intershort()
+            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt
 
 
     #定义滑动滤波函数....................................................................................
@@ -115,6 +116,11 @@ class BatInterShort():
     def _cellvolt_get(self,num):
         cellvolt = np.array(self.df_bms.loc[num,self.cellvolt_name])/1000
         return cellvolt
+    
+    #获取当前行所有温度数据........................................................................................
+    def _celltemp_get(self,num):
+        celltemp = np.array(self.df_bms.loc[num,self.celltemp_name])
+        return celltemp
 
     #获取当前行所有soc差...........................................................................................
     def _celldeltsoc_get(self,cellvolt_list,dict_baltime,capacity): 
@@ -122,16 +128,8 @@ class BatInterShort():
         celldeltsoc=[]
         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)
-<<<<<<< HEAD
             if j+1 in dict_baltime.keys():
                 ocv_soc=ocv_soc+dict_baltime[j+1]*self.param.BalCurrent/(capacity*3600)   #补偿均衡电流
-=======
-
-            if j+1 in dict_baltime.keys():
-                ocv_soc=ocv_soc+dict_baltime[j+1]*self.param.BalCurrent/(capacity*3600)   #补偿均衡电流
-
->>>>>>> master
             else:
                 pass
             cellsoc.append(ocv_soc)
@@ -212,11 +210,51 @@ class BatInterShort():
             
         return np.array(celldeltAs)
     
+    #充电delt_volt获取.................................................................................
+    def _deltvolt(self,chrg_start,chrg_end,voltmax_index):
+        if self.celltype<50:
+            volt_list=[4.16, 4.18, 4.2]
+        else:
+            volt_list=[3.47, 3.49, 4.51]
+        deltvolt_list=[]
+        packcrnt_mean_list=[]
+        temp_mean_list=[]
+        df_chrg=self.df_bms.loc[chrg_start:chrg_end]
+        
+        for volt in volt_list:
+            df_chrg1=df_chrg[(df_chrg['单体电压'+str(voltmax_index)]/1000>=volt-0.02) & (df_chrg['单体电压'+str(voltmax_index)]/1000<volt) & (df_chrg['总电流[A]']>-20)]
+            if not df_chrg1.empty:
+                packcrnt_mean_list.append(np.mean(df_chrg1['总电流[A]']))
+                temp_mean=df_chrg1[self.celltemp_name].mean(axis=1)
+                temp_mean_list.append(np.mean(temp_mean))
+                cellvolt=(df_chrg1[self.cellvolt_name].mean(axis=0))/1000
+                cellvolt_mean=(np.sum(cellvolt)-min(cellvolt)-max(cellvolt))/(len(cellvolt)-2)
+                deltvolt=np.array(cellvolt-cellvolt_mean)
+                deltvolt_list.append(deltvolt)
+                
+                # if volt>4.19:
+                #     df_chrg1=df_chrg[(df_chrg['CellVoltage'+str(voltmax_index)]>=volt) & (df_chrg['CellVoltage'+str(voltmax_index)]<4.3)]
+                #     if not df_chrg1.empty:
+                #         packcrnt_mean_list.append(np.mean(df_chrg1['PackCrnt']))
+                #         temp_mean=df_chrg1[self.celltemp_name].mean(axis=1)
+                #         temp_mean_list.append(np.mean(temp_mean))
+                #         cellvolt=df_chrg1[self.cellvolt_name].mean(axis=0)
+                #         cellvolt_mean=(np.sum(cellvolt)-min(cellvolt)-max(cellvolt))/(len(cellvolt)-2)
+                #         deltvolt=np.array(cellvolt-cellvolt_mean)
+                #         deltvolt_list.append(deltvolt)
+                #     else:
+                #         break
+            else:
+                break
+
+        return deltvolt_list, packcrnt_mean_list, temp_mean_list
+
     #寻找DVDQ的峰值点,并返回..........................................................................................................................
     def _dvdq_peak(self, time, soc, cellvolt, packcrnt):
         cellvolt = self._np_move_avg(cellvolt, 3, mode="same")
         Soc = 0
         Ah = 0
+        Ah_total=0
         Volt = cellvolt[0]
         DV_Volt = []
         DQ_Ah = []
@@ -228,10 +266,11 @@ class BatInterShort():
 
         for m in range(1, len(time)):
             Step = (time[m] - time[m - 1]).total_seconds()
-            Soc = Soc - packcrnt[m] * Step * 100 / (3600 * self.param.Capacity)
+            Soc = Soc - packcrnt[m] * Step * 100 / (3600 * float(self.param.Capacity))
             Ah = Ah - packcrnt[m] * Step / 3600
+            Ah_total=Ah_total+Ah
             if (cellvolt[m]-Volt)>0.0015 and Ah>0:
-                DQ_Ah.append(Ah)
+                DQ_Ah.append(Ah_total)
                 DV_Volt.append(cellvolt[m]-Volt)
                 DVDQ.append((DV_Volt[-1])/Ah)
                 xvolt.append(cellvolt[m])
@@ -257,7 +296,7 @@ class BatInterShort():
             df_Data1=df_Data1[(df_Data1['SOC']>40) & (df_Data1['SOC']<80)]
         else:
             df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['SOC']<80)]
-        df_Data1=df_Data1[(df_Data1['XVOLT']>self.param.PeakVoltLowLmt) & (df_Data1['XVOLT']<self.param.PeakVoltUpLmt)]
+        df_Data1=df_Data1[(df_Data1['XVOLT']>3.33) & (df_Data1['XVOLT']<3.95)]
 
         # print(packcrnt[int(len(time)/2)], min(self.celltemp))
         # ax1 = plt.subplot(3, 1, 1)
@@ -277,17 +316,27 @@ class BatInterShort():
         # plt.legend()
         # # plt.show()
 
-        if len(df_Data1)>2:     #寻找峰值点,且峰值点个数>2
+        if len(df_Data1)>2:   
             PeakIndex = df_Data1['DVDQ'].idxmax()
             df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
-            if len(df_Data2) > 1 and df_Data1.loc[PeakIndex,'XVOLT']<self.param.PeakVoltUpLmt-0.015:
-                return df_Data1['AhSoc'][PeakIndex]
+            if len(df_Data2) > 1 and min(df_Data1['SOC'])+0.5<df_Data1['SOC'][PeakIndex]<max(df_Data1['SOC'])-1:
+                return df_Data1['DQ_Ah'][PeakIndex]
+            
             else:
-                df_Data1 = df_Data1.drop([PeakIndex])
-                PeakIndex = df_Data1['DVDQ'].idxmax()
-                df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
-                if len(df_Data2) > 1 and df_Data1.loc[PeakIndex,'XVOLT']<self.param.PeakVoltUpLmt-0.015:
-                    return df_Data1['AhSoc'][PeakIndex]
+                if min(df_Data1['SOC'])+0.5<df_Data1['SOC'][PeakIndex]<max(df_Data1['SOC'])-1:
+                    df_Data1=df_Data1.drop([PeakIndex])
+                elif df_Data1['SOC'][PeakIndex]>max(df_Data1['SOC'])-1:
+                    df_Data1=df_Data1[df_Data1['SOC']<(df_Data1['SOC'][PeakIndex]-1)]
+                else:
+                    df_Data1=df_Data1[df_Data1['SOC']>(df_Data1['SOC'][PeakIndex]+0.5)]
+
+                if len(df_Data1)>2:
+                    PeakIndex = df_Data1['DVDQ'].idxmax()
+                    df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
+                    if len(df_Data2) > 1 and min(df_Data1['SOC'])+0.5<df_Data1['SOC'][PeakIndex]<max(df_Data1['SOC'])-1: #
+                        return df_Data1['DQ_Ah'][PeakIndex]
+                    else:
+                        return 0
                 else:
                     return 0
         else:
@@ -340,7 +389,10 @@ class BatInterShort():
         df_res=pd.DataFrame(columns=['time_st', 'time_sp', 'sn', 'method','short_current','baltime'])
         df_ram_last=self.df_last
         df_ram_last1=self.df_last1
+        df_ram_last2=self.df_last2
         df_ram_last3=self.df_last3
+        df_ram_lfp=pd.DataFrame(columns=self.df_bms.columns.tolist())
+        df_ram_chrgvolt=self.df_chrgvolt_ram_sn
 
         #容量初始化
         if self.df_soh.empty:
@@ -355,8 +407,8 @@ class BatInterShort():
             firsttime=1
             dict_bal={}
         else:
-            deltsoc_last=df_ram_last.loc[0,'deltsoc']
-            cellsoc_last=df_ram_last.loc[0,'cellsoc']
+            deltsoc_last=np.array(df_ram_last.loc[0,'deltsoc'])
+            cellsoc_last=np.array(df_ram_last.loc[0,'cellsoc'])
             time_last=df_ram_last.loc[0,'time']
             firsttime=0
             dict_bal={}
@@ -364,14 +416,27 @@ class BatInterShort():
             firsttime1=1
             dict_bal1={}
         else:
-            deltsoc_last1=df_ram_last1.loc[0,'deltsoc1']
+            deltsoc_last1=np.array(df_ram_last1.loc[0,'deltsoc1'])
             time_last1=df_ram_last1.loc[0,'time1']
             firsttime1=0
             dict_bal1={}
+        if df_ram_chrgvolt.empty:
+            firsttime2=1
+            charging=0
+            dict_bal2={}
+        else:
+            deltvolt_last2=[np.array(x) for x in df_ram_chrgvolt.loc[0,'deltvolt']]
+            time_last2=df_ram_chrgvolt.loc[0,'time2']
+            temp_mean_last=df_ram_chrgvolt.loc[0,'temp_avg']
+            packcrnt_mean_last=df_ram_chrgvolt.loc[0,'packcrnt_avg']
+            firsttime2=0
+            charging=0
+            dict_bal2={}
         if df_ram_last3.empty:
             standingtime=0
             standingtime1=0
             standingtime2=0
+            # standingtime3=0
         else:
             standingtime=df_ram_last3.loc[0,'standingtime']
             standingtime1=df_ram_last3.loc[0,'standingtime1']
@@ -406,6 +471,7 @@ class BatInterShort():
                 delttime=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
                 standingtime=standingtime+delttime
                 standingtime1=standingtime1+delttime
+                # standingtime3=0
                 self._celltemp_weight(i)
 
                 #长时间静置法计算内短路-开始.....................................................................................................................................
@@ -478,6 +544,7 @@ class BatInterShort():
                 #满电静置法计算内短路-开始.....................................................................................................................................................
                 if self.StandardStandingTime<standingtime1:  
                     standingtime1=0
+                    # standingtime3=0
                     cellvolt_now1=self._avgvolt_get(i)
                     if not cellvolt_now1.empty:
                         cellvolt_max1=max(cellvolt_now1)
@@ -524,16 +591,83 @@ class BatInterShort():
                 firsttime=1
                 standingtime=0
                 standingtime1=0
+                # standingtime3=0
                 pass
+
+            #充电等效电压法计算内短路....................................................................
+            if charging==0 or charging==2:
+                if self.packcrnt[i]<=-1 and self.packcrnt[i-1]<=-1 and self.packcrnt[i+1]<=-1:
+                    celltemp_now=self._celltemp_get(i)
+                    cellvolt_now=self._cellvolt_get(i)
+                    if min(celltemp_now)>0 and max(cellvolt_now)<4:
+                        charging=2
+                    if charging==2 and min(cellvolt_now)>3 and 4.1<max(cellvolt_now)<4.14:
+                        charging=1
+                        chrg_start=i
+                    else:
+                        pass
+
+            else: #充电中
+                cellvolt_now=self._cellvolt_get(i)
+                #计算漏电流......................................................................
+                if max(cellvolt_now)>4.2 and self.packcrnt[i]>-0.1 and self.packcrnt[i+1]>-0.1:   #电压>93%对应的电压
+                    if i-chrg_start>10:
+                        chrg_end=i
+                        charging=0
+
+                        #计算漏电流值...................................................................
+                        if firsttime2==1:
+                            firsttime2=0
+                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                            
+                            deltvolt_last2,packcrnt_mean_last,temp_mean_last=self._deltvolt(chrg_start,chrg_end,voltmax_index)  #获取deltAs
+                            
+                            time_last2=self.bmstime[chrg_end]
+                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
+                        else:
+                            dict_baltime2={}
+                            time_now2=self.bmstime[chrg_end]
+                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                            
+                            deltvolt_now2,packcrnt_mean_now,temp_mean_now=self._deltvolt(chrg_start,chrg_end,voltmax_index)
+                            leak_current2=[]
+                            for j in range(min(len(deltvolt_now2),len(deltvolt_last2))):
+                                if abs(packcrnt_mean_now[j]-packcrnt_mean_last[j])<10 and (abs(temp_mean_now[j]-temp_mean_last[j])<10 or (temp_mean_now[j]>20 and temp_mean_last[j]>20)) and (time_now2-time_last2).total_seconds()<14*24*3600:
+                                    list_sub2=(deltvolt_now2[j]-deltvolt_last2[j])*1000
+                                    list_sub2=np.round(list_sub2,1)
+                                    leak_current2.append(list(list_sub2))
+                                else:
+                                    break
+                            if len(leak_current2)>0:
+                                df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,4,str(leak_current2),str(dict_baltime2)]  #计算结果存入Dataframe
+                            time_last2=time_now2
+                            deltvolt_last2=deltvolt_now2
+                            packcrnt_mean_last=packcrnt_mean_now
+                            temp_mean_last=temp_mean_now
+                            dict_bal2={}
+                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
+                    
+                    else:
+                        charging=0
+                
+                elif self.packcrnt[i]>-0.1 and self.packcrnt[i-1]>-0.1: #(self.packcrnt[i]<-eval(self.pack_param['capacity'])/2 and self.packcrnt[i-1]<-eval(self.pack_param['capacity'])/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
+                    charging=0
+                elif i==len(self.df_bms)-2:  #数据中断后仍在充电,将前段充电数据写入RAM
+                    df_ram_lfp=self.df_bms.iloc[chrg_start:]
+                    df_ram_lfp['sn']=self.sn
+                else:
+                    pass
         
         #更新RAM的standingtime
         df_ram_last3.loc[0]=[self.sn,self.bmstime[len(self.bmstime)-1],standingtime,standingtime1,standingtime2]
 
         #返回计算结果
         if df_res.empty:    
-            return pd.DataFrame(), df_ram_last, df_ram_last1, df_ram_last3
+            return pd.DataFrame(), df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt
         else:
-            return df_res, df_ram_last, df_ram_last1, df_ram_last3
+            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt
 
     #磷酸铁锂电池内短路计算程序.............................................................................................................................
     def _lfp_intershort(self):
@@ -544,6 +678,7 @@ class BatInterShort():
         df_ram_last2=self.df_last2
         df_ram_last3=self.df_last3
         df_ram_lfp=pd.DataFrame(columns=self.df_bms.columns.tolist())
+        df_ram_chrgvolt=self.df_chrgvolt_ram_sn
 
         #容量初始化
         if self.df_soh.empty:
@@ -570,13 +705,25 @@ class BatInterShort():
             time_last1=df_ram_last1.loc[0,'time1']
             firsttime1=0
             dict_bal1={}
-        if df_ram_last2.empty:
+        # if df_ram_last2.empty:
+        #     firsttime2=1
+        #     charging=0
+        #     dict_bal2={}
+        # else:
+        #     deltAs_last2=df_ram_last2.loc[0,'deltAs2']
+        #     time_last2=df_ram_last2.loc[0,'time2']
+        #     firsttime2=0
+        #     charging=0
+        #     dict_bal2={}
+        if df_ram_chrgvolt.empty:
             firsttime2=1
             charging=0
             dict_bal2={}
         else:
-            deltAs_last2=df_ram_last2.loc[0,'deltAs2']
-            time_last2=df_ram_last2.loc[0,'time2']
+            deltvolt_last2=[np.array(x) for x in df_ram_chrgvolt.loc[0,'deltvolt']]
+            time_last2=df_ram_chrgvolt.loc[0,'time2']
+            temp_mean_last=df_ram_chrgvolt.loc[0,'temp_avg']
+            packcrnt_mean_last=df_ram_chrgvolt.loc[0,'packcrnt_avg']
             firsttime2=0
             charging=0
             dict_bal2={}
@@ -758,148 +905,133 @@ class BatInterShort():
                     pass
             except:
                 dict_bal2={}
-
-            #判断充电状态
-            if self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i-1]<=-1:
-                if charging==0:
-                    if self.bms_soc[i]<41:
-                        cellvolt_now=self._cellvolt_get(i)
-                        if min(cellvolt_now)<self.param.CellFullChrgVolt-0.15:
-                            charging=1
-                            chrg_start=i
-                        else:
-                            pass
+            
+             #充电等效电压法计算内短路....................................................................
+            if charging==0 or charging==2:
+                if self.packcrnt[i]<=-1 and self.packcrnt[i-1]<=-1 and self.packcrnt[i+1]<=-1:
+                    celltemp_now=self._celltemp_get(i)
+                    cellvolt_now=self._cellvolt_get(i)
+                    if min(celltemp_now)>0 and max(cellvolt_now)<3.4:
+                        charging=2
+                    if charging==2 and min(cellvolt_now)>2 and 3.44<max(cellvolt_now)<3.7:
+                        charging=1
+                        chrg_start=i
                     else:
                         pass
 
-                else: #充电中
-                    cellvolt_now=self._cellvolt_get(i)
-                    if (self.bmstime[i+1]-self.bmstime[i]).total_seconds()>180 or (self.packcrnt[i]>self.param.Capacity/2 and self.packcrnt[i+1]>self.param.Capacity/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
+            else: #充电中
+                cellvolt_now=self._cellvolt_get(i)
+                #计算漏电流......................................................................
+                if max(cellvolt_now)>3.51 and self.packcrnt[i]>-0.1 and self.packcrnt[i+1]>-0.1:   #电压>93%对应的电压
+                    if i-chrg_start>10:
+                        chrg_end=i
                         charging=0
-                        continue
-                    elif min(cellvolt_now)>self.param.CellFullChrgVolt-0.13:   #电压>满充电压-0.13V,即3.37V
-                        self._celltemp_weight(i)
-                        if i-chrg_start>10 and self.celltemp>20:
-                            chrg_end=i+1
-                            charging=0
-
-                            #计算漏电流值...................................................................
-                            if firsttime2==1:
-                                dict_baltime={}
-                                deltAs_last2=self._cellDeltAs_get(chrg_start,chrg_end,dict_baltime)
-                                time_last2=self.bmstime[chrg_end]
-                                df_ram_last2.loc[0]=[self.sn,time_last2,deltAs_last2]    #更新RAM信息
-                            else:
-                                dict_baltime=self._bal_time(dict_bal2)   #获取每个电芯的均衡时间
-                                deltAs_now2=self._cellDeltAs_get(chrg_start,chrg_end,dict_baltime)  #获取每个电芯的As差
-                                time_now2=self.bmstime[chrg_end]
-                                df_ram_last2.loc[0]=[self.sn,time_now2,deltAs_now2]    #更新RAM信息
-
-                                list_sub2=deltAs_now2-deltAs_last2
-                                list_pud2=-1000/(time_now2-time_last2).total_seconds()
-                                leak_current2=list_sub2*list_pud2
-                                # leak_current=np.array(leak_current)
-                                leak_current2=np.round(leak_current2,3)
-                                leak_current2=list(leak_current2)
-
-                                df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,3,str(leak_current2),str(dict_baltime)]  #计算结果存入Dataframe
-                                deltAs_last2=deltAs_now2
-                                time_last2=time_now2
-                                dict_bal2={}
 
+                        #计算漏电流值...................................................................
+                        if firsttime2==1:
+                            firsttime2=0
+                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                            
+                            deltvolt_last2,packcrnt_mean_last,temp_mean_last=self._deltvolt(chrg_start,chrg_end,voltmax_index)  #获取deltAs
+                            
+                            time_last2=self.bmstime[chrg_end]
+                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
                         else:
-                            charging=0
-                            continue
-                    # elif min(cellvolt_now)>self.param.CellFullChrgVolt-0.1:   #电压>满充电压
-                    #     self._celltemp_weight(i)
-                    #     if i-chrg_start>10 and self.celltemp>10:
-                    #         chrg_end=i+1
-                    #         charging=0
-
-                    #         #计算漏电流值...................................................................
-                    #         if firsttime2==1:
-                    #             dict_baltime={}
-                    #             peaksoc_list=[]
-                    #             for j in range(1, self.param.CellVoltNums + 1):
-                    #                 cellvolt = self._singlevolt_get(i,j,2)  #取单体电压j的所有电压值
-                    #                 cellvolt = list(cellvolt[chrg_start:chrg_end])
-                    #                 time = list(self.bmstime[chrg_start:chrg_end])
-                    #                 packcrnt = list(self.packcrnt[chrg_start:chrg_end])
-                    #                 soc = list(self.bms_soc[chrg_start:chrg_end])
-                    #                 peaksoc = self._dvdq_peak(time, soc, cellvolt, packcrnt)
-                    #                 if peaksoc>1:
-                    #                     peaksoc_list.append(peaksoc)
-                    #                 else:
-                    #                     break
-                    #             if len(peaksoc_list)==self.param.CellVoltNums:
-                    #                 celldeltsoc=[]
-                    #                 consum_num=10
-                    #                 cellsoc1=peaksoc_list[:self.param.CellVoltNums-consum_num]    #切片,将bms耗电的电芯和非耗电的电芯分离开
-                    #                 cellsocmean1=(sum(cellsoc1)-max(cellsoc1)-min(cellsoc1))/(len(cellsoc1)-2)
-                    #                 cellsoc2=peaksoc_list[self.param.CellVoltNums-consum_num:]
-                    #                 cellsocmean2=(sum(cellsoc2)-max(cellsoc2)-min(cellsoc2))/(len(cellsoc2)-2)
-                                    
-                    #                 for j in range(len(peaksoc_list)):   #计算每个电芯的soc差
-                    #                     if j<self.param.CellVoltNums-consum_num:
-                    #                         celldeltsoc.append(peaksoc_list[j]-cellsocmean1)
-                    #                     else:
-                    #                         celldeltsoc.append(peaksoc_list[j]-cellsocmean2)
-                    #                 deltsoc_last2=celldeltsoc
-                    #                 time_last2=self.bmstime[chrg_end]
-                    #                 df_ram_last2.loc[0]=[self.sn,time_last2,deltsoc_last2]    #更新RAM信息
-                    #         else:
-                    #             dict_baltime=self._bal_time(dict_bal2)   #获取每个电芯的均衡时间
-                    #             peaksoc_list=[]
-                    #             for j in range(1, self.param.CellVoltNums + 1):
-                    #                 cellvolt = self._singlevolt_get(i,j,2)  #取单体电压j的所有电压值
-                    #                 cellvolt = list(cellvolt[chrg_start:chrg_end])
-                    #                 time = list(self.bmstime[chrg_start:chrg_end])
-                    #                 packcrnt = list(self.packcrnt[chrg_start:chrg_end])
-                    #                 soc = list(self.bms_soc[chrg_start:chrg_end])
-                    #                 peaksoc = self._dvdq_peak(time, soc, cellvolt, packcrnt)
-                    #                 if peaksoc>1:
-                    #                     peaksoc_list.append(peaksoc)
-                    #                 else:
-                    #                     break
-                    #             if len(peaksoc_list)==self.param.CellVoltNums:
-                    #                 celldeltsoc=[]
-                    #                 consum_num=10
-                    #                 cellsoc1=peaksoc_list[:self.param.CellVoltNums-consum_num]    #切片,将bms耗电的电芯和非耗电的电芯分离开
-                    #                 cellsocmean1=(sum(cellsoc1)-max(cellsoc1)-min(cellsoc1))/(len(cellsoc1)-2)
-                    #                 cellsoc2=peaksoc_list[self.param.CellVoltNums-consum_num:]
-                    #                 cellsocmean2=(sum(cellsoc2)-max(cellsoc2)-min(cellsoc2))/(len(cellsoc2)-2)
-                                    
-                    #                 for j in range(len(peaksoc_list)):   #计算每个电芯的soc差
-                    #                     if j<self.param.CellVoltNums-consum_num:
-                    #                         celldeltsoc.append(peaksoc_list[j]-cellsocmean1)
-                    #                     else:
-                    #                         celldeltsoc.append(peaksoc_list[j]-cellsocmean2)
-                    #                 deltsoc_now2=celldeltsoc
-                    #                 time_now2=self.bmstime[chrg_end]
-                    #                 df_ram_last2.loc[0]=[self.sn,time_now2,deltsoc_now2]    #更新RAM信息
-
-                    #                 list_sub2=deltsoc_now2-deltsoc_last2
-                    #                 list_pud2=(0.01*capacity*3600*1000)/(time_now2-time_last2).total_seconds()
-                    #                 leak_current2=list_sub2*list_pud2
-                    #                 leak_current2=np.round(leak_current2,3)
-                    #                 leak_current2=list(leak_current2)
-
-                    #                 df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,3,str(leak_current2),str(dict_baltime)]  #计算结果存入Dataframe
-                    #                 deltsoc_last2=deltsoc_now2
-                    #                 time_last2=time_now2
-                    #                 dict_bal2={}
-                        
-                    #     else:
-                    #         charging=0
-                    #         continue
-
-                    elif i==len(self.df_bms)-2:  #数据中断后仍在充电,将前段充电数据写入RAM
-                        df_ram_lfp=self.df_bms.iloc[chrg_start:]
-                        df_ram_lfp['sn']=self.sn
+                            dict_baltime2={}
+                            time_now2=self.bmstime[chrg_end]
+                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                            
+                            deltvolt_now2,packcrnt_mean_now,temp_mean_now=self._deltvolt(chrg_start,chrg_end,voltmax_index)
+                            leak_current2=[]
+                            for j in range(min(len(deltvolt_now2),len(deltvolt_last2))):
+                                if abs(packcrnt_mean_now[j]-packcrnt_mean_last[j])<10 and (abs(temp_mean_now[j]-temp_mean_last[j])<10 or (temp_mean_now[j]>20 and temp_mean_last[j]>20)) and (time_now2-time_last2).total_seconds()<14*24*3600:
+                                    list_sub2=(deltvolt_now2[j]-deltvolt_last2[j])*1000
+                                    list_sub2=np.round(list_sub2,1)
+                                    leak_current2.append(list(list_sub2))
+                                else:
+                                    break
+                            if len(leak_current2)>0:
+                                df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,4,str(leak_current2),str(dict_baltime2)]  #计算结果存入Dataframe
+                            time_last2=time_now2
+                            deltvolt_last2=deltvolt_now2
+                            packcrnt_mean_last=packcrnt_mean_now
+                            temp_mean_last=temp_mean_now
+                            dict_bal2={}
+                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
+                    
                     else:
-                        pass
-            else:
-                pass
+                        charging=0
+                
+                elif self.packcrnt[i]>-0.1 and self.packcrnt[i-1]>-0.1: #(self.packcrnt[i]<-eval(self.pack_param['capacity'])/2 and self.packcrnt[i-1]<-eval(self.pack_param['capacity'])/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
+                    charging=0
+                elif i==len(self.df_bms)-2:  #数据中断后仍在充电,将前段充电数据写入RAM
+                    df_ram_lfp=self.df_bms.iloc[chrg_start:]
+                    df_ram_lfp['sn']=self.sn
+                else:
+                    pass
+
+            # #判断充电状态
+            # if self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i-1]<=-1:
+            #     if charging==0:
+            #         if self.bms_soc[i]<41:
+            #             cellvolt_now=self._cellvolt_get(i)
+            #             if min(cellvolt_now)<self.param.CellFullChrgVolt-0.15:
+            #                 charging=1
+            #                 chrg_start=i
+            #             else:
+            #                 pass
+            #         else:
+            #             pass
+
+            #     else: #充电中
+            #         cellvolt_now=self._cellvolt_get(i)
+            #         if (self.bmstime[i+1]-self.bmstime[i]).total_seconds()>180 or (self.packcrnt[i]>self.param.Capacity/2 and self.packcrnt[i+1]>self.param.Capacity/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
+            #             charging=0
+            #             continue
+            #         elif min(cellvolt_now)>self.param.CellFullChrgVolt-0.13:   #电压>满充电压-0.13V,即3.37V
+            #             self._celltemp_weight(i)
+            #             if i-chrg_start>10 and self.celltemp>20:
+            #                 chrg_end=i+1
+            #                 charging=0
+
+            #                 #计算漏电流值...................................................................
+            #                 if firsttime2==1:
+            #                     dict_baltime={}
+            #                     deltAs_last2=self._cellDeltAs_get(chrg_start,chrg_end,dict_baltime)
+            #                     time_last2=self.bmstime[chrg_end]
+            #                     df_ram_last2.loc[0]=[self.sn,time_last2,deltAs_last2]    #更新RAM信息
+            #                 else:
+            #                     dict_baltime=self._bal_time(dict_bal2)   #获取每个电芯的均衡时间
+            #                     deltAs_now2=self._cellDeltAs_get(chrg_start,chrg_end,dict_baltime)  #获取每个电芯的As差
+            #                     time_now2=self.bmstime[chrg_end]
+            #                     df_ram_last2.loc[0]=[self.sn,time_now2,deltAs_now2]    #更新RAM信息
+
+            #                     list_sub2=deltAs_now2-deltAs_last2
+            #                     list_pud2=-1000/(time_now2-time_last2).total_seconds()
+            #                     leak_current2=list_sub2*list_pud2
+            #                     # leak_current=np.array(leak_current)
+            #                     leak_current2=np.round(leak_current2,3)
+            #                     leak_current2=list(leak_current2)
+
+            #                     df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,3,str(leak_current2),str(dict_baltime)]  #计算结果存入Dataframe
+            #                     deltAs_last2=deltAs_now2
+            #                     time_last2=time_now2
+            #                     dict_bal2={}
+
+            #             else:
+            #                 charging=0
+            #                 continue
+                   
+
+            #         elif i==len(self.df_bms)-2:  #数据中断后仍在充电,将前段充电数据写入RAM
+            #             df_ram_lfp=self.df_bms.iloc[chrg_start:]
+            #             df_ram_lfp['sn']=self.sn
+            #         else:
+            #             pass
+            # else:
+            #     pass
 
     
         #更新RAM
@@ -907,6 +1039,6 @@ class BatInterShort():
 
         #返回结果
         if df_res.empty:    
-            return pd.DataFrame(), df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3,df_ram_lfp
+            return pd.DataFrame(), df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt
         else:
-            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp
+            return df_res, df_ram_last, df_ram_last1, df_ram_last2, df_ram_last3, df_ram_lfp, df_ram_chrgvolt

+ 122 - 207
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSSafetyWarning.py

@@ -7,256 +7,171 @@ import pymannkendall as mk
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
 class SafetyWarning:
-    def __init__(self,sn,celltype,df_short,df_uniform,OutLineVol_Rate,df_soh):  #参数初始化
+    def __init__(self,sn,celltype,df_short,df_uniform,df_soh,df_fault_ram_sn):  #参数初始化
 
         self.sn=sn
         self.celltype=celltype
         self.param=BatParam.BatParam(celltype)
         self.df_short=df_short
         self.df_uniform=df_uniform
-        self.OutLineVol_Rate=OutLineVol_Rate
+        # self.OutLineVol_Rate=OutLineVol_Rate
         self.df_soh=df_soh
+        self.df_warning_ram=df_fault_ram_sn.copy()
     
     def diag(self):
-        if self.celltype<=50:
-            df_res=self._warning_diag()
-            return df_res    
-        else:
-            df_res=self._warning_diag()
-            return df_res
-        
+        df_res_new, df_res_chg=self._warning_diag()
+        return df_res_new, df_res_chg
 
     #电池热安全预警诊断功能.................................................................................................
     def _warning_diag(self):
 
-        df_res=pd.DataFrame(columns=['start_time', 'end_time', 'product_id', 'code', 'level', 'info','advice'])
+        df_res_new=pd.DataFrame(columns=['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice'])
+        df_res_chg=pd.DataFrame(columns=['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice'])
 
         time_now=datetime.datetime.now()
         time_now=time_now.strftime('%Y-%m-%d %H:%M:%S')
-        time_sp='0000-00-00 00:00:00'
+        end_time='0000-00-00 00:00:00'
 
-        #参数初始化.......................................
-        voltsigmafault=0
-        uniformfault=0
+         #参数初始化.......................................
         cellshortfault=0
-        volt_rate=[]
-        R2_list=[]
-        voltsigmafault_list=[]
-        uniformfault_list=[]
-        mk_trend_list=[]
-        mk_p_list=[]
-        mk_z_list=[]
-        mk_Tau_list=[]
-        mk_slope_list=[]
-        mk_s_list=[]
-        mk_svar_list=[]
-
-        if not self.df_short.empty:
-            short_current=self.df_short['short_current']
-            short_current=short_current.str.replace("[", '')
-            short_current=short_current.str.replace("]", '')
-        
-        if not self.OutLineVol_Rate.empty:
-            volt_column = ['单体电压'+str(i) for i in range(1,self.param.CellVoltNums+1)]
-            self.OutLineVol_Rate['VolChng_Uni']=self.OutLineVol_Rate['VolChng_Uni'].str.replace("[","")
-            self.OutLineVol_Rate['VolChng_Uni']=self.OutLineVol_Rate['VolChng_Uni'].str.replace("]","")
-            self.OutLineVol_Rate['VolOl_Uni']=self.OutLineVol_Rate['VolOl_Uni'].str.replace("[","")
-            self.OutLineVol_Rate['VolOl_Uni']=self.OutLineVol_Rate['VolOl_Uni'].str.replace("]","")
-            Volt_3Sigma=self.OutLineVol_Rate['VolOl_Uni'].str.split(',',expand=True)
-            Volt_3Sigma.columns=volt_column
+        cellshortfault1=0
+        uniformfault=0
 
-            #电压变化率
-            VoltChange=self.OutLineVol_Rate['VolChng_Uni'].str.split(',',expand=True)
-            VoltChange.columns=volt_column
-            VoltChange['time']=self.OutLineVol_Rate['time']
-            VoltChange = VoltChange.reset_index(drop=True)
-            xtime1=VoltChange['time']
-            time0=time.mktime(VoltChange.loc[0,'time'].timetuple())
-            for i in range(0,len(VoltChange)):
-                VoltChange.loc[i,'time']=(time.mktime(VoltChange.loc[i,'time'].timetuple())-time0)/36000
-            
-        #计算漏电流离群度
+        #计算漏电流离群度 &  拆分电芯漏电流值---------------------------------------
+        df_short=pd.DataFrame()
+        df_short1=pd.DataFrame()
         if not self.df_short.empty:
+            df_short1=self.df_short[self.df_short['method']==4]
+            df_short1.reset_index(drop=True,inplace=True)
+            self.df_short=self.df_short.drop(self.df_short[self.df_short['method']==4].index)
+            self.df_short.reset_index(drop=True,inplace=True)
+            short_name=['cellshort'+str(i) for i in range(1,self.CellVoltNums+1)]
+            df_short_current=pd.DataFrame(columns=short_name)
             self.df_short['cellshort_sigma']=0
             for i in range(len(self.df_short)):
                 cellshort=eval(self.df_short.loc[i,'short_current'])
+                df_short_current.loc[i]=cellshort
                 cellshort_std=np.std(cellshort)
                 cellshort_mean=np.mean(cellshort)
                 self.df_short.loc[i,'cellshort_sigma']=str(list((cellshort-cellshort_mean)/cellshort_std))
-            
-    
+            df_short=pd.concat([self.df_short,df_short_current],axis=1)
+        
+        #拆分电压排名----------------------------------------------------------------------------------------
+        self.df_uniform=self.df_uniform.drop(self.df_uniform[self.df_uniform['cellvolt_rank']=='0'].index)
+        self.df_uniform.reset_index(inplace=True,drop=True)
         if not self.df_uniform.empty:
-            cellvolt_rank=self.df_uniform['cellvolt_rank']
-            cellvolt_rank=cellvolt_rank.str.replace("[", '')
-            cellvolt_rank=cellvolt_rank.str.replace("]", '')
+            rank_name=['cellvolt_rank'+str(i) for i in range(1,self.CellVoltNums+1)]
+            df_rank=pd.DataFrame(columns=rank_name)
+            for i in range(len(self.df_uniform)):
+                df_rank.loc[i]=eval(self.df_uniform.loc[i,'cellvolt_rank'])
+           
     
-        for i in range(self.param.CellVoltNums):
-            #漏电流故障判断...........................................................................
-            if not self.df_short.empty:
-                self.df_short['cellshort'+str(i+1)]=short_current.map(lambda x:eval(x.split(',')[i]))
-                cellshort=self.df_short['cellshort'+str(i+1)]
+        if len(df_short)>1.5:     #超过2行
+            #出现两次漏电流<阈值...........................................................................
+            for i in range(self.CellVoltNums):
+                cellshort=df_short['cellshort'+str(i+1)]
                 index_list=cellshort[cellshort<self.param.LeakCurrentLv2].index
-                if len(index_list)>1:
+                if len(index_list)>1:   
                     for j in range(1,len(index_list)):
-                        if index_list[j]-index_list[j-1]==1:
-                            cellshort_sigma1=eval(self.df_short.loc[index_list[j],'cellshort_sigma'])
-                            cellshort_sigma2=eval(self.df_short.loc[index_list[j-1],'cellshort_sigma'])
+                        if (df_short.loc[index_list[j],'time_st']-df_short.loc[index_list[j-1],'time_st']).total_seconds()<10*24*3600:
+                            cellshort_sigma1=eval(df_short.loc[index_list[j],'cellshort_sigma'])
+                            cellshort_sigma2=eval(df_short.loc[index_list[j-1],'cellshort_sigma'])
                             if cellshort_sigma1[i]<-3 or cellshort_sigma2[i]<-3:
-                                cellshortfault=1                       
+                                cellshortfault=1
+                                cellshort_num=i+1
+                            else:
+                                cellshortfault=0                  
                         else:
-                            pass
+                            cellshortfault=0
                 else:
-                    pass
-            
-            #电压变化率及电压离群度.................................................................................
-            if not self.OutLineVol_Rate.empty and VoltChange.iloc[-1]['time']*36000>18*3600 and len(VoltChange)>5:
-
-                VoltChange[volt_column[i]]=VoltChange[volt_column[i]].map(lambda x:eval(x))
-                y=VoltChange[volt_column[i]]
-                volt3sigma=np.array(Volt_3Sigma[volt_column[i]].map(lambda x:eval(x)))
-                volt3sigma_sum=np.sum(volt3sigma<-3)
-                #电压变化率
-                a1,b1=np.polyfit(VoltChange['time'].tolist(),y.tolist(),1)
-                y1=a1*VoltChange['time']+b1
-                y_mean=y.mean()
-                R2=1-(np.sum((y1-y)**2))/(np.sum((y-y_mean)**2))
-                R2_list.append(R2)
-                
-                volt_rate.append(a1)
-                # plt.plot(xtime1,y1,label='单体电压'+str(i+1))
-                # plt.xlabel('时间', fontsize=25)
-                # plt.ylabel('SOC差', fontsize=25)
-                # plt.xticks(fontsize=20)
-                # plt.yticks(fontsize=20)
-                # plt.scatter( xtime1,VoltChange[volt_column[i]],marker='o')
-                # plt.legend(bbox_to_anchor=(1, 0), loc=3, fontsize=16)
-                # plt.title(self.celltype)
-                # plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
-                # plt.rcParams['axes.unicode_minus']=False #用来正常显示负号  
-                # # plt.show()
-                
-                if volt3sigma_sum>len(volt3sigma)/2:
-                    voltsigmafault=1
+                    cellshortfault=0
+        
+            #漏电流的和满足且最大漏电流值<阈值.........................................................................
+            cellshort_sum=list(df_short_current.sum())
+            if min(cellshort_sum)<2*self.param.LeakCurrentLv2:
+                cellshort_num=cellshort_sum.index(min(cellshort_sum))+1
+                cellshort=df_short_current['cellshort'+str(cellshort_num)]   #获取内短路电芯的所有漏电流值,且最小值<阈值
+                cellshort_sum.remove(min(cellshort_sum))    #删除最小值,并判断其他所有电芯内短路电流>阈值
+                if min(cellshort)<self.df_adjust_param.loc[24,'threshold'] and min(cellshort_sum)>self.df_adjust_param.loc[24,'threshold']:
+                    cellshortfault=1
                 else:
-                    voltsigmafault=0
-                voltsigmafault_list.append(voltsigmafault)
-                
-                #mana-kendell趋势检验
-                mk_res=mk.regional_test(np.array(y)) 
-                mk_trend_list.append(mk_res.trend)
-                mk_p_list.append(mk_res.p)
-                mk_z_list.append(mk_res.z)
-                mk_Tau_list.append(mk_res.Tau)
-                mk_slope_list.append(mk_res.slope)
-                mk_s_list.append(mk_res.s)
-                mk_svar_list.append(mk_res.var_s)
-                """
-                trend:趋势;
-                h:有无趋势;
-                p:趋势的显著水平,越小趋势越明显;
-                z:检验统计量,正代表随时间增大趋势,负代表随时间减小趋势;
-                Tau:反映两个序列的相关性,接近1的值表示强烈的正相关,接近-1的值表示强烈的负相关;
-                s:Mann-Kendal的分数,如果S是一个正数,那么后一部分的观测值相比之前的观测值会趋向于变大;如果S是一个负数,那么后一部分的观测值相比之前的观测值会趋向于变小
-                slope:趋势斜率
-                """
-                # print('单体电压{}:\n'.format(i+1), mk_res)
-
+                    cellshortfault=0
             else:
-                volt_rate.append(0)
-                R2_list.append(0)
-                voltsigmafault_list.append(0)
-                mk_trend_list.append(0)
-                mk_p_list.append(0)
-                mk_z_list.append(0)
-                mk_Tau_list.append(0)
-                mk_slope_list.append(0)
-                mk_s_list.append(0)
-                mk_svar_list.append(0)
-
-            #电芯SOC排名判断.............................................................................
-            if not self.df_uniform.empty:
-                self.df_uniform['cellvolt_rank'+str(i+1)]=cellvolt_rank.map(lambda x:eval(x.split(',')[i]))
+                cellshortfault=0
+            
+        elif len(df_short)>0.5: #漏电流只有一行
+            cellshort=eval(self.df_short.loc[0,'short_current'])
+            cellshort1=cellshort
+            cellshort1.remove(min(cellshort))
+            if min(cellshort)<self.param.LeakCurrentLv2*3 and min(cellshort1)>self.param.LeakCurrentLv2:
+                cellshortfault=1
+                cellshort_num=list(cellshort).index(min(cellshort))+1
+            else:
+                cellshortfault=0
+        
+        else:
+            cellshortfault=0  
+            
+        #充电电压判断--------------------------------------------
+        if not df_short1.empty:
+            for i in range(3):
+                deltvolt_init=eval(df_short1.loc[0,'short_current'])
+                deltvolt_rst=np.array(deltvolt_init[0])
+                for j in range(len(df_short1)):
+                    try:
+                        deltvolt=eval(df_short1.loc[j+1,'short_current'])
+                        deltvolt_rst=deltvolt_rst+np.array(deltvolt[i]) #所有结果累加
+                    except:
+                        continue
                 
-                if max(self.df_uniform['cellvolt_rank'+str(i+1)])<5:
-                    uniformfault=1
+                # 故障判断
+                if min(deltvolt_rst)<-6 and i>1:
+                    deltvolt_rst1=list(deltvolt_rst)
+                    deltvolt_rst1.remove(min(deltvolt_rst))
+                    if min(deltvolt_rst1)>-3:
+                        cellshortfault1=1
+                        cellshort_num=list(deltvolt_rst).index(min(deltvolt_rst))+1
+                        break
+                elif min(deltvolt_rst)<-6:
+                    deltvolt_rst1=list(deltvolt_rst)
+                    deltvolt_rst1.remove(min(deltvolt_rst))
+                    if min(deltvolt_rst1)>-3:
+                        cellshortfault1=1
+                        cellshort_num=list(deltvolt_rst).index(min(deltvolt_rst))+1
                 else:
-                    uniformfault=0
-            else:
-                uniformfault=0
-            uniformfault_list.append(uniformfault)
+                    cellshortfault1=0
             
-            #漏电流热失控预警确认........................................................
+        #漏电流热失控预警确认.......................................................................................
+        if not 'C490' in list(self.df_warning_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
             if cellshortfault==1:
-                faultcode=110
+                faultcode='C490'
                 faultlv=4
-                faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-                faultadvice='1联系用户远离电池,立刻召回电池'
-                df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-                break
+                faultinfo='电芯{}发生内短路'.format([cellshort_num])
+                faultadvice='请立刻召回电池包,更换模组'
+                df_res_new.loc[0]=[time_now, end_time, self.sn, faultcode, faultlv, faultinfo, faultadvice]
             else:
-                pass  
-        
-        # plt.show()   
-        #电池电压变化率离群度计算...............................................................................
-        volt_rate_std=np.std(volt_rate)
-        volt_rate_mean=np.mean(volt_rate)
-        volt_rate_3sigma=(np.array(volt_rate)-volt_rate_mean)/volt_rate_std
-        
-        #mk离群度计算
-        mk_slope_std=np.std(mk_slope_list)
-        mk_slope_mean=np.mean(mk_slope_list)
-        mk_slope_3sigma=(np.array(mk_slope_list)-mk_slope_mean)/mk_slope_std
-
-        # mk_s_std=np.std(mk_s_list)
-        # mk_s_mean=np.mean(mk_s_list)
-        # mk_s_3sigma=(np.array(mk_s_list)-mk_s_mean)/mk_s_std 
-
-        mk_z_std=np.std(mk_z_list)
-        mk_z_mean=np.mean(mk_z_list)
-        mk_z_3sigma=(np.array(mk_z_list)-mk_z_mean)/mk_z_std  
-
-        if not self.df_soh.empty and self.celltype<50:
-            cellsoh=eval(self.df_soh.loc[0,'cellsoh'])
-            cellsoh_std=np.std(cellsoh)
-            cellsoh_mean=np.mean(cellsoh)
-            cellsoh_3sigma=((np.array(cellsoh)-cellsoh_mean)/cellsoh_std)
+                pass
         else:
-            cellsoh_3sigma=[0]*self.param.CellVoltNums
+            if cellshortfault==1 or cellshortfault1==1:
+                pass
+            else:
+                df_res_chg=self.df_warning_ram
+                df_res_chg.loc[df_res_chg[df_res_chg['code']=='C490'].index, 'end_time'] = time_now
         
-        #电压/SOC变化率
-        # for i in range(len(volt_rate)):
-        #     if volt_rate[i]<self.param.TrwVoltRate and volt_rate_3sigma[i]<-3 and abs(cellsoh_3sigma[i])<2.5 and  voltsigmafault_list[i]==1:
-        #         faultcode=110
-        #         faultlv=4
-        #         faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-        #         faultadvice='2联系用户远离电池,立刻召回电池'
-        #         df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-        #     else:
-        #         pass
-
-        #mana-kendall趋势检测
-        for i in range(len(mk_p_list)):
-            #适用动态工况判断
-            if mk_trend_list[i]=='decreasing' and mk_p_list[i]<self.param.mk_p and mk_z_list[i]<self.param.mk_z and mk_Tau_list[i]<self.param.mk_Tau and mk_slope_3sigma[i]<-3 and mk_slope_list[i]<self.param.mk_slope and abs(cellsoh_3sigma[i])<2.5 and volt_rate_3sigma[i]<-3:
-                faultcode=110
-                faultlv=4
-                faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-                faultadvice='2联系用户远离电池,立刻召回电池'
-                df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-            #适用静态工况判断
-            elif self.celltype<=50 and mk_trend_list[i]=='decreasing' and mk_p_list[i]<self.param.mk_p and mk_z_list[i]<-6 and (mk_Tau_list[i]<-0.9 or mk_z_3sigma[i]<-3) and mk_slope_3sigma[i]<-3.5 and mk_slope_list[i]<-0.025 and volt_rate_3sigma[i]<-3:
-                faultcode=110
-                faultlv=4
-                faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-                faultadvice='2联系用户远离电池,立刻召回电池'
-                df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-            elif self.celltype>50 and mk_trend_list[i]=='decreasing' and mk_p_list[i]<self.param.mk_p and mk_z_list[i]<-6 and (mk_Tau_list[i]<-0.9 or mk_z_3sigma[i]<-3) and mk_slope_3sigma[i]<-3.5 and mk_slope_list[i]<-0.25 and volt_rate_3sigma[i]<-3:
-                faultcode=110
+        if not 'C490' in list(self.df_warning_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+            if cellshortfault1==1:
+                faultcode='C490'
                 faultlv=4
-                faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-                faultadvice='2联系用户远离电池,立刻召回电池'
-                df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
+                faultinfo='电芯{}发生内短路'.format([cellshort_num])
+                faultadvice='请立刻召回电池包,更换模组'
+                df_res_new.loc[0]=[time_now, end_time, self.sn, faultcode, faultlv, faultinfo, faultadvice]
             else:
                 pass
-
-        return df_res
+        else:
+            if cellshortfault==1 or cellshortfault1==1:
+                pass
+            else:
+                df_res_chg=self.df_warning_ram
+                df_res_chg.loc[df_res_chg[df_res_chg['code']=='C490'].index, 'end_time'] = time_now
+        
+        return df_res_new, df_res_chg

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

@@ -93,11 +93,9 @@ class BatParam:
             self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
-<<<<<<< HEAD
-            self.CellTempHighLv2=50
-=======
+
             self.CellTempHighLv2=55
->>>>>>> master
+
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
@@ -142,11 +140,9 @@ class BatParam:
             self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
-<<<<<<< HEAD
-            self.CellTempHighLv2=50
-=======
+
             self.CellTempHighLv2=55
->>>>>>> master
+
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
@@ -191,11 +187,9 @@ class BatParam:
             self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
-<<<<<<< HEAD
-            self.CellTempHighLv2=50
-=======
+
             self.CellTempHighLv2=55
->>>>>>> master
+
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
@@ -243,11 +237,9 @@ class BatParam:
             self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
-<<<<<<< HEAD
-            self.CellTempHighLv2=50
-=======
+
             self.CellTempHighLv2=55
->>>>>>> master
+
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
@@ -303,11 +295,9 @@ class BatParam:
             self.LeakCurrentLv2=-30
             self.LeakCurrentLv3=-100
             self.CellTempHighLv1=45
-<<<<<<< HEAD
-            self.CellTempHighLv2=50
-=======
+
             self.CellTempHighLv2=55
->>>>>>> master
+
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10