2 Replies Latest reply on Mar 31, 2015 1:55 AM by mcclellandr

    More efficient ways of cycling through Data


      HI All,


      I have recently started developing basic tools in .Net to help analyse data.

      My background is mostly working with vba and I think some habbits from excel macros have began impacting the speed of some of these tools.


      My current project follows a rough logic as set out below


      Start with predefined AFElements list [A].

      Cycle through this list[A] (For each) to get next level of elements[B]

      Cycle through each of the elements [B] (For each) and look at their attributes [C].


      Each element in B has >100 Attributes. I am interested in 3 of these attributes which will always either have the same name or will not exist.

      For each  of the 3 attributes of interest I do an AFValues function

                  AFValues attributeValues = MyAttribute.GetValues(afTimeRange, 0, null);

      which gets data over a 24 hour period of interest.

      I then cycle through the results to find particualt key events using functions.



      There are some problems wioth the way this is done that I know of and I am hoping I can fix

      • Cycling through 100 attributes for 3 known names seems redundant, I am quite sure I should be able to set them somehow.
      • I think there should be a way to query all 3 attributes at once to make things slightly faster?
      • And again If i am cycling through all element and looking for the same 3 attributes I think I should be able to query those at once as well.



      Any help on this would be great.

      My search through some preious questions in a similar area left me rather confused.




        • Re: More efficient ways of cycling through Data
          Rick Davin

          There's a lot of different ways to achieve something.  Some may or may not be a good fit for you, because there are an equally number of user environments to consider.  Without more specifics, I can only offer some general advice.


          In general with AF, one would use an AFElement.FindElements to find the minimal, basic info about some elements.  This does not include an attribute info.


          Next one would call AFElement.LoadElements or LoadElementsToDepth to get all the info for an element, including all of its attributes.


          If you are working with element templates, then you may consider the AFElement.LoadAttributes method.  Also, review your AFSDK Help File for the topic "Loading Partial Elements", which seems to be the closest match what you desire.


          You may also consider putting an attribute category on the 3 attributes you want to work with.  If you ever add a 4th attribute, just assign it the same category, and if your code is written correctly, there is nothing else to do.


          If you gather the 3 attributes into an AFAttributeList instance, then you may issue one bulk call to AFAttributeList.GetValues().


          I encourage you to browse the AFSDK Help file.

            • Re: More efficient ways of cycling through Data

              Thanks for the response Rick.


              I am currently waiting for an upgrade on my PI Install so that I get the developers tool installed and can see the AF SDK help file.

              I imagine this will probably help me answering some of these questions myself.


              I'll try and work the sugegstions above into my solution once I properly understand how they all work.