imuehlenhoff

Error in AFCalculation.PercentTrue  -  gives always 100 percent true results

Discussion created by imuehlenhoff on Dec 18, 2013
Latest reply on Jan 29, 2014 by imuehlenhoff

Hello,

we are migrating for a customer a PI SDK based tool due to speed and compatiblity increasement to the AF SDK. The customer uses the PI SDK to evaluate some PI Expression with the percent true method of the PI SDK to get time intervales where a condition is true.

We ported the code to AF SDK and started to compare the old and new results. We found out that with AF SDK the PercentTrue Method gives us always 100 percent true for every intervall. We have tested it with serveral expressions (lets say 'sinusoid'>200 and the sinusoid does never go beyond 100, and the the result was also 100 percent true for every interval). This seems not be okay.

 

Is this an error or did we something wrong?

 

Here is a code sniplet

 
                PIServers myPIServers = new PIServers();
                PIServer myPIServer = PIServer.FindPIServer(PiServerTextbox.Text);
                AFTimeRange timeRange = new AFTimeRange();
                timeRange.StartTime = new AFTime(DateTime.UtcNow.AddHours(-24));
                timeRange.EndTime = AFTime.Now;

                AFTimeSpan calculationInterval =   AFTimeSpan.Parse("1h");
                AFTimeSpan minimumSampleInterval =   AFTimeSpan.Parse("1m");
                AFValues results = null;               

                //Independent from the expression which we enter ('sinusoid'>200) or whatever the results are always 100 percent true
                //It seems that the function does not work correct?
                //We used AF SDK 2.5.2.5396
                AFCalculation.PercentTrue(myPIServer, ExpressionTextBox.Text, timeRange, calculationInterval, minimumSampleInterval,
                    AFTimestampCalculation.Auto, out results);
               
                //All Results are always 100percent true
                foreach (AFValue currentItem in results)
                {                   
                    richTextBox1.AppendText(String.Format("Time: {0:yyyy-MM-dd HH:MM:mm} PcTrue: {1}\r\n", currentItem.Timestamp.LocalTime, currentItem.Value));
                }

 Result is always like the following:

 

Time: 2013-12-17 11:12:36 PcTrue: 100
Time: 2013-12-17 12:12:36 PcTrue: 100
Time: 2013-12-17 13:12:36 PcTrue: 100
Time: 2013-12-17 14:12:36 PcTrue: 100
Time: 2013-12-17 15:12:36 PcTrue: 100
Time: 2013-12-17 16:12:36 PcTrue: 100
Time: 2013-12-17 17:12:36 PcTrue: 100
Time: 2013-12-17 18:12:36 PcTrue: 100
Time: 2013-12-17 19:12:36 PcTrue: 100
Time: 2013-12-17 20:12:36 PcTrue: 100
Time: 2013-12-17 21:12:36 PcTrue: 100
Time: 2013-12-17 22:12:36 PcTrue: 100
Time: 2013-12-17 23:12:36 PcTrue: 100
Time: 2013-12-18 00:12:36 PcTrue: 100
Time: 2013-12-18 01:12:36 PcTrue: 100
Time: 2013-12-18 02:12:36 PcTrue: 100
Time: 2013-12-18 03:12:36 PcTrue: 100
Time: 2013-12-18 04:12:36 PcTrue: 100
Time: 2013-12-18 05:12:36 PcTrue: 100
Time: 2013-12-18 06:12:36 PcTrue: 100
Time: 2013-12-18 07:12:36 PcTrue: 100
Time: 2013-12-18 08:12:36 PcTrue: 100
Time: 2013-12-18 09:12:36 PcTrue: 100
Time: 2013-12-18 10:12:36 PcTrue: 100

Outcomes