7 Replies Latest reply on Feb 9, 2017 2:36 PM by Guilherme Ferreira

    PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)

    Hans_Drost

      Hi all,

       

      I am trying to get the PIPoint.RecordedValue to work. Yet it keeps giving me a timeout ([-10010] PI System Timed Out).

      Currently I am trying out the following code in C# with the AFSDK:

                  var AFServer = new PISystems().DefaultPISystem;
                  var AFDB = AFServer.Databases.DefaultDatabase;
                  var piservers = new PIServers();
                  var piServer = piservers.DefaultPIServer;
                  var point = PIPoint.FindPIPoint(piServer, "Sinusoid");
                  var time = point.RecordedValue(DateTime.UtcNow, OSIsoft.AF.Data.AFRetrievalMode.AtOrBefore);
                  Console.ReadKey();
      

       

      The timeout is given at line 6. This seems very weird to me since the values are available in SMT.

      Can anyone give me a better understanding of what I am doing wrong?

       

      Also, the reason why I am trying to get the value is because I need the DateTime when the current value has been inserted into the archive.

      If anyone knows a better way then I am open to it.

       

      Kind regards,

       

      Hans Drost

        • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
          Rick Davin

          The better way for historical points would just be to query the CurrentValue.

            • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
              gregor

              Hello Hans,

               

              Rick is right. You are asking for a snapshot of SINUSOID, so querying for CurrentValue appears more natural. You should however not run into any timeout under normal circumstances. Can you please check KB00801 - PI System Timed Out, error [-10010]?

                • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
                  Hans_Drost

                  I figured out the reason why it timed out. Apparently the license on my development env. expired.

                  Now that i have that fixed, it works again. Then back to my question since I think i formulated it wrong.

                  The thing i would like is to have the DateTime value of the value of a tag at the time the value changed for the first time.

                  Ok, that sounded better in my head to be honest. An example, the following values are from a tag:

                  10, 10, 10, 19, 19

                   

                  With currentval I would get the last value, so the last "19". This is not the value I want. I want to know when the value of this tag changed to 19, so the first 19.

                  Any idea what the best way would be to get that value (and thus its DateTime value)?


                  Kind regards,

                   

                   

                  Hans

                    • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
                      gregor

                      Hello Hans,

                       

                      Under normal circumstances, you should not see archived values without any change in value. You may want to review Exception and Compression settings.

                       

                              static void Main(string[] args)
                              {
                                  string piDataArchiveHost = "BECKPI2015R2";
                                  string piPointName = "SINUSOID";
                                  PIServer piServer = new PIServers()[piDataArchiveHost];
                                  PIPoint pt = PIPoint.FindPIPoint(piServer, piPointName);
                                  // Retrieve the snapshot value
                                  AFValue snapshot = pt.CurrentValue();
                                  // Get the timestamp of the snapshot
                                  AFTime timeSnapshot = snapshot.Timestamp;
                                  // Retrieve the archived event before snapshot time
                                  AFValue prevEvent = pt.RecordedValue(timeSnapshot, AFRetrievalMode.Before);
                                  Console.WriteLine("The value preceding the snapshot is {0} at {1}", prevEvent.Value, prevEvent.Timestamp.LocalTime);
                                  Console.ReadKey();
                              }
                      
                        • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
                          Hans_Drost

                          Although this would work in the example that I gave, when we add another 19 in the mix this code would nog give the latest value of 10, it would give a 19.

                          I found a way to get the last tag value of the previous value in a certain time period (if it exists) with the following code:

                          var pointValues = pipoint.RecordedValues(new OSIsoft.AF.Time.AFTimeRange(DateTime.UtcNow, DateTime.UtcNow.AddSeconds(-phaseTimeInSeconds)), OSIsoft.AF.Data.AFBoundaryType.Inside, $"FindNE('{pipoint.Name}', '*-10m','*','{pipoint.CurrentValue()}')", false);

                           

                          We have our reasons to have a multitude of the same values after each other in this tag and reducing the amount would cause more problems then it would solve in our case.

                           

                          With kind regards,

                           

                          Hans

                            • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
                              gregor

                              Hello Hans,

                               

                              Retrieving RecordedValues, as identified by you as your solution, works if you have an idea about the time range to find the value in. You may have to iterate through the collection of returned values still to find the event (value, timestamp and status) you are interested in. With Looking for the previous event backwards in time will work even you don't have an idea about the period between 2 events.

                               

                              If you need the previous event of the previous event of the snapshot, you would start off with the snapshot, take the timestamp, look for the previous event, take the timestamp and look once more for the previous event. While this approach is bullet proof, it there's one roundtrip to the server with every single request for data (snapshot, previous event, previous previous event).

                              • Re: PIPoint.RecordedValue is timing out ([-10010] PI System Timed Out)
                                Guilherme Ferreira

                                Hi Hans!

                                 

                                I guess you could simplify your filter expression with

                                 

                                '{pipoint.Name}' <> currentValue  //where currentValue = pipoint.CurrentValue()

                                 

                                '{pipoint.Name}' will be evaluated by the recordedValues function for each timestamp within the specified period.

                                 

                                The way yo have it, you won't get the result if values are more than 10m apart.

                                 

                                Regards