9 Replies Latest reply on Oct 19, 2016 9:19 AM by pthivierge

    "Calc Failed" Output error message through AFSDK?

    magnusst

      Hello,

      When using OSIsoft.AF.Data.AFCalculation to evaluate expressions, is it possible to get some more details about the underlying problem when getting "Calc Failed" as result?

      In System Explorer, there is an Output: error message. Is it possible to retrieve the same associated error message when evaluating expressions through AFSDK?

       

      Untitled.png

        • Re: "Calc Failed" Output error message through AFSDK?
          pthivierge

          Hello Magnus,

           

          Yes this is possible, the evaluation errors are contained in the AFAnalysisRuleState object. It's EvaluationError property will be non-null is there is an error.

           

          You can look at a full example here:

          analyses-engine/AnalysisRunner.cs at master · pthivierge/analyses-engine · GitHub

           

          Let me know if this works for you

          3 of 3 people found this helpful
            • Re: "Calc Failed" Output error message through AFSDK?
              magnusst

              Hello Patrice,

               

              Thanks for your reply.

              This does not work for me because my expressions are not stored as AnalysisRules in AF. They are string-based expressions that are evaluated "on the fly" through OSIsoft.AF.Data.AFCalculation.CalculateAtTimes(). My screenshot was just an example of the type of evaluation information I would like to retrieve from afsdk.

               

              Is there any way to get something like EvaluationError from AFCaclculation? Or alternatively a way to instantiate AnalysisRule objects at runtime?

               

              Best regards,

              Magnus

                • Re: "Calc Failed" Output error message through AFSDK?
                  Rick Davin

                  Hi Magnus,

                   

                  Can you share the relevant section of code where you are creating the string-based expressions and then performing the calculations?

                   

                  From your exception message, I would think that you have 0 data values for that particular tag for the requested time range.  Can you verify whether or not you have data for the time range in question?

                   

                  Thanks,

                  Rick

                    • Re: "Calc Failed" Output error message through AFSDK?
                      magnusst

                      Hello Rick,

                       

                      I am looking for a way to retrieve information about errors that might occur during evaluation of expressions (in general) - I'm not looking for how to solve one particular error.

                       

                      AFCalculation class does not have any properties similar to EvaluationError, so I am looking for alternative ways to get error information from afsdk so that it can be displayed in client's reports automatically.

                       

                       

                      Best regards,

                      Magnus

                        • Re: "Calc Failed" Output error message through AFSDK?
                          gregor

                          Hello Magnus,

                           

                          According to the documentation, AFCalculation is intended for evaluation purposes. I am with you that it would be very useful having more details rather than just "Calc Failed". Because I wasn't able to figure out where those messages might go, I've contacted AF SDK development.

                          1 of 1 people found this helpful
                          • Re: "Calc Failed" Output error message through AFSDK?
                            gregor

                            Hello Magnus,

                             

                            The AFCalculation class was implemented to AF SDK as equivalent of the IPICalculation Interface in PI SDK. With both, expressions become evaluated on the PI Data Archive node. I still need to confirm with the PI Data Archive team if calculation failures are supposed to become logged or not.

                             

                            For certain types of errors, AFCalculation will return meaningful error information but "Calc Failed" is a result, not an error code. I've tested this and found that e.g. with a malformed expression, AFCalculation will raise an exception with message -12301 Performance Equation parsing error

                             

                            I also found that the behavior of AFCalculation methods is consistent with the behavior of PI SMT when evaluating expressions. 

                             

                            AF SDK development has a Work Item (WI 36095) to support a client side RDA (Rich Data Access) implementation. There's currently no priority defined for WI 36095 which translates "to be implemented sometime in future".

                             

                            You should be able to verify most of your expressions through Asset Analytics. By configuring an Analysis Data Reference at runtime, you should be able to evaluate expressions on demand. I believe that you've found this already and hence marked above reply from Patrice Thivierge helpful.

                            2 of 2 people found this helpful
                              • Re: "Calc Failed" Output error message through AFSDK?
                                gregor

                                Hello Magnus,

                                 

                                I received the confirmation from the PI Data Archive specialists that there's no guarantee a message with details becomes printed to the PI Message Log on the PI Data Archive node when "Calc Failed" is returned.

                                • Re: "Calc Failed" Output error message through AFSDK?
                                  magnusst

                                  Hello Gregor,

                                   

                                  Thank you for your deep investigations into this matter. I do appreciated all the information

                                   

                                  But I didn't quite manage to create an AFAnalysisRule at runtime in order to utilize the EvaluationError property. Anyways, I went down a slightly different road using Summaries instead of AFCalcuation for some parts of my code.

                                   

                                  Best Regards,

                                  Magnus

                                    • Re: "Calc Failed" Output error message through AFSDK?
                                      pthivierge

                                      The easiest way to get an analysis rule would be to create your analyse with PI System Explorer ( you could turn off the analyse so it is not running). 

                                      Then from the element object you can get the analyses, and from an analysis you can get the analysisRule...

                                       

                                      It is certainly possible to create them programatically but I have no example at this time to show you.

                                       

                                      Let us know in case you need to go down this path way may be able to find something.

                                       

                                      Hope this helps,