@@ 251-294 (lines=44) @@ | ||
248 | ||
249 | # get battery state point |
|
250 | battery_state_point_value = None |
|
251 | if is_online: |
|
252 | query = (" SELECT tescb.battery_state_point_id " |
|
253 | " FROM tbl_energy_storage_power_stations_containers tespsesc, " |
|
254 | " tbl_energy_storage_containers_batteries tescb " |
|
255 | " WHERE tespsesc.energy_storage_power_station_id = %s " |
|
256 | " AND tespsesc.energy_storage_container_id = tescb.energy_storage_container_id " |
|
257 | " LIMIT 1 ") |
|
258 | cursor_system_db.execute(query, (energy_storage_power_station_id,)) |
|
259 | row_point = cursor_system_db.fetchone() |
|
260 | if row_point is not None and len(row_point) > 0: |
|
261 | if digital_value_latest_dict.get(row_point[0]) is not None: |
|
262 | battery_state_point_value = digital_value_latest_dict.get(row_point[0])['actual_value'] |
|
263 | ||
264 | # 0预留 1故障 2预警 3待机 4禁放 5禁充 6正常 7充电 8放电 9空闲 |
|
265 | print(battery_state_point_value) |
|
266 | if point_definition_dict.get(row_point[0]) is not None: |
|
267 | definition = point_definition_dict.get(row_point[0]) |
|
268 | print(definition) |
|
269 | battery_operating_state = definition.get(str(battery_state_point_value)) |
|
270 | else: |
|
271 | if battery_state_point_value is None: |
|
272 | battery_operating_state = 'Unknown' |
|
273 | elif battery_state_point_value == 0: |
|
274 | battery_operating_state = 'Reserved' |
|
275 | elif battery_state_point_value == 1: |
|
276 | battery_operating_state = 'Fault' |
|
277 | elif battery_state_point_value == 2: |
|
278 | battery_operating_state = 'Warning' |
|
279 | elif battery_state_point_value == 3: |
|
280 | battery_operating_state = 'Standby' |
|
281 | elif battery_state_point_value == 4: |
|
282 | battery_operating_state = 'ProhibitDisCharging' |
|
283 | elif battery_state_point_value == 5: |
|
284 | battery_operating_state = 'ProhibitCharging' |
|
285 | elif battery_state_point_value == 6: |
|
286 | battery_operating_state = 'Normal' |
|
287 | elif battery_state_point_value == 7: |
|
288 | battery_operating_state = 'Charging' |
|
289 | elif battery_state_point_value == 8: |
|
290 | battery_operating_state = 'Discharging' |
|
291 | elif battery_state_point_value == 9: |
|
292 | battery_operating_state = 'Idle' |
|
293 | else: |
|
294 | battery_operating_state = 'Unknown' |
|
295 | ||
296 | # get battery soc point, power point |
|
297 | battery_soc_point_value = None |
@@ 247-290 (lines=44) @@ | ||
244 | # get battery state point |
|
245 | battery_state_point_value = None |
|
246 | battery_operating_state = 'Unknown' |
|
247 | if is_online: |
|
248 | query = (" SELECT tescb.battery_state_point_id " |
|
249 | " FROM tbl_energy_storage_power_stations_containers tespsesc, " |
|
250 | " tbl_energy_storage_containers_batteries tescb " |
|
251 | " WHERE tespsesc.energy_storage_power_station_id = %s " |
|
252 | " AND tespsesc.energy_storage_container_id = tescb.energy_storage_container_id " |
|
253 | " LIMIT 1 ") |
|
254 | cursor_system.execute(query, (energy_storage_power_station_id,)) |
|
255 | row_point = cursor_system.fetchone() |
|
256 | if row_point is not None and len(row_point) > 0: |
|
257 | if digital_value_latest_dict.get(row_point[0]) is not None: |
|
258 | battery_state_point_value = digital_value_latest_dict.get(row_point[0]) |
|
259 | ||
260 | # 0预留 1故障 2预警 3待机 4禁放 5禁充 6正常 7充电 8放电 9空闲 |
|
261 | print(battery_state_point_value) |
|
262 | if point_definition_dict.get(row_point[0]) is not None: |
|
263 | definition = point_definition_dict.get(row_point[0]) |
|
264 | print(definition) |
|
265 | battery_operating_state = definition.get(str(battery_state_point_value)) |
|
266 | else: |
|
267 | if battery_state_point_value is None: |
|
268 | battery_operating_state = 'Unknown' |
|
269 | elif battery_state_point_value == 0: |
|
270 | battery_operating_state = 'Reserved' |
|
271 | elif battery_state_point_value == 1: |
|
272 | battery_operating_state = 'Fault' |
|
273 | elif battery_state_point_value == 2: |
|
274 | battery_operating_state = 'Warning' |
|
275 | elif battery_state_point_value == 3: |
|
276 | battery_operating_state = 'Standby' |
|
277 | elif battery_state_point_value == 4: |
|
278 | battery_operating_state = 'ProhibitDisCharging' |
|
279 | elif battery_state_point_value == 5: |
|
280 | battery_operating_state = 'ProhibitCharging' |
|
281 | elif battery_state_point_value == 6: |
|
282 | battery_operating_state = 'Normal' |
|
283 | elif battery_state_point_value == 7: |
|
284 | battery_operating_state = 'Charging' |
|
285 | elif battery_state_point_value == 8: |
|
286 | battery_operating_state = 'Discharging' |
|
287 | elif battery_state_point_value == 9: |
|
288 | battery_operating_state = 'Idle' |
|
289 | else: |
|
290 | battery_operating_state = 'Unknown' |
|
291 | meta_result = {"id": row[0], |
|
292 | "name": row[1], |
|
293 | "uuid": row[2], |