diff --git a/main.py b/main.py index fe6577e..92d0ca2 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -from asyncio.windows_utils import pipe import os import io from typing import * @@ -37,8 +36,6 @@ async def fastapi_have_project(network: str): @app.post("/createproject/") async def fastapi_create_project(network: str): create_project(network) - - print(network) return network @app.get("/isprojectopen/") @@ -48,8 +45,6 @@ async def fastapi_is_project_open(network: str): @app.post("/openproject/") async def fastapi_open_project(network: str): open_project(network) - - print(network) return network @app.post("/closeproject/") @@ -180,10 +175,21 @@ async def fastapi_get_junction_elevation(network: str, junction: str) -> float: ps = get_junction(network, junction) return ps['elevation'] +@app.get("/getjunctionx/") +async def fastapi_get_junction_x(network: str, junction: str) -> float: + ps = get_junction(network, junction) + return ps['x'] + +@app.get("/getjunctiony/") +async def fastapi_get_junction_x(network: str, junction: str) -> float: + ps = get_junction(network, junction) + return ps['y'] + @app.get("/getjunctioncoord/") async def fastapi_get_junction_coord(network: str, junction: str) -> dict[str, float]: ps = get_junction(network, junction) - return ps['coord'] + coord = { 'x' : ps['x'], 'y' : ps['y']} + return coord @app.get("/getjunctiondemand/") async def fastapi_get_junction_demand(network: str, junction: str) -> float: @@ -201,10 +207,23 @@ async def fastapi_set_junction_elevation(network: str, junction: str, elevation: props['elevation'] = elevation return set_junction(network, junction, props) -@app.post("/setjunctioncoord/") -async def fastapi_set_junction_coord(network: str, junction: str, x: float, y: float) -> ChangeSet: +@app.post("/setjunctionx/") +async def fastapi_set_junction_x(network: str, junction: str, x: float) -> ChangeSet: props = {} - props['coord'] = {'x' : x, 'y' : y} + props['x'] = x + return set_junction(network, junction, props) + +@app.post("/setjunctionx/") +async def fastapi_set_junction_y(network: str, junction: str, y: float) -> ChangeSet: + props = {} + props['y'] = y + return set_junction(network, junction, props) + +@app.post("/setjunctioncoord/") +async def fastapi_set_junction_coord(network: str, junction: str, x, float, y: float) -> ChangeSet: + props = {} + props['x'] = x + props['y'] = y return set_junction(network, junction, props) @app.post("/setjunctiondemand/") @@ -252,10 +271,21 @@ async def fastapi_get_reservoir_pattern(network: str, reservoir: str) -> str | N ps = get_reservoir(network, reservoir) return ps['pattern'] -@app.get("/getreservoircoord/") -async def fastapi_get_reservoir_coord(network: str, reservoir: str) -> dict[str, float] | None: +@app.get("/getreservoirx/") +async def fastapi_get_reservoir_x(network: str, reservoir: str) -> dict[str, float] | None: ps = get_reservoir(network, reservoir) - return ps['coord'] + return ps['x'] + +@app.get("/getreservoiry/") +async def fastapi_get_reservoir_y(network: str, reservoir: str) -> dict[str, float] | None: + ps = get_reservoir(network, reservoir) + return ps['y'] + +@app.get("/getreservoircoord/") +async def fastapi_get_reservoir_y(network: str, reservoir: str) -> dict[str, float] | None: + ps = get_reservoir(network, reservoir) + coord = { 'x' : ps['x'], 'y' : ps['y']} + return coord @app.post("/setreservoirhead/") async def fastapi_set_reservoir_head(network: str, reservoir: str, head: float) -> ChangeSet: @@ -269,10 +299,23 @@ async def fastapi_set_reservoir_pattern(network: str, reservoir: str, pattern: s props['pattern'] = pattern return set_reservoir(network, reservoir, props) -@app.post("/setreservoircoord/") -async def fastapi_set_reservoir_coord(network: str, reservoir: str, x: float, y: float) -> ChangeSet: +@app.post("/setreservoirx/") +async def fastapi_set_reservoir_x(network: str, reservoir: str, x: float) -> ChangeSet: props = {} - props['coord'] = {'x' : x, 'y' : y} + props['x'] = x + return set_reservoir(network, reservoir, props) + +@app.post("/setreservoirx/") +async def fastapi_set_reservoir_y(network: str, reservoir: str, y: float) -> ChangeSet: + props = {} + props['y'] = y + return set_reservoir(network, reservoir, props) + +@app.post("/setreservoircoord/") +async def fastapi_set_reservoir_y(network: str, reservoir: str, x: float, y: float) -> ChangeSet: + props = {} + props['x'] = x + props['y'] = y return set_reservoir(network, reservoir, props) @app.get("/getreservoirproperties/") @@ -339,10 +382,21 @@ async def fastapi_get_tank_overflow(network: str, tank: str) -> str | None: ps = get_tank(network, tank) return ps['overflow'] -@app.get("/gettankcoord/") -async def fastapi_get_tank_coord(network: str, tank: str) -> dict[str, float] | None: +@app.get("/gettankx/") +async def fastapi_get_tank_x(network: str, tank: str) -> float: ps = get_tank(network, tank) - return ps['coord'] + return ps['x'] + +@app.get("/gettanky/") +async def fastapi_get_tank_x(network: str, tank: str) -> float: + ps = get_tank(network, tank) + return ps['y'] + +@app.get("/gettankcoord/") +async def fastapi_get_tank_coord(network: str, tank: str) -> dict[str, float]: + ps = get_tank(network, tank) + coord = { 'x' : ps['x'], 'y' : ps['y']} + return coord @app.post("/settankelevation/") async def fastapi_set_tank_elevation(network: str, tank: str, elevation: float) -> ChangeSet: @@ -392,10 +446,23 @@ async def fastapi_set_tank_overflow(network: str, tank: str, overflow: str) -> C props['overflow'] = overflow return set_tank(network, tank, props) +@app.post("/settankx/") +async def fastapi_set_tank_x(network: str, tank: str, x: float) -> ChangeSet: + props = {} + props['x'] = x + return set_tank(network, tank, props) + +@app.post("/settanky/") +async def fastapi_set_tank_y(network: str, tank: str, y: float) -> ChangeSet: + props = {} + props['y'] = y + return set_tank(network, tank, props) + @app.post("/settankcoord/") async def fastapi_set_tank_coord(network: str, tank: str, x: float, y: float) -> ChangeSet: props = {} - props['coord'] = {'x' : x, 'y' : y} + props['x'] = x + props['y'] = y return set_tank(network, tank, props) @app.get("/gettankproperties/")