3 Replies Latest reply on Jul 6, 2015 6:06 PM by msandova

    C#, leer datos desde un tag pointType=timestamp:

    msandova

      Hola: No logro leer datos vía C#, desde un tag pointType=timestamp:

      PISDK.PIValue valor = pt.Data.ArcValue(System.Convert.ToDateTime(FechaHora), PISDK.RetrievalTypeConstants.rtCompressed);

      retorna: System.__ComObject

      Gracias desde ya,

      Manuel

        • Re: C#, leer datos desde un tag pointType=timestamp:
          Eugene Lee

          Hi Manuel,

           

          Please take note that PI SDK is officially transitioning to deprecated. As such, we do not encourage use of it since there is AF SDK to take over it.

           

          Deprecating the PI SDK

           

          Please find a code snippet here that I wrote to extract out timestamp value from points of type timestamp using AF SDK

           

          var a =  pt.RecordedValue(new AFTime("12:41"));
          Console.WriteLine(DateTime.Parse(a.Value.ToString()).ToLocalTime() + "\t" + a.Timestamp);
          

           

          1 of 1 people found this helpful
            • Re: C#, leer datos desde un tag pointType=timestamp:
              gregor

              Hi Manuel,

               

              Eugene is right. We discourage from using PI SDK for new developments because PI SDK is on its way to deprecation, the majority of functionality today included with AF SDK which is what we recommend to use instead of PI SDK.

              Until PI SDK is deprecated, we still support it.

               

              To answer your question, when you select TimeStamp as pointtype the value will be off type PITime. If your project doesn't already have a reference to OSIsoft.PITimeServer, please add one.

               

               

               string sDateFormat = "dd-MMM-yyyy HH:mm:ss";
                PIValue valor = myPt.Data.ArcValue("*-2m", PISDK.RetrievalTypeConstants.rtAuto);
                PITime valTime = valor.TimeStamp;
                PITime valValue = valor.Value;
                Console.WriteLine("Point {0} has value {1} at {2}", myPt.Name, valValue.LocalDate.ToString(sDateFormat), valTime.LocalDate.ToString(sDateFormat));
              1 of 1 people found this helpful