2 Commits b36deffadf ... 890cafc462

Author SHA1 Message Date
  Eric412V 890cafc462 Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev 2 years ago
  Eric412V f6bd06c00d 增加真芯好电4820电池参数,增加dbmanager平峰储能信息取数逻辑 2 years ago

+ 43 - 6
LIB/BACKEND/DBManager.py

@@ -224,6 +224,25 @@ class DBManager():
                     columns=['时间戳','累计充电电量','累计充电能量','累计放电电量','累计放电能量', '累积里程'],data=data_block)
         return df
     
+    @staticmethod
+    def _convert_to_dataframe_storage_accum(data, mode=0):
+        if mode == 0:
+            
+            data_block = np.array([data['info'].get('obdTime',None),data['ffEnergyStoreStat'].get('usedEnergy',None), data['ffEnergyStoreStat'].get('inputEnergy',None),
+                                    data['ffEnergyStoreStat'].get('outputEnergy',None), data['ffEnergyStoreStat'].get('usedEnergy2',None), data['ffEnergyStoreStat'].get('inputEnergy2',None),
+                                    data['ffEnergyStoreStat'].get('outputEnergy2',None)]).reshape(1,7)
+            df = pd.DataFrame(
+                columns=['时间戳','累计用电kWh数1', '累计正向输入kWh1','累计反向输出kWh数1',
+                        '累计用电kWh数2', '累计正向输入kWh2','累计反向输出kWh数2'],data=data_block)
+
+        if mode == 1:
+                data_block = np.array([data['info'].get('obdTime',None),data['ffEnergyStoreStat'].get('usedEnergy',None), data['ffEnergyStoreStat'].get('inputEnergy',None),
+                                    data['ffEnergyStoreStat'].get('outputEnergy',None), data['ffEnergyStoreStat'].get('usedEnergy2',None), data['ffEnergyStoreStat'].get('inputEnergy2',None),
+                                    data['ffEnergyStoreStat'].get('outputEnergy2',None)]).reshape(1,7)
+                df = pd.DataFrame(
+                    columns=['时间戳','累计用电kWh数1', '累计正向输入kWh1','累计反向输出kWh数1',
+                        '累计用电kWh数2', '累计正向输入kWh2','累计反向输出kWh数2'],data=data_block)
+        return df
     
     
     @staticmethod
@@ -337,8 +356,7 @@ class DBManager():
                 df_all = df_all.append(df_add,ignore_index=True)
             if not df_all.empty:
                 df_all.loc[:,'时间戳'] = df_all.loc[:,'时间戳'].apply(lambda x:time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(int(x)/1000)))
-            return df_all
-        
+            return df_all       
         elif type_name =='accum':
             if mode == 0:
                 df_all = pd.DataFrame(columns=['时间戳','SOH未标定时间', '累计充电电量','累计充电能量','累计放电电量','累计放电能量',
@@ -351,6 +369,18 @@ class DBManager():
             if not df_all.empty:
                 df_all.loc[:,'时间戳'] = df_all.loc[:,'时间戳'].apply(lambda x:time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(int(x)/1000)))
             return df_all
+        elif type_name =='storage_accum':
+            if mode == 0:
+                df_all = pd.DataFrame(columns=['时间戳','累计用电kWh数1', '累计正向输入kWh1','累计反向输出kWh数1',
+                                               '累计用电kWh数2', '累计正向输入kWh2','累计反向输出kWh数2'])
+            elif mode == 1:
+                df_all = pd.DataFrame()
+            for line in data:
+                df_add = DBManager._convert_to_dataframe_storage_accum(line, mode)
+                df_all = df_all.append(df_add,ignore_index=True)
+            if not df_all.empty:
+                df_all.loc[:,'时间戳'] = df_all.loc[:,'时间戳'].apply(lambda x:time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(int(x)/1000)))
+            return df_all
     def get_data(self, url='http://172.16.126.13/store/load?dataType={}&limit=0&sn={}', sn='', start_time='', end_time='', 
                  data_groups=['bms', 'gps']):
         '''
@@ -373,7 +403,7 @@ class DBManager():
         df_data: {'bms':dataframe, 'gps':dataframe, 'system':dataframe, ;accum':dataframe}
         '''
         
-        if len(set(data_groups) - (set(data_groups) and set(['bms', 'gps', 'system', 'accum']))) > 0:
+        if len(set(data_groups) - (set(data_groups) and set(['bms', 'gps', 'system', 'accum', 'storage_accum']))) > 0:
             raise Exception("data_groups 参数错误")
         
         
@@ -386,6 +416,7 @@ class DBManager():
         gps_all_data = pd.DataFrame()
         system_all_data = pd.DataFrame()
         accum_all_data = pd.DataFrame()
+        storage_accum_all_data = pd.DataFrame()
         maxnum = (datetime.datetime.strptime(end_time, "%Y-%m-%d %H:%M:%S") - datetime.datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S")).days +1
         print("### start to get data {} from {} to {}".format(sn, start_time, end_time))
         # 为避免chunkEncodingError错误,数据每天获取一次,然后将每天的数据合并,得到最终的数据
@@ -402,6 +433,7 @@ class DBManager():
             gps_data = pd.DataFrame()
             system_data = pd.DataFrame()
             accum_data = pd.DataFrame()
+            storage_accum_all_data = pd.DataFrame()
             while True:
                 try:
                     print('\r' + "# get data from {} to {}.........".format(str(timefrom), str(timeto)), end=" ")
@@ -418,6 +450,9 @@ class DBManager():
                         if data_group == 'accum':
                             file_url = url.format(23, sn) + "&from="+timefrom.strftime('%Y-%m-%d %H:%M:%S')+"&to="+timeto.strftime('%Y-%m-%d %H:%M:%S')
                             accum_data = DBManager._get_data(file_url,'accum',mode)
+                        if data_group == 'storage_accum':
+                            file_url = url.format(29, sn) + "&from="+timefrom.strftime('%Y-%m-%d %H:%M:%S')+"&to="+timeto.strftime('%Y-%m-%d %H:%M:%S')
+                            storage_accum_data = DBManager._get_data(file_url,'storage_accum',mode)                        
                 except Exception as e:
                     if 'Connection broken' in str(e):
                         continue
@@ -430,13 +465,15 @@ class DBManager():
                     gps_all_data = pd.concat([gps_all_data, gps_data], ignore_index=True)
                     system_all_data = pd.concat([system_all_data, system_data], ignore_index=True)
                     accum_all_data = pd.concat([accum_all_data, accum_data], ignore_index=True)
+                    storage_accum_all_data = pd.concat([storage_accum_all_data, storage_accum_data], ignore_index=True)
                     break
 
         bms_all_data = bms_all_data.reset_index(drop=True)
         gps_all_data = gps_all_data.reset_index(drop=True)
         system_all_data = system_all_data.reset_index(drop=True)
         accum_all_data = accum_all_data.reset_index(drop=True)
-        print('\nall data-getting done, bms_count is {}, gps_count is {}, system_count is {}, accum_count is {} \n'.format(
-            str(len(bms_all_data)), str(len(gps_all_data)), str(len(system_all_data)), str(len(accum_all_data))))
-        return {'bms':bms_all_data, 'gps':gps_all_data, 'system':system_all_data, 'accum':accum_all_data}
+        storage_accum_all_data = storage_accum_all_data.reset_index(drop=True)
+        print('\nall data-getting done, bms_count is {}, gps_count is {}, system_count is {}, accum_count is {} ,storage_accum_count is {}\n'.format(
+            str(len(bms_all_data)), str(len(gps_all_data)), str(len(system_all_data)), str(len(accum_all_data)), str(len(storage_accum_all_data))))
+        return {'bms':bms_all_data, 'gps':gps_all_data, 'system':system_all_data, 'accum':accum_all_data,'storage_accum':storage_accum_all_data}
 

+ 22 - 2
LIB/MIDDLE/CellStateEstimation/Common/BatParam.py

@@ -93,7 +93,7 @@ class BatParam:
             self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
             self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
         
-        elif celltype==100:
+        elif celltype==100:  #金茂
             self.Capacity = 228*2
             self.PackFullChrgVolt=3.65*192
             self.CellFullChrgVolt=3.5
@@ -127,7 +127,27 @@ class BatParam:
             self.PackVoltUvLv2=self.CellUvLv2*self.CellVoltNums/2
 
             self.PackChgOc=-800
-            self.PackDisOc=800        
+            self.PackDisOc=800      
+            
+        elif celltype==101:   #真芯好电_20ah磷酸铁锂电芯
+                self.Capacity = 20
+                self.PackFullChrgVolt=54
+                self.CellFullChrgVolt=3.65
+                self.OcvInflexionBelow=3.2849
+                self.OcvInflexion2=3.2998
+                self.OcvInflexion3=3.3268
+                self.OcvInflexionAbove=3.3333
+                self.CellVoltNums=15
+                self.CellTempNums=1
+                self.FullChrgSoc=100
+                self.PeakSoc=62.5
+                self.PeakVoltLowLmt=3.35
+                self.PeakVoltUpLmt=3.4
+                self.PeakCellVolt=[3.362,3.363,3.365,3.366,3.367]
+                self.PackCrntDec=1
+                self.BalCurrent=0.015
+                self.LookTab_SOC = [0.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5, 50.0, 52.5, 55.0, 57.5, 60.0, 62.5, 65.0, 67.5, 70.0, 72.5, 75.0, 77.5, 80.0, 82.5, 85.0, 87.5, 90.0, 92.5, 95.0, 97.5, 100.0]
+                self.LookTab_OCV = [2.5220, 2.8283, 3.0608, 3.1690, 3.1981, 3.2012, 3.2071, 3.2229, 3.2341, 3.2452, 3.2533, 3.2607, 3.2691, 3.2775, 3.2849, 3.2859, 3.2859, 3.2862, 3.2865, 3.2871, 3.2874, 3.2886, 3.2896, 3.2908, 3.2933, 3.2998, 3.3181, 3.3249, 3.3258, 3.3262, 3.3268, 3.3268, 3.3274, 3.3277, 3.3280, 3.3286, 3.3289, 3.3299, 3.3305, 3.3333, 3.4406]  
         else:
             print('未找到对应电池编号!!!')
             # sys.exit()

+ 19 - 1
LIB/MIDDLE/SaftyCenter/Common/QX_BatteryParam.py

@@ -143,7 +143,25 @@ class BatteryInfo():
             self.CellUVlmt=2
             self.CantChrgVol=2.6
             self.AvgOtherTempGap=40
- 
+        elif celltype==101:   #真芯好电_20ah磷酸铁锂电芯
+            self.Capacity = 20
+            self.PackFullChrgVolt=54
+            self.CellFullChrgVolt=3.65
+            self.OcvInflexionBelow=3.2849
+            self.OcvInflexion2=3.2998
+            self.OcvInflexion3=3.3268
+            self.OcvInflexionAbove=3.3333
+            self.CellVoltNums=15
+            self.CellTempNums=1
+            self.FullChrgSoc=100
+            self.PeakSoc=62.5
+            self.PeakVoltLowLmt=3.35
+            self.PeakVoltUpLmt=3.4
+            self.PeakCellVolt=[3.362,3.363,3.365,3.366,3.367]
+            self.PackCrntDec=1
+            self.BalCurrent=0.015
+            self.LookTab_SOC = [0.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5, 50.0, 52.5, 55.0, 57.5, 60.0, 62.5, 65.0, 67.5, 70.0, 72.5, 75.0, 77.5, 80.0, 82.5, 85.0, 87.5, 90.0, 92.5, 95.0, 97.5, 100.0]
+            self.LookTab_OCV = [2.5220, 2.8283, 3.0608, 3.1690, 3.1981, 3.2012, 3.2071, 3.2229, 3.2341, 3.2452, 3.2533, 3.2607, 3.2691, 3.2775, 3.2849, 3.2859, 3.2859, 3.2862, 3.2865, 3.2871, 3.2874, 3.2886, 3.2896, 3.2908, 3.2933, 3.2998, 3.3181, 3.3249, 3.3258, 3.3262, 3.3268, 3.3268, 3.3274, 3.3277, 3.3280, 3.3286, 3.3289, 3.3299, 3.3305, 3.3333, 3.4406]  
 
         else:
             print('未找到对应电池编号!!!')

+ 2 - 0
LIB/MIDDLE/SaftyCenter/Low_Soc_Alarm/main.py

@@ -68,6 +68,8 @@ def Low_Soc_Alarm():
             celltype=3 #力信50ah三元电芯
         elif 'MGMCLN750' or 'UD' in sn: 
             celltype=4 #CATL 50ah三元电芯
+        elif 'BT1048020' in sn:
+            celltype=101    #20ah林磷酸铁锂电芯
         else:
             print('SN:{},未找到对应电池类型!!!'.format(sn))
             continue