Accept Merge Request #22: (api -> master)
Merge Request: Clean repo Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/22
This commit is contained in:
Binary file not shown.
207
demo.py
207
demo.py
@@ -1,57 +1,184 @@
|
||||
from tjnetwork import *
|
||||
|
||||
JUNCTION = 0
|
||||
RESERVOIR = 1
|
||||
TANK = 2
|
||||
PIPE = 1
|
||||
NODE_COUNT = 0
|
||||
LINK_COUNT = 2
|
||||
|
||||
create_project("net1")
|
||||
open_project("net1")
|
||||
def demo_snapshot():
|
||||
p = "demo_snapshot"
|
||||
|
||||
add_node("net1", "node-1", JUNCTION)
|
||||
print(p)
|
||||
|
||||
undo("net1")
|
||||
redo("net1")
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
add_node("net1", "node-2", RESERVOIR)
|
||||
add_node("net1", "node-3", TANK)
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
set_node_coord("net1", "node-3", 10.0, 10.0)
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
delete_node("net1", "node-3")
|
||||
undo("net1")
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1-2-3-4")
|
||||
|
||||
set_node_coord("net1", "node-1", 10.0, 10.0)
|
||||
undo("net1")
|
||||
redo("net1")
|
||||
undo(p)
|
||||
undo(p)
|
||||
undo(p)
|
||||
undo(p)
|
||||
|
||||
set_node_coord("net1", "node-2", 20.0, 20.0)
|
||||
add_junction(p, 'j-5', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-6', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-7', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-8', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "5-6-7-8")
|
||||
|
||||
add_link("net1", "link-1", PIPE, "node-1", "node-2")
|
||||
print("before checkout, it should be 5, 6, 7, 8")
|
||||
print(get_nodes(p))
|
||||
|
||||
add_link("net1", "link-2", PIPE, "node-1", "node-3")
|
||||
undo("net1")
|
||||
redo("net1")
|
||||
pick_snapshot(p, "1-2-3-4")
|
||||
|
||||
add_link("net1", "link-3", PIPE, "node-2", "node-3")
|
||||
undo("net1")
|
||||
print("after checkout, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
# this could fail since link-1 & link-2 ref node-1
|
||||
delete_node("net1", "node-1")
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
node_count = get_count("net1", NODE_COUNT)
|
||||
print(node_count.value)
|
||||
for i in range(1, node_count.value + 1):
|
||||
node_id = get_node_id("net1", i)
|
||||
print(node_id.value)
|
||||
|
||||
link_count = get_count("net1", LINK_COUNT)
|
||||
print(link_count.value)
|
||||
for i in range(1, link_count.value + 1):
|
||||
link_id = get_link_id("net1", i)
|
||||
print(link_id.value)
|
||||
def demo_transaction():
|
||||
p = "demo_transaction"
|
||||
|
||||
close_project("net1")
|
||||
delete_project("net1")
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1")
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "2")
|
||||
|
||||
start_transaction(p)
|
||||
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "3")
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "4")
|
||||
|
||||
print("before rollback, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
print("after rollback, it should be 1, 2")
|
||||
abort_transaction(p)
|
||||
|
||||
print(get_nodes(p))
|
||||
|
||||
print(f"have snapshot 1: {have_snapshot(p, '1')}")
|
||||
print(f"have snapshot 2: {have_snapshot(p, '2')}")
|
||||
print(f"have snapshot 3: {have_snapshot(p, '3')}")
|
||||
print(f"have snapshot 4: {have_snapshot(p, '4')}")
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
def demo_1_title():
|
||||
p = "demo_1_title"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
print(get_title(p)) #
|
||||
|
||||
set_title(p, "title")
|
||||
print(get_title(p)) # title
|
||||
|
||||
set_title(p, "test")
|
||||
print(get_title(p)) # test
|
||||
|
||||
undo(p)
|
||||
print(get_title(p)) # title
|
||||
|
||||
undo(p)
|
||||
print(get_title(p)) #
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
def demo_2_junctions():
|
||||
p = "demo_2_junctions"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
j = 'j-1'
|
||||
print(get_junction_coord(p, j)) # None
|
||||
print(get_junction_elevation(p, j)) # None
|
||||
print(get_junction_demand(p, j)) # None
|
||||
print(get_junction_pattern(p, j)) # None
|
||||
|
||||
add_junction(p, j, 10.0, 20.0, 30.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
print(get_junction_elevation(p, j)) # 30.0
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
print(get_junction_pattern(p, j)) # NULL
|
||||
|
||||
set_junction_demand(p, j, 100.0)
|
||||
print(get_junction_demand(p, j)) # 100.0
|
||||
|
||||
undo(p)
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
|
||||
undo(p)
|
||||
print(get_junction_coord(p, j)) # None
|
||||
print(get_junction_elevation(p, j)) # None
|
||||
print(get_junction_demand(p, j)) # None
|
||||
print(get_junction_pattern(p, j)) # None
|
||||
|
||||
add_junction(p, j, 10.0, 20.0, 30.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
print(get_junction_elevation(p, j)) # 30.0
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
print(get_junction_pattern(p, j)) # NULL
|
||||
|
||||
set_junction_coord(p, j, 100.0, 200.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 100.0, 'y': 200.0}
|
||||
|
||||
undo(p)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
|
||||
redo(p)
|
||||
print(get_junction_coord(p, j)) # {'x': 100.0, 'y': 200.0}
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo_snapshot()
|
||||
demo_transaction()
|
||||
demo_1_title()
|
||||
demo_2_junctions()
|
||||
pass
|
||||
|
||||
BIN
epanet2.dll
BIN
epanet2.dll
Binary file not shown.
2
main.py
2
main.py
@@ -7,7 +7,7 @@ from fastapi import FastAPI, File, UploadFile
|
||||
from pydantic import BaseModel
|
||||
from starlette.responses import FileResponse, JSONResponse
|
||||
from fastapi import FastAPI, Response, status
|
||||
from tjnetwork_new import *
|
||||
from tjnetwork import *
|
||||
|
||||
JUNCTION = 0
|
||||
RESERVOIR = 1
|
||||
|
||||
184
new_demo.py
184
new_demo.py
@@ -1,184 +0,0 @@
|
||||
from tjnetwork_new import *
|
||||
|
||||
|
||||
def demo_snapshot():
|
||||
p = "demo_snapshot"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1-2-3-4")
|
||||
|
||||
undo(p)
|
||||
undo(p)
|
||||
undo(p)
|
||||
undo(p)
|
||||
|
||||
add_junction(p, 'j-5', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-6', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-7', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-8', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "5-6-7-8")
|
||||
|
||||
print("before checkout, it should be 5, 6, 7, 8")
|
||||
print(get_nodes(p))
|
||||
|
||||
pick_snapshot(p, "1-2-3-4")
|
||||
|
||||
print("after checkout, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
def demo_transaction():
|
||||
p = "demo_transaction"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1")
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "2")
|
||||
|
||||
start_transaction(p)
|
||||
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "3")
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "4")
|
||||
|
||||
print("before rollback, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
print("after rollback, it should be 1, 2")
|
||||
abort_transaction(p)
|
||||
|
||||
print(get_nodes(p))
|
||||
|
||||
print(f"have snapshot 1: {have_snapshot(p, '1')}")
|
||||
print(f"have snapshot 2: {have_snapshot(p, '2')}")
|
||||
print(f"have snapshot 3: {have_snapshot(p, '3')}")
|
||||
print(f"have snapshot 4: {have_snapshot(p, '4')}")
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
def demo_1_title():
|
||||
p = "demo_1_title"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
print(get_title(p)) #
|
||||
|
||||
set_title(p, "title")
|
||||
print(get_title(p)) # title
|
||||
|
||||
set_title(p, "test")
|
||||
print(get_title(p)) # test
|
||||
|
||||
undo(p)
|
||||
print(get_title(p)) # title
|
||||
|
||||
undo(p)
|
||||
print(get_title(p)) #
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
def demo_2_junctions():
|
||||
p = "demo_2_junctions"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
j = 'j-1'
|
||||
print(get_junction_coord(p, j)) # None
|
||||
print(get_junction_elevation(p, j)) # None
|
||||
print(get_junction_demand(p, j)) # None
|
||||
print(get_junction_pattern(p, j)) # None
|
||||
|
||||
add_junction(p, j, 10.0, 20.0, 30.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
print(get_junction_elevation(p, j)) # 30.0
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
print(get_junction_pattern(p, j)) # NULL
|
||||
|
||||
set_junction_demand(p, j, 100.0)
|
||||
print(get_junction_demand(p, j)) # 100.0
|
||||
|
||||
undo(p)
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
|
||||
undo(p)
|
||||
print(get_junction_coord(p, j)) # None
|
||||
print(get_junction_elevation(p, j)) # None
|
||||
print(get_junction_demand(p, j)) # None
|
||||
print(get_junction_pattern(p, j)) # None
|
||||
|
||||
add_junction(p, j, 10.0, 20.0, 30.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
print(get_junction_elevation(p, j)) # 30.0
|
||||
print(get_junction_demand(p, j)) # NULL
|
||||
print(get_junction_pattern(p, j)) # NULL
|
||||
|
||||
set_junction_coord(p, j, 100.0, 200.0)
|
||||
print(get_junction_coord(p, j)) # {'x': 100.0, 'y': 200.0}
|
||||
|
||||
undo(p)
|
||||
print(get_junction_coord(p, j)) # {'x': 10.0, 'y': 20.0}
|
||||
|
||||
redo(p)
|
||||
print(get_junction_coord(p, j)) # {'x': 100.0, 'y': 200.0}
|
||||
|
||||
close_project(p)
|
||||
delete_project(p)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo_snapshot()
|
||||
demo_transaction()
|
||||
demo_1_title()
|
||||
demo_2_junctions()
|
||||
pass
|
||||
Binary file not shown.
BIN
pytjnetwork.pyd
BIN
pytjnetwork.pyd
Binary file not shown.
220
tjnetwork.py
220
tjnetwork.py
@@ -1,98 +1,170 @@
|
||||
import ctypes
|
||||
import api
|
||||
|
||||
max_name_len = 32
|
||||
|
||||
server = ctypes.windll.LoadLibrary("./TJNetworkServer.dll")
|
||||
############################################################
|
||||
# ChangeSet
|
||||
############################################################
|
||||
|
||||
class LinkNodes:
|
||||
def __init__(self, from_node, to_node):
|
||||
self.from_node = from_node
|
||||
self.to_node = to_node
|
||||
ChangeSet = api.ChangeSet
|
||||
|
||||
class Point:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
class Result:
|
||||
def __init__(self, ec, v):
|
||||
self.error_code = ec
|
||||
self.value = v
|
||||
############################################################
|
||||
# enum
|
||||
############################################################
|
||||
|
||||
def c_str(value):
|
||||
return ctypes.c_char_p(value.encode())
|
||||
JUNCTION = api.JUNCTION
|
||||
RESERVOIR = api.RESERVOIR
|
||||
TANK = api.TANK
|
||||
PIPE = api.PIPE
|
||||
PUMP = api.PUMP
|
||||
VALVE = api.VALVE
|
||||
|
||||
def c_ref(value):
|
||||
return ctypes.byref(value)
|
||||
|
||||
# have database
|
||||
def have_project(name):
|
||||
yes = 406
|
||||
ec = server.TJ_haveproject(c_str(name))
|
||||
return True if ec == yes else False
|
||||
############################################################
|
||||
# project
|
||||
############################################################
|
||||
|
||||
# create database
|
||||
def create_project(name):
|
||||
return server.TJ_createproject(c_str(name))
|
||||
def have_project(name: str) -> bool:
|
||||
return api.have_project(name)
|
||||
|
||||
# delete database
|
||||
def delete_project(name):
|
||||
return server.TJ_deleteproject(c_str(name))
|
||||
def create_project(name: str) -> None:
|
||||
return api.create_project(name)
|
||||
|
||||
# create runtime project and connect to database
|
||||
def open_project(name):
|
||||
return server.TJ_openproject(c_str(name))
|
||||
def delete_project(name: str) -> None:
|
||||
return api.delete_project(name)
|
||||
|
||||
# delete runtime project and disconnect from database
|
||||
def close_project(name):
|
||||
return server.TJ_closeproject(c_str(name))
|
||||
def is_project_open(name: str) -> bool:
|
||||
return api.is_project_open(name)
|
||||
|
||||
def undo(name):
|
||||
return server.TJ_undo(c_str(name))
|
||||
def open_project(name: str) -> None:
|
||||
return api.open_project(name)
|
||||
|
||||
def redo(name):
|
||||
return server.TJ_redo(c_str(name))
|
||||
def close_project(name: str) -> None:
|
||||
return api.close_project(name)
|
||||
|
||||
def get_count(name, object_type):
|
||||
count = ctypes.c_int()
|
||||
ec = server.TJ_getcount(c_str(name), object_type, c_ref(count))
|
||||
return Result(ec, count.value)
|
||||
def copy_project(source: str, new: str) -> None:
|
||||
return api.copy_project(source, new)
|
||||
|
||||
def add_node(name, node_id, node_type):
|
||||
return server.TJ_addnode(c_str(name), c_str(node_id), node_type)
|
||||
|
||||
def delete_node(name, node_id):
|
||||
return server.TJ_deletenode(c_str(name), c_str(node_id))
|
||||
############################################################
|
||||
# operation
|
||||
############################################################
|
||||
|
||||
def get_node_id(name, node_index):
|
||||
id = ctypes.create_string_buffer(max_name_len)
|
||||
ec = server.TJ_getnodeid(c_str(name), node_index, c_ref(id))
|
||||
return Result(ec, id.value)
|
||||
def undo(name: str) -> None:
|
||||
return api.undo(name)
|
||||
|
||||
def get_node_coord(name, node_id):
|
||||
x = ctypes.c_double()
|
||||
y = ctypes.c_double()
|
||||
ec = server.TJ_getnodecoord(c_str(name), c_str(node_id), c_ref(x), c_ref(y))
|
||||
return Result(ec, Point(x.value, y.value))
|
||||
def redo(name: str) -> None:
|
||||
return api.redo(name)
|
||||
|
||||
def set_node_coord(name, node_id, x, y):
|
||||
func = server.TJ_setnodecoord
|
||||
func.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_double, ctypes.c_double]
|
||||
return func(c_str(name), c_str(node_id), x, y)
|
||||
def have_snapshot(name: str, tag: str) -> bool:
|
||||
return api.have_snapshot(name, tag)
|
||||
|
||||
def add_link(name, link_id, link_type, from_node, to_node):
|
||||
return server.TJ_addlink(c_str(name), c_str(link_id), link_type, c_str(from_node), c_str(to_node))
|
||||
def take_snapshot(name: str, tag: str) -> None:
|
||||
return api.take_snapshot(name, tag)
|
||||
|
||||
def delete_link(name, link_id):
|
||||
return server.TJ_deletelink(c_str(name), c_str(link_id))
|
||||
def pick_snapshot(name: str, tag: str) -> None:
|
||||
return api.pick_snapshot(name, tag)
|
||||
|
||||
def get_link_id(name, link_index):
|
||||
id = ctypes.create_string_buffer(max_name_len)
|
||||
ec = server.TJ_getlinkid(c_str(name), link_index, c_ref(id))
|
||||
return Result(ec, id.value)
|
||||
def have_transaction(name: str) -> bool:
|
||||
return api.have_transaction(name)
|
||||
|
||||
def get_link_nodes(name, link_id):
|
||||
from_node = ctypes.create_string_buffer(max_name_len)
|
||||
to_node = ctypes.create_string_buffer(max_name_len)
|
||||
ec = server.TJ_getlinknodes(c_str(name), c_str(link_id), c_ref(from_node), c_ref(to_node))
|
||||
return Result(ec, LinkNodes(from_node.value, to_node.value))
|
||||
def start_transaction(name: str, strict: bool = False) -> None:
|
||||
return api.start_transaction(name, strict)
|
||||
|
||||
def commit_transaction(name: str) -> None:
|
||||
return api.commit_transaction(name)
|
||||
|
||||
def abort_transaction(name: str) -> None:
|
||||
return api.abort_transaction(name)
|
||||
|
||||
############################################################
|
||||
# type
|
||||
############################################################
|
||||
|
||||
def is_node(name: str, node_id: str) -> bool:
|
||||
return api.is_node(name, node_id)
|
||||
|
||||
def is_junction(name: str, node_id: str) -> bool:
|
||||
return api.is_junction(name, node_id)
|
||||
|
||||
def is_reservoir(name: str, node_id: str) -> bool:
|
||||
return api.is_reservoir(name, node_id)
|
||||
|
||||
def is_tank(name: str, node_id: str) -> bool:
|
||||
return api.is_tank(name, node_id)
|
||||
|
||||
def is_link(name: str, link_id: str) -> bool:
|
||||
return api.is_link(name, link_id)
|
||||
|
||||
def is_pipe(name: str, link_id: str) -> bool:
|
||||
return api.is_pipe(name, link_id)
|
||||
|
||||
def is_pump(name: str, link_id: str) -> bool:
|
||||
return api.is_pump(name, link_id)
|
||||
|
||||
def is_valve(name: str, link_id: str) -> bool:
|
||||
return api.is_valve(name, link_id)
|
||||
|
||||
def is_curve(name: str, curve_id: str) -> bool:
|
||||
return api.is_curve(name, curve_id)
|
||||
|
||||
def is_pattern(name: str, pattern_id: str) -> bool:
|
||||
return api.is_pattern(name, pattern_id)
|
||||
|
||||
def get_nodes(name: str) -> list[str]:
|
||||
return api.get_nodes(name)
|
||||
|
||||
def get_links(name: str) -> list[str]:
|
||||
return api.get_links(name)
|
||||
|
||||
def get_curves(name: str) -> list[str]:
|
||||
return api.get_curves(name)
|
||||
|
||||
def get_patterns(name: str) -> list[str]:
|
||||
return api.get_patterns(name)
|
||||
|
||||
|
||||
############################################################
|
||||
# title 1.[TITLE]
|
||||
############################################################
|
||||
|
||||
def set_title(name: str, title: str) -> ChangeSet:
|
||||
return api.set_title(name, title)
|
||||
|
||||
def get_title(name: str) -> str:
|
||||
return api.get_title(name)
|
||||
|
||||
|
||||
############################################################
|
||||
# junction 2.[JUNCTIONS]
|
||||
############################################################
|
||||
|
||||
def add_junction(name: str, junction_id: str, x: float, y: float, elevation: float) -> ChangeSet:
|
||||
return api.add_junction(name, junction_id, x, y, elevation)
|
||||
|
||||
def delete_junction(name: str, junction_id: str) -> ChangeSet:
|
||||
return api.delete_junction(name, junction_id)
|
||||
|
||||
def get_junction_elevation(name: str, junction_id: str) -> float | None:
|
||||
return api.get_junction_elevation(name, junction_id)
|
||||
|
||||
def get_junction_demand(name: str, junction_id: str) -> float | str | None:
|
||||
return api.get_junction_demand(name, junction_id)
|
||||
|
||||
def get_junction_pattern(name: str, junction_id: str) -> str | None:
|
||||
return api.get_junction_pattern(name, junction_id)
|
||||
|
||||
def get_junction_coord(name: str, junction_id: str) -> dict[str, float] | None:
|
||||
return api.get_junction_coord(name, junction_id)
|
||||
|
||||
def set_junction_elevation(name: str, junction_id: str, elevation: float) -> ChangeSet:
|
||||
return api.set_junction_elevation(name, junction_id, elevation)
|
||||
|
||||
def set_junction_demand(name: str, junction_id: str, demand: float) -> ChangeSet:
|
||||
return api.set_junction_demand(name, junction_id, demand)
|
||||
|
||||
def set_junction_pattern(name: str, junction_id: str, pattern: str) -> ChangeSet:
|
||||
return api.set_junction_pattern(name, junction_id, pattern)
|
||||
|
||||
def set_junction_coord(name: str, junction_id: str, x: float, y: float) -> ChangeSet:
|
||||
return api.set_junction_coord(name, junction_id, x, y)
|
||||
|
||||
170
tjnetwork_new.py
170
tjnetwork_new.py
@@ -1,170 +0,0 @@
|
||||
import api
|
||||
|
||||
|
||||
############################################################
|
||||
# ChangeSet
|
||||
############################################################
|
||||
|
||||
ChangeSet = api.ChangeSet
|
||||
|
||||
|
||||
############################################################
|
||||
# enum
|
||||
############################################################
|
||||
|
||||
JUNCTION = api.JUNCTION
|
||||
RESERVOIR = api.RESERVOIR
|
||||
TANK = api.TANK
|
||||
PIPE = api.PIPE
|
||||
PUMP = api.PUMP
|
||||
VALVE = api.VALVE
|
||||
|
||||
|
||||
############################################################
|
||||
# project
|
||||
############################################################
|
||||
|
||||
def have_project(name: str) -> bool:
|
||||
return api.have_project(name)
|
||||
|
||||
def create_project(name: str) -> None:
|
||||
return api.create_project(name)
|
||||
|
||||
def delete_project(name: str) -> None:
|
||||
return api.delete_project(name)
|
||||
|
||||
def is_project_open(name: str) -> bool:
|
||||
return api.is_project_open(name)
|
||||
|
||||
def open_project(name: str) -> None:
|
||||
return api.open_project(name)
|
||||
|
||||
def close_project(name: str) -> None:
|
||||
return api.close_project(name)
|
||||
|
||||
def copy_project(source: str, new: str) -> None:
|
||||
return api.copy_project(source, new)
|
||||
|
||||
|
||||
############################################################
|
||||
# operation
|
||||
############################################################
|
||||
|
||||
def undo(name: str) -> None:
|
||||
return api.undo(name)
|
||||
|
||||
def redo(name: str) -> None:
|
||||
return api.redo(name)
|
||||
|
||||
def have_snapshot(name: str, tag: str) -> bool:
|
||||
return api.have_snapshot(name, tag)
|
||||
|
||||
def take_snapshot(name: str, tag: str) -> None:
|
||||
return api.take_snapshot(name, tag)
|
||||
|
||||
def pick_snapshot(name: str, tag: str) -> None:
|
||||
return api.pick_snapshot(name, tag)
|
||||
|
||||
def have_transaction(name: str) -> bool:
|
||||
return api.have_transaction(name)
|
||||
|
||||
def start_transaction(name: str, strict: bool = False) -> None:
|
||||
return api.start_transaction(name, strict)
|
||||
|
||||
def commit_transaction(name: str) -> None:
|
||||
return api.commit_transaction(name)
|
||||
|
||||
def abort_transaction(name: str) -> None:
|
||||
return api.abort_transaction(name)
|
||||
|
||||
############################################################
|
||||
# type
|
||||
############################################################
|
||||
|
||||
def is_node(name: str, node_id: str) -> bool:
|
||||
return api.is_node(name, node_id)
|
||||
|
||||
def is_junction(name: str, node_id: str) -> bool:
|
||||
return api.is_junction(name, node_id)
|
||||
|
||||
def is_reservoir(name: str, node_id: str) -> bool:
|
||||
return api.is_reservoir(name, node_id)
|
||||
|
||||
def is_tank(name: str, node_id: str) -> bool:
|
||||
return api.is_tank(name, node_id)
|
||||
|
||||
def is_link(name: str, link_id: str) -> bool:
|
||||
return api.is_link(name, link_id)
|
||||
|
||||
def is_pipe(name: str, link_id: str) -> bool:
|
||||
return api.is_pipe(name, link_id)
|
||||
|
||||
def is_pump(name: str, link_id: str) -> bool:
|
||||
return api.is_pump(name, link_id)
|
||||
|
||||
def is_valve(name: str, link_id: str) -> bool:
|
||||
return api.is_valve(name, link_id)
|
||||
|
||||
def is_curve(name: str, curve_id: str) -> bool:
|
||||
return api.is_curve(name, curve_id)
|
||||
|
||||
def is_pattern(name: str, pattern_id: str) -> bool:
|
||||
return api.is_pattern(name, pattern_id)
|
||||
|
||||
def get_nodes(name: str) -> list[str]:
|
||||
return api.get_nodes(name)
|
||||
|
||||
def get_links(name: str) -> list[str]:
|
||||
return api.get_links(name)
|
||||
|
||||
def get_curves(name: str) -> list[str]:
|
||||
return api.get_curves(name)
|
||||
|
||||
def get_patterns(name: str) -> list[str]:
|
||||
return api.get_patterns(name)
|
||||
|
||||
|
||||
############################################################
|
||||
# title 1.[TITLE]
|
||||
############################################################
|
||||
|
||||
def set_title(name: str, title: str) -> ChangeSet:
|
||||
return api.set_title(name, title)
|
||||
|
||||
def get_title(name: str) -> str:
|
||||
return api.get_title(name)
|
||||
|
||||
|
||||
############################################################
|
||||
# junction 2.[JUNCTIONS]
|
||||
############################################################
|
||||
|
||||
def add_junction(name: str, junction_id: str, x: float, y: float, elevation: float) -> ChangeSet:
|
||||
return api.add_junction(name, junction_id, x, y, elevation)
|
||||
|
||||
def delete_junction(name: str, junction_id: str) -> ChangeSet:
|
||||
return api.delete_junction(name, junction_id)
|
||||
|
||||
def get_junction_elevation(name: str, junction_id: str) -> float | None:
|
||||
return api.get_junction_elevation(name, junction_id)
|
||||
|
||||
def get_junction_demand(name: str, junction_id: str) -> float | str | None:
|
||||
return api.get_junction_demand(name, junction_id)
|
||||
|
||||
def get_junction_pattern(name: str, junction_id: str) -> str | None:
|
||||
return api.get_junction_pattern(name, junction_id)
|
||||
|
||||
def get_junction_coord(name: str, junction_id: str) -> dict[str, float] | None:
|
||||
return api.get_junction_coord(name, junction_id)
|
||||
|
||||
def set_junction_elevation(name: str, junction_id: str, elevation: float) -> ChangeSet:
|
||||
return api.set_junction_elevation(name, junction_id, elevation)
|
||||
|
||||
def set_junction_demand(name: str, junction_id: str, demand: float) -> ChangeSet:
|
||||
return api.set_junction_demand(name, junction_id, demand)
|
||||
|
||||
def set_junction_pattern(name: str, junction_id: str, pattern: str) -> ChangeSet:
|
||||
return api.set_junction_pattern(name, junction_id, pattern)
|
||||
|
||||
def set_junction_coord(name: str, junction_id: str, x: float, y: float) -> ChangeSet:
|
||||
return api.set_junction_coord(name, junction_id, x, y)
|
||||
Binary file not shown.
Reference in New Issue
Block a user