I have been having an issue that is very frustrating and I am wondering if anyone else has had some similar issue or if these was an established method for this I just cant find.
We have some PI Point attributes that record the time stamps of several key events for our system (e.g. Timestamp when valve closed, when system reached T1, T2, etc.). Let's say these are all stored as TS1, TS2, TS3...
Our goal was to then take the max of these values to find the most recent one Max(TS1, TS2, TS3,...). Then compare this most recent value to the list of values from which the max was taken from one by one to find which one was the match. This way we could determine what state the system was in at any point in time.
e.g. MostRecentTS = Max(TS1, TS2,TS3,...)
if MostRecentTS = TS1 then 1 else if MostRecentTS = TS2 then 2 else if MostRecentTS = TS3 then 3 else if ... else 0
We tested this out on one system and it appeared to work great... then when implementing on a second system it appears that a very slightly different value (~100ns) was returned when performing this second test. Effectively about 50% of the time there is no match found for Max(List) in List and we get a 0 returned saying that no current mode was found.
It looks like it may be possible to do some conversion cast from Timestamp -> Float and then take the Abs(MostRecentTS - TS1) and compare to some tolerance (e.g. 1ms). However, if there is ever a digital state thrown in one of the TSi variables then this breaks the whole nested if statement and this becomes an issue (the template we are using has some modes in it that are not applicable to all systems).
It looks like there may be a way to brute force out what we need through some more logic tests for if the digital state is found etc. but this is all starting to feel like I am solving a self made problem.
Is there any better way of comparing timestamps in AF that anyone has had success with?
Many thanks in advance for anyone who can provide experience that may be helpful.