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?
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.
3 of 3 people found this helpful
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):
- The Value Symbol name is Value1
- Tag receives "Active" (1) and "Inactive" (0) values
- 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 Else myPoint.Data.UpdateValue 1, "*", dmInsertDuplicates ' This code allows duplicate entries End If End If End Sub
Hope it helps.
That is an excellent sample code. Thanks Gustavo!
The breaker changes it status perfectly from 0 to 1, however it seems that it doesn't response when from 1 to 0. I believe there is an issue with comparing the value (myPoint.Data.Snapshot = "Active")
Many thanks for your support, it is highly appreciated.