5 Replies Latest reply on Jun 29, 2018 7:06 AM by Roger Palmen

    Odd handling of errors in the PI Vision datapump

    Roger Palmen

      In a custom symbol, i was just digging through an issue. I typically check IsGood on the data received to check if the value received from the datapump is of any use, until i got this item in my data:

       

      Description: "---removed"

      ErrorCode: 1000

      ErrorDescription:"Failed to resolve required input '---removed'"

      IsGood:true

      Label:"----removed"

      Path:"af:\\-------removed"

      Value:"Keine Daten"

       

      I'm a bit surprised about this result, never ran into this before. Why do i get a valid value where there is none? I can't really follow th reasoning behand that...

      Do i need to do checking on the existence of the ErrorCode too in the results to determine if i have a valid value? As i can't determine that from either IsGood or Value properties...

        • Re: Odd handling of errors in the PI Vision datapump
          Rick Davin

          Hi Roger,

           

          Don't know about PI Vision but here's what I do know about IsGood:

           

          A value is good if it matches the data type of its owning AFAttribute or PIPoint.  Curiously, a value of Single or Double.NaN could return IsGood of True since it matches the data type BUT a BadVal(NaN) returns False.  For values coming from the PI Data Archive, this has not been an issue since 2012 when NaN's were forbidden to be written back to the archives and instead a digital state 317 Invalid Float is written.  However, other data providers (custom data references) could still emit NaN's instead of digital state 317.  Another interesting edge case is what if you have a digital tag and its assigned digital set is SYSTEM?!  Should those bad system states be considered good since it matches the declared type, or bad because by definition they are SYSTEM states?

           

          It would be interesting to know what is the data source of that is giving you problems?  Is it the PI Data Archive or other?

          1 of 1 people found this helpful
            • Re: Odd handling of errors in the PI Vision datapump
              Roger Palmen

              In this case, the data comes from an AdHoc Analysis. The underlying problem reported is that one particular child-attribute cannot be found failing the analysis. I believe that is caused by a dirty AFmodel in PI Vision not catching this change. E.g. PI Web API resolves the value fine.

               

              But that's a side issue. I think i was really surpised that there are two different error modes for a value in PI Vision. I would expect a "Calc failed" and IsGood: false in this case, just when i would get when i would have an error in the AdHoc Analysis.

              I did not look around in the call stack and look and the underlying PI Vision code, but my first idea is that there is specific handling in place here.

                • Re: Odd handling of errors in the PI Vision datapump
                  Roger Palmen

                  The underlying problem went away as expected and thereby the problem disappeared, but i still have an unhandled error condition to cover in my code.

                  • Re: Odd handling of errors in the PI Vision datapump
                    nagarwal

                    Hi Roger - When you say ad-hoc analysis, are you talking about an AF analysis with its output configured to not save history - i.e. mapped to an attribute configured as Analysis data reference? For that case, you should be getting an AFValue with bad status, as shown by this code snippet:

                     

                                // Configure an analyis with configuration error and map its output to an Analysis data reference attribute
                                var element = database.Elements.Add("*");
                                var analysisOutput = element.Attributes.Add("*");
                                analysisOutput.DataReferencePlugIn = database.PISystem.DataReferencePlugIns["Analysis"];
                                var analysis = Configuration.NewAnalysis(element);
                                analysis.AnalysisRulePlugIn = database.PISystem.AnalysisRulePlugIns["PerformanceEquation"];
                                analysis.AnalysisRule.ConfigString = "'DoesNotExist'";
                                analysis.AnalysisRule.VariableMap["Output"] = new AFVariableMappingData(analysisOutput);
                    
                    
                                // Get value for analysis output and show that it's a bad value with exception
                                var value = analysisOutput.GetValue();
                                Assert.IsTrue(value.Value is AFAnalysisException);
                                Assert.IsFalse(value.IsGood);
                                Assert.AreEqual("Failed to resolve required input 'DoesNotExist'", (value.Value as AFAnalysisException).Message.ToString());
                    
                    
                    
                    
                    
                    

                     

                    -Nitin