Fluctuating value displayed on vision power table in Time column

Hi ,
I am using the below script on vision Power table to display the value of seconds in the format DD HH MM SS . The script is a timer script and is running every 5 seconds .For some reason it is alternating between both the retuned outputs every 5 seconds . Attaching the code below .

def convertSecondsToDHMS(secs):
    days = int(secs / (24 * 3600))
    secs = secs % (24 * 3600)
    hour = int(secs / 3600)
    secs %= 3600
    minutes = int(secs / 60)
    secs %= 60
    seconds = int(secs)
    if days <= 0:
        return str(hour) + ':' + str(minutes) + ':' + str(seconds)
    else:
        return str(days) + ' days ' + str(hour) + ':' + str(minutes) + ':' + str(seconds)
    
tagNamePathsList = []
tagNameValuesList = []

#tagNamePathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime C9')
tagNamePathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime D9')
tagNamePathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime E7')
tagNamePathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime E8')
tagNamePathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime G2')

valuesName= system.tag.readBlocking(tagNamePathsList)

for index in range(len(tagNamePathsList)):
	valueName=tagNamePathsList[index][-2:]
	tagNameValuesList.append(valueName)
	
namesDS=system.dataset.toDataSet(['Machine Name'],[[x] for x in tagNameValuesList])

#HasFaultTags

tagHasFaultPathsList = []
tagHasFaultValuesList = []

#tagHasFaultPathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime C9')
tagHasFaultPathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime D9')
tagHasFaultPathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime E7')
tagHasFaultPathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime E8')
tagHasFaultPathsList.append('[default]ML/Area/Braiding/CompletionTime/CompletionTime G2')

valuesFault= system.tag.readBlocking(tagHasFaultPathsList)

for index in range(len(tagHasFaultPathsList)):
	valueFault=valuesFault[index].value
	tagHasFaultValuesList.append(valueFault)
	
hasFaultDS=system.dataset.toDataSet(['Faulted'],[[x] for x in tagHasFaultValuesList])

rows= zip(tagNameValuesList,tagHasFaultValuesList)

headers=['Machine Name','Time']
comboData = system.dataset.toDataSet(headers,rows)

newData=system.dataset.sort(comboData, 'Time', 0)
pyDataSet = system.dataset.toPyDataSet(newData)
dataRows = []
for row in pyDataSet:	
	formatedTime = convertSecondsToDHMS(float(row[1]))
	assetName = row[0]
	dataRows.append([assetName,formatedTime])

finalDataSet = system.dataset.toDataSet(headers,dataRows)


system.tag.writeBlocking('[default]ML/Area/Braiding/CompletionTime/CompletionTimeAll', finalDataSet)

power table op

You probably have a script and a binding 'fighting' over what value to display (or even two different scripts). Without your actual window, that's just a guess. Double check your flow of execution.

1 Like