kepconfig.adv_tags
adv_tags module provides support for Kepware's Advanced Tags plug-in
specific objects within the Kepware Configuration API
1# ------------------------------------------------------------------------- 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved. 3# See License.txt in the project root for 4# license information. 5# -------------------------------------------------------------------------- 6 7r"""`adv_tags` module provides support for Kepware's Advanced Tags plug-in 8specific objects within the Kepware Configuration API 9""" 10 11from ..error import KepError 12from . import adv_tag_group, average_tags, derived_tags, complex_tags, cumulative_tags, min_tags, max_tags, link_tags 13ADV_TAGS_ROOT = '/project/_advancedtags' 14 15def _adv_tag_path_split(path: str, *, isItem=False) -> dict: 16 '''Used to split the standard Kepware address decimal notation into a dict that contains the 17 advanced tag path components. 18 19 :param path: standard Kepware address in decimal notation ("_advancedtags.tg1.tg2.tg3") 20 :return: dict that contains the "adv_tag_root" and "tag_path" 21 :rtype: dict 22 23 Ex: path = "_advancedtags.tg1.tg2.tg3" 24 25 return = {'adv_tag_root': '_advancedtags', 'tag_path': ['tg1','tg2','tg3']} 26 27 Ex: path = "_advancedtags.ch1.dev1" 28 29 return = {'adv_tag_root': '_advancedtags', 'tag_path': ['ch1','dev1']} 30 ''' 31 path_list = path.split('.', 2) 32 if path_list[0] != '_advancedtags': 33 raise KepError('Error: Invalid advanced tag path - Must start with "_advancedtags"') 34 35 path_obj = {} 36 for x in range(0, len(path_list)): 37 if x == 0: 38 path_obj['adv_tag_root'] = path_list[0] 39 elif x == 1: 40 if isItem: 41 path_obj['tag_path'] = path_list[1:-1] 42 path_obj['item'] = path_list[-1] 43 else: 44 path_obj['tag_path'] = path_list[1:] 45 return path_obj 46 47def _create_adv_tags_base_url(base_url, path_obj): 48 '''Creates url object for the "path_obj" which provides the adv tags tag group structure of Kepware's project tree. Used 49 to build a part of Kepware Configuration API URL structure 50 51 Returns the advanced tag group specific url when a value is passed as the tag group name. 52 ''' 53 url = base_url + ADV_TAGS_ROOT 54 url += adv_tag_group._create_adv_tags_group_url(path_obj) 55 56 return url
ADV_TAGS_ROOT =
'/project/_advancedtags'