5 Replies Latest reply on Jun 27, 2018 5:57 PM by matt.au

    Is there a complete example of how to use groupbyid in aftransformer

    matt.au

      I'm starting to use AFTransformer to generate my AF database. Looking through the XML reference manual the tool supports GroupById and has an example of it. However, there is no mention of the input or what it outputs, thus it is very difficult to know how to use GroupById. Are there any examples of using it which include the input database and  AFTransformer XML?

       

      What I'm trying to do with GroupById is use it to read in a flat set of tags in an AF database. I'm stating small and only working with water reservoirs in our system and only volume (amount of water in the tank) and level (height of the water column in the tank in feet). The tag structure has an "LIY" in it for the volume and an "LI_" for the level. There is one volume per reservoir and one or more levels. Long story, but a single reservoir can have multiple cells for storing the water and the cells have levels. A strapping table is used to calculate the volume of each cell. The sum of all these individual cell volumes is stored as the volume of the reservoir. The SCADA system stores individual cell levels but only a single sum for the entire reservoir volume. Example tags look like:

       

      SITE1_LIY_7050

      SITE1_LI_7050A

      SITE1_LI_7050B

      SITE1_LIY_7051

      SITE1_LI_7051

       

      Which is to say, site 1 has 2 reservoirs. Reservoir 1 (id=7050) has a volume (LIY_7050) and 2 cells, thus 2 level tags (LI_7050A and LI_7050B). Reservoir 2 has a volume (LIY_7051) just 1 cell and level tag (LI_7051).

       

      It's easy to break out the number part from the very last suffix ("A", "B" etc), which I'm doing in Excel and loading the input AF tag database with nicely parsed out tag name components. My thought is to write a single AFTransformer XML script to group the tags into an element for the reservoir volume and sub-elements for the levels. GroupByID seems like a good fit, but the examples given are just not complete enough to understand how the grouping actually works and how to use the groups for writing the data out.

        • Re: Is there a complete example of how to use groupbyid in aftransformer
          csawyer

          Hi Matthew

           

          I've been working on simplified examples of grouping (and also explaining the first metering example that comes in the .ZIP).    You hit me at a good time since I was struggling whether to build a Lua example or come up with a different grouping pattern.    I'll work on your case and draw up a solution.   GroupByID might work or it might be easier to do this with Lua script.

          • Re: Is there a complete example of how to use groupbyid in aftransformer
            csawyer

            If I can restate your problem structure:

             

            Your Origin database where all your tags are read in are broken down by a single Site element, each site has a long list of attributes, each with a PI Point reference to each tag that's on that site.

             

            i.e.

            (Root)

            |

            |-Site 1

              |- SITE1_LIY_7050 >>  \\piserver\SITE1_LIY_7050

              |- SITE1_LI_7050A

              |- SITE1_LI_7050B

              |- SITE1_LIY_7051

              |- SITE1_LI_7051

             

            Then your target database that is transformed would look more like this

             

            (Root)

            |

            |-Site 1

              |-Reservoir 50

                     | - Total Volume  >> \\piserver\SITE1_LIY_7050

                     | - Level Cell A >> \\piserver\SITE1_LI_7050A

                     | - Level Cell B >> \\piserver\SITE1_LI_7050B

              |-Reservoir 51

                     | - Total Volume >> \\piserver\SITE1_LIY_7051

                     | - Level >> \\piserver\ITE1_LI_7051

             

            Is that about right for your problem statement?

            • Re: Is there a complete example of how to use groupbyid in aftransformer
              matt.au

              Hi Christopher,

               

              I apologize for falling off the face of the plaent. I haven't been monitoring this and forgot all about it. I believe I met you at PI World at the AFTransformer talk you gave (I was the guy who gave the glowing unsolicited AFTransformer endorsement and asked all of the Emacs questions at the end).

               

              Your restatement of my problem is spot on. Currently I'm doing this by making a bunch of XML transformer files and running AFTransformer multiple times (about 21 passes) to build up the rich hierarchy at the end of the day. I tried to send a zip file of my work over to Dwaine, but the firewall/antivirus software stripped it out. The other approach I was contemplating was to read multiple shapes in and then try to write them out, but I got terribly confused and just went with the simple multi-pass approach even though it's a bit slower. With that said I can convert about 30-40 sites in about 15-20 minutes. This is about 2500 tags total (about 60-70 tags per site).

               

              I'm currently working on other projects and have had to tabled this for now. I have our first cut of the new database done and playing with it using PIVision every now and then. I will definitely revisit this in the future and will continue to use AFTransformer.

               

              Thanks and great hearing from you,

               

              Matt