Every day we collect samples from a product line. We perform several laboratory analyses on the sample, and the results from these analyses are timestamped at 00:00:00 on the day that the sample was collected by the lab data system, which is then pushed to PI. The result from each recurring analysis is stored in a PI point.
The timing on when the result is available and pushed into PI can vary quite a lot, depending on availability of lab equipment etc, and various results from a given sample can arrive to PI in different orders on different days.
Often these results need to be combined in various ways to produce useful information. As a simplified example, say we have a wet product that we want to know the water contents of - the lab weighs the collected sample, then dries it in an oven and then weighs it again. The wet weight and dry weight results then make their way into PI into their respective PI points. The water content is then determined via a simple calculation in a PI analysis (in this example the order may be quite fixed, but assume the weights may arrive in any order with quite large delays).
The question we struggle with is how to trigger this analysis consistently when both inputs for a given day have arrived.
Since we want the information as soon as it is available and the delay is very unpredictable, it is unsatisfactory to schedule it periodically with a large enough offset to guarantee data availability.
Since the order of arrival is unknown, we are currently trying to trigger the analysis on both inputs and exiting on the first row if either of the two inputs doesn't have an event on the trigger time (the idea being that it will trigger twice - once when the first of the two show up where it immediately exits, and a second time when the second shows up in which case the analysis will proceed and a result would be output to a third PI point).
Currently we've been using something similar to this (but also checking for BadVal) to determine that both results are present:
IF (SecSinceChange('Input1') > 0) or (SecSinceChange('Input2') > 0)
THEN Exit()
ELSE ...Followed by a line performing the actual calculation and it seems to work. A majority of the time. But quite often we get no result at all stored in the output point. Auto-recalculate is enabled for the analyses, and we've had success using the same approach on other data, so we're not really sure what the conditions are that would make this approach sometimes fail.
I've looked into the arrival timings in some of the data and can't see a satisfying explanation there either. If both values arrive pretty much simultaneously (sent to PI at the same second), it seems fine, but if the arrival is staggered it is a bit more inconsistent.
Do you have any ideas what might be going on? Is the approach bad, and what other options should we consider? Is the approach good but the choice of function for detecting simultaneous events is bad?
Thank you in advance,
John