9 Replies Latest reply on Jan 27, 2017 1:40 AM by Marcos Vainer Loeff

    Expressions evaluated at time "*" fail when client machine is ahead of the PI Server time

    exelejames

      I work on a product that allows a user to execute an arbitrary PI expression. Often, the intent is to evaluate the expression "now" so I use something like (please excuse the VB.NET if you're a C# developer):

       

      AFCalculation.CalculateAtTimes(rootObject, userExpression, {New AFTime("*")})

       

      This call is intended to run the user's PI expression "now", and then we ensure there's a single result and give it back to the user.

       

      What we've found is that if the client machine's clock is ahead of the PI server by just a little bit, the expression returns with a '249' Calc Failed-like response. I've been able to reproduce this problem by sending an expression to run against an AFTime with a future time (something like: "*+10s").

       

      So... my question: is it reasonable for me to get a 'Calc Failed' in this instance? This seems awful unforgiving, and I thought that maybe the PI system would protect me against a little bit of clock drift.

       

      I can understand the sentiment that responds to my "Doctor, it hurts when I do this" with "Well, don't do that." In some ways, it makes sense that "now" is based on the client and therefore the client is asking for values that probably don't exist. BUT, a response of '249' with 'IsGood' of False doesn't provide me with much information either.

       

      Maybe that's my main complaint, it's not clear why my expressions failed until my co-workers started plugging in future timestamps and got similar errors. Is there something different I can do to expose this problem or workaround it? I can probably resolve the rootObject's Server time and calculate based on that instead, but I'd rather specify that I want this expression run against the server's time. I could also provide the user to send the time for the evaluation, but that is more responsibility than I want to place on them.

       

      Also, when searching PI Square for a similar issue, I found this one: Calc Failed when using Analysis , I wonder if the OP there is up against a similar scenario.