From e8fddfb71ad8cf809d7ed6b1f72ec5a241cd8bde Mon Sep 17 00:00:00 2001 From: xinzish <32566857+xinzish@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:59:09 +0800 Subject: [PATCH] redistribute the demands --- api/s36_wda_cal.py | 11 +++++++++++ get_current_status.py | 14 ++++++++++---- run_simlation.py | 3 +++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/api/s36_wda_cal.py b/api/s36_wda_cal.py index b2b9f8a..4583993 100644 --- a/api/s36_wda_cal.py +++ b/api/s36_wda_cal.py @@ -91,3 +91,14 @@ def distribute_demand_to_nodes(name: str, demand: float, nodes: list[str], type: def distribute_demand_to_region(name: str, demand: float, region: str, type: str = DISTRIBUTION_TYPE_ADD) -> ChangeSet: nodes = get_nodes_in_region(name, region) return distribute_demand_to_nodes(name, demand, nodes, type) + +def get_total_base_demand(name:str,region:str)->float: + nodes = get_nodes_in_region(name, region) + t_demands=0.0 + for node in nodes: + if not is_junction(name, node): + continue + ds = get_demand(name, node)['demands'] + t_demands= t_demands+ds[0]['demand'] + + return t_demands \ No newline at end of file diff --git a/get_current_status.py b/get_current_status.py index 605fae8..2b63f2b 100644 --- a/get_current_status.py +++ b/get_current_status.py @@ -2,6 +2,7 @@ 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'] @@ -54,7 +55,12 @@ def get_l_tank_leve()->float: # 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')) \ No newline at end of file + # 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}") \ No newline at end of file diff --git a/run_simlation.py b/run_simlation.py index 0a3e2b1..2d7408b 100644 --- a/run_simlation.py +++ b/run_simlation.py @@ -2,4 +2,7 @@ from tjnetwork import * from get_current_status import * def run_simulation(cur_datetime:str=None)->str: + + open_project('beibei_skeleton') + return \ No newline at end of file