Understanding perspective playback control from Ignition Exchange

Hello All

I was trying to reuse the Historical Playback Control from Ignition Exchange.

It works :grinning: but I don’t understand all of it :cold_sweat:. I don’t understand how

if currentTimeString in cache:

can be true.

in this part:

globals = system.util.getGlobals()
		
		if 'playbackCache' not in globals:
			globals['playbackCache'] = {}
		cache = globals['playbackCache']
		if currentTimeString in cache:
			#self.custom.debug = "stringInCache"
			row = cache[currentTimeString]
			foundAll = True
			for tag in tags:
				if (tag.split("]")[1] if len(tag.split("]"))>1 else tag).replace("/","_").replace(" ","_") not in row:
					foundAll = False
			if foundAll:
				# Cache Hit
				info += "Cache hit. "
				self.params.values = row

if not 'foundAll' in vars() or foundAll == False:
			# Cache Miss
			info += "Cache miss. "
			#self.custom.debug = foundAll
			
			# Set the length of the cache retrieval:
			seconds = 10
			
			# Grab the values from the current second
			dataset = system.tag.queryTagHistory([tag for tag in tags], currentTimeDate, system.date.addSeconds(currentTimeDate, seconds), seconds)
			pyDataset = system.dataset.toPyDataSet(dataset)
			columns = pyDataset.getColumnNames()
			
			# Make sure the cache isn't too big.  If it is, dump it.
			if len(cache) > 10000:
				cache = {}
			
			for row in pyDataset:
				values = {}
				timeStampString = ""
				for i in range(len(columns)):
					if columns[i] == "t_stamp":
						timeStampString = "T"+system.date.format(row[i], "yyyy-MM-dd HH-mm-ss").replace(" ", "T")
					else:
						values[columns[i].replace("/","_").replace(" ","_")] = row[i]
				cache[timeStampString] = values

			self.params.values = cache[currentTimeString]

How does currentTimeString get into cache.

I hope you guys can help me and understand the use of globals in this case.

When i try to turn on the “turnOnGaterwayLogger”

The Message is all the time “Cache miss”.

Tick: Historical mode. Time: T2019-11-27T21-35-55 Cache miss. Total time: 13