Reporting Is Connected (Online) Filter

Hello,

I need to report the amount of time a machine is actually online between 2 timestamps. I tried to do this with a Tag Calculation Query on the ‘Is Connected’ Modbus OPC diagnostic tag using the ‘Duration On (Seconds)’ calculation. Unfortunately, the connection to the machine is unreliable and so the modbus ‘Is Connected’ tag goes up and down all the time. As a result, the ‘Duration On (Seconds)’ calculation is much less than it actually should be.

To get around this, I am trying to ‘filter’ the ‘Is Connected’ tag such that it needs to be off for a certain duration for me to actually count it as turned off.

This is what I came up with:

	onlineFilterSeconds = data['OnlineFilterSeconds']
	
	path = ['[default]Meissner Filtration Products/Production/ESRT01/_Diagnostics_/Is Connected']
	startTime = data['StartTime']
	endTime = data['EndTime']
	columnNames = ['is connected']
	dataset = system.tag.queryTagHistory(paths=path, startDate=startTime, endDate=endTime, columnNames=columnNames, noInterpolation=1, ignoreBadQuality = 1, timeout = 10000)
	
	#find first online timestamp
	if dataset.getValueAt(0, 'is connected') == 1:
		i = 1
	else:
		i = 2

	#delete every row pair that is less than onlineFilterSeconds
	while True:
		try:
			offlineTime = dataset.getValueAt(i, 't_stamp')
			onlineTime = dataset.getValueAt(i + 1, 't_stamp')
			if system.date.secondsBetween(offlineTime, onlineTime) < onlineFilterSeconds:
				dataset = system.dataset.deleteRow(dataset, i)
				dataset = system.dataset.deleteRow(dataset, i)
			else:
				i = i + 1
		except:
			break	
	data['FilteredOnline'] = dataset

If I place that code (with a little tweaking) on a button in a vision window it works but it is returning the original dataset in the reporting module preview…

Any ideas?

I have not tried generating a real report (without the designer report preview mode) - will try tomorrow.

Figured it out, I had the default value for my OnlineFilterSeconds report parameter set to 0 instead of something that would actually filter.