3 Replies Latest reply on Dec 17, 2009 4:33 PM by hanyong

    Is pipt.PointAttributes("userint2").Value supposed to work?

    formerpigeek

      The other PointAttributes I have tried all return the value stored in the attribute, but for some reason the user values (ints and reals) don't work.  I can see the value in Processbook, but extract it with PI-SKD.

       

       

       

      Any ideas?

        • Re: Is pipt.PointAttributes("userint2").Value supposed to work?
          hanyong

          Strange, I tried to run the following codes and it worked for me (both the loop and reading using the attribute name)

          myserver.Open("");
          PISDK.PIPoint pt = myserver.PIPoints["CDT158"];
          /*foreach (PISDK.PointAttribute attr in pt.PointAttributes)
          {
              MessageBox.Show(attr.Name + ":" + attr.Value.ToString());
          }*/

          MessageBox.Show(pt.PointAttributes["userint1"].Name + ":" + pt.PointAttributes["userint1"].Value.ToString());
          MessageBox.Show(pt.PointAttributes["userint2"].Name + ":" + pt.PointAttributes["userint2"].Value.ToString());
          MessageBox.Show(pt.PointAttributes["userreal1"].Name + ":" + pt.PointAttributes["userreal1"].Value.ToString());
          MessageBox.Show(pt.PointAttributes["userreal2"].Name + ":" + pt.PointAttributes["userreal2"].Value.ToString());

          Perhaps you show us the codes that you are using to access the point attributes?  =]

            • Re: Is pipt.PointAttributes("userint2").Value supposed to work?
              formerpigeek

              Sorry I didn't include more details, I threw that out as I was headed out the door.  Apparently, I just needed to reboot my computer as it works this morning.  The function is an Excel VBA function that does a replacement of constants in a formula to be pasted into a cell.forumla.

              Private Function ReplaceDsgnVals(FormulaStr As String, TagName As String) As String
                Dim pipt As PIPoint
                Dim piProp As PointAttributes
                Dim buff As String
                Dim propVal As String

                On Error GoTo ERR_ROUTINE

                If (InStr(FormulaStr, "DSGN") > 0) Then
                  ConnectToPI srv

                  Set pipt = srv.PIPoints(TagName)
                  Set piProp = pipt.PointAttributes
                  'DSGNTEMP
                  propVal = piProp("userint2").Value
                  buff = Replace(FormulaStr, "DSGNTEMP", propVal)

                  'DSGNGRV
                  propVal = piProp("userreal1")
                  buff = Replace(buff, "DSGNGRV", propVal)

                  'DSGNPRS
                  propVal = piProp("userreal2")
                  buff = Replace(buff, "DSGNPRS", propVal)
                Else
                  buff = FormulaStr
                End If

                ReplaceDsgnVals = buff
                Exit Function
              ERR_ROUTINE:
                Debug.Print Err.Description
                ReplaceDsgnVals = ""

              End Function