10 Replies Latest reply on Oct 23, 2009 8:58 PM by spilon

    Attribute ConfigString

    MELang

      I have created elements based on a template that has PI Point data reference attributes which uses substitution parameters.  I would write .Net code using the AF-SDK to retrieve the attributes' PI Points.  I've tried various properties including the ConfigString property.  However, all I seem to be able to get is the configuration string of the template which includes the substitution parameters, not the substituted values.  Is this the way it is supposed to work or am I doing something wrong?

       

      Sample Code:  sPITag = afTank.Attributes("NetVolume").ConfigString

       

      afTank is an element object

       

      Sample Result:  "\\P600018?ea557ce1-eda3-4b53-ac8e-bf956d49b378\%@FacilityCode%.%element%.com;ptclassname=classic;pointtype=String;compdev=0;compdevpercent=0;excdev=0;excdevpercent=0;excmax=0;pointsource=SD&P;shutdown=0"

       

      Note the substitution parameters and PI Point attributes.

       

      Sample Desired Result:  \\P600018\BAYC.100-107.NV;ptclassname=classic;pointtype=Float32;compdev=10;compdevpercent=.0001;excdev=0;excdevpercent=0;excmax=0;pointsource=SD&P;shutdown=0;span=10000000

       

      This is taken from PI System Explorer.  Note that the values of substituted parameters are present.  This is what I am trying to get in my code.  But I would prefer that the PI Point attributes were not returned. 

        • Re: Attribute ConfigString
          hanyong

          Hi

           

          Perhaps you can try using the RawPIPointPath() method, knowing that the attribute has a PI Point Data Reference?

           

          Set the encoding type to OSIsoft.AF.AFEncodeType.Name to not display the ServerID and PointID.

           

          Example:

           

          string PointPath = aftank.Attributes("NetVolume").RawPIPointPath(OSIsoft.AF.AFEncodeType.Name);

            • Re: Attribute ConfigString
              hanyong

              Forgot to mentioned, the method that I mentioned is supported in AF 2.1 =)

                • Re: Attribute ConfigString
                  MELang

                  I have AF 2.1.  I had already tried RawPIPoint and RawPIPointPath.  The example you gave me using the OSIsoft.AF.AFEncodeType.Name parameter produce a result of "Nothing".

                   

                  Note that Tech Support is also trying to help me with this but I though I'd try vCampus to see if anyone else out there might have had a similar issue.

                   

                  Thanks.

                    • Re: Attribute ConfigString

                      Not sure why your RawPIPoint code doesn't work, the following example works fine.

                      For Each AFE As OSIsoft.AF.Asset.AFElement In DB.Elements
                          For Each AFA As OSIsoft.AF.Asset.AFAttribute In AFE.Attributes
                              If Not AFA.DataReference Is Nothing Then
                                  If AFA.DataReference.Name = "PI Point" Then
                                      Dim PIPnt As PISDK.PIPoint = CType(AFA.RawPIPoint(), PISDK.PIPoint)
                                      MsgBox("\\" & PIPnt.Server.Name & "\" & PIPnt.Name)
                                  End If
                              End If
                          Next
                      Next
                        • Re: Attribute ConfigString

                          Both the RawPIPoint property and RawPIPointPath methods should work - Rhys raises a good point in his code snippet: you should make sure you are on an Element that uses the "PI Point" Data Reference. Then depending on what you need to do with that PI Point, you'll have to choose between:

                          • using the actual PI Point object through the RawPIPoint - this will give you access to the PI Point's properties and methods and allow you to make use of the point's attribute and data. However, this implies the instanciation of the PI Point object which is done in PI SDK, not AF SDK (i.e. requires a reference to at least the main PI SDK type library). lIn other words, this may be an overkill if all you need is the point's name (the Tag).
                              
                          • getting basic information (server name, point name, point id) on the referenced PI Point - this is done through RawPIPointPath
                            Below is the result of calling that method for an Attribute that references tag 'sinusoid', with the various AFEncodeTypes:
                            FriendlyName: PIPoint 'SINUSOID' on Server 'YUL-SPILON'
                            ID: \\?ba90bed3-8d15-49bb-9f75-d6ccf324b906\?1
                            IDThenName: \\?ba90bed3-8d15-49bb-9f75-d6ccf324b906;YUL-SPILON\?1;SINUSOID
                            LongName: \\Server[YUL-SPILON]\PIPoint[SINUSOID
                            Name: \\YUL-SPILON\SINUSOID
                            NameThenID: \\YUL-SPILON;?ba90bed3-8d15-49bb-9f75-d6ccf324b906\SINUSOID;?1
                            ShortName: \\YUL-SPILON\SINUSOID
                            • Re: Attribute ConfigString
                              cmanhard

                              Also note, RawPIPoint could fail if either the point cannot be retrieved (it does not exist, the user does not have read access to the point, the PIServer cannot be connected to, etc).  RawPIPointPath will not fail, even if the point does not exist.

                                • Re: Attribute ConfigString
                                  MELang

                                  You guys are about to convince me that I have something wrong somewhere within my AF setup.  I modified Rhys' code snippet to produce the following:

                                  For Each AFA As OSIsoft.AF.Asset.AFAttribute In afTank.Attributes
                                     If Not AFA.DataReference Is Nothing Then
                                        If AFA.DataReference.Name = "PI Point" Then
                                           Log("afTank.Name = " & afTank.Name)
                                           Log("AFA.Name = " & AFA.Name)
                                           Log("AFA.ConfigString = " & AFA.ConfigString)
                                           Log("AFA.DataReference.Name = " & AFA.DataReference.Name)
                                           Log("AFA.RawPIPointPath(AFEncodeType.Name) = " & AFA.RawPIPointPath(AFEncodeType.Name))
                                           Log("")
                                        End If
                                     End If
                                  Next

                                  This produced the following:

                                  afTank.Name = 25-5
                                  AFA.Name = Commodity
                                  AFA.ConfigString = \\P600018?ea557ce1-eda3-4b53-ac8e-bf956d49b378\%@FacilityCode%.%element%.com;ptclassname=classic;pointtype=String;compdev=0;compdevpercent=0;excdev=0;excdevpercent=0;excmax=0;pointsource=SD&P;shutdown=0
                                  AFA.DataReference.Name = PI Point
                                  AFA.RawPIPointPath(AFEncodeType.Name) =

                                  afTank.Name = 25-5
                                  AFA.Name = NetVolume
                                  AFA.ConfigString = \\P600018?ea557ce1-eda3-4b53-ac8e-bf956d49b378\BIRM.25-5.NV
                                  AFA.DataReference.Name = PI Point
                                  AFA.RawPIPointPath(AFEncodeType.Name) =

                                  afTank.Name = 30-2
                                  AFA.Name = Commodity
                                  AFA.ConfigString = \\P600018?ea557ce1-eda3-4b53-ac8e-bf956d49b378\%@FacilityCode%.%element%.com;ptclassname=classic;pointtype=String;compdev=0;compdevpercent=0;excdev=0;excdevpercent=0;excmax=0;pointsource=SD&P;shutdown=0
                                  AFA.DataReference.Name = PI Point
                                  AFA.RawPIPointPath(AFEncodeType.Name) =

                                  afTank.Name = 30-2
                                  AFA.Name = NetVolume
                                  AFA.ConfigString = \\P600018?ea557ce1-eda3-4b53-ac8e-bf956d49b378\%@FacilityCode%.%element%.NV;ptclassname=classic;pointtype=Float32;compdev=10;compdevpercent=.0001;excdev=0;excdevpercent=0;excmax=0;pointsource=SD&P;shutdown=0;span=10000000
                                  AFA.DataReference.Name = PI Point
                                  AFA.RawPIPointPath(AFEncodeType.Name) =

                                  Two things to note:  1) All attributes are "PI Point" data references; and 2) RawPIPointPath does not produce anything.

                                   

                                  Also note what the attributes' ConfigString property returns.  In each case the ConfigString of the template the element is based on seems to be returned (note the substitution parameters) EXCEPT for tank 25-5's netVolume attribute.  The only difference between this particular attribute and the other three is that I used PI System Explorer's "Create or Update PI Point" on this attribute.

                                    • Re: Attribute ConfigString
                                      cmanhard

                                      Do you happen to be running your AF 2.1 client App on a 64 bit machine in 64 bits, while your AF Server is still 2.0?  Try printing out AFA.DataReference.Description - it will let you know if there is an issue loading the PI Point Data Reference. 

                                        • Re: Attribute ConfigString
                                          cmanhard

                                          After some debugging, Matt and I determined what was causing his issues.

                                           

                                          In his project he had a created a reference to the COM Libraries, PISDK, PISDKCommon, and PITimeLibrary.  When adding COM libraries to a .NET project, visual stuido will automatically generate a .NET interop assemblies.  However, PISDK ships primary interops, and the PI Point Data Reference includes references to those interop assemblies.  Because these assemblies are implementing the same classes with the same GUIDs, they will conflict with the ones Visual Studio.  This was preventing his application from loading the PI Point Data Reference correctly.

                                           

                                          In summary, when adding references to PISDK, PISDKCommon, and PITimeLibrary to a .NET application, you should choose the assemblies OSIsoft.PISDK, OSIsoft.PISDKCommon, and OSIsoft.PITimeLibrary from the .NET tab, and NOT the libraries in the COM tab.