5 Replies Latest reply on Jan 26, 2018 5:59 AM by Steve Boyko

    VB.net Get the Min and Max of a Digital Tag

    Thomas1

      I am writing some VB.net code to capture the min and max of pi tags in a Process Book Trend.  The idea is to then use the min and max values to set the trace scales.

       

      These two calls work just fine for float32 type pi tags, but fail for digital tags.

       

      myTagMin = pt.Data.Summary("*-15m", "*", PISDK.ArchiveSummaryTypeConstants.astMinimum, PISDK.CalculationBasisConstants.cbTimeWeighted)

      myTagMax = pt.Data.Summary("*-15m", "*", PISDK.ArchiveSummaryTypeConstants.astMaximum, PISDK.CalculationBasisConstants.cbEventWeighted)

       

      What is the syntax to capture the min and max of a digital tag?  Thanks.

        • Re: VB.net Get the Min and Max of a Digital Tag
          vkaufmann

          That idea of summary calculations with digital tags doesn't make a lot of sense to me. What are the values of these digital tags?

           

          --Vince

            • Re: VB.net Get the Min and Max of a Digital Tag
              Thomas1

              I agree that a calculation on a digital tag is why these calls fail.

               

              Lets say that I have two digital tags on my trend, one of them is "Tag1" and is  Boolean, and the other "Tag2"can have states of 0,1,2,3,4.  What I am trying to do is see what the largest and smallest values of Tag1 and Tag2 are and then set that as the trace Min and Max.  For example, if Tag1 has values of 0 and 1  in the trend and Tag2 only has values of 1 and 2 in the trend, then I want to set the trace scales for Tag1 and Tag2 to Min=0 and Max=2.

               

              I also have two float32 type tags on the same trend.  "Tag3" has a min=200 and max= 220.  "Tag4" has a min=205 and max = 225.  I set the trace scales for Tag3 and Tag4 to Min=200 and Max=225. 

               

              Currently I query and find that the pi tag type for Tag1 and Tag2 is digital and I set the trace to be autorange for Tag1 and Tag2.

                • Re: VB.net Get the Min and Max of a Digital Tag
                  Rick Davin

                  Hi Thomas,

                   

                  The Live Library Help for AFData.Summary has this under Remarks:

                   

                  Count is the only summary type supported on non-numeric attributes. Requesting a summary for any other type will generate an error.

                   

                  A digital tag is considered non-numeric.  So you cannot use the Summary call.  You may retrieve all of the values and loop over each one and keep track of its code.  Tedious, I know but then again you are trying to use digital tags in a way in which is not recommended.  The important part of a digital state is the human readable text, not the associated code.

                   

                  If you have an AF hierarchy, you could have a child attribute referencing the same PI Point but that attribute is strictly an Int32.  This would allow a Summary call to be made.

                  2 of 2 people found this helpful
                    • Re: VB.net Get the Min and Max of a Digital Tag
                      vkaufmann

                      I was going to suggest something similar to this. There is no server-side data call that can be performed here to get any summary information about a range of digital state values. Even though you are using digital states for simple discreet integer values, there is nothing in the server that restricts these states to an integer type and therefore there is no logic in the server to do a summary for digital states. I think your best option is to retrieve the values of digital states and handle the required logic client-side to accomplish your trend restrictions.

                       

                      --Vince

                      1 of 1 people found this helpful
                • Re: VB.net Get the Min and Max of a Digital Tag
                  Steve Boyko

                  If you are trying to set the min/max of the trend scale, the best you can do is look up the digitalset associated with the tag and get the number of entries in the digitalset and use that number-1 as your maximum and zero as your minimum.