12 Replies Latest reply on Apr 12, 2014 5:02 PM by ekuwana

    Writing tag value to all collective members

    ineoscgn

      Hi,

       

      there is a small application I developed by using AF SDK 2.5.2 and Visual C# 2012. The connection to the collective is realized as proposed in the SDK help:

       
       PIServer myPIServer = new PIServers().DefaultPIServer
       myPIServer.Connect();
      

      I am able to create a new tag and set the value:

       
      myTag.UpdateValue(val, OSIsoft.AF.Data.AFUpdateOption.Insert);
      

      Unfortunately, the value is only written to the archive of the primary collective member. Enabling SDK Buffering does not succeed (is it used by AFSDK at all?).

       

      Is there a simple and generic way to write the same AFValue to all members simultaneously?

       

      Thanks.

        • Re: Writing tag value to all collective members
          bshang

          Hi Martin,
          The AF SDK 2.5.2 ships with two versions: .NET framework 3.5 and 4.0. Which one is your application using?

           

          The .NET 3.5 assembly is in:
          ..\PIPC\AF\PublicAssemblies\OSIsoft.AFSDK.dll
          while the .NET 4.0 assembly is in:
          ..\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll

           

          I ask because PI SDK buffering is not enabled in the .NET 4.0 AF SDK. This is because it does not return PI SDK objects. Here are some notes I found in the AF SDK help file:

           

          Data Behavior Changes
          There are some behavior changes between the .NET 3.5 and .NET 4 versions of the AF SDK. The .NET 4 version of the AF SDK does not return PI SDK objects.

           

          Buffering
          The .NET 4 AF SDK does not support buffering of PI Server data writes nor direct fanning of data writes to PI Server Collectives. For PI Server Collectives, data writes will be made to the currently connected collective member, if supported. Users who need to write data to PI Collectives are encouraged to use the PI SDK or .NET 3.5 AF SDK, with buffering enabled. Buffering and fanning of PI Server data writes with the .NET 4 AF SDK is scheduled for a later release.

           

          You can find more by searching “buffering” in the AFSDK.chm file. You will want to read the section “.NET 4 Differences”.

           

          As for whether PI SDK buffering for .NET 4.0 AFSDK in the new AF SDK version 2.6, I’m not sure but perhaps someone else here could answer this.

           

          I suspect the .NET version issue is causing the problems here, but if you are using .NET 3.5 AF SDK then the problem is elsewhere. I would then check if you have enabled PI SDK buffering correctly on the application machine correctly (KB00572) and have the latest PI SDK (1.4.2.445).

           

          Hope it helps. Let me know how it goes.

           

           

           

          Best,

           

          Barry

            • Re: Writing tag value to all collective members
              skwan

              AF 2014 (v2.6) will allow you to do this.  AF 2014 will be available shortly.

                • Re: Writing tag value to all collective members
                  ineoscgn

                  Hi,

                   

                  will a change of the AF SDK assemblies on client side to the version 2.6 suffice to realize this functionality? Or will an update of both AF server and client SDK be required?

                    • Re: Writing tag value to all collective members
                      ineoscgn

                      I tried to migrate the application using PI SDK.

                       

                      Now I get problems when writing a new value to a tag using the UpdateValue function:

                       
                      PISDK.PIValue  val = countTag.Data.Snapshot;
                      PISDK.PIValue newVal = new PISDK.PIValue();                   
                      newVal.Value = (Int32)usedPoints.Count;
                      countTag.Data.UpdateValue(newVal, DateTime.Now.ToUniversalTime());
                      

                      This leads to the exception: System.Runtime.InteropServices.COMException: Write failed.  Unbuffered write would desynchronize archive data. PISDK._PIData.UpdateValue(Object newValue, Object TimeStamp, DataMergeConstants MergeType, PIAsynchStatus asynchStatus)

                        • Re: Writing tag value to all collective members
                          ekuwana

                          Hi Martin,

                           

                          This error you're seeing is due to the current limitation of PI Buffer Subsystem that buffers to only one PI Collective. For more detail, see the following PLI:

                           

                          https://techsupport.osisoft.com/Troubleshooting/Known-Issues/25103OSI8

                           

                          The upcoming PI Buffer Subsystem (will be available later this year) allows writing to multiple PI Servers and Collectives.

                            • Re: Writing tag value to all collective members
                              ineoscgn

                              Hi Eddy,

                               

                              thank you for the hint.

                               

                              But in fact, I try to only write to one collective (consisting of two PI servers) and get this error. Or is there anything wrong with the way I am connecting to the server?

                               
                              PISDK.PISDK  piSDK = new PISDK.PISDK ();
                              PISDK.Server myPIServer = piSDK.Servers.DefaultServer;
                              myPIServer.Open();
                              

                               

                                • Re: Writing tag value to all collective members
                                  ineoscgn

                                  Hi,

                                   

                                  I'd appreciate some help, because I can't see the cause of the error message (since I am trying to write to exactly one collective).

                                   

                                  Thank you.

                                    • Re: Writing tag value to all collective members

                                      Hello Martin,

                                       

                                      I don't see anything wrong with the code you posted. The error message you are getting is not very common and hence I believe the reference to known issue 25103OSI8 provided by Eddy is sufficient.

                                       

                                      If you post the content of piclient.ini, we can verify if there's some obvious misconfiguration of PI Buffer Subsystem.

                                       

                                      There exist several tools for the troubleshooting of PI Buffer Subsystem issues. You may want to investigate your issue together with a Technical Support Engineer in a remote session. Please let us know if you want to be contacted by a Technical Support Engineer.

                                        • Re: Writing tag value to all collective members
                                          ineoscgn

                                          Hello Gregor,

                                           

                                          thank you for the hint which helped me so solve the problem.

                                           

                                          On the development system, there was a problem with PI buffer subsystem

                                           

                                          3146.capture.jpg

                                           

                                          I was not able to solve it, but after copying my application to one of the productive AF servers (where it was intended to run), everything worked.

                                           

                                          The cause of the buffer error is not clear to me, but as long as the application runs on the productive system, it is ok.

                                           

                                          Best regards

                                           

                                          Martin

                                            • Re: Writing tag value to all collective members

                                              Hello Martin,

                                               

                                              Thank you for the update. The issue with your development machine is the authentication of PI Buffer Subsystem with the PI Server. It connects but the credentials don't allow reading digital states. You are welcome to open a ticket with OSIsoft Technical Support at any time convenient for you to get assistance with this issue.

                                                • Re: Writing tag value to all collective members
                                                  ekuwana

                                                  Hi Martin,

                                                   

                                                  Theoretically, this error could happen (when PISDK Buffering is on) if:

                                                   

                                                  1. A PISDK call that does not support buffering is made to a collective such as RemoveValues, ReplaceValue, and RemoveSpecifiedValues, or

                                                   

                                                  2. PI Buffer Subsystem (3.4.380) is currently buffering to another server or collective and the client is trying to write to another collective, which is the known issue that I mentioned previously.

                                                   

                                                  I thought the 2nd was more likely the case here since you're calling UpdateValue.

                                                   

                                                  Another possibility is that the error is a  subsequence of an earlier “recoverable” PIBufSS error. UpdateValue will attempt to buffer, unless there was an error, in which case PISDK may write directly to the server for a single server or return the “unsynch” error for a collective.

                                                   

                                                  It is hard to determine precisely the reason behind this error without seeing your message logs at the time of the error. As Gregor stated, feel free to contact OSIsoft Technical Support to get assistance in troubleshooting this issue.    

                                • Re: Writing tag value to all collective members
                                  ineoscgn

                                  Hi,

                                   

                                  thank you for the information. Indeed I was using AF SDK for .NET 4 and reading the corresponding chapter in the help file made things clear.

                                   

                                  However, returning to the 3.5 version seems to require other API calls, for example for connecting to a PI server or collective. When changing the reference to the 3.5 assemblies, my project will not compile anymore (for example, the class "PIServer" is not known anymore).

                                   

                                  I will have a look at the required effort to migrate "backwards". Maybe it is better to wait for the 2.6 version.

                                   

                                  Best regards

                                   

                                  Martin