I am building a display in PI process book using PI AF attributes. Is there a way to include a dropdown box or some method to easily convert units of measure in process book? For example to easily convert pounds to kilograms.
When you're adding the value symbol to the display, you can select the AF UoM from the drop down list, which then appends it after a semicolon on the data item path, as seen here:
If you would like to control this unit of measure from a drop down list in run mode, as opposed to going into the value symbol configuration itself to change it from the drop down list above, then you'd need to implement some ActiveX controls most likely, then enumerate the list of units of measure in this attribute's UoM family (VBA does not inherently accept AFSDK commands, so this part would either be hard coded or would require a quite extensive development effort), then you can use VBA to change the data time string replacing the unit portion to match what the user selected. Here's a sample VBA snippet that swaps degrees F for degrees C, as seen in the screenshots below.
Private Sub Value1_Click(ByVal lvarX As Long, ByVal lvarY As Long)Dim tagName As StringDim newTagName As StringtagName = Value1.GetTagName(1)newTagName = Left(tagName, (Len(tagName) - 1))newTagName = newTagName & "C"Value1.SetTagName (newTagName)End Sub
Original showing degrees F:
Symbol switching to degrees C after being clicked on:
This example is very hard coded to just switch the F for the C, and does not show how to hook in a drop down list, etc, but it shows a very basic approach for this.
I strongly suggest using the built in UoM drop down lists in the symbol's configuration dialog box, though, if that's sufficient for what you're looking for.
Thank you for the reply, that helps with the question I had. I knew it was fairly easy inside AF but it looks like it is much more complicated in process book.
Thank you again,
Retrieving data ...