6 Replies Latest reply on Apr 21, 2016 10:02 AM by Arco

    AFSDK Read from / write to one member of a collective

    Arco

      Hi all,

       

      I am in the process of converting classic PI Points into Future PI Points.

      The idea is to copy old values from a classic PI Point into a new future PI Point and later on delete the classic PI Point and rename the new future PI Point and move on.

      But, in the past the classic PI Points can have different values in the primary PI Server compared to the second PI Server, and the wish is there to copy these differences for historic reasons.

       

      So, question, how do I read from one collectivemember and write into this collectivemember by means of the AF SDK?

      With the PI SDK this was possible easily, I cannot find how to do it with the AF SDK.

       

      What I tried already. Turning off buffering. Using the DoNotBuffer option of the UpdateValues method in combination with Collective.SwitchMember. Nothing seems to work so far.

       

      Any help would be appreciated.

       

      Arco

        • Re: AFSDK Read from / write to one member of a collective
          gregor

          Hello Arco,

           

          Thank you for sharing the background of your question. I could imagine you've done this to get some feedback on the idea itself too.

          It was at the EMEA UC in Paris a few years ago when I first heard Denis Vacher talking about how development had implemented an early version of future data. It surprised me that future data points were treated as a separate set of points supposed to co-exist with the historical points. But the reasoning made perfect sense to me.

           

          I don't enjoy playing the role of an "always negative idea killer" because I understand myself as a rather positive human being. There are however some questions to consider but you may have found the answers to those for yourself already and developed a bulled proof concept covering your requirements. If this is the case, please reach out to OSIsoft Technical Support and introduce your concept. Ask them to escalate your support case to the PI Data Archive experts to receive their comments.

           

          Where exactly do you see the issue with AF SDK? Is it with reading from the right collective member or is it with writing? Is it just you don't know how you are connected? Do you like to share a snippet of your code that does not work as expected?

            • Re: AFSDK Read from / write to one member of a collective
              Arco

              Hi Gregor,

               

              thanks for thinking with me. I must admit though that I do not completely understand what you are saying.

              I don't want any feedback on the idea itself and I am completely on par with the idea that future datapoints are treated as a separate set of points.

              I just want to copy old values of a PI Point from one collective member to another future PI Point on the same collective member because that is a requirement over here.

              We simply must maintain the history of a PI Point and copy this history to a Future PI Point.

               

              In the mean time, as how it always goes, I found the solution.

              It took some time to figure it out but I succeeded.

               

              What to do:

              //Select the PI Collective

              var sourcePIServer = OSIsoft.AF.PI.PIServer.FindPIServer(null, "mypiservername");

               

              // Get the collective members

              var collectiveMembers = from p in sourcePIServer.Collective.Members

                                                       select p;

               

              // Loop through the collective members

              foreach (var collectiveMember in collectiveMembers)

              {

                        sourcePIServer.Collective.SwitchMember(collectiveMember);

                         var values = sourcePIPoint.RecordedValues(timeRange, OSIsoft.AF.Data.AFBoundaryType.Inside, "", true);

                         if (values.Count > 0)

                             destinationPIPoint.UpdateValues(values, parameters.UpdateOption, OSIsoft.AF.Data.AFBufferOption.DoNotBuffer);

               

              }

               

              The initialisation of the source and destination PI Points is done previously.

               

              Hope this helps for future stumblers of this requirement.

              1 of 1 people found this helpful