Add source methods
This commit is contained in:
83
main.py
83
main.py
@@ -880,7 +880,7 @@ async def fastapi_set_demand_properties(network: str, junction: str, req: Reques
|
||||
return set_demand(network, ChangeSet(ps))
|
||||
|
||||
############################################################
|
||||
# status 10.[STATUS]
|
||||
# status 10.[STATUS] init_status
|
||||
############################################################
|
||||
@app.get('/getstatusschema')
|
||||
async def fast_get_status_schema(network: str) -> dict[str, dict[str, Any]]:
|
||||
@@ -1065,6 +1065,87 @@ async def fastapi_set_quality_properties(network: str, req: Request) -> ChangeSe
|
||||
return set_quality(network, ChangeSet(ps))
|
||||
|
||||
|
||||
############################################################
|
||||
# source 18.[SOURCES]
|
||||
############################################################
|
||||
@app.get('/getsourcechema/')
|
||||
async def fastapi_get_source_schema(network: str) -> dict[str, dict[str, Any]]:
|
||||
return get_source_schema(network)
|
||||
|
||||
@app.get('/getsource/')
|
||||
async def fastapi_get_source(network: str, node: str) -> dict[str, Any]:
|
||||
return get_source(network, node)
|
||||
|
||||
@app.post('/setsource/')
|
||||
async def fastapi_set_source(network: str, req: Request) -> ChangeSet:
|
||||
props = await req.json()
|
||||
return set_source(network, ChangeSet(props))
|
||||
|
||||
# example: add_source(p, ChangeSet({'node': 'j0', 's_type': SOURCE_TYPE_CONCEN, 'strength': 10.0, 'pattern': 'p0'}))
|
||||
@app.post('/addsource/')
|
||||
async def fastapi_add_source(network: str, req: Request) -> ChangeSet:
|
||||
props = await req.json()
|
||||
return add_source(network, ChangeSet(props))
|
||||
|
||||
@app.post('/deletesource/')
|
||||
async def fastapi_delete_source(network: str, req: Request) -> ChangeSet:
|
||||
props = await req.json()
|
||||
return delete_source(network, ChangeSet(props))
|
||||
|
||||
|
||||
############################################################
|
||||
# reaction 19.[REACTIONS]
|
||||
############################################################
|
||||
|
||||
def get_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return api.get_reaction_schema(name)
|
||||
|
||||
def get_reaction(name: str) -> dict[str, Any]:
|
||||
return api.get_reaction(name)
|
||||
|
||||
def set_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.set_reaction(name, cs)
|
||||
|
||||
def get_pipe_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return api.get_pipe_reaction_schema(name)
|
||||
|
||||
def get_pipe_reaction(name: str, pipe: str) -> dict[str, Any]:
|
||||
return api.get_pipe_reaction(name, pipe)
|
||||
|
||||
def set_pipe_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.set_pipe_reaction(name, cs)
|
||||
|
||||
def get_tank_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return api.get_tank_reaction_schema(name)
|
||||
|
||||
def get_tank_reaction(name: str, tank: str) -> dict[str, Any]:
|
||||
return api.get_tank_reaction(name, tank)
|
||||
|
||||
def set_tank_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.set_tank_reaction(name, cs)
|
||||
|
||||
|
||||
############################################################
|
||||
# mixing 20.[MIXING]
|
||||
############################################################
|
||||
|
||||
def get_mixing_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return api.get_mixing_schema(name)
|
||||
|
||||
def get_mixing(name: str, tank: str) -> dict[str, Any]:
|
||||
return api.get_mixing(name, tank)
|
||||
|
||||
def set_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.set_mixing(name, cs)
|
||||
|
||||
# example: add_mixing(p, ChangeSet({'tank': 't0', 'model': MIXING_MODEL_MIXED, 'value': 10.0}))
|
||||
def add_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.add_mixing(name, cs)
|
||||
|
||||
def delete_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return api.delete_mixing(name, cs)
|
||||
|
||||
|
||||
############################################################
|
||||
# time 21.[TIME]
|
||||
############################################################
|
||||
|
||||
Reference in New Issue
Block a user