main.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import CBMSBatInterShort
  2. import datetime
  3. import pandas as pd
  4. import datetime
  5. from USER.Common import DBDownload
  6. from USER.Common import log
  7. if __name__ == "__main__":
  8. SNnums= ['HeZhong']
  9. end_time=datetime.datetime.now()-datetime.timedelta(seconds=10)
  10. start_time=end_time-datetime.timedelta(seconds=12000)
  11. start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
  12. end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
  13. #log信息配置............................................................................................................................................................................
  14. mylog=log.Mylog('log_short.txt','error')
  15. mylog.logcfg()
  16. for sn in SNnums:
  17. try:
  18. # if 'PK500' in sn:
  19. # celltype=1 #6040三元电芯
  20. # elif 'PK502' in sn:
  21. # celltype=2 #4840三元电芯
  22. # elif 'PK504' in sn:
  23. # celltype=99 #60ah林磷酸铁锂电芯
  24. # elif 'MGMLXN750' in sn:
  25. # celltype=3 #力信50ah三元电芯
  26. # elif 'MGMCLN750' in sn:
  27. # celltype=4 #CATL 50ah三元电芯
  28. # else:
  29. # print('未找到对应电池编号!!!\n',sn)
  30. # # sys.exit()
  31. celltype=15
  32. #............................................................读取原始数据库数据...........................................................................
  33. df_bms= pd.read_csv(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\98Download\合众data924T101(1).csv',encoding='GB18030')
  34. #............................................................读取结果数据库数据.........................................................................
  35. # host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  36. # port=3306
  37. # db='qx_cas'
  38. # user='qx_read'
  39. # password='Qx@123456'
  40. # mode=1
  41. # tablename='cellstateestimation_soh'
  42. # DBRead=DBDownload.DBDownload(host, port, db, user, password, mode)
  43. # with DBRead as DBRead:
  44. # df_soh=DBRead.getdata(param='time_st,time_sp,sn,method,soh,cellsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time)
  45. df_soh=pd.DataFrame({'time_st':[1],'sn':[2],'soh':[100]})
  46. # print(df_soh)
  47. #...........................................................................计算漏电流............................................................................
  48. BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh)
  49. df_res=BatInterShort.intershort()
  50. df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_short_'+sn+'_1.xlsx')
  51. # print('done!!!')
  52. except Exception as e:
  53. print(repr(e))
  54. mylog.logopt(sn,e)
  55. pass