|
@@ -20,13 +20,13 @@ def saftywarning_cal():
|
|
|
global df_lfp_ram
|
|
|
global df_lfp_ram1
|
|
|
global df_chrgvolt_ram
|
|
|
+ global now_time
|
|
|
|
|
|
pd.set_option('display.width', 300)
|
|
|
pd.set_option('display.max_rows', None)
|
|
|
pd.set_option('display.max_columns', None)
|
|
|
|
|
|
|
|
|
- now_time=datetime.datetime.now()
|
|
|
start_time=now_time-datetime.timedelta(hours=6)
|
|
|
start_time1=now_time-datetime.timedelta(days=7)
|
|
|
start_time2=now_time-datetime.timedelta(days=3)
|
|
@@ -36,6 +36,7 @@ def saftywarning_cal():
|
|
|
start_time2=start_time2.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
start_time3=start_time3.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
+ now_time=now_time+datetime.timedelta(hours=6)
|
|
|
|
|
|
|
|
|
|
|
@@ -50,7 +51,7 @@ def saftywarning_cal():
|
|
|
cursor = mysql.cursor()
|
|
|
param='start_time,end_time,product_id,code,level,info,advice'
|
|
|
tablename='all_fault_info'
|
|
|
- sql = "select %s from %s where code=110 and end_time='0000-00-00 00:00:00'" %(param,tablename)
|
|
|
+ sql = "select %s from %s where code='C490' and end_time='0000-00-00 00:00:00'" %(param,tablename)
|
|
|
cursor.execute(sql)
|
|
|
res = cursor.fetchall()
|
|
|
df_fault_ram= pd.DataFrame(res,columns=param.split(','))
|
|
@@ -166,7 +167,7 @@ def saftywarning_cal():
|
|
|
tablename4='outlier_voltchangeratio'
|
|
|
DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
|
|
|
with DBRead as DBRead:
|
|
|
- df_short=DBRead.getdata('time_sp,sn,method,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
|
|
|
+ df_short=DBRead.getdata('time_st,time_sp,sn,method,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
|
|
|
df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank', tablename=tablename3, sn=sn, timename='time', st=start_time2, sp=end_time)
|
|
|
df_voltsigma=DBRead.getdata('time,sn,VolOl_Uni,VolChng_Uni', tablename=tablename4, sn=sn, timename='time', st=start_time3, sp=end_time)
|
|
|
|
|
@@ -175,40 +176,31 @@ def saftywarning_cal():
|
|
|
|
|
|
|
|
|
if df_fault_ram_sn.empty:
|
|
|
- BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_voltsigma,df_soh)
|
|
|
- df_warning_res=BatWarning.diag()
|
|
|
+ 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_warning_res.empty:
|
|
|
- with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
|
|
|
- file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
|
|
|
+ if not df_res_new.empty:
|
|
|
+ with open(r'热失控预警.txt','a',encoding="utf-8") as file:
|
|
|
+ file.write(str(tuple(df_res_new.iloc[-1]))+'\n')
|
|
|
+ if not df_res_chg.empty:
|
|
|
+ with open(r'热失控预警.txt','a',encoding="utf-8") as file:
|
|
|
+ file.write(str(tuple(df_res_chg.iloc[-1]))+'\n')
|
|
|
|
|
|
- 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_fault_ram_sn['end_time']=end_time
|
|
|
- df_fault_ram_sn['Batpos']=1
|
|
|
- with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
|
|
|
- file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SNnums=['PK50001A100000577']
|
|
|
+ SNnums=['PK50201A000002052']
|
|
|
+ now_time='2022-11-22 14:00:00'
|
|
|
+ now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
|
|
|
|
|
@@ -225,7 +217,7 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
scheduler = BlockingScheduler()
|
|
|
- scheduler.add_job(saftywarning_cal, 'interval', seconds=6)
|
|
|
+ scheduler.add_job(saftywarning_cal, 'interval', seconds=10)
|
|
|
|
|
|
try:
|
|
|
scheduler.start()
|