def calc_avg():
paths = ["[default]Machines/20902_L9_OD_GRINDER_1/Cycle_Time", "[default]Machines/20903_L9_OD_GRINDER_2/Cycle_Time", "[default]Machines/20904_L9_OD_GRINDER_3/Cycle_Time", "[default]Machines/20905_L9_OD_GRINDER_4/Cycle_Time"]
value = [0] * len(paths)
for x in range(len(paths)):
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -30)
dataSet = system.tag.queryTagCalculations(paths=[paths[x]], startDate=startTime, endDate=endTime, calculations=["Average"])
value[x] = dataSet.getValueAt(0, 1)
outpaths =["[default]Machines/20902_L9_OD_GRINDER_1/CycleTimeAverage","[default]Machines/20903_L9_OD_GRINDER_2/CycleTimeAverage","[default]Machines/20904_L9_OD_GRINDER_3/CycleTimeAverage","[default]Machines/20905_L9_OD_GRINDER_4/CycleTimeAverage"]
system.tag.writeBlocking(outpaths, value, 1000)
I’d like to know how to link the paths to a UDT property so that I don’t have to list individual path and value tags.