6 Replies Latest reply on Mar 28, 2018 3:16 PM by azizaltoraifi

    Change PI Tag Value in Processbook  by clicking




      I'm working in building electrical system using PI Processbook and  I used multi-state symbol to represent breakers ( Either Open"0" or Close" 1" )  . What I'm struggling with is that"  I want the pi tag value to be changed when by clicking in the breaker symbol" .



      Appreciate your support

        • Re: Change PI Tag Value in Processbook  by clicking

          Greetings to you.


          Thanks for posting on PI Square.  I'm trying to better understand your use case.  Are you looking to click on your beaker symbol to change the value of the PI Tag governing the multistate symbol? 


          For example, if the current value of the tag is 0, then clicking on the symbol will change the value to 1?


          If that's the case, you'll need to write a custom VBA script that will send a value to PI.  This is not exactly an easy solution as this will require using a PI SDK Reference in VBA which is nonideal if you wish to make this display available to multiple users across many machines.


          Is there a particular use case for why you would like Processbook to be a data entry point?



            • Re: Change PI Tag Value in Processbook  by clicking

              Hey Jesse,


              Thanks for your prompt response. Yes you got it right, that's exactly what I need.


              This configuration is needed to facilitate changing the breaker status without searching for a particular tag in PI and change its value since the system will contain large number of breakers and it will be used by users who are not familiar with PI.




              Thanks Again.

                • Re: Change PI Tag Value in Processbook  by clicking


                  As Jesse suggested you can use a VBA code to update the value whenever an user clicks on it.

                  Assumptions for the code below (which can be edited as you want):


                  1. The Value Symbol name is Value1
                  2. Tag receives "Active" (1) and "Inactive" (0) values
                  3. A message prompt will appear everytime the user clicks on the symbol


                  The code needs the PI SDK 1.3 Type Library and the PISDKCommon 1.0 Type Library to work.

                  Keep in mind that if the tag receives data through buffer from another source you will need to enable buffering on the PI Processbook machine as well and the data might take a few seconds to refresh on the PI Processbook screen.


                  Private Sub Value1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                      Dim response As String
                      Dim myServer As PISDK.server
                      Dim myPoint As PISDK.PIPoint
                      Dim serverName As String
                      Dim pointPath As String
                      Dim pointName As String
                      response = MsgBox("Are you sure you want to update the value?", vbYesNo) 'prompts a message to user
                      If (response = 6) Then 'proceeds if response is yes
                          'Sets the PI Data Archive
                          serverName = "server_name" 'USE YOUR SERVER NAME HERE
                          Set myServer = PISDK.Servers(serverName)
                          'Sets the reference to the PIPoint object
                          pointPath = Value1.GetTagName(1) 'point path is \\server_name\tag_name
                          pointName = Right(pointPath, Len(pointPath) - Len(serverName) - 3)  'removes servers name and backslashes
                          Set myPoint = myServer.PIPoints.Item(pointName)
                          'Inserts 0 or 1 according to snapshot value
                          If (myPoint.Data.Snapshot = "Active") Then
                              myPoint.Data.UpdateValue 0, "*", dmInsertDuplicates  ' This code allows duplicate entries
                              myPoint.Data.UpdateValue 1, "*", dmInsertDuplicates  ' This code allows duplicate entries
                          End If
                      End If
                  End Sub


                  Hope it helps.

                  3 of 3 people found this helpful