2 Replies Latest reply on Feb 1, 2019 1:04 PM by Rhys Kirk

    How to evaluate analysis in .Net?

    Rituparna

      I am able to write analysis and set values through .net(c#) , but how can we evaluate that through coding?

        • Re: How to evaluate analysis in .Net?
          gregor

          Hello Rituparna,

           

          My understanding is that you don't fully trust into analysis results and like to confirm the results.

           

          I believe the best option for this would be to retrieve the raw data and implement your own analysis methods and compare the results against what you get from Asset Analytics. No valid option appears to me to do the verification using the same methods which are used to perform the analysis.

          • Re: How to evaluate analysis in .Net?
            Rhys Kirk

            Or Gregor Beck perhaps Rituparna means something like the following (essentially running the Analysis Rule for a given time without it being run by the Analysis Service):

             

            The Analysis:

             

            Evaluation code:

                         var element = db.Elements["Element1"];
                        var analysis = element.Analyses["Analysis1"];
            
            
                        OSIsoft.AF.Analysis.AFAnalysisRuleState rs = new OSIsoft.AF.Analysis.AFAnalysisRuleState(analysis.AnalysisRule);
            
            
                        rs.SetExecutionTimeAndPopulateInputs(new OSIsoft.AF.Time.AFTime("*"));
            
            
                        analysis.AnalysisRule.Run(rs);
            
            
                        Console.WriteLine(analysis.AnalysisRule.ConfigString);
            
            
                        var inputs = rs.Inputs;
                        for(int inputIndex = 0; inputIndex < inputs.Count; inputIndex ++)
                        {
                            Console.WriteLine($"Input = {inputs[inputIndex].ToString()}");
                        }
                        var outputs = rs.Outputs;
                        for (int outputIndex = 0; outputIndex < outputs.Count; outputIndex++)
                        {
                            Console.WriteLine($"Output = {outputs[outputIndex].ToString()}");
                        }
            

             

             

            Which produces something like this from the code: