diff --git a/orchestrator/utils/orchestrator_functions.py b/orchestrator/utils/orchestrator_functions.py index 505d079..de3530e 100644 --- a/orchestrator/utils/orchestrator_functions.py +++ b/orchestrator/utils/orchestrator_functions.py @@ -280,4 +280,10 @@ def build_tag_config( **tag, } + frequencies = [x['frequency'] for x in slot_config[f'{i}'][server_name]['tags'].values()] + + min_frequency = min(frequencies) if frequencies else 500 + + slot_config[f"{i}"][server_name]['subscription_period_ms'] = min_frequency/2 + return slot_config diff --git a/tests/orchestrator/utils/test_orchestrator_functions.py b/tests/orchestrator/utils/test_orchestrator_functions.py index 628b2f8..5a1f64f 100644 --- a/tests/orchestrator/utils/test_orchestrator_functions.py +++ b/tests/orchestrator/utils/test_orchestrator_functions.py @@ -249,8 +249,8 @@ def test_gather_read_tags(): def test_build_tag_config(): - tag = {'server_id': '1', 'server_name': 'test_server_name', 'tag_address': 'test_tag_address'} - opc_servers = {'1': {'server_name': 'test_server_name', 'url': 'test_url', 'uri': 'test_uri'}} + tag = {'server_id': '1', 'server_name': 'test_server_name', 'tag_address': 'test_tag_address', 'frequency': 1000} + opc_servers = {'1': {'server_name': 'test_server_name', 'url': 'test_url', 'uri': 'test_uri', 'subscription_period_ms': 1000}} slot_config: dict = {'1': {}} i = 1 result = build_tag_config(tag, slot_config, opc_servers, i) @@ -264,11 +264,13 @@ def test_build_tag_config(): 'cert_path': None, 'private_key_path': None, 'server_cert_path': None, + 'subscription_period_ms': 500, 'tags': { 'test_tag_address': { 'server_id': '1', 'server_name': 'test_server_name', 'tag_address': 'test_tag_address', + 'frequency': 1000, } }, }