7 Replies Latest reply on Apr 27, 2016 3:11 AM by Eugene Lee

    Hide some ERD values in Process book display

    Charles Zhang

      Hello,

       

      I am a beginner of VS and development on the process book and AF.

       

      I create a set of element template in AF system. The purpose is for the use the function ERD in display. As we click on the different element, the display will automatically updated base on the element name. However, for the different element, we want to hide some ERD data on the display.. This is because the element has some little difference under special condition. 

       

      After review this PI square space, I want to try the AF wrapper to support the function of "hide value" function. Currently, I use the VS 2012 to combine the AF wrapper sample code  ( from extra downloading of OSIsoft website).

       

      I am confusion about my solution. Please give me some suggestions on this case,

      1. For the ERD display, what is the fast solution on "hide attribute value" ?

      2. If my understanding on AF wrapper is right,  using the AF wrapper to enable the Process book using VBA communicate with AF, how to continue to load the AF wrapper for processbook?

      3. does the OLEDB enterprise provide the easily solution on this?

       

      Thanks for your help!

       

      charles.

        • Re: Hide some ERD values in Process book display
          zge

          Hi Charles,

           

          To hide symbols in a display, you can use VBA code and modifying the "Visible" property of symbols.

           

          For the symbols that reference an attribute that does not exist on the AF Element, the value returned by GetValue function would be 0, and timestamp would be 1970/1/1, you can also try to use these info to tell if the element includes the attribute referenced by the symbol, here's a code snippet, I'm using a value symbol as example:

           

          Dim vrDate, vrStatus, value As Variant
          
          value = Value1.GetValue(vrDate, vrStatus)
          
          If Value1.GetValue(vrDate, vrStatus) = 0 Then
          Value1.Visible = False
          Else
          Value1.Visible = True
          End If
          

           

          Zhengqi Ge

          1 of 1 people found this helpful
            • Re: Hide some ERD values in Process book display
              Charles Zhang

              Hello, zhengqi,

              The "visible" property of symbols I consider it as a good solution as we have many elements and definitely know the how to handle the attribute. I am sorry I miss a little introduction on the background.

               

              Here I use the AF to get the data from a third party database table. I create 40 attribute for the element, one of them is the PI tag, which will dynamic update according the real environment.The other attributes use the TLDR to query the third party table matched on the tag value. Therefore, the attribute value will be dynamic as soon as the tag value change. Some attribute will show "no data" or "set to bad" because the query has not match record.

              PIAFdisplay_ERD hide value on display20160425235843672.jpg

              I create an ERD display to show these attributes. I need to hide the value "no data" or "set to bad". This is the reason why I want to hide the value on the display.  Currently, I just check the AF Wrapper from downloading. I am not sure what is better solution for this case.

              PIAFAttribute_ERD hide value on display20160425235843672.jpg

              Additionally, I want to enable the attribute value in specific column according their catogory in the table. I am not sure the workload on coding. Eugene LeeZhengqi Ge Thank you again for your prompt response!

               

              I appreciate your support for this topic!

               

              Best regards,

              charles.

                • Re: Hide some ERD values in Process book display
                  Charles Zhang

                  Hello, with the help from  Eugene and zhengqi to revise the code, considering on the ERD value has a few types, "No data" and "Cannot retrieve PI Point" etc, so the code like below,

                   

                  Sub test()

                  Dim vrdate, vrstatus, val As Variant

                  Dim PITagdata, NoMatcheddata, Nulldata As String

                  PITagdata = "Cannot retrieve PI Point"

                  NoMatcheddata = "No Data"

                  Nulldata = "Set to Bad"

                   

                   

                  val = Value10.GetValue(vrdate, vrstatus)

                  If (Left(val, 24) = PITagdata Or Left(val, 7) = NoMatcheddata Or Left(val, 10) = Nulldata) Then

                     Value10.Visible = False

                  Else

                     Value10.Visible = True

                  End If

                  val = Value4.GetValue(vrdate, vrstatus)

                  If (Left(val, 24) = PITagdata Or Left(val, 7) = NoMatcheddata Or Left(val, 10) = Nulldata) Then

                     Value4.Visible = False

                  Else

                     Value4.Visible = True

                  End If

                    val = Value12.GetValue(vrdate, vrstatus)

                  If Left(Value12.GetValue(vrdate, vrstatus), 24) = "Cannot retrieve PI Point" Then

                  Value12.Visible = False

                  Else

                  Value12.Visible = True

                  End If

                  'Debug.Print Left(val, 24)

                  End Sub

                   

                  It works fine to hide the value that the user needn't. I may want to use a loop for each value on the display. Please give me some guide on this. Thanks.

                  1 of 1 people found this helpful
                    • Re: Hide some ERD values in Process book display
                      Eugene Lee

                      Hi Charles,

                       

                      Please find a sample code here.

                       

                      Private Sub Display_DataUpdate()
                      Dim vrdate, vrstatus, val As Variant
                      Dim PITagdata, NoMatcheddata, Nulldata As String
                      PITagdata = "Cannot retrieve PI Point"
                      NoMatcheddata = "No Data"
                      Nulldata = "Set to Bad"
                      
                      
                      Dim sym As Symbol
                      For Each sym In ThisDisplay.Symbols
                      If sym.Type = 7 Then
                      val = sym.GetValue(vrdate, vrstatus)
                      If (Left(val, 24) = PITagdata Or Left(val, 7) = NoMatcheddata Or Left(val, 10) = Nulldata) Then
                         sym.Visible = False
                      Else
                         sym.Visible = True
                      End If
                      End If
                      Next sym
                      End Sub
                      
                    • Re: Hide some ERD values in Process book display
                      André Åsheim

                      If you alwas want to hide bad data it might be easier to just add a multi-state to the values. No VBA needed.

                      Downside is that you have to do this for all attibutes/tags in VBA you might be able to crawl trought all values(?).

                       

                      Multi-state

                      1. Select the content you want to have a multistate on and click the multi-state button
                      2. Chose your tag/attibute and just make sure the value is visible with all valid data. Select none color for bad data
                      3. That's it
                      4 of 4 people found this helpful
                        • Re: Hide some ERD values in Process book display
                          zge

                          To add to Andres comments, the Multistate symbol currently reads the upper and lower limit from PI Data Archive tag attribute (Zero, Zero+Span). Any value beyond the boundary will be treated as bad data, so please make sure that you configure the Zero and Span attribute of the PI Tag correctly.

                           

                          P.S. With the upcoming PI AF Server 2016, the AF Server will be able to store the zero & span information.

                          • Re: Hide some ERD values in Process book display
                            Eugene Lee

                            Hi Andre,

                             

                            That is a good suggestion. We also tried that but the problem arises when the attribute is of data type 'string' because there is no concept of Bad Data when talking about string data type. This concept only exists for numeric and digital attributes. Therefore, we couldn't use that.