6 Replies Latest reply on Oct 27, 2009 8:31 AM by RJKSolutions

    Write to PI Collective with Excel/ Datalink

    fkeereweer

      Hello,

       

      I read the discussion about 'HA Manual Data Entry: Using the PI-SDK (Part 1)'. My question is: how can this be replicated in VBA? In our prior situation there was one PI server and the next VBA code worked fine:

      Result = Application.Run("PIPutValx", sTagname, valueCell, stime, ServerName, resultCell)

      In the current situation the VBA code has to deal with a collective of two PI servers. First I tried to simply duplicate the code, like this:

      Result = Application.Run("PIPutValx", sTagname, valueCell, stime, ServerName1, resultCell)
      Result = Application.Run("PIPutValx", sTagname, valueCell, stime, ServerName2, resultCell)

      Unfortunately, this doesn't work. The values are only written to the primary server. Would anybody help me with this issue? Thanks in advance!

       

      Kind regards,

       

      Frits

        • Re: Write to PI Collective with Excel/ Datalink

          Hi Frits,

           


          When you connect to a collective, you refer by it to its collective name rather than the currently connected member.  So having multiple server names in your code would not work unless they were individual servers or the names of 2 collectives.

           

          When you use PIPutValx is will write to the currently connected member of the collective (ServerName variable in your example).  To write to each collective member you need to inject some SDK code to switch members, which has its own issues.

           

          You could...wait for PISDK 1.4, wait for SSB, use PItoPI or add some PISDK code to manage your connection to collective members. 

          Your code would remain:

          Result = Application.Run("PIPutValx", sTagname, valueCell, stime, ServerName, resultCell)

           

          But around that you would add code to loop through each member of the collective and run the same line of code above each time you switch member.  Just remember SDK writes are disabled by default on secondary servers (as mentioned in Sam's blog post).

           

          Cheers,

           

          Rhys.

           

          @vCampus: By the way, where is Sam...not seen posts from him for a while.

            • Re: Write to PI Collective with Excel/ Datalink
              fkeereweer

               

               

              Hello Rhys,

               

               

               

              Thanks for you reaction. I'm trying to add some PI-SDK code to write to both collective members. At the moment there are no PI-SDK references added to my Excel project. So, the "piputvalx" is a PI-API function instead of a PI-SDK function?? I thought that Excel/ Datalink uses the PI-SDK. Do you know more about this?

               

               

               

              Kind regards,

               

              Frits

               

               

                • Re: Write to PI Collective with Excel/ Datalink

                  Hi Frits,

                   

                  Will need the vCampus guys to confirm but my understanding is:

                   

                  Datalink used to be PI-API based, later versions moved to PISDK.

                   

                  PIPutValx is a function name in the Datalink addin, so calling it then calls the underlying components used to communicate with PI...PISDK.  The function will use the PISDK's connection to the collective (and connect if not already) then perform the write value(s) using PISDK functions.

                   

                   

                   

                   

                    • Re: Write to PI Collective with Excel/ Datalink

                      Rhys @ RJK Solutions

                      Datalink used to be PI-API based, later versions moved to PISDK. PIPutValx is a function name in the Datalink addin, so calling it then calls the underlying components used to communicate with PI...PISDK.

                      That is correct.

                       

                      As Rhys pointed out, PIPutValX will only write data to the Primary server, even when we specify the Secondary node. Note that is the default/traditional behaviour for our communication libraries (PI SDK now, PI API back then). The buffering mechanisms (the older PI Buffer Server and the newer PI Buffering Subsystem) are those handling the "fanning" of the data to various members of a PI Server Collective. As of now, PI SDK cannot benefit from that buffering/fanning capability but this is coming in PI SDK 1.4 (see Engineering Plan).

                       

                      While we strongly advise to wait for PI SDK 1.4 and its buffering/fanning capabilities, a workaround would be to use PI SDK directly rather than the PIPutValX macro, and force the connections to each member of the Collective.

                       

                      Hope this helps!

                  • Re: Write to PI Collective with Excel/ Datalink

                    Rhys @ RJK Solutions

                    where is Sam...not seen posts from him for a while.

                     

                    unfortunately, Sam left the company shortly after writing his "Writing to Collectives - Part 1" blog post   He enjoyed working with PI so much that he pursued other opportunities with a customer of ours   We hope that his new role will bring him back to vCampus at some point!

                      • Re: Write to PI Collective with Excel/ Datalink

                        Steve Pilon

                        unfortunately, Sam left the company shortly after writing his "Writing to Collectives - Part 1" blog post   He enjoyed working with PI so much that he pursued other opportunities with a customer of ours   We hope that his new role will bring him back to vCampus at some point!

                         

                         

                        Seems to be the nature of the PI world at the moment, lots of people being approached for attractive PI opportunities.