소스 검색

更新漏电流检测代码

qingfeng 3 년 전
부모
커밋
96054feafa
2개의 변경된 파일34개의 추가작업 그리고 6개의 파일을 삭제
  1. 7 6
      LIB/MIDDLE/LeakCurrent/LFPLeakCurrent20210812.py
  2. 27 0
      LIB/MIDDLE/LeakCurrent/main.py

+ 7 - 6
LIB/MIDDLE/LeakCurrent/LFPLeakCurrent20210812.py

@@ -86,6 +86,9 @@ def cal_LFPLeakCurrent(sn, end_time, start_time):
                 break
     
     if ChgStartValid:
+        df_DetaTime=pd.DataFrame()
+        df_DetaTime1=pd.DataFrame()
+        df_detatime=pd.DataFrame()
         for i in range(len(ChgStartValid)):
             DetaSoc1=[]
             DetaSoc2 = []
@@ -123,8 +126,7 @@ def cal_LFPLeakCurrent(sn, end_time, start_time):
             Socmean2=(sum(DetaSoc2)-max(DetaSoc2)-min(DetaSoc2))/(len(DetaSoc2)-2)
 
             #计算每个电芯的Soc差
-            df_DetaTime=pd.DataFrame()
-            df_detatime=pd.DataFrame()
+
             DetaSoc3=DetaSoc1+DetaSoc2
             for j in range(len(DetaSoc3)):
                 if j<10:
@@ -134,7 +136,6 @@ def cal_LFPLeakCurrent(sn, end_time, start_time):
                 DetaSoc.append(DetaSoc3[j]-Socmean)
                 # DetaSoc.append((DetaT[j]-Tmean)*9.5/(Capacity*3600))
             df_DetaTime[time[ChgStartValid[i]]]=DetaSoc
-
         #漏电流计算
         column=[]
         time1=[]
@@ -144,16 +145,16 @@ def cal_LFPLeakCurrent(sn, end_time, start_time):
             column.append(index) #提取列名称
 
         for  i in range(1,len(column)):#计算漏电流值
-            df_DetaTime[column[i]] = df_DetaTime.apply(lambda x: (x[column[i-1]] -  x[column[i]])*1000*Capacity*3600/((column[i]-column[i-1]).total_seconds()), axis=1)
+            df_DetaTime1[column[i]] = df_DetaTime.apply(lambda x: (x[column[i-1]] -  x[column[i]])*1000*Capacity*3600/((column[i]-column[i-1]).total_seconds()), axis=1)
             time1.append(column[i])
             sn1.append(sn)
         df_detatime['time']=time1
         df_detatime['sn']=sn1
 
-        for i in range(len(CellVoltNums)):
+        for i in range(CellVoltNums):
             cell=[]
             for j in range(1,len(column)):
-                cell.append(df_DetaTime[1,column[j]])
+                cell.append(df_DetaTime1[column[j]][i])
             df_detatime['cell'+str(i+1)]=cell
         return df_detatime
     return pd.DataFrame()

+ 27 - 0
LIB/MIDDLE/LeakCurrent/main.py

@@ -0,0 +1,27 @@
+#coding=utf-8
+import os
+import datetime
+import pandas as pd
+from LIB.BACKEND import DBManager, Log
+from LIB.MIDDLE import SignalMonitor
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+import time, datetime
+import traceback
+import LFPLeakCurrent20210812 as LFPLeakCurrent
+
+from urllib import parse
+
+dbManager = DBManager.DBManager()
+if __name__ == "__main__":
+    SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
+    SNnums_6060=SNdata_6060['SN号']
+    now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+    now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
+    start_time=now_time-datetime.timedelta(days=31)
+    end_time=str(now_time)
+    start_time=str(start_time)
+
+    for sn in SNnums_6060.tolist():
+        res = LFPLeakCurrent.cal_LFPLeakCurrent(sn, end_time, start_time)
+        res.to_csv('BMS_LeakCurrent_'+sn+'.csv',encoding='GB18030')