3 Replies Latest reply on Jan 24, 2018 4:46 PM by vkaufmann

    How to retrive archival data of a PI digital tag using VB

    Rameshdaniel

      I want to get historical data of a Digital PI tag in Text file using VB, is it possible?. I am able to get the data for a analog tag but  not digital tag.

      Any body can help in this regard.

      Thanks in advance...

        • Re: How to retrive archival data of a PI digital tag using VB
          sraposo

          Hi Ramesh,

           

          Are you using the PI SDK or AF SDK?


          We'd recommend using the AF SDK if possible. You can get the compressed values of a PI Point using the PIPoint.RecordedValues Method. Here is a link to the documentation:

           

          https://techsupport.osisoft.com/Documentation/PI-AF-SDK/Html/M_OSIsoft_AF_PI_PIPoint_RecordedValues.htm

           

          There is an example in VB in the above link.

           

          Let us know if you need further assistance.

           

          Thanks,

          Seb

          1 of 1 people found this helpful
          • Re: How to retrive archival data of a PI digital tag using VB
            kduffy

            Hi Ramesh,

             

            In addition to Sebastien's recommendation, if you are willing to post the code you already have that works for analog tags, we may be able to quickly spot the necessary change to get it to work for digital tags.

             

            Kelsey

            2 of 2 people found this helpful
            • Re: How to retrive archival data of a PI digital tag using VB
              vkaufmann

              In the AF SDK this case is handled by a GetValue call with no additional code changes needed. In this case "myattribute" is an AF attribute that is pointed to a digital tag. Note that I am using C# and not VB but the principles are the same. Also my code here is doing some different data calls other than just archive data. The first retrieves snapshot data and the second is retrieving plot data.

               

              PISystem AF = new PISystems()["myafserver"];
                          PIServer myDA = new PIServers()["mydataarchive"];
                          AFDatabase myDB = AF.Databases["mydatabase"];
                          AFElement myEl = myDB.Elements["myelement"];
                          AFAttribute myAtt = myEl.Attributes["myattribute"];
                          var val = myAtt.GetValue();
                          Console.WriteLine($" The value of Attribute \"{myAtt}\" is {val}");
              

               

              In the case of the PI SDK, you have to access the Name property of the value object to get the value of a digital tag.

               

              var mySDK = new PISDK.PISDK();
                          var mySrv = mySDK.Servers["myserver"];
                          var pt = mySrv.PIPoints["BA:Active.1"];
                          PIValues plotValue = pt.Data.PlotValues(startTime, endTime, 24);
                          foreach (PIValue plot in plotValue)
                          {
                              if (plot.IsGood())
                              {
                                  Console.WriteLine($"{plot.TimeStamp.LocalDate} {plot.Value.Name}");
                              }
                              else
                              {
                                  Console.WriteLine($"{plot.TimeStamp.LocalDate} {plot.Value.Name}");
                              }
                          }
              
              
              1 of 1 people found this helpful