|
@@ -16,7 +16,8 @@ def saftywarning_cal():
|
|
global df_warning_ram2
|
|
global df_warning_ram2
|
|
global df_warning_ram3
|
|
global df_warning_ram3
|
|
global df_lfp_ram
|
|
global df_lfp_ram
|
|
-
|
|
|
|
|
|
+ global now_time
|
|
|
|
+
|
|
now_time=datetime.datetime.now()
|
|
now_time=datetime.datetime.now()
|
|
start_time=now_time-datetime.timedelta(hours=12)
|
|
start_time=now_time-datetime.timedelta(hours=12)
|
|
start_time1=now_time-datetime.timedelta(days=7)
|
|
start_time1=now_time-datetime.timedelta(days=7)
|
|
@@ -125,24 +126,29 @@ def saftywarning_cal():
|
|
DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
|
|
DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
|
|
with DBRead as DBRead:
|
|
with DBRead as DBRead:
|
|
df_short=DBRead.getdata('time_sp,sn,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
|
|
df_short=DBRead.getdata('time_sp,sn,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
|
|
- df_liplated=DBRead.getdata('time,sn,liplated,lipltd_amount', tablename=tablename2, sn=sn, timename='time_sp', st=start_time2, sp=end_time)
|
|
|
|
|
|
+ df_liplated=DBRead.getdata('time,sn,liplated,liplated_amount', tablename=tablename2, sn=sn, timename='time', st=start_time2, sp=end_time)
|
|
df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellmin_num', tablename=tablename3, sn=sn, timename='time', st=start_time1, sp=end_time)
|
|
df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellmin_num', tablename=tablename3, sn=sn, timename='time', st=start_time1, sp=end_time)
|
|
|
|
|
|
#获取sn的故障RAM
|
|
#获取sn的故障RAM
|
|
df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
|
|
df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
|
|
|
|
|
|
#热安全预警
|
|
#热安全预警
|
|
- BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_fault_ram_sn)
|
|
|
|
- df_warning_res=BatWarning.diag()
|
|
|
|
-
|
|
|
|
- df_warning_end=df_warning_res[df_warning_res['end_time'] != '0000-00-00 00:00:00']
|
|
|
|
- if not df_warning_end.empty: #df_warning_end历史故障筛选并更改数据库故障结束时间
|
|
|
|
- pass
|
|
|
|
- elif df_fault_ram_sn.empty and (not df_warning_res.empty):
|
|
|
|
- with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a') as file:
|
|
|
|
- file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
|
|
|
|
|
|
+ if df_fault_ram_sn.empty:
|
|
|
|
+ BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform)
|
|
|
|
+ df_warning_res=BatWarning.diag()
|
|
|
|
+ #当前热失控故障写入数据库
|
|
|
|
+ if not df_warning_res.empty:
|
|
|
|
+ with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a') as file:
|
|
|
|
+ file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
|
|
|
|
+
|
|
else:
|
|
else:
|
|
- pass
|
|
|
|
|
|
+ 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()>24*3600: #df_warning_end历史故障筛选并更改数据库故障结束时间
|
|
|
|
+ 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') as file:
|
|
|
|
+ file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
|
|
|
|
+
|
|
|
|
|
|
#...............................................主函数起定时作用.......................................................................................................................
|
|
#...............................................主函数起定时作用.......................................................................................................................
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
@@ -161,7 +167,7 @@ if __name__ == "__main__":
|
|
SNnums_C7255=SNdata_C7255['SN号'].tolist()
|
|
SNnums_C7255=SNdata_C7255['SN号'].tolist()
|
|
SNnums_U7255=SNdata_U7255['SN号'].tolist()
|
|
SNnums_U7255=SNdata_U7255['SN号'].tolist()
|
|
SNnums=SNnums_L7255 + SNnums_C7255 + SNnums_U7255, SNnums_6040 + SNnums_4840 + SNnums_6060
|
|
SNnums=SNnums_L7255 + SNnums_C7255 + SNnums_U7255, SNnums_6040 + SNnums_4840 + SNnums_6060
|
|
- SNnums=['MGMCLN750N215N099','PK504B10100004425']
|
|
|
|
|
|
+ SNnums=['MGMCLN750N215N155']
|
|
|
|
|
|
mylog=log.Mylog('log_warning.txt','error')
|
|
mylog=log.Mylog('log_warning.txt','error')
|
|
mylog.logcfg()
|
|
mylog.logcfg()
|
|
@@ -170,12 +176,15 @@ if __name__ == "__main__":
|
|
df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
|
|
df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
|
|
df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
|
|
df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
|
|
df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
|
|
df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
|
|
- df_warning_ram3=pd.DataFrame(columns=['sn','standingtime','standingtime1'])
|
|
|
|
|
|
+ df_warning_ram3=pd.DataFrame(columns=['sn','time3','standingtime','standingtime1'])
|
|
df_lfp_ram=pd.DataFrame()
|
|
df_lfp_ram=pd.DataFrame()
|
|
|
|
|
|
|
|
+ now_time='2021-10-15 00:00:00'
|
|
|
|
+ now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
|
|
|
|
+
|
|
#定时任务.......................................................................................................................................................................
|
|
#定时任务.......................................................................................................................................................................
|
|
scheduler = BlockingScheduler()
|
|
scheduler = BlockingScheduler()
|
|
- scheduler.add_job(saftywarning_cal, 'interval', seconds=5)
|
|
|
|
|
|
+ scheduler.add_job(saftywarning_cal, 'interval', hours=12)
|
|
|
|
|
|
try:
|
|
try:
|
|
scheduler.start()
|
|
scheduler.start()
|