Initial commit

This commit is contained in:
DingZQ
2022-08-21 11:13:13 +08:00
commit 7ca9cb5d28
21 changed files with 279 additions and 0 deletions

57
demo.py Normal file
View File

@@ -0,0 +1,57 @@
from tjnetwork import *
JUNCTION = 0
RESERVOIR = 1
TANK = 2
PIPE = 1
NODE_COUNT = 0
LINK_COUNT = 2
create_project("net1")
open_project("net1")
add_node("net1", "node-1", JUNCTION)
undo("net1")
redo("net1")
add_node("net1", "node-2", RESERVOIR)
add_node("net1", "node-3", TANK)
set_node_coord("net1", "node-3", 10.0, 10.0)
delete_node("net1", "node-3")
undo("net1")
set_node_coord("net1", "node-1", 10.0, 10.0)
undo("net1")
redo("net1")
set_node_coord("net1", "node-2", 20.0, 20.0)
add_link("net1", "link-1", PIPE, "node-1", "node-2")
add_link("net1", "link-2", PIPE, "node-1", "node-3")
undo("net1")
redo("net1")
add_link("net1", "link-3", PIPE, "node-2", "node-3")
undo("net1")
# this could fail since link-1 & link-2 ref node-1
delete_node("net1", "node-1")
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)
close_project("net1")
delete_project("net1")