Add API to get all pipes

This commit is contained in:
DingZQ
2025-03-29 16:30:15 +08:00
parent 94773a59f8
commit 1dafaa6dcc
4 changed files with 30 additions and 1 deletions

View File

@@ -33,6 +33,26 @@ def get_pipe(name: str, id: str) -> dict[str, Any]:
d['status'] = str(p['status'])
return d
# DingZQ, 2025-03-29
def get_all_pipes(name: str) -> list[dict[str, Any]]:
p = try_read(name, f"select * from pipes")
if p == None:
return []
result = []
for p in p:
d = {}
d['id'] = str(p['id'])
d['node1'] = str(p['node1'])
d['node2'] = str(p['node2'])
d['length'] = float(p['length'])
d['diameter'] = float(p['diameter'])
d['roughness'] = float(p['roughness'])
d['minor_loss'] = float(p['minor_loss'])
d['status'] = str(p['status'])
result.append(d)
return result
class Pipe(object):
def __init__(self, input: dict[str, Any]) -> None: