4 Replies Latest reply on Jan 12, 2015 11:56 AM by bpalomo

    How Do I get a digital value using the api Library

    yisrael

      I used to extract values from PI using the PI API. We use the

       

      pisn_getsnapshotx() and piar_getarcvaluex() functions. Recently we get a request to extract also digital tags. The value we get through those function for digital value is really strange. I uses the status value. it returns an integer value but not a normal value nearby the zero as I expected.

      I get  

      True: -13303809
      False: -13303808

       

       

      Can anyone help me?

       

        • Re: How Do I get a digital value using the api Library
          Eugene Lee

          Hi Yisrael,

           

          OSIsoft does not recommend the use of the PI API anymore as most of our active development is focused on .NET programming languages. Our .NET libraries (AF SDK) also provide much richer features (enhanced object models, data access options, multithreading) and are better supported for long-term development. We also have more resources on learning how to develop using the AF SDK in the Master PI section of this forum. Furthermore, we do not license PI API for development under normal circumstances anymore. You can refer to Q7 at the link below.

          PI Developers Club FAQ

           

          • Re: How Do I get a digital value using the api Library
            Ahmad Fattahi

            On top of what Eugene suggested, if .NET is not your thing, we have a platform-agnostic rich data access technology PI Web API. These are newer and safer technologies that are superior to PI API in terms of features and security.

            • Re: How Do I get a digital value using the api Library
              gachen

              Hi Yisrael,

               

              As Eugene and Ahmad have emphasized, please do not use the PI API for data access. However, for reference, the value you got returned is what is referred to as the "istat" value. For digital points, the "istat" value is the actual value of the tag, whereas for other tags (numeric, etc), the "istat" contains status information about the value.

               

              To interpret a digital "istat" value: the upper 16 bits of the number is the digital state set, the lower 16 bits of the number is the offset within the state set.

               

              In your case, True = -13303809

              0n13303809 = 0b1100 1011 0000 0000 0000 0001

              upper 16 bits = 0b1100 1011 = 0n203 (digital state set 203)

              lower 16 bits = 0b1 = 0n1 (first offset within set 203)

               

              Hope this helps.

              1 of 1 people found this helpful
              • Re: How Do I get a digital value using the api Library
                bpalomo

                Hi Yisrael; Although not stated by colleagues is true that the API is no longer being used, I understand that sometimes migrate to other platform is complicated when large developments. Maybe this  VB6 with API code   can help you..

                     Dim count&

                     Const array_size = 5000

                     Dim times(array_size) As Long

                     Dim rvals(array_size) As Single

                     Dim istat(array_size) As Long

                     Dim pttype As String * 1

                     res = pipt_pointtype(pt, pttype)

                     If pttype = "D" Then

                     res = piar_compvalues(pt, count&, times(0), rvals(0), istat(0), rev)

                     If res = 0 Then

                        For L = 0 To count - 1

                           n_aux = times(L)

                           pitm_formtime n_aux, fecha_string1, Len(fecha_string1)

                           res = pipt_digstate(istat(L), state, 12)

                           n_aux = times(L)

                           pitm_formtime n_aux, fecha_string, Len(fecha_string)

                           Estao = Mid(state, 1, 2)

                           If Estao = "SI" Or Estao = "NO" Then

                              continue ptrogram........

                 

                 

                Best Regards.