csawyer

"Hello World" In AF Transformer To Pivot Your AF Database (Part 2)

Blog Post created by csawyer Employee on May 25, 2018

Enhancing the Hello World example from Part 1

 

Now we're going to take the Line Pressure and Tubing Pressure AF Elements that were under the gas wells from our example database and convert those Elements into Attributes that live directly under the wells.  This is pretty easy!

 

 

The additions to the AF Transform XML file are straightforward.   First, the Measures template defines the two AF Elements where the values for each sensor are.   And these elements are always found underneath each well, so we can enhance the search for the wells to bring in the Line Pressure and Tubing Pressure child elements, like this:

 

...
<SearchShapes>
  <!-- Specify the elements and attributes of the search pattern that AF Transformer uses to search the source PI AF database -->
  <Shape ID="1001" Required="true" FilterMatchType="Any" ShapeWalkType="TopBottom">
    <ShapeElements>
      <ShapeElement ID="1" Required="true" FilterMatchType="Any" MaxDepthFromParent="1" IsEntryPoint="false">
        <Filters>
          <ElementFilter Category="" Template="Facility" Name="*" />
        </Filters>
        <Attributes>
          <ShapeAttribute ID="10" Required="true" FilterMatchType="Any">
            <Filters>
              <AttributeFilter Category="" Template="" Name="Contractor Name" />
            </Filters>
          </ShapeAttribute>
          <ShapeAttribute ID="11" Required="true" FilterMatchType="Any">
            <Filters>
              <AttributeFilter Category="" Template="" Name="Description" />
            </Filters>
          </ShapeAttribute>
        </Attributes>
        <ShapeElements>
          <!-- Line Pressure AF Element -->
          <ShapeElement ID="2" Require="true" FilterMatchType="Any" MaxDepthFromParent="1" IsEntryPoint="false">
            <Filters>
              <ElementFilter Category="" Template="Measures" Name="*PLN" />
            </Filters>
            <Attributes>
              <ShapeAttribute ID="20" Required="true" FilterMatchType="Any">
                <Filters>
                  <AttributeFilter Category="" Template="" Name="Value" />
                </Filters>
              </ShapeAttribute>
            </Attributes>
          </ShapeElement>
          <!-- End of Line Pressure AF Element -->
          <!-- Tubing Pressure AF Element -->
          <ShapeElement ID="3" Require="true" FilterMatchType="Any" MaxDepthFromParent="1" IsEntryPoint="false">
            <Filters>
              <ElementFilter Category="" Template="Measures" Name="*PTUB" />
            </Filters>
            <Attributes>
              <ShapeAttribute ID="30" Required="true" FilterMatchType="Any">
                <Filters>
                  <AttributeFilter Category="" Template="" Name="Value" />
                </Filters>
              </ShapeAttribute>
            </Attributes>
          </ShapeElement>
          <!-- End of Tubing Pressure AF Element -->
        </ShapeElements>
      </ShapeElement>
    </ShapeElements>
  </Shape>
</SearchShapes>
...

 

 

And then we just add the line pressure and tubing pressure attributes, referring back to the two elements:

 

...
<OutputElementShapes>
  <!-- Create and populate the asset model in the destination database -->
  <OutputElementShape ID="1003">
    <Elements>
      <Element Name="Injection Wells by Contractor" Guid="" ReadOnly="false" Template="">
        <Elements>
          <Element Name="[10.Value]" Guid="" Description="Contractor" ReadOnly="false" Template="">
            <Elements>
              <Element Name="[1.Name]">
                <Attributes>
                  <Attribute Name="Description" Value="[11.Value]" />
                  <Attribute Name="Line Pressure" Value="[20.DataReference]" />
                  <Attribute Name="Tubing Pressure" Value="[30.DataReference]" />
                </Attributes>
              </Element>
            </Elements>
          </Element>
        </Elements>
      </Element>
    </Elements>
  </OutputElementShape>
</OutputElementShapes>
...

 

Make sure when you're using PI Point data references (as well as AF table lookups) you use the .DataReference reference and not the .Value reference, otherwise you'll be pulling across the snapshot values of what those attributes are at the time you run AF Transformer.

Outcomes