Querying Historical Data Values

TLDR:
Is there a function that can pull the last state change of a bool tag? I have a bool tag and on the falling edge of the tag, i want to pull the datetime it changed to the on state (Its last rising edge).

I guess if its a bool tag, and i set the max time between samples to 10 years, then it would be the next to last data point...

Details:


I am trying to automatically audit a furnace run. It needs to not heat too fast and stay at a temp for at least a certain time. As you can see from the graph, they are also running different parts in the same furnace. The first step is to segment out the historical data into different runs data.

Bonus points if you can figure out how to send it to a report each time the run ends (the run bit goes low)

Sounds like a Tag change Script (or Gateway Events level) can work:

You have access to the incoming and previous Qualified Values (includes timestamps), since you are dealing with a Boolean this would lead to the currentValue having the 0 while previousValue gets the 1 every time it goes False. Executing a report when a tag changes is also done this way using system.report.executeAndDistribute().