Add API to get all valve and pumps

This commit is contained in:
DingZQ
2025-03-29 17:02:30 +08:00
parent 6e3d149503
commit d1687b8464
5 changed files with 62 additions and 2 deletions

View File

@@ -34,6 +34,27 @@ def get_valve(name: str, id: str) -> dict[str, Any]:
d['minor_loss'] = float(p['minor_loss'])
return d
def get_all_valves(name: str) -> list[dict[str, Any]]:
rows = read_all(name, f"select * from valves")
if rows == None:
return []
result = []
for row in rows:
d = {}
d['id'] = str(row['id'])
d['node1'] = str(row['node1'])
d['node2'] = str(row['node2'])
d['diameter'] = float(row['diameter'])
d['v_type'] = str(row['v_type'])
d['setting'] = str(row['setting'])
d['minor_loss'] = float(row['minor_loss'])
result.append(d)
return result
class Valve(object):
def __init__(self, input: dict[str, Any]) -> None: