39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
def get_devices(fc):
|
|
tag_path = "[%s_SCADA_TAG_PROVIDER]Configuration/DetailedViews" % (fc)
|
|
tags_to_read = system.tag.readBlocking([tag_path])
|
|
devices = system.util.jsonDecode(tags_to_read[0].value)
|
|
device_list = []
|
|
for k,v in devices.items():
|
|
for i in v:
|
|
device_list.append(i)
|
|
return(device_list)
|
|
|
|
def reset_disconnect_tags(whid, device_list):
|
|
tags_to_write = []
|
|
values_to_write = []
|
|
for i in device_list:
|
|
tag_path = "[%s_SCADA_TAG_PROVIDER]%s/DCN" % (whid, i)
|
|
tags_to_write.append(tag_path)
|
|
values_to_write.append(0)
|
|
system.tag.writeAsync(tags_to_write, values_to_write)
|
|
|
|
def get_tag_paths(fc):
|
|
tags_to_read = system.tag.readBlocking(["Configuration/FC"])
|
|
fc = tags_to_read[0].value
|
|
results = system.tag.browse(path ="["+fc+"_SCADA_TAG_PROVIDER]", filter = {"recursive":True, "tagType": "Folder"})
|
|
tag_list = results.getResults()
|
|
source_list = []
|
|
items_to_exclude = ["Configuration", "System","_types_"]
|
|
for i in tag_list:
|
|
full_path = str(i["fullPath"])
|
|
try:
|
|
source_id = full_path.split("]")[1]
|
|
except IndexError:
|
|
continue
|
|
if source_id not in items_to_exclude:
|
|
item_to_add = {"value": source_id, "label": source_id}
|
|
source_list.append(item_to_add)
|
|
return(source_list)
|
|
|
|
|