14 Replies Latest reply on May 12, 2016 2:22 PM by anirkul07

    Get Attributes from ProcessBook using AFSDK

    Korablev-ds

      Hi all,

       

      Is it possible to get all attributes from dysplay.pdi using afsdk? 

        • Re: Get Attributes from ProcessBook using AFSDK
          Marcos Vainer Loeff

          Hello Dmitry,

           

          There is no way to access PI AF SDK on PI ProcessBook through VBA, since PI AF SDK is a pure .NET library. Neverthess, there is a workaround  which is using  AF Wrapper. This library can be downloaded accessing vCampus Download Center  under Extras category.

           

          Please refer to this thread about how to extend the AFWrapper.

           

          Hope it helps!

            • Re: Get Attributes from ProcessBook using AFSDK

              Hello Dmitry,

               

              In case you asked how to read point / AF Attribute references from ProcessBook symbols, this can be done through VBA without involving AF SDK. You would first iterate through the symbols existent in your display and do further treatment by symbol type (Trend, Bar Graph, Value ...). As far as I recall the trend is the only control (symbol) allowing to specify multiple references.

                • Re: Get Attributes from ProcessBook using AFSDK
                  mjarvis

                  There is also the PI ProcessBook Support tool which is available in the tech support download center. This PI ProcessBook Support Tool will extract PI Point data references from given pdi(s).

                   

                   

                   

                  1881.pb-support.png

                    • Re: Get Attributes from ProcessBook using AFSDK
                      Korablev-ds

                      The PI ProcessBook Support Tool is good. But i need to get the same result in code. How can i do this?

                        • Re: Get Attributes from ProcessBook using AFSDK

                          Hello Dmitry,

                           

                          I'll be moving this thread to "ProcessBook/ActiveView and Microsoft Office Development" because what you are looking for doesn't involve AF SDK.

                           

                          To illustrate what I suggested yesterday, I have created a simple example that should get you started. Here's a screenshot of the display that has a Trend, a Button and a ListBox.

                           

                          1273.PB_5F00_SymbolReferenceEx.jpg

                           

                          The code behind the command button looks as follows:

                           

                           

                           
                          Private Sub CommandButton1_Click()
                              ListBox1.Clear
                              For Each Symbol In ThisDisplay.Symbols
                                  If Symbol.Type = pbSYMBOLTYPE.pbSymbolTrend Then
                                      Dim iTraceCount As Integer
                                      iTraceCount = Symbol.TraceCount
                                      For i = 1 To Symbol.TraceCount
                                          ListBox1.AddItem Trend1.GetTagName(i)
                                      Next i
                                  End If
                              Next
                          End Sub
                          

                           You'll have to enhance the code for other Symbol types. 

                            • Re: Get Attributes from ProcessBook using AFSDK

                               

                               
                              Private Sub CommandButton1_Click()
                                  ListBox1.Clear
                                  For Each Symbol In ThisDisplay.Symbols
                                      If Symbol.Type = pbSYMBOLTYPE.pbSymbolTrend Then
                                          For i = 1 To Symbol.TraceCount
                                              ListBox1.AddItem Trend1.GetTagName(i)
                                          Next i
                                      End If
                                  Next
                              End Sub
                              

                               

                               

                              Sorry, I just recognized that I've wasted 2 lines.

                                • Re: Get Attributes from ProcessBook using AFSDK
                                  Korablev-ds

                                  Gregor, Hello

                                   

                                  I develop the programm in Visual Studio and i need to get the same result like in PI ProcessBook Support Tool in code. With installing support tool i get dll library OSIsoft.PBSupportToolPlugIn.TagReturn.dll. "PI ProcessBook Support Tool Developer's Guide" is pure and haven't code example, but TagReturn.dll must do exactly what i need.

                                    • Re: Get Attributes from ProcessBook using AFSDK
                                      rmcerlean

                                      Hi Dmitry,

                                       

                                      Would a custom plug-in to the PI ProcessBook Support Tool be acceptable or are you trying to write your own standalone utility?

                                       

                                      If you are able to use the PI ProcessBook Support Tool, you can use the template that is provided (located in PIPC\Procbook\SupportTool\PBSupportToolPlugIn.zip). You begin by specifying the IterationSupport level in the ProcessButton_Click method:

                                       
                                      private void ProcessButton_Click(object sender, EventArgs e)
                                              {
                                                  // TODO change IterationSupport to the desired level
                                                  m_host.Start(PBSupportToolTypes.IterationSupport.Symbols);
                                              }
                                      

                                       In this case, you want to be sure to specify the level as Symbols so that all symbols in each display are processed.

                                       Next you will want to check out IPlugInCtrl Members where you will see the ProcessSymbol method. This method gets run for each symbol in every display that is selected:

                                       
                                      public bool ProcessSymbol(object symbolAsObj, object display)
                                              {
                                      
                                                  PBObjLib.Symbol sym = symbolAsObj as PBObjLib.Symbol;
                                      
                                                  // Determine symbol type
                                                  switch (sym.Type)
                                                  {
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolComposite:
                                                          // the framework will handling calling this method for the symbols
                                                          // inside composites
                                                          break;
                                      
                                                      // Case pbSymbolBar
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolBar:
                                                          break;
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolValue:
                                                          break;
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolSQC:
                                                          break; 
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolXYPlot:
                                                          break;
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolBTrend:
                                                          break; 
                                      
                                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolTrend:
                                                          break;
                                      
                                                      default:
                                                          break;
                                                  }
                                      
                                                  // check for multistate
                                                  if (sym.IsMultiState)
                                                  {
                                                  }
                                      
                                                  return true;
                                              }
                                      

                                      This will allow you to retrieve the data item from each of the symbols. Different cases are required since each symbol is unique, for example some symbols can have multiple data items associated so you will need to loop through them all. For example, below is how to get the data item out of a few different symbols:

                                       
                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolValue:
                                                          PBSymLib.Value sValue = (PBSymLib.Value)sym;
                                                          string attribute = sValue.GetTagName(1);
                                                          // do something with attribute
                                                          break;
                                      
                                      case (int)PBObjLib.pbSYMBOLTYPE.pbSymbolTrend:
                                                          PBSymLib.Trend sTrend = (PBSymLib.Trend)sym;
                                                          for (int i = 0; i < sTrend.PtCount; i++)
                                                          {
                                                              string attribute = sTrend.GetTagName(i + 1);
                                                              // do something with attribute
                                                          }
                                                          break;
                                      

                                      From there, you can do whatever you wish with the tag/attribute in C#. Note, attributes will appear exactly as they do in the configuration of the symbol, so they will either be in the form of AF2.\\AFserver\AFDatabase\AFElement|AFAttribute or E.Attribute (there are other possible scenarios for E. as well such as E..RelativePathToAttr|Attribute).

                                      Hope this helps,
                                      Ryan

                          • Re: Get Attributes from ProcessBook using AFSDK
                            anirkul07

                            Hi Marcos,

                            Where can i find vCampus Download Center  AF Wrapper for pocessbook since vCampus does not exist now?

                            Also is it possible to get event frames data using this wrapper?

                             

                            Thanks in Advance,

                            Aniruddha