4 Replies Latest reply on Jun 23, 2016 4:13 PM by dclark

    Is there a way to load event frames with their attributes and values through the Web API?

    dclark

      I've seen some posts that suggest using the "loadEventFrames" method in the AFSDK. Is there a similar method for the Web API?

       

      I don't want to have to load attributes and values for each individual event frame that I get back from a query. That would have terrible performance.

        • Re: Is there a way to load event frames with their attributes and values through the Web API?
          asorokina

          Hi David,

           

          PI Web API does this automatically behind the scenes: LoadEventFrames() is called in methods that can return multiple event frames such as GetEventFrames or ExecuteSearchByAttribute methods.

            • Re: Is there a way to load event frames with their attributes and values through the Web API?
              dclark

              Anna,

              If I understand correctly, both of those methods only return the basic event frame information, right?

              I'm looking for a method that returns event frame information like name, start time, end time and additionally the attributes with a value. Such a thing might not exist, and maybe I misunderstood what the "loadEventFrames" method does in the AF SDK.

               

              Let me give an example of what I'm trying to do.

              Let's say we have heaters throughout a plant that are overheating, and I'm capturing those events through an "Overheat" event frame template. And let's say these templates capture a ID of the heater. What I need to do is find all Overheat events and get the heater ID to which the event pertains.

              GetEventFrames can give me the basic event frame info, but won't tell me the heater's ID?

               

              What I've settled on for now is the Batch operation. First I pull the event frames I want, then I build a bunch of calls to get each event frame's attribute values in batch. It's a total of two calls instead of one per event frame, which is much better.

              I'd still rather have one call that pulls the attribute values with the event frame to begin with, though.

                • Re: Is there a way to load event frames with their attributes and values through the Web API?
                  asorokina

                  If I understand correctly, both of those methods only return the basic event frame information, right?

                  I'm looking for a method that returns event frame information like name, start time, end time and additionally the attributes with a value. Such a thing might not exist, and maybe I misunderstood what the "loadEventFrames" method does in the AF SDK.

                  That's right. In the AF SDK, LoadEventFrames() just fully loads Event Frame metadata objects into the client in bulk so they're ready for subsequent call(s) to get the Attributes' data. If you don't do the metadata load in bulk, then each Event Frame object will get loaded individually when its properties are accessed. As for the data calls, those can generally be bulked too.

                   

                  Anyway, back to the WebAPI. It sounds like you are on the right path. What kind of calls do you make in batch after getting event frames with GetEventFrames? GetValues with nameFilter=ID?

                  If so, that's the most straightforward way to do it. Keep in mind, though, that while processing the batched operations, the WebAPI server will process each GetValues request independently. For static Attribute values of your Event Frame, such as ID, those are part of the metadata already loaded in the WebAPI, so processing the requests independently is no problem. If, on the other hand, the desired Attribute data came from a PI Point, a different bulking scheme might produce better performance (e.g. get the desired attribute WebID from all Event Frames, and split those into sufficiently-many GetValuesAdHoc calls)

                  2 of 2 people found this helpful