重构现代化 FastAPI 后端项目框架
This commit is contained in:
66
scripts/get_current_status.py
Normal file
66
scripts/get_current_status.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from tjnetwork import *
|
||||
from get_realValue import *
|
||||
from get_hist_data import *
|
||||
import datetime
|
||||
from api.s36_wda_cal import *
|
||||
|
||||
|
||||
ids=['2498','3854','3853','2510','2514','4780','4854']
|
||||
cur_data=None
|
||||
|
||||
|
||||
def get_latest_cal_time()->datetime:
|
||||
current_time=datetime.datetime.now()
|
||||
return current_time
|
||||
|
||||
|
||||
def get_current_data(str_datetime: str=None)->bool:
|
||||
global cur_data
|
||||
if str_datetime==None:
|
||||
cur_data=get_realValue(ids)
|
||||
else:
|
||||
cur_date=get_hist_data(ids,str_datetime)
|
||||
if cur_data ==None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_current_total_Q(str_dt:str='')->float:
|
||||
q_ids=['2498','3854','3853']
|
||||
q_dn900=cur_data[q_ids[0]]
|
||||
q_dn500=cur_data[q_ids[1]]
|
||||
q_dn1000=cur_data[q_ids[2]]
|
||||
total_q=q_dn1000+q_dn500+q_dn900
|
||||
return total_q
|
||||
|
||||
def get_h_pressure()->float:
|
||||
head_id='2510'
|
||||
h_pressure=cur_data[head_id]
|
||||
return h_pressure
|
||||
|
||||
def get_l_pressure()->float:
|
||||
head_id='2514'
|
||||
l_pressure=cur_data[head_id]
|
||||
return l_pressure
|
||||
|
||||
def get_h_tank_leve()->float:
|
||||
h_tank_id='4780'
|
||||
h_tank_level=cur_data[h_tank_id]
|
||||
return h_tank_level
|
||||
|
||||
def get_l_tank_leve()->float:
|
||||
l_tank_id='4854'
|
||||
l_tank_level=cur_data[l_tank_id]
|
||||
return l_tank_level
|
||||
|
||||
|
||||
# test interface
|
||||
if __name__ == '__main__':
|
||||
# if get_current_data()==True:
|
||||
# tQ=get_current_total_Q()
|
||||
# print(f"the current tQ is {tQ}\n")
|
||||
# data=get_hist_data(ids,conver_beingtime_to_ucttime('2024-04-10 15:05:00'),conver_beingtime_to_ucttime('2024-04-10 15:10:00'))
|
||||
open_project("beibeizone")
|
||||
regions=get_all_service_area_ids("beibeizone")
|
||||
for region in regions:
|
||||
t_basedmds=api.s36_wda_cal.get_total_base_demand("beibeizone",region)
|
||||
print(f"{region}:{t_basedmds}")
|
||||
Reference in New Issue
Block a user