From 895d4d2031a22499ab29420f8aba09469e897b1b Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sun, 23 Feb 2025 00:05:12 +0800 Subject: [PATCH] Add scada_info API --- api/__init__.py | 2 ++ api/s38_scada_info.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index 59c74e1..af3b2ce 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -161,3 +161,5 @@ from .s35_vd import get_all_virtual_district_ids, get_all_virtual_districts from .s35_vd_gen import generate_virtual_district from .s36_wda_cal import calculate_demand_to_nodes, calculate_demand_to_region, calculate_demand_to_network + +from .s38_scada_info import get_scada_info_schema, get_scada_info, get_all_scada_info \ No newline at end of file diff --git a/api/s38_scada_info.py b/api/s38_scada_info.py index a225f9a..e650772 100644 --- a/api/s38_scada_info.py +++ b/api/s38_scada_info.py @@ -4,11 +4,12 @@ from .s24_coordinates import * def get_scada_info_schema(name: str) -> dict[str, dict[str, Any]]: - return { 'id' : {'type': 'str' , 'optional': False , 'readonly': True }, - 'x' : {'type': 'float' , 'optional': False , 'readonly': False}, - 'y' : {'type': 'float' , 'optional': False , 'readonly': False}, - 'elevation' : {'type': 'float' , 'optional': False , 'readonly': False}, - 'links' : {'type': 'str_list' , 'optional': False , 'readonly': True } } + return { 'id' : {'type': 'str' , 'optional': False , 'readonly': True }, + 'type' : {'type': 'str' , 'optional': False , 'readonly': True }, + 'x' : {'type': 'float' , 'optional': False , 'readonly': False}, + 'y' : {'type': 'float' , 'optional': False , 'readonly': False}, + 'query_api_id' : {'type': 'str' , 'optional': False , 'readonly': False}, + 'associated_element_id' : {'type': 'str' , 'optional': False , 'readonly': True } } def get_scada_info(name: str, id: str) -> dict[str, Any]: @@ -22,6 +23,7 @@ def get_scada_info(name: str, id: str) -> dict[str, Any]: d['x'] = float(si['x']) d['y'] = float(si['y']) d['api_query_id'] = str(si['api_query_id']) + d['associated_element_id'] = str(si['associated_element_id']) return d @@ -32,6 +34,6 @@ def get_all_scada_info(name: str) -> list[dict[str, Any]]: d = [] for si in sis: - d.append({ 'id': str(si['id']), 'type': str(si['type']), 'x': float(si['x']), 'y': float(si['y']), 'api_query_id': str(si['api_query_id']) }) + d.append({ 'id': str(si['id']), 'type': str(si['type']), 'x': float(si['x']), 'y': float(si['y']), 'api_query_id': str(si['api_query_id']), 'associated_element_id': str(si['associated_element_id']) }) return d \ No newline at end of file