4 Replies Latest reply on Feb 1, 2011 6:52 PM by Ahmad Fattahi

    Writing value to a tag when using ERD in ProcessBook

    Robert Raesemann

      I'm converting an existing ProcessBook display to use element relative displays. The ProcessBook has some VBA code to write a value to a tag.

       
      Set myServer = Servers("servername")
      Set myStateSet = myServer.StateSets("NotRunningRunning")
      Set myDigitalState = myStateSet("Running")
      Set myPiData = myServer.PIPoints("pitagname").Data
      myPiData.UpdateValue myDigitalState, "*"
      

      Of course after updating the display to use AF, I need the tagname that is pointed to by the AF element that I have chosen. Since I have a value element on the display named valFuelFlow, I was hoping that the GetTagName method would provide me with the PI tag that was feeding the value display simliar to this...

       
      dim TagName as string
      TagName = valFuelFlow.GetTagName(1)
      Set myPiData = myServer.PIPoints("pitagname").Data
      

      The problem is that GetTagName returns the AF attibute name and not the tag name that the attribute is pointing to. I can't figure out an easy way to write to the value.

       

      I know that AF 2.0 does not have a COM interface so I would need to write a ProcessBook add-in. I was thinking that I could maybe get the tagname using the module database instead if I moved the elements so that they would be sync'ed with the MD. Anyone have any ideas. I feel like this is harder than it should be so I suspect I may just be missing something in the heat of battle.

        • Re: Writing value to a tag when using ERD in ProcessBook

          Hey Rob...when I looked at this same issue I found no easy way to do this either.  Instead I switched the focus to manual entry to AF rather than PI directly.

           

          One option I had was to call an external command (e.g. web service) from VBA passing the full path of the AF Attribute and return the configuration,

           
          'Full Path of ERD attribute
          sFullPath = Value1.DataPoint.ColumnName
          

           Another option was for each point to receive manual entries was to double up the AF Attributes, with the second Attribute's value being the PI Server + Tag combination as a string data type - add it via ERD and hide the symbol but access its contents via VBA.  Problem with this was maintenance.

           

          ...but in the end I just went for the .Net addin to AF.  It is actually only a few lines of code using the AFSDK because you just call the "FindObject" method of the AFObject.

           
          If TheDisplay.Value1.DataPoint.Dataset.Name = "AF2" Then
          
          Dim TheAttribute As OSIsoft.AF.Asset.AFAttribute = CType(OSIsoft.AF.AFObject.FindObject(TheDisplay.Value1.DataPoint.ColumnName), OSIsoft.AF.Asset.AFAttribute)
          
          ...
          
          End If
          

           I would avoid the MDB route, feels like a side step instead of a step forward in my opinion.