Hi,
I have UDT tags in different folders. I have created a custom property in UDT definition - called getOPCPath
i need to write a function to get the opc path of corresponding udt instance tag and write it to the custom property.
Why i am doing this because i am using MQQT so it's not fetching the OPC item path. so i am creating custom property and though that i am planing to fetch the OPC item path for all tags
this is the code i have used
parentPath = "[default]test_path"
# Get the current configurations recursivly, which is useful when targeting
# folders and UDT Instances
configs = system.tag.getConfiguration(parentPath, True)
print configs
# The getConfiguration() above always returns a list of dictionaries, and our results
# are inside of the first dictionary.
for tag in configs[0]['tags']:
print tag
it fetching all the udt tags in dictionary i don't know i how to Manipulate to each tag in dictionary and get their OPC item path and write it to same tag custom property
custom property i have created in each tag - GetOpcPath (its also there in dictionary )
[{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'OPC_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'OPC_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'OPC_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': gas, u'tagType': Folder, u'name': u'gas'}, {u'tags': [{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'water_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'water_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'water_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': water, u'tagType': Folder, u'name': u'water'}, {u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'comp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'comp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'comp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': compressor, u'tagType': Folder, u'name': u'compressor'}, {u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'temp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'temp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'temp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': temp, u'tagType': Folder, u'name': u'temp'}], u'path': Electric, u'tagType': Folder, u'name': u'Electric'}], u'path': [default]test_path, u'tagType': Folder, u'name': u'test_path'}]
{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'OPC_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'OPC_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'OPC_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': gas, u'tagType': Folder, u'name': u'gas'}
{u'tags': [{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'water_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'water_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'water_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': water, u'tagType': Folder, u'name': u'water'}, {u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'comp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'comp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'comp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': compressor, u'tagType': Folder, u'name': u'compressor'}, {u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'temp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'temp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'temp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': temp, u'tagType': Folder, u'name': u'temp'}], u'path': Electric, u'tagType': Folder, u'name': u'Electric'}
can any help me on this please
Attached sample tags for your reference
OPCPath_test.json (3.3 KB)