Add scada_info API
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user