Update run_simulation method
This commit is contained in:
28
main.py
28
main.py
@@ -2712,19 +2712,19 @@ def generate_openapi_json():
|
||||
|
||||
|
||||
# 必须用这个PlainTextResponse,不然每个key都有引号
|
||||
@app.get("/runsimulation/", response_class = PlainTextResponse)
|
||||
async def fastapi_run_project(network: str,start_time:str,end_time=None) -> str:
|
||||
filename = 'c:/lock.simulation'
|
||||
filename2 = 'c:/lock.simulation2'
|
||||
if os.path.exists(filename2):
|
||||
print('file exists')
|
||||
raise HTTPException(status_code=409, detail="is in simulation")
|
||||
else:
|
||||
print('file doesnt exists')
|
||||
#os.rename(filename, filename2)
|
||||
result = run_simulation_ex(name=network, simulation_type='realtime', start_datetime=start_time, end_datetime=end_time)
|
||||
#os.rename(filename2, filename)
|
||||
return result
|
||||
# @app.get("/runsimulation/", response_class = PlainTextResponse)
|
||||
# async def fastapi_run_project(network: str,start_time:str,end_time=None) -> str:
|
||||
# filename = 'c:/lock.simulation'
|
||||
# filename2 = 'c:/lock.simulation2'
|
||||
# if os.path.exists(filename2):
|
||||
# print('file exists')
|
||||
# raise HTTPException(status_code=409, detail="is in simulation")
|
||||
# else:
|
||||
# print('file doesnt exists')
|
||||
# #os.rename(filename, filename2)
|
||||
# result = run_simulation_ex(name=network, simulation_type='realtime', start_datetime=start_time, end_datetime=end_time)
|
||||
# #os.rename(filename2, filename)
|
||||
# return result
|
||||
|
||||
# DingZQ, 2025-05-17
|
||||
@app.get("/runsimulationbydate/", response_class = PlainTextResponse)
|
||||
@@ -2745,7 +2745,7 @@ async def fastapi_run_project_by_date(network: str, querydate: str) -> str:
|
||||
bg_end_time_str = bg_end_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
print(f"bg_end_time_str: {bg_end_time_str}")
|
||||
|
||||
result = simulation.run_simulation(name=network, simulation_type='realtime', start_datetime=bg_start_time_str, end_datetime=bg_end_time_str)
|
||||
result = simulation.run_simulation(name=network, simulation_type='realtime', modify_pattern_start_time=bg_start_time_str, modify_total_duration=86400)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user