From cd467b71c8eae397fb12adaa5b5550347e6038d4 Mon Sep 17 00:00:00 2001 From: wqy Date: Sun, 25 Sep 2022 01:28:54 +0800 Subject: [PATCH] Try operation api --- try_operation_api.py | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 try_operation_api.py diff --git a/try_operation_api.py b/try_operation_api.py new file mode 100644 index 0000000..03c34a6 --- /dev/null +++ b/try_operation_api.py @@ -0,0 +1,51 @@ +from tjnetwork import * + +p = "demo" + +if is_project_open(p): + close_project(p) + +if have_project(p): + delete_project(p) + +create_project(p) +open_project(p) + +print(get_junction_schema(p)) +print(get_reservoir_schema(p)) +print(get_tank_schema(p)) + +print(add_junction(p, 'j1', 0.0, 0.0, 0.0).operations) +print(add_junction(p, 'j2', 0.0, 0.0, 0.0).operations) +print(add_junction(p, 'j3', 0.0, 0.0, 0.0).operations) +print(add_junction(p, 'j4', 0.0, 0.0, 0.0).operations) + +client_op = get_current_operation(p) +print(client_op) +print(take_snapshot(p, 'x')) + +print(execute_undo(p).operations) +print(execute_undo(p).operations) +print(add_junction(p, 'j5', 0.0, 0.0, 0.0).operations) +print(add_junction(p, 'j6', 0.0, 0.0, 0.0).operations) + +print(take_snapshot(p, 'xx')) + +print(sync_with_server(p, client_op).operations) + +print(pick_snapshot(p, 'x').operations) + +print(get_junction(p, 'j1')) +print(get_junction(p, 'j2')) +print(get_junction(p, 'j3')) +print(get_junction(p, 'j4')) +print(get_junction(p, 'j5')) +print(get_junction(p, 'j6')) + +print(set_junction(p, 'j1', {'elevation': 10.0, 'coord': {'x': 10.0, 'y': 10.0}, 'demand': 10.0}).operations) +print(get_junction(p, 'j1')) +print(execute_undo(p).operations) +print(get_junction(p, 'j1')) + +close_project(p) +delete_project(p) \ No newline at end of file