14 Replies Latest reply on Dec 12, 2016 5:02 PM by Steve Boyko

    Does GetEventFrames() Cache The Event Frames?

    Steve Boyko

      I am using Element.GetEventFrames() to retrieve event frames for a particular element. It seems like it is caching the results and not noticing when event frames are changed on the server side, even though PI System Explorer run from my machine does see the changes.

       

      Is it actually caching or is something else going on?

       

      I'm using PI AF 2.7.5.7166 and I'm limited to that because of some software compatibility issues with a third party product. I'd love to use the AFEventFrameSearch class but that doesn't seem to exist in 2.7.5.7166, despite what the documentation says.

        • Re: Does GetEventFrames() Cache The Event Frames?
          Rhys Kirk

          Are you refreshing the AFDatabase object before re-issuing your call to GetEventFrames()?

          • Re: Does GetEventFrames() Cache The Event Frames?
            Eugene Lee

            Hi Steve,

             

            For your version, Event Frames are indeed cached.

             

            There is an internal work item that states that this won't be so anymore in a future release of AF.

            2 of 2 people found this helpful
            • Re: Does GetEventFrames() Cache The Event Frames?
              Rick Davin

              Hi Steve,

               

              AFEventFrameSearch does exist in AF 2.7.5.  However, there are only 2 constructors available.

               

              Constructor using IList<AFSearchToken>

               

              Construct using query string

               

              THIS INFO IS WRONG: However, the AFEventFrameSearch.FindEventFrames method takes a different signature than what's available in 2.8.  The signature for 2.7.5 is:

               

              public IEnumerable<AFEventFrame> FindEventFrames(int startIndex = 0,

                          AFSortField sortField = AFSortField.StartTime,

                          AFSortOrder sortOrder = AFSortOrder.Descending,

                          int pageSize = 0)

               

              Also some methods such as CacheTimeout and GetTotalCount were not introduced until 2.8.

              1 of 1 people found this helpful
                • Re: Does GetEventFrames() Cache The Event Frames?
                  Steve Boyko

                  Thanks, Rick. I was able to build an app using the PI AF Developer Tools 2015 R2 on my machine, but when I deployed it to a system with PI AF 2.7.5.7166 installed, it errored out saying the method didn't exist. I didn't dig any further into it and just assumed it wasn't actually part of the AF client libraries.

                  • Re: Does GetEventFrames() Cache The Event Frames?
                    Steve Boyko

                    Hi Rick Davin - a little update. I tried it again and this is the error message I get when deploying to our test server with PI AF Client 2015 R2 (2.7.5.7166):

                    Method not found: 'Void OSIsoft.AF.Search.AFEventFrameSearch..ctor(OSIsoft.AF.AFDatabase, System.String, OSIsoft.AF.Asset.AFSearchMode, OSIsoft.AF.Time.AFTime, OSIsoft.AF.Time.AFTime, System.String)'.

                    It's strange because the 2.7.5.7166 help file includes the AFEventFrameSearch class as you said, with the two constructors, but it doesn't seem to exist on this server.

                      • Re: Does GetEventFrames() Cache The Event Frames?
                        Rick Davin

                        Steve,

                         

                        The constructor throwing your exception is:

                         

                             AFEventFrameSearch(AFDatabase, string, AFSearchMode, AFTime, AFTime, string)

                         

                        Which was not available until AF 2.8.  You must use either of the 2 constructors supported in AF 2.7.5:

                         

                             AFEventFrameSeach(AFDatabase, string, IList<AFSearchToken>)

                         

                             AFEventFrameSearch(AFDatabase, string, string)

                        1 of 1 people found this helpful
                          • Re: Does GetEventFrames() Cache The Event Frames?
                            Rick Davin

                            Hello again Steve Boyko

                             

                            In light of my previous post, here's a code example to demonstrate how you would use AFEventFrameSearch with AF 2.7.5 if trying to find Overlapped event frames within a time range:

                             

                            Starting at line 14, this code will NOT work in AF 2.7.5 because AFEventFrameSearch.FindEventFrames was not an available method.

                             

                            private void SearchExample275(AFElementTemplate template, AFTimeRange timeRange)
                            {
                                var tokens = new List<AFSearchToken>();
                            
                                tokens.Add(new AFSearchToken(AFSearchFilter.Template, AFSearchOperator.Equal, template.GetPath(template.Database)));
                            
                                // Here's how to code tokens for AFSearchMode.Overlapped.
                                // For time strings, I strongly recommend using the culture insensitve Round-trip specifier "O"
                                tokens.Add(new AFSearchToken(AFSearchFilter.Start, AFSearchOperator.LessThanOrEqual, EndTime.UtcTime.ToString("O")));
                                tokens.Add(new AFSearchToken(AFSearchFilter.End, AFSearchOperator.GreaterThanOrEqual, StartTime.UtcTime.ToString("O")));
                            
                                var search = new AFEventFrameSearch(template.Database, "", tokens);
                            
                                var frames = search.FindEventFrames();
                            
                                foreach (var frame in frames)
                                {
                                    // do your magic
                                }
                            }
                            

                             

                            Knowing that you can't use this constructor AFEventFrameSearch(AFDatabase, string, AFSearchMode, AFTime, AFTime, string) because it was not available in 2.7.5, you would have to build your own token list to produce the same filter.  You will have to pass the time comparisons yourself.  For time strings, I can't recommend the ISO 8601 format strongly enough.  For both DateTime and AFTime, this is format is easy to produce using the Round-trip specifier "O".

                            1 of 1 people found this helpful