PI AF Analysis Template: Calculating Device Uptime with Timestamps

Discussion created by flavio_cesar on Oct 21, 2020
Latest reply on Oct 23, 2020 by skwan

I am using PI System Explorer Analysis Templates to notify whether a device is online or offline and also when it entered either state. 


I have two expressions that help me format the uptime for a device: 


timeCameOnline is the equation that checks if it is online, if so then we output the timestamp that shows since when it went online:




I also want to notify when the device goes offline, see timeCameOffline. Very similar to how timeCameOnline is setup


Everything works as expected: 


However, I am uncertain whether timeCameOffline would work in the event of a device going offline. It works for online since this is currently true, but I don't have a way to check for the second case.



Here is the Health analysis for this case: 


The big question is whether the offline condition will actually take effect when it is true. Whether the device goes back online almost instantly, I am still interested of timestamping the event and record it. 


Is this setup correctly? 

How can we check for these conditions without having to make one of the devices go OFFLINE?


Thank you!